diff options
author | David Thompson <dthompson2@worcester.edu> | 2023-02-19 13:30:08 -0500 |
---|---|---|
committer | David Thompson <dthompson2@worcester.edu> | 2023-06-08 08:14:41 -0400 |
commit | 07fc116e7be92c005a1cd9a73dc435ec7969dd3c (patch) | |
tree | 45769b3614f03d2f8df47adf8e8b2c47b9e792bd | |
parent | bbe79c2fd6d87d6327b11876bc46ec9231868855 (diff) |
Add gl_FragCoord support.
-rw-r--r-- | chickadee/graphics/seagull.scm | 16 |
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)) |