Add missing support for gl_MeshViewCountNV/gl_MeshViewIndicesNV in task shaders

This commit is contained in:
Sahil Parmar 2019-02-07 14:28:12 -08:00
parent 9dda1281e6
commit 3958927a59
3 changed files with 166 additions and 131 deletions

View File

@ -1,14 +1,14 @@
spv.meshTaskShader.task spv.meshTaskShader.task
// Module Version 10000 // Module Version 10000
// Generated by (magic number): 80007 // Generated by (magic number): 80007
// Id's are bound by 104 // Id's are bound by 116
Capability StorageImageWriteWithoutFormat Capability StorageImageWriteWithoutFormat
Capability MeshShadingNV Capability MeshShadingNV
Extension "SPV_NV_mesh_shader" Extension "SPV_NV_mesh_shader"
1: ExtInstImport "GLSL.std.450" 1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450 MemoryModel Logical GLSL450
EntryPoint TaskNV 4 "main" 11 17 80 101 EntryPoint TaskNV 4 "main" 11 17 24 25 90 113
ExecutionMode 4 LocalSize 32 1 1 ExecutionMode 4 LocalSize 32 1 1
Source GLSL 450 Source GLSL 450
SourceExtension "GL_NV_mesh_shader" SourceExtension "GL_NV_mesh_shader"
@ -17,34 +17,42 @@ spv.meshTaskShader.task
Name 11 "gl_LocalInvocationID" Name 11 "gl_LocalInvocationID"
Name 16 "gid" Name 16 "gid"
Name 17 "gl_WorkGroupID" Name 17 "gl_WorkGroupID"
Name 20 "i" Name 20 "viewID"
Name 34 "mem" Name 24 "gl_MeshViewIndicesNV"
Name 37 "block0" Name 25 "gl_MeshViewCountNV"
MemberName 37(block0) 0 "uni_value" Name 30 "i"
Name 39 "" Name 44 "mem"
Name 55 "uni_image" Name 47 "block0"
Name 78 "Task" MemberName 47(block0) 0 "uni_value"
MemberName 78(Task) 0 "dummy" Name 49 ""
MemberName 78(Task) 1 "submesh" Name 65 "uni_image"
Name 80 "mytask" Name 88 "Task"
Name 101 "gl_TaskCountNV" MemberName 88(Task) 0 "dummy"
MemberName 88(Task) 1 "submesh"
MemberName 88(Task) 2 "viewID"
Name 90 "mytask"
Name 113 "gl_TaskCountNV"
Decorate 11(gl_LocalInvocationID) BuiltIn LocalInvocationId Decorate 11(gl_LocalInvocationID) BuiltIn LocalInvocationId
Decorate 17(gl_WorkGroupID) BuiltIn WorkgroupId Decorate 17(gl_WorkGroupID) BuiltIn WorkgroupId
MemberDecorate 37(block0) 0 Offset 0 Decorate 24(gl_MeshViewIndicesNV) BuiltIn MeshViewIndicesNV
Decorate 37(block0) Block Decorate 25(gl_MeshViewCountNV) BuiltIn MeshViewCountNV
Decorate 39 DescriptorSet 0 MemberDecorate 47(block0) 0 Offset 0
Decorate 39 Binding 0 Decorate 47(block0) Block
Decorate 55(uni_image) DescriptorSet 0 Decorate 49 DescriptorSet 0
Decorate 55(uni_image) Binding 0 Decorate 49 Binding 0
Decorate 55(uni_image) NonReadable Decorate 65(uni_image) DescriptorSet 0
Decorate 77 ArrayStride 8 Decorate 65(uni_image) Binding 0
MemberDecorate 78(Task) 0 PerTaskNV Decorate 65(uni_image) NonReadable
MemberDecorate 78(Task) 0 Offset 0 Decorate 87 ArrayStride 8
MemberDecorate 78(Task) 1 PerTaskNV MemberDecorate 88(Task) 0 PerTaskNV
MemberDecorate 78(Task) 1 Offset 8 MemberDecorate 88(Task) 0 Offset 0
Decorate 78(Task) Block MemberDecorate 88(Task) 1 PerTaskNV
Decorate 101(gl_TaskCountNV) BuiltIn TaskCountNV MemberDecorate 88(Task) 1 Offset 8
Decorate 103 BuiltIn WorkgroupSize MemberDecorate 88(Task) 2 PerTaskNV
MemberDecorate 88(Task) 2 Offset 32
Decorate 88(Task) Block
Decorate 113(gl_TaskCountNV) BuiltIn TaskCountNV
Decorate 115 BuiltIn WorkgroupSize
2: TypeVoid 2: TypeVoid
3: TypeFunction 2 3: TypeFunction 2
6: TypeInt 32 0 6: TypeInt 32 0
@ -55,119 +63,133 @@ spv.meshTaskShader.task
12: 6(int) Constant 0 12: 6(int) Constant 0
13: TypePointer Input 6(int) 13: TypePointer Input 6(int)
17(gl_WorkGroupID): 10(ptr) Variable Input 17(gl_WorkGroupID): 10(ptr) Variable Input
27: 6(int) Constant 10 21: 6(int) Constant 4
28: TypeBool 22: TypeArray 6(int) 21
30: TypeFloat 32 23: TypePointer Input 22
31: TypeVector 30(float) 4 24(gl_MeshViewIndicesNV): 23(ptr) Variable Input
32: TypeArray 31(fvec4) 27 25(gl_MeshViewCountNV): 13(ptr) Variable Input
33: TypePointer Workgroup 32 37: 6(int) Constant 10
34(mem): 33(ptr) Variable Workgroup 38: TypeBool
37(block0): TypeStruct 6(int) 40: TypeFloat 32
38: TypePointer Uniform 37(block0) 41: TypeVector 40(float) 4
39: 38(ptr) Variable Uniform 42: TypeArray 41(fvec4) 37
40: TypeInt 32 1 43: TypePointer Workgroup 42
41: 40(int) Constant 0 44(mem): 43(ptr) Variable Workgroup
42: TypePointer Uniform 6(int) 47(block0): TypeStruct 6(int)
48: TypePointer Workgroup 31(fvec4) 48: TypePointer Uniform 47(block0)
51: 40(int) Constant 1 49: 48(ptr) Variable Uniform
53: TypeImage 30(float) 2D nonsampled format:Unknown 50: TypeInt 32 1
54: TypePointer UniformConstant 53 51: 50(int) Constant 0
55(uni_image): 54(ptr) Variable UniformConstant 52: TypePointer Uniform 6(int)
59: TypeVector 40(int) 2 58: TypePointer Workgroup 41(fvec4)
69: 6(int) Constant 1 61: 50(int) Constant 1
73: 6(int) Constant 264 63: TypeImage 40(float) 2D nonsampled format:Unknown
74: 6(int) Constant 2 64: TypePointer UniformConstant 63
75: TypeVector 30(float) 2 65(uni_image): 64(ptr) Variable UniformConstant
76: 6(int) Constant 3 69: TypeVector 50(int) 2
77: TypeArray 75(fvec2) 76 79: 6(int) Constant 1
78(Task): TypeStruct 75(fvec2) 77 83: 6(int) Constant 264
79: TypePointer Output 78(Task) 84: 6(int) Constant 2
80(mytask): 79(ptr) Variable Output 85: TypeVector 40(float) 2
81: 30(float) Constant 1106247680 86: 6(int) Constant 3
82: 30(float) Constant 1106771968 87: TypeArray 85(fvec2) 86
83: 75(fvec2) ConstantComposite 81 82 88(Task): TypeStruct 85(fvec2) 87 6(int)
84: TypePointer Output 75(fvec2) 89: TypePointer Output 88(Task)
86: 30(float) Constant 1107296256 90(mytask): 89(ptr) Variable Output
87: 30(float) Constant 1107558400 91: 40(float) Constant 1106247680
88: 75(fvec2) ConstantComposite 86 87 92: 40(float) Constant 1106771968
90: 30(float) Constant 1107820544 93: 85(fvec2) ConstantComposite 91 92
91: 30(float) Constant 1108082688 94: TypePointer Output 85(fvec2)
92: 75(fvec2) ConstantComposite 90 91 96: 40(float) Constant 1107296256
94: 40(int) Constant 2 97: 40(float) Constant 1107558400
100: TypePointer Output 6(int) 98: 85(fvec2) ConstantComposite 96 97
101(gl_TaskCountNV): 100(ptr) Variable Output 100: 40(float) Constant 1107820544
102: 6(int) Constant 32 101: 40(float) Constant 1108082688
103: 9(ivec3) ConstantComposite 102 69 69 102: 85(fvec2) ConstantComposite 100 101
104: 50(int) Constant 2
111: TypePointer Output 6(int)
113(gl_TaskCountNV): 111(ptr) Variable Output
114: 6(int) Constant 32
115: 9(ivec3) ConstantComposite 114 79 79
4(main): 2 Function None 3 4(main): 2 Function None 3
5: Label 5: Label
8(iid): 7(ptr) Variable Function 8(iid): 7(ptr) Variable Function
16(gid): 7(ptr) Variable Function 16(gid): 7(ptr) Variable Function
20(i): 7(ptr) Variable Function 20(viewID): 7(ptr) Variable Function
30(i): 7(ptr) Variable Function
14: 13(ptr) AccessChain 11(gl_LocalInvocationID) 12 14: 13(ptr) AccessChain 11(gl_LocalInvocationID) 12
15: 6(int) Load 14 15: 6(int) Load 14
Store 8(iid) 15 Store 8(iid) 15
18: 13(ptr) AccessChain 17(gl_WorkGroupID) 12 18: 13(ptr) AccessChain 17(gl_WorkGroupID) 12
19: 6(int) Load 18 19: 6(int) Load 18
Store 16(gid) 19 Store 16(gid) 19
Store 20(i) 12 26: 6(int) Load 25(gl_MeshViewCountNV)
Branch 21 27: 6(int) UMod 26 21
21: Label 28: 13(ptr) AccessChain 24(gl_MeshViewIndicesNV) 27
LoopMerge 23 24 None 29: 6(int) Load 28
Branch 25 Store 20(viewID) 29
25: Label Store 30(i) 12
26: 6(int) Load 20(i) Branch 31
29: 28(bool) ULessThan 26 27 31: Label
BranchConditional 29 22 23 LoopMerge 33 34 None
22: Label Branch 35
35: 6(int) Load 20(i) 35: Label
36: 6(int) Load 20(i) 36: 6(int) Load 30(i)
43: 42(ptr) AccessChain 39 41 39: 38(bool) ULessThan 36 37
44: 6(int) Load 43 BranchConditional 39 32 33
45: 6(int) IAdd 36 44 32: Label
46: 30(float) ConvertUToF 45 45: 6(int) Load 30(i)
47: 31(fvec4) CompositeConstruct 46 46 46 46 46: 6(int) Load 30(i)
49: 48(ptr) AccessChain 34(mem) 35 53: 52(ptr) AccessChain 49 51
Store 49 47 54: 6(int) Load 53
Branch 24 55: 6(int) IAdd 46 54
24: Label 56: 40(float) ConvertUToF 55
50: 6(int) Load 20(i) 57: 41(fvec4) CompositeConstruct 56 56 56 56
52: 6(int) IAdd 50 51 59: 58(ptr) AccessChain 44(mem) 45
Store 20(i) 52 Store 59 57
Branch 21 Branch 34
23: Label 34: Label
56: 53 Load 55(uni_image) 60: 6(int) Load 30(i)
57: 6(int) Load 8(iid) 62: 6(int) IAdd 60 61
58: 40(int) Bitcast 57 Store 30(i) 62
60: 59(ivec2) CompositeConstruct 58 58 Branch 31
61: 6(int) Load 16(gid) 33: Label
62: 48(ptr) AccessChain 34(mem) 61 66: 63 Load 65(uni_image)
63: 31(fvec4) Load 62 67: 6(int) Load 8(iid)
ImageWrite 56 60 63 68: 50(int) Bitcast 67
64: 53 Load 55(uni_image) 70: 69(ivec2) CompositeConstruct 68 68
65: 6(int) Load 8(iid) 71: 6(int) Load 16(gid)
66: 40(int) Bitcast 65 72: 58(ptr) AccessChain 44(mem) 71
67: 59(ivec2) CompositeConstruct 66 66 73: 41(fvec4) Load 72
68: 6(int) Load 16(gid) ImageWrite 66 70 73
70: 6(int) IAdd 68 69 74: 63 Load 65(uni_image)
71: 48(ptr) AccessChain 34(mem) 70 75: 6(int) Load 8(iid)
72: 31(fvec4) Load 71 76: 50(int) Bitcast 75
ImageWrite 64 67 72 77: 69(ivec2) CompositeConstruct 76 76
MemoryBarrier 69 73 78: 6(int) Load 16(gid)
ControlBarrier 74 74 73 80: 6(int) IAdd 78 79
85: 84(ptr) AccessChain 80(mytask) 41 81: 58(ptr) AccessChain 44(mem) 80
Store 85 83 82: 41(fvec4) Load 81
89: 84(ptr) AccessChain 80(mytask) 51 41 ImageWrite 74 77 82
Store 89 88 MemoryBarrier 79 83
93: 84(ptr) AccessChain 80(mytask) 51 51 ControlBarrier 84 84 83
Store 93 92 95: 94(ptr) AccessChain 90(mytask) 51
95: 6(int) Load 16(gid) Store 95 93
96: 6(int) UMod 95 74 99: 94(ptr) AccessChain 90(mytask) 61 51
97: 84(ptr) AccessChain 80(mytask) 51 96
98: 75(fvec2) Load 97
99: 84(ptr) AccessChain 80(mytask) 51 94
Store 99 98 Store 99 98
MemoryBarrier 69 73 103: 94(ptr) AccessChain 90(mytask) 61 61
ControlBarrier 74 74 73 Store 103 102
Store 101(gl_TaskCountNV) 76 105: 6(int) Load 16(gid)
106: 6(int) UMod 105 84
107: 94(ptr) AccessChain 90(mytask) 61 106
108: 85(fvec2) Load 107
109: 94(ptr) AccessChain 90(mytask) 61 104
Store 109 108
110: 6(int) Load 20(viewID)
112: 111(ptr) AccessChain 90(mytask) 104
Store 112 110
MemoryBarrier 79 83
ControlBarrier 84 84 83
Store 113(gl_TaskCountNV) 86
Return Return
FunctionEnd FunctionEnd

