-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathglsl.lisp
96 lines (86 loc) · 4.74 KB
/
glsl.lisp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
(in-package #:3bgl-glsl)
;; define builtin types, probably should move builtin functions here
;; from glsl-base, and add separate package for each version...
(let ((3bgl-shaders::*environment* *glsl-base-environment*)
(3bgl-shaders::*global-environment* *glsl-base-environment*)
(walker (make-instance 'glsl-walker)))
(macrolet ((input (name type stage &rest qualifiers)
(declare (ignorable qualifiers))
`(3bgl-shaders::walk '(input ,name ,type :stage ,stage
:internal t)
walker))
;; alias for INPUT for now
(const (name type stage &rest qualifiers)
(declare (ignorable qualifiers))
`(3bgl-shaders::walk '(input ,name ,type :stage ,stage
:internal t)
walker))
(output (name type stage &rest qualifiers)
(declare (ignorable qualifiers))
`(3bgl-shaders::walk '(output ,name ,type :stage ,stage
:internal t)
walker))
(interface (name (&rest bind) &body slots)
`(3bgl-shaders::walk '(interface ,name (,@bind :internal t)
,@slots)
walker)))
;; compute (430+)
(input (gl-num-work-groups "gl_NumWorkGroups") :uvec3 :compute)
(const (gl-work-group-size "gl_WorkGroupSize") :uvec3 :compute)
(input (gl-work-group-id "gl_WorkGroupID") :uvec3 :compute)
(input (gl-local-invocation-id "gl_LocalInvocationID") :uvec3 :compute)
(input (gl-global-invocation-id "gl_GlobalInvocationID") :uvec3 :compute)
(input (gl-local-invocation-index "gl_LocalInvocationIndex") :int :compute)
;; vertex
(input (gl-vertex-id "gl_VertexID") :int :vertex)
(input (gl-instance-id "gl_InstanceID") :int :vertex)
(input (gl-draw-id "gl_DrawID") :int :vertex)
(input (gl-base-vertex "gl_BaseVertex") :int :vertex)
(input (gl-base-instance "gl_BaseInstance") :int :vertex)
(interface (gl-per-vertex "gl_PerVertex")
(:out (:vertex t
:geometry t
;; fixme: should be gl_out[]
:tess-control gl-out
:tess-eval t)
;; fixme: should be gl_in[]
:in (:geometry (gl-in "gl_in")
:tess-control (gl-in "gl_in")
:tess-eval (gl-in "gl_in")))
((gl-position "gl_Position") :vec4)
((gl-point-size "gl_PointSize") :float)
((gl-clip-distance "gl_ClipDistance") (:float *)) ;; fixme: array syntax?
((gl-cull-distance "gl_CullDistance") (:float *))) ;; glsl 450
;; geometry
(input (gl-primitive-id-in "gl_PrimitiveIDIn") :int :geometry)
(input (gl-invocation-id "gl_InvocationID") :int :geometry)
(output (gl-primitive-id "gl_PrimitiveID") :int :geometry)
(output (gl-layer "gl_Layer") :int :geometry) ;; 430?
(output (gl-viewport-index "gl_ViewportIndex") :int :geometry) ;; 430?
;; tessellation control
(input (gl-patch-vertices-in "gl_PatchVerticesIn") :int :tess-control)
(input (gl-primitive-id "gl_PrimitiveID") :int :tess-control)
(input (gl-invocation-id "gl_InvocationID") :int :tess-control)
(output (gl-tess-level-outer "gl_TessLevelOuter") (:float 4) :tess-control :patch)
(output (gl-tess-level-inner "gl_TessLevelInner") (:float 2) :tess-control :patch)
;; tessellation evaluation
(input (gl-patch-vertices-in "gl_PatchVerticesIn") :int :tess-eval)
(input (gl-primitive-id "gl_PrimitiveID") :int :tess-eval)
(input (gl-tess-coord "gl_TessCoord") :vec3 :tess-eval)
(input (gl-tess-level-outer "gl_TessLevelOuter" (:float 4)) :tess-eval :patch)
(input (gl-tess-level-inner "gl_TessLevelInner" (:float 2)) :tess-eval :patch)
;; fragment
(input (gl-frag-coord "gl_FragCoord") :vec4 :fragment)
(input (gl-front-facing "gl_FrontFacing") :bool :fragment)
(input (gl-clip-distance "gl_ClipDistance") (:float *) :fragment)
(input (gl-cull-distance "gl_CullDistance") (:float *) :fragment) ;; 450
(input (gl-point-coord "gl_PointCoord") :vec2 :fragment)
(input (gl-primitive-ID "gl_PrimitiveID") :int :fragment)
(input (gl-sample-id "gl_SampleID") :int :fragment)
(input (gl-sample-position "gl_SamplePosition") :vec2 :fragment)
(input (gl-sample-mask-in "gl_SampleMaskIn") (:int *) :fragment)
(input (gl-layer "gl_Layer") :int :fragment) ;; 430?
(input (gl-viewport-index "gl_ViewportIndex") :int :fragment) ;; 430?
(input (gl-helper-invocation "gl_HelperInvocation") :bool :fragment) ;; 450
(output (gl-frag-depth "gl_FragDepth") :float :fragment)
(output (gl-sample-mask "gl_SampleMask") (:int *) :fragment)))