Skip to content

Commit

Permalink
Allow redeclaration of builtin interface blocks in mesh shader
Browse files Browse the repository at this point in the history
Apart from allowing redeclaration of gl_MeshPerVertexNV and gl_MeshPerPrimitiveNV blocks, this change also -
- Resize clip/cull perview distances based on static index use
- Error out use of both single-view and per-view builtins
- Add new gtests with redeclared blocks and edit existing test output
- Fix couple of typos
  • Loading branch information
sparmarNV committed Oct 4, 2018
1 parent ca042a0 commit 035cbbe
Show file tree
Hide file tree
Showing 13 changed files with 875 additions and 305 deletions.
4 changes: 3 additions & 1 deletion StandAlone/StandAlone.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1222,6 +1222,8 @@ int C_DECL main(int argc, char* argv[])
// .rchit = ray closest hit
// .rmiss = ray miss
// .rcall = ray callable
// .mesh = mesh
// .task = task
// Additionally, the file names may end in .<stage>.glsl and .<stage>.hlsl
// where <stage> is one of the stages listed above.
//
Expand Down Expand Up @@ -1360,7 +1362,7 @@ void usage()
" .rahit for a ray any hit shader\n"
" .rchit for a ray closest hit shader\n"
" .rmiss for a ray miss shader\n"
" .rcall for a ray callable shader"
" .rcall for a ray callable shader\n"
#endif
" .glsl for .vert.glsl, .tesc.glsl, ..., .comp.glsl compound suffixes\n"
" .hlsl for .vert.hlsl, .tesc.hlsl, ..., .comp.hlsl compound suffixes\n"
Expand Down
2 changes: 1 addition & 1 deletion Test/baseResults/spv.320.meshShaderUserDefined.mesh.out
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
spv.meshShaderUserDefined.mesh
spv.320.meshShaderUserDefined.mesh
// Module Version 10000
// Generated by (magic number): 80007
// Id's are bound by 140
Expand Down
299 changes: 149 additions & 150 deletions Test/baseResults/spv.meshShaderBuiltins.mesh.out

Large diffs are not rendered by default.

294 changes: 148 additions & 146 deletions Test/baseResults/spv.meshShaderPerViewBuiltins.mesh.out

Large diffs are not rendered by default.

201 changes: 201 additions & 0 deletions Test/baseResults/spv.meshShaderRedeclBuiltins.mesh.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,201 @@
spv.meshShaderRedeclBuiltins.mesh
// Module Version 10000
// Generated by (magic number): 80007
// Id's are bound by 120