View File

@ -1,5 +1,7 @@
#version 450 #version 450
#define MAX_VIEWS gl_MaxMeshViewCountNV
#define BARRIER() \ #define BARRIER() \
memoryBarrierShared(); \ memoryBarrierShared(); \
barrier(); barrier();
@ -19,12 +21,14 @@ shared vec4 mem[10];
taskNV out Task { taskNV out Task {
vec2 dummy; vec2 dummy;
vec2 submesh[3]; vec2 submesh[3];
uint viewID;
} mytask; } mytask;
void main() void main()
{ {
uint iid = gl_LocalInvocationID.x; uint iid = gl_LocalInvocationID.x;
uint gid = gl_WorkGroupID.x; uint gid = gl_WorkGroupID.x;
uint viewID = gl_MeshViewIndicesNV[gl_MeshViewCountNV%MAX_VIEWS];
// 1. shared memory load and stores // 1. shared memory load and stores
for (uint i = 0; i < 10; ++i) { for (uint i = 0; i < 10; ++i) {
@ -41,6 +45,7 @@ void main()
mytask.submesh[0] = vec2(32.0, 33.0); mytask.submesh[0] = vec2(32.0, 33.0);
mytask.submesh[1] = vec2(34.0, 35.0); mytask.submesh[1] = vec2(34.0, 35.0);
mytask.submesh[2] = mytask.submesh[gid%2]; mytask.submesh[2] = mytask.submesh[gid%2];
mytask.viewID = viewID;
BARRIER(); BARRIER();

View File

@ -5357,6 +5357,9 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
"in highp uvec3 gl_GlobalInvocationID;" "in highp uvec3 gl_GlobalInvocationID;"
"in highp uint gl_LocalInvocationIndex;" "in highp uint gl_LocalInvocationIndex;"
"in uint gl_MeshViewCountNV;"
"in uint gl_MeshViewIndicesNV[4];"
"\n"); "\n");
} }
@ -8843,6 +8846,8 @@ void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion
symbolTable.setVariableExtensions("gl_LocalInvocationID", 1, &E_GL_NV_mesh_shader); symbolTable.setVariableExtensions("gl_LocalInvocationID", 1, &E_GL_NV_mesh_shader);
symbolTable.setVariableExtensions("gl_GlobalInvocationID", 1, &E_GL_NV_mesh_shader); symbolTable.setVariableExtensions("gl_GlobalInvocationID", 1, &E_GL_NV_mesh_shader);
symbolTable.setVariableExtensions("gl_LocalInvocationIndex", 1, &E_GL_NV_mesh_shader); symbolTable.setVariableExtensions("gl_LocalInvocationIndex", 1, &E_GL_NV_mesh_shader);
symbolTable.setVariableExtensions("gl_MeshViewCountNV", 1, &E_GL_NV_mesh_shader);
symbolTable.setVariableExtensions("gl_MeshViewIndicesNV", 1, &E_GL_NV_mesh_shader);
BuiltInVariable("gl_TaskCountNV", EbvTaskCountNV, symbolTable); BuiltInVariable("gl_TaskCountNV", EbvTaskCountNV, symbolTable);
BuiltInVariable("gl_WorkGroupSize", EbvWorkGroupSize, symbolTable); BuiltInVariable("gl_WorkGroupSize", EbvWorkGroupSize, symbolTable);
@ -8850,8 +8855,11 @@ void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion
BuiltInVariable("gl_LocalInvocationID", EbvLocalInvocationId, symbolTable); BuiltInVariable("gl_LocalInvocationID", EbvLocalInvocationId, symbolTable);
BuiltInVariable("gl_GlobalInvocationID", EbvGlobalInvocationId, symbolTable); BuiltInVariable("gl_GlobalInvocationID", EbvGlobalInvocationId, symbolTable);
BuiltInVariable("gl_LocalInvocationIndex", EbvLocalInvocationIndex, symbolTable); BuiltInVariable("gl_LocalInvocationIndex", EbvLocalInvocationIndex, symbolTable);
BuiltInVariable("gl_MeshViewCountNV", EbvMeshViewCountNV, symbolTable);
BuiltInVariable("gl_MeshViewIndicesNV", EbvMeshViewIndicesNV, symbolTable);
symbolTable.setVariableExtensions("gl_MaxTaskWorkGroupSizeNV", 1, &E_GL_NV_mesh_shader); symbolTable.setVariableExtensions("gl_MaxTaskWorkGroupSizeNV", 1, &E_GL_NV_mesh_shader);
symbolTable.setVariableExtensions("gl_MaxMeshViewCountNV", 1, &E_GL_NV_mesh_shader);
symbolTable.setFunctionExtensions("barrier", 1, &E_GL_NV_mesh_shader); symbolTable.setFunctionExtensions("barrier", 1, &E_GL_NV_mesh_shader);
symbolTable.setFunctionExtensions("memoryBarrierShared", 1, &E_GL_NV_mesh_shader); symbolTable.setFunctionExtensions("memoryBarrierShared", 1, &E_GL_NV_mesh_shader);