summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--chickadee/graphics/seagull.scm16
1 files changed, 12 insertions, 4 deletions
diff --git a/chickadee/graphics/seagull.scm b/chickadee/graphics/seagull.scm
index 2d7b7f8..800a513 100644
--- a/chickadee/graphics/seagull.scm
+++ b/chickadee/graphics/seagull.scm
@@ -224,8 +224,12 @@
(proc name exp)))
env))
-(define (top-level-env)
- (empty-env))
+(define (top-level-env stage)
+ (case stage
+ ((vertex)
+ (empty-env))
+ ((fragment)
+ '((fragment:coord . fragment:coord)))))
;;;
@@ -2391,6 +2395,7 @@
(vertex:clip-distance ,type:float)))
((fragment)
`((fragment:depth ,type:float)
+ (fragment:coord ,type:vec4)
(texture . ,type:texture))))))
;; TODO: Add some kind of context object that is threaded through the
@@ -2802,6 +2807,9 @@
names exps))
'(#f))
+(define %built-in-input-map
+ '((fragment:coord . gl_FragCoord)))
+
(define* (emit-glsl exp stage version port #:optional (level 0))
(match exp
(('t _ (? exact-integer? n))
@@ -2811,7 +2819,7 @@
(('t _ (? boolean? b))
(emit:boolean b stage version port level))
(('t _ (? symbol? var))
- (list var))
+ (list (or (assq-ref %built-in-input-map var) var)))
(('t _ ('if predicate consequent alternate))
(emit:if predicate consequent alternate stage version port level))
(('t _ ('values exps ...))
@@ -2900,7 +2908,7 @@
(let ((source* `(top-level ,(append inputs outputs uniforms)
,body)))
(define-values (expanded global-map)
- (expand source* stage (top-level-env)))
+ (expand source* stage (top-level-env stage)))
(let* ((simplified (simplify-exp expanded (empty-env)))
(pruned (prune simplified))
(hoisted (hoist-functions* pruned))