summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2019-10-23 08:07:21 -0400
committerDavid Thompson <dthompson2@worcester.edu>2019-10-23 17:09:55 -0400
commit026e42f212da6bcc6fc533e8419029df2afea936 (patch)
tree062b0ae6a6db9cd90783f4c521cfeb6aa11a1647
parent0325613238e4c778c185e922e857a8aa2b875f36 (diff)
render: shader: Allow client-side only fields in shader structs.
-rw-r--r--chickadee/render/shader.scm13
1 files changed, 11 insertions, 2 deletions
diff --git a/chickadee/render/shader.scm b/chickadee/render/shader.scm
index 5442097..0b0e631 100644
--- a/chickadee/render/shader.scm
+++ b/chickadee/render/shader.scm
@@ -45,10 +45,11 @@
float-vec4
mat4
sampler-2d
+ local-field
+ define-shader-type
uniform-namespace?
uniform-namespace-ref
uniform-namespace-for-each
- define-shader-type
make-shader
shader?
null-shader
@@ -238,6 +239,8 @@
(format port "#<shader-struct ~a>"
(shader-struct-fields vt)))))
+(define local-field (gensym "local-shader-field-"))
+
(define (shader-struct? struct)
(eq? (struct-vtable (struct-vtable struct)) <shader-struct>))
@@ -258,6 +261,8 @@
(shader-data-type-validate type value))
(error "invalid type for shader struct field" field value)))
(cond
+ ((eq? type local-field)
+ #t)
((= size 1)
(validate value))
((and (vector? value)
@@ -306,7 +311,11 @@
(() #f)
(((name index type size) . rest)
(format port " ~a[~d ~a]: ~a"
- name size (shader-data-type-name type) (struct-ref obj index))
+ name size
+ (if (eq? type local-field)
+ 'local
+ (shader-data-type-name type))
+ (struct-ref obj index))
(loop rest))))
(display ">" port)))