Capability ClipDistance
Capability CullDistance
Capability MultiViewport
Capability ShaderViewportMaskNV
Capability MeshShadingNV
Extension "SPV_NV_mesh_shader"
Extension "SPV_NV_viewport_array2"
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint MeshNV 4 "main" 11 17 28 81
ExecutionMode 4 LocalSize 32 1 1
ExecutionMode 4 OutputVertices 81
ExecutionMode 4 OutputPrimitivesNV 32
ExecutionMode 4 OutputTrianglesNV
Source GLSL 460
SourceExtension "GL_NV_mesh_shader"
Name 4 "main"
Name 8 "iid"
Name 11 "gl_LocalInvocationID"
Name 16 "gid"
Name 17 "gl_WorkGroupID"
Name 24 "gl_MeshPerVertexNV"
MemberName 24(gl_MeshPerVertexNV) 0 "gl_Position"
MemberName 24(gl_MeshPerVertexNV) 1 "gl_PointSize"
MemberName 24(gl_MeshPerVertexNV) 2 "gl_ClipDistance"
MemberName 24(gl_MeshPerVertexNV) 3 "gl_CullDistance"
Name 28 "gl_MeshVerticesNV"
Name 77 "gl_MeshPerPrimitiveNV"
MemberName 77(gl_MeshPerPrimitiveNV) 0 "gl_PrimitiveID"
MemberName 77(gl_MeshPerPrimitiveNV) 1 "gl_Layer"
MemberName 77(gl_MeshPerPrimitiveNV) 2 "gl_ViewportIndex"
MemberName 77(gl_MeshPerPrimitiveNV) 3 "gl_ViewportMask"
Name 81 "gl_MeshPrimitivesNV"
Decorate 11(gl_LocalInvocationID) BuiltIn LocalInvocationId
Decorate 17(gl_WorkGroupID) BuiltIn WorkgroupId
MemberDecorate 24(gl_MeshPerVertexNV) 0 BuiltIn Position
MemberDecorate 24(gl_MeshPerVertexNV) 1 BuiltIn PointSize
MemberDecorate 24(gl_MeshPerVertexNV) 2 BuiltIn ClipDistance
MemberDecorate 24(gl_MeshPerVertexNV) 3 BuiltIn CullDistance
Decorate 24(gl_MeshPerVertexNV) Block
MemberDecorate 77(gl_MeshPerPrimitiveNV) 0 PerPrimitiveNV
MemberDecorate 77(gl_MeshPerPrimitiveNV) 0 BuiltIn PrimitiveId
MemberDecorate 77(gl_MeshPerPrimitiveNV) 1 PerPrimitiveNV
MemberDecorate 77(gl_MeshPerPrimitiveNV) 1 BuiltIn Layer
MemberDecorate 77(gl_MeshPerPrimitiveNV) 2 PerPrimitiveNV
MemberDecorate 77(gl_MeshPerPrimitiveNV) 2 BuiltIn ViewportIndex
MemberDecorate 77(gl_MeshPerPrimitiveNV) 3 PerPrimitiveNV
MemberDecorate 77(gl_MeshPerPrimitiveNV) 3 BuiltIn ViewportMaskNV
Decorate 77(gl_MeshPerPrimitiveNV) Block
Decorate 119 BuiltIn WorkgroupSize
2: TypeVoid
3: TypeFunction 2
6: TypeInt 32 0
7: TypePointer Function 6(int)
9: TypeVector 6(int) 3
10: TypePointer Input 9(ivec3)
11(gl_LocalInvocationID): 10(ptr) Variable Input
12: 6(int) Constant 0
13: TypePointer Input 6(int)
17(gl_WorkGroupID): 10(ptr) Variable Input
20: TypeFloat 32
21: TypeVector 20(float) 4
22: 6(int) Constant 4
23: TypeArray 20(float) 22
24(gl_MeshPerVertexNV): TypeStruct 21(fvec4) 20(float) 23 23
25: 6(int) Constant 81
26: TypeArray 24(gl_MeshPerVertexNV) 25
27: TypePointer Output 26
28(gl_MeshVerticesNV): 27(ptr) Variable Output
30: TypeInt 32 1
31: 30(int) Constant 0
32: 20(float) Constant 1065353216
33: 21(fvec4) ConstantComposite 32 32 32 32
34: TypePointer Output 21(fvec4)
37: 30(int) Constant 1
38: 20(float) Constant 1073741824
39: TypePointer Output 20(float)
42: 30(int) Constant 2
43: 30(int) Constant 3
44: 20(float) Constant 1077936128
47: 20(float) Constant 1082130432
49: 6(int) Constant 1
50: 6(int) Constant 264
51: 6(int) Constant 2
76: TypeArray 30(int) 49
77(gl_MeshPerPrimitiveNV): TypeStruct 30(int) 30(int) 30(int) 76
78: 6(int) Constant 32
79: TypeArray 77(gl_MeshPerPrimitiveNV) 78
80: TypePointer Output 79
81(gl_MeshPrimitivesNV): 80(ptr) Variable Output
83: 30(int) Constant 6
84: TypePointer Output 30(int)
87: 30(int) Constant 7
90: 30(int) Constant 8
93: 30(int) Constant 9
119: 9(ivec3) ConstantComposite 78 49 49
4(main): 2 Function None 3
5: Label
8(iid): 7(ptr) Variable Function
16(gid): 7(ptr) Variable Function
14: 13(ptr) AccessChain 11(gl_LocalInvocationID) 12
15: 6(int) Load 14
Store 8(iid) 15
18: 13(ptr) AccessChain 17(gl_WorkGroupID) 12
19: 6(int) Load 18
Store 16(gid) 19
29: 6(int) Load 8(iid)
35: 34(ptr) AccessChain 28(gl_MeshVerticesNV) 29 31
Store 35 33
36: 6(int) Load 8(iid)
40: 39(ptr) AccessChain 28(gl_MeshVerticesNV) 36 37
Store 40 38
41: 6(int) Load 8(iid)
45: 39(ptr) AccessChain 28(gl_MeshVerticesNV) 41 42 43
Store 45 44
46: 6(int) Load 8(iid)
48: 39(ptr) AccessChain 28(gl_MeshVerticesNV) 46 43 42
Store 48 47
MemoryBarrier 49 50
ControlBarrier 51 51 50
52: 6(int) Load 8(iid)
53: 6(int) IAdd 52 49
54: 6(int) Load 8(iid)
55: 34(ptr) AccessChain 28(gl_MeshVerticesNV) 54 31
56: 21(fvec4) Load 55
57: 34(ptr) AccessChain 28(gl_MeshVerticesNV) 53 31
Store 57 56
58: 6(int) Load 8(iid)
59: 6(int) IAdd 58 49
60: 6(int) Load 8(iid)
61: 39(ptr) AccessChain 28(gl_MeshVerticesNV) 60 37
62: 20(float) Load 61
63: 39(ptr) AccessChain 28(gl_MeshVerticesNV) 59 37
Store 63 62
64: 6(int) Load 8(iid)
65: 6(int) IAdd 64 49
66: 6(int) Load 8(iid)
67: 39(ptr) AccessChain 28(gl_MeshVerticesNV) 66 42 43
68: 20(float) Load 67
69: 39(ptr) AccessChain 28(gl_MeshVerticesNV) 65 42 43
Store 69 68
70: 6(int) Load 8(iid)
71: 6(int) IAdd 70 49
72: 6(int) Load 8(iid)
73: 39(ptr) AccessChain 28(gl_MeshVerticesNV) 72 43 42
74: 20(float) Load 73
75: 39(ptr) AccessChain 28(gl_MeshVerticesNV) 71 43 42
Store 75 74
MemoryBarrier 49 50
ControlBarrier 51 51 50
82: 6(int) Load 8(iid)
85: 84(ptr) AccessChain 81(gl_MeshPrimitivesNV) 82 31
Store 85 83
86: 6(int) Load 8(iid)
88: 84(ptr) AccessChain 81(gl_MeshPrimitivesNV) 86 37
Store 88 87
89: 6(int) Load 8(iid)
91: 84(ptr) AccessChain 81(gl_MeshPrimitivesNV) 89 42
Store 91 90
92: 6(int) Load 8(iid)
94: 84(ptr) AccessChain 81(gl_MeshPrimitivesNV) 92 43 31
Store 94 93
MemoryBarrier 49 50
ControlBarrier 51 51 50
95: 6(int) Load 8(iid)
96: 6(int) IAdd 95 49
97: 6(int) Load 8(iid)
98: 84(ptr) AccessChain 81(gl_MeshPrimitivesNV) 97 31
99: 30(int) Load 98
100: 84(ptr) AccessChain 81(gl_MeshPrimitivesNV) 96 31
Store 100 99
101: 6(int) Load 8(iid)
102: 6(int) IAdd 101 49
103: 6(int) Load 8(iid)
104: 84(ptr) AccessChain 81(gl_MeshPrimitivesNV) 103 37
105: 30(int) Load 104
106: 84(ptr) AccessChain 81(gl_MeshPrimitivesNV) 102 37
Store 106 105
107: 6(int) Load 8(iid)
108: 6(int) IAdd 107 49
109: 6(int) Load 8(iid)
110: 84(ptr) AccessChain 81(gl_MeshPrimitivesNV) 109 42
111: 30(int) Load 110
112: 84(ptr) AccessChain 81(gl_MeshPrimitivesNV) 108 42
Store 112 111
113: 6(int) Load 8(iid)
114: 6(int) IAdd 113 49
115: 6(int) Load 8(iid)
116: 84(ptr) AccessChain 81(gl_MeshPrimitivesNV) 115 43 31
117: 30(int) Load 116
118: 84(ptr) AccessChain 81(gl_MeshPrimitivesNV) 114 43 31
Store 118 117
MemoryBarrier 49 50
ControlBarrier 51 51 50
Return
FunctionEnd
Loading

0 comments on commit 035cbbe

Please sign in to comment.