Add ES 320 support and additional error checks for SPV_NV_mesh_shader

- Add ES 320 support
- Error out use of perprimitiveNV for non mesh/fragment shaders
- Error out use of mesh/task shaders w/o use of NV_mesh_shader
- Error out use of NV_mesh_shader for non task/mesh shaders
- Error out use of perviewNV for non mesh shaders
- Error out use of taskNV for non mesh/task shaders
- Add test case for mesh shader with ES 320 profile
This commit is contained in:
Sahil Parmar 2018-09-25 13:45:32 -07:00
parent a8453d4bc0
commit 95e2d4ec02
11 changed files with 1345 additions and 1279 deletions

View File

@ -1,203 +1,205 @@
spv.meshShaderUserDefined.mesh spv.meshShaderUserDefined.mesh
// Module Version 10000 // Module Version 10000
// Generated by (magic number): 80007 // Generated by (magic number): 80007
// Id's are bound by 138 // Id's are bound by 140
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 MeshNV 4 "main" 11 17 34 101 EntryPoint MeshNV 4 "main" 12 19 37 103
ExecutionMode 4 LocalSize 32 1 1 ExecutionMode 4 LocalSize 32 1 1
ExecutionMode 4 OutputVertices 81 ExecutionMode 4 OutputVertices 81
ExecutionMode 4 OutputPrimitivesNV 32 ExecutionMode 4 OutputPrimitivesNV 32
ExecutionMode 4 OutputTrianglesNV ExecutionMode 4 OutputTrianglesNV
Source GLSL 450 Source ESSL 320
SourceExtension "GL_NV_mesh_shader" SourceExtension "GL_NV_mesh_shader"
Name 4 "main" Name 4 "main"
Name 8 "iid" Name 8 "iid"
Name 11 "gl_LocalInvocationID" Name 12 "gl_LocalInvocationID"
Name 16 "gid" Name 18 "gid"
Name 17 "gl_WorkGroupID" Name 19 "gl_WorkGroupID"
Name 30 "myblock" Name 33 "myblock"
MemberName 30(myblock) 0 "f" MemberName 33(myblock) 0 "f"
MemberName 30(myblock) 1 "fArr" MemberName 33(myblock) 1 "fArr"
MemberName 30(myblock) 2 "pos" MemberName 33(myblock) 2 "pos"
MemberName 30(myblock) 3 "posArr" MemberName 33(myblock) 3 "posArr"
MemberName 30(myblock) 4 "m" MemberName 33(myblock) 4 "m"
MemberName 30(myblock) 5 "mArr" MemberName 33(myblock) 5 "mArr"
Name 34 "blk" Name 37 "blk"
Name 97 "myblock2" Name 99 "myblock2"
MemberName 97(myblock2) 0 "f" MemberName 99(myblock2) 0 "f"
MemberName 97(myblock2) 1 "pos" MemberName 99(myblock2) 1 "pos"
MemberName 97(myblock2) 2 "m" MemberName 99(myblock2) 2 "m"
Name 101 "blk2" Name 103 "blk2"
Decorate 11(gl_LocalInvocationID) BuiltIn LocalInvocationId Decorate 12(gl_LocalInvocationID) BuiltIn LocalInvocationId
Decorate 17(gl_WorkGroupID) BuiltIn WorkgroupId Decorate 19(gl_WorkGroupID) BuiltIn WorkgroupId
MemberDecorate 30(myblock) 0 PerPrimitiveNV MemberDecorate 33(myblock) 0 PerPrimitiveNV
MemberDecorate 30(myblock) 1 PerPrimitiveNV MemberDecorate 33(myblock) 1 PerPrimitiveNV
MemberDecorate 30(myblock) 2 PerPrimitiveNV MemberDecorate 33(myblock) 2 PerPrimitiveNV
MemberDecorate 30(myblock) 3 PerPrimitiveNV MemberDecorate 33(myblock) 3 PerPrimitiveNV
MemberDecorate 30(myblock) 4 PerPrimitiveNV MemberDecorate 33(myblock) 4 PerPrimitiveNV
MemberDecorate 30(myblock) 5 PerPrimitiveNV MemberDecorate 33(myblock) 5 PerPrimitiveNV
Decorate 30(myblock) Block Decorate 33(myblock) Block
Decorate 34(blk) Location 0 Decorate 37(blk) Location 0
Decorate 97(myblock2) Block Decorate 99(myblock2) Block
Decorate 101(blk2) Location 20 Decorate 103(blk2) Location 20
Decorate 137 BuiltIn WorkgroupSize Decorate 139 BuiltIn WorkgroupSize
2: TypeVoid 2: TypeVoid
3: TypeFunction 2 3: TypeFunction 2
6: TypeInt 32 0 6: TypeInt 32 1
7: TypePointer Function 6(int) 7: TypePointer Function 6(int)
9: TypeVector 6(int) 3 9: TypeInt 32 0
10: TypePointer Input 9(ivec3) 10: TypeVector 9(int) 3
11(gl_LocalInvocationID): 10(ptr) Variable Input 11: TypePointer Input 10(ivec3)
12: 6(int) Constant 0 12(gl_LocalInvocationID): 11(ptr) Variable Input
13: TypePointer Input 6(int) 13: 9(int) Constant 0
17(gl_WorkGroupID): 10(ptr) Variable Input 14: TypePointer Input 9(int)
20: TypeFloat 32 19(gl_WorkGroupID): 11(ptr) Variable Input
21: 6(int) Constant 4 23: TypeFloat 32
22: TypeArray 20(float) 21 24: 9(int) Constant 4
23: TypeVector 20(float) 3 25: TypeArray 23(float) 24
24: TypeVector 20(float) 4 26: TypeVector 23(float) 3
25: TypeArray 24(fvec4) 21 27: TypeVector 23(float) 4
26: TypeMatrix 24(fvec4) 4 28: TypeArray 27(fvec4) 24
27: TypeMatrix 23(fvec3) 3 29: TypeMatrix 27(fvec4) 4
28: 6(int) Constant 2 30: TypeMatrix 26(fvec3) 3
29: TypeArray 27 28 31: 9(int) Constant 2
30(myblock): TypeStruct 20(float) 22 23(fvec3) 25 26 29 32: TypeArray 30 31
31: 6(int) Constant 32 33(myblock): TypeStruct 23(float) 25 26(fvec3) 28 29 32
32: TypeArray 30(myblock) 31 34: 9(int) Constant 32
33: TypePointer Output 32 35: TypeArray 33(myblock) 34
34(blk): 33(ptr) Variable Output 36: TypePointer Output 35
36: TypeInt 32 1 37(blk): 36(ptr) Variable Output
37: 36(int) Constant 0 39: 6(int) Constant 0
38: 20(float) Constant 1093664768 40: 23(float) Constant 1093664768
39: TypePointer Output 20(float) 41: TypePointer Output 23(float)
42: 6(int) Constant 1 44: 6(int) Constant 1
44: 36(int) Constant 1 52: 6(int) Constant 2
52: 36(int) Constant 2 54: 23(float) Constant 1096810496
53: 20(float) Constant 1096810496 55: 23(float) Constant 1097859072
54: 20(float) Constant 1097859072 56: 23(float) Constant 1095761920
55: 20(float) Constant 1095761920 57: 26(fvec3) ConstantComposite 54 55 56
56: 23(fvec3) ConstantComposite 53 54 55 58: TypePointer Output 26(fvec3)
57: TypePointer Output 23(fvec3) 64: 6(int) Constant 3
63: 36(int) Constant 3 69: TypePointer Output 27(fvec4)
68: TypePointer Output 24(fvec4) 74: 6(int) Constant 4
74: 36(int) Constant 4 76: 23(float) Constant 1098907648
75: 20(float) Constant 1098907648 77: 27(fvec4) ConstantComposite 56 54 55 76
76: 24(fvec4) ConstantComposite 55 53 54 75 82: 6(int) Constant 5
81: 36(int) Constant 5 85: 9(int) Constant 3
84: 6(int) Constant 3 88: 9(int) Constant 1
91: 20(float) Constant 1099431936 93: 23(float) Constant 1099431936
92: 20(float) Constant 1099956224 94: 23(float) Constant 1099956224
93: 20(float) Constant 1100480512 95: 23(float) Constant 1100480512
94: 23(fvec3) ConstantComposite 91 92 93 96: 26(fvec3) ConstantComposite 93 94 95
96: 6(int) Constant 264 98: 9(int) Constant 264
97(myblock2): TypeStruct 20(float) 24(fvec4) 26 99(myblock2): TypeStruct 23(float) 27(fvec4) 29
98: 6(int) Constant 81 100: 9(int) Constant 81
99: TypeArray 97(myblock2) 98 101: TypeArray 99(myblock2) 100
100: TypePointer Output 99 102: TypePointer Output 101
101(blk2): 100(ptr) Variable Output 103(blk2): 102(ptr) Variable Output
107: 20(float) Constant 1101004800 109: 23(float) Constant 1101004800
111: 20(float) Constant 1101529088 113: 23(float) Constant 1101529088
112: 20(float) Constant 1102053376 114: 23(float) Constant 1102053376
113: 20(float) Constant 1102577664 115: 23(float) Constant 1102577664
114: 20(float) Constant 1103101952 116: 23(float) Constant 1103101952
115: 24(fvec4) ConstantComposite 111 112 113 114 117: 27(fvec4) ConstantComposite 113 114 115 116
127: 20(float) Constant 1105723392 129: 23(float) Constant 1105723392
137: 9(ivec3) ConstantComposite 31 42 42 139: 10(ivec3) ConstantComposite 34 88 88
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 18(gid): 7(ptr) Variable Function
14: 13(ptr) AccessChain 11(gl_LocalInvocationID) 12 15: 14(ptr) AccessChain 12(gl_LocalInvocationID) 13
15: 6(int) Load 14 16: 9(int) Load 15
Store 8(iid) 15 17: 6(int) Bitcast 16
18: 13(ptr) AccessChain 17(gl_WorkGroupID) 12 Store 8(iid) 17
19: 6(int) Load 18 20: 14(ptr) AccessChain 19(gl_WorkGroupID) 13
Store 16(gid) 19 21: 9(int) Load 20
35: 6(int) Load 8(iid) 22: 6(int) Bitcast 21
40: 39(ptr) AccessChain 34(blk) 35 37 Store 18(gid) 22
Store 40 38 38: 6(int) Load 8(iid)
41: 6(int) Load 8(iid) 42: 41(ptr) AccessChain 37(blk) 38 39
43: 6(int) IAdd 41 42 Store 42 40
45: 6(int) Load 16(gid) 43: 6(int) Load 8(iid)
46: 6(int) Load 8(iid) 45: 6(int) IAdd 43 44
47: 39(ptr) AccessChain 34(blk) 46 37 46: 6(int) Load 18(gid)
48: 20(float) Load 47 47: 6(int) Load 8(iid)
49: 39(ptr) AccessChain 34(blk) 43 44 45 48: 41(ptr) AccessChain 37(blk) 47 39
Store 49 48 49: 23(float) Load 48
50: 6(int) Load 8(iid) 50: 41(ptr) AccessChain 37(blk) 45 44 46
51: 6(int) UDiv 50 28 Store 50 49
58: 57(ptr) AccessChain 34(blk) 51 52 51: 6(int) Load 8(iid)
59: 23(fvec3) Load 58 53: 6(int) SDiv 51 52
60: 23(fvec3) VectorShuffle 59 56 5 3 4 59: 58(ptr) AccessChain 37(blk) 53 52
Store 58 60 60: 26(fvec3) Load 59
61: 6(int) Load 8(iid) 61: 26(fvec3) VectorShuffle 60 57 5 3 4
62: 6(int) IMul 61 28 Store 59 61
64: 6(int) Load 8(iid) 62: 6(int) Load 8(iid)
65: 6(int) UDiv 64 28 63: 6(int) IMul 62 52
66: 57(ptr) AccessChain 34(blk) 65 52 65: 6(int) Load 8(iid)
67: 23(fvec3) Load 66 66: 6(int) SDiv 65 52
69: 68(ptr) AccessChain 34(blk) 62 63 44 67: 58(ptr) AccessChain 37(blk) 66 52
70: 24(fvec4) Load 69 68: 26(fvec3) Load 67
71: 24(fvec4) VectorShuffle 70 67 0 4 5 6 70: 69(ptr) AccessChain 37(blk) 63 64 44
Store 69 71 71: 27(fvec4) Load 70
72: 6(int) Load 8(iid) 72: 27(fvec4) VectorShuffle 71 68 0 4 5 6
73: 6(int) UDiv 72 21 Store 70 72
77: 68(ptr) AccessChain 34(blk) 73 74 52 73: 6(int) Load 8(iid)
78: 24(fvec4) Load 77 75: 6(int) SDiv 73 74
79: 24(fvec4) VectorShuffle 78 76 7 6 5 4 78: 69(ptr) AccessChain 37(blk) 75 74 52
Store 77 79 79: 27(fvec4) Load 78
80: 6(int) Load 8(iid) 80: 27(fvec4) VectorShuffle 79 77 7 6 5 4
82: 6(int) Load 8(iid) Store 78 80
83: 6(int) UDiv 82 21 81: 6(int) Load 8(iid)
85: 39(ptr) AccessChain 34(blk) 83 74 52 84 83: 6(int) Load 8(iid)
86: 20(float) Load 85 84: 6(int) SDiv 83 74
87: 39(ptr) AccessChain 34(blk) 80 81 37 44 42 86: 41(ptr) AccessChain 37(blk) 84 74 52 85
Store 87 86 87: 23(float) Load 86
88: 6(int) Load 8(iid) 89: 41(ptr) AccessChain 37(blk) 81 82 39 44 88
89: 6(int) IMul 88 21 Store 89 87
90: 6(int) Load 16(gid) 90: 6(int) Load 8(iid)
95: 57(ptr) AccessChain 34(blk) 89 81 44 90 91: 6(int) IMul 90 74
Store 95 94 92: 6(int) Load 18(gid)
MemoryBarrier 42 96 97: 58(ptr) AccessChain 37(blk) 91 82 44 92
ControlBarrier 28 28 96 Store 97 96
102: 6(int) Load 8(iid) MemoryBarrier 88 98
103: 6(int) Load 8(iid) ControlBarrier 31 31 98
104: 6(int) ISub 103 42 104: 6(int) Load 8(iid)
105: 39(ptr) AccessChain 101(blk2) 104 37 105: 6(int) Load 8(iid)
106: 20(float) Load 105 106: 6(int) ISub 105 44
108: 20(float) FAdd 106 107 107: 41(ptr) AccessChain 103(blk2) 106 39
109: 39(ptr) AccessChain 101(blk2) 102 37 108: 23(float) Load 107
Store 109 108 110: 23(float) FAdd 108 109
110: 6(int) Load 8(iid) 111: 41(ptr) AccessChain 103(blk2) 104 39
116: 68(ptr) AccessChain 101(blk2) 110 44 Store 111 110
Store 116 115 112: 6(int) Load 8(iid)
117: 6(int) Load 8(iid) 118: 69(ptr) AccessChain 103(blk2) 112 44
118: 6(int) IAdd 117 42 Store 118 117
119: 6(int) Load 16(gid) 119: 6(int) Load 8(iid)
120: 6(int) Load 8(iid) 120: 6(int) IAdd 119 44
121: 68(ptr) AccessChain 101(blk2) 120 44 121: 6(int) Load 18(gid)
122: 24(fvec4) Load 121 122: 6(int) Load 8(iid)
123: 68(ptr) AccessChain 101(blk2) 118 52 119 123: 69(ptr) AccessChain 103(blk2) 122 44
Store 123 122 124: 27(fvec4) Load 123
124: 6(int) Load 8(iid) 125: 69(ptr) AccessChain 103(blk2) 120 52 121
125: 6(int) IAdd 124 42 Store 125 124
126: 6(int) Load 16(gid) 126: 6(int) Load 8(iid)
128: 39(ptr) AccessChain 101(blk2) 125 52 126 28 127: 6(int) IAdd 126 44
Store 128 127 128: 6(int) Load 18(gid)
129: 6(int) Load 8(iid) 130: 41(ptr) AccessChain 103(blk2) 127 52 128 31
130: 6(int) IAdd 129 28 Store 130 129
131: 6(int) Load 8(iid) 131: 6(int) Load 8(iid)
132: 6(int) IAdd 131 42 132: 6(int) IAdd 131 52
133: 6(int) Load 16(gid) 133: 6(int) Load 8(iid)
134: 68(ptr) AccessChain 101(blk2) 132 52 133 134: 6(int) IAdd 133 44
135: 24(fvec4) Load 134 135: 6(int) Load 18(gid)
136: 68(ptr) AccessChain 101(blk2) 130 52 63 136: 69(ptr) AccessChain 103(blk2) 134 52 135
Store 136 135 137: 27(fvec4) Load 136
MemoryBarrier 42 96 138: 69(ptr) AccessChain 103(blk2) 132 52 64
ControlBarrier 28 28 96 Store 138 137
MemoryBarrier 88 98
ControlBarrier 31 31 98
Return Return
FunctionEnd FunctionEnd

View File

@ -1,4 +1,4 @@
#version 450 #version 320 es
#define MAX_VER 81 #define MAX_VER 81
#define MAX_PRIM 32 #define MAX_PRIM 32
@ -36,8 +36,8 @@ layout(location=20) out myblock2 {
void main() void main()
{ {
uint iid = gl_LocalInvocationID.x; int iid = int(gl_LocalInvocationID.x);
uint gid = gl_WorkGroupID.x; int gid = int(gl_WorkGroupID.x);
blk[iid].f = 11.0; blk[iid].f = 11.0;
blk[iid+1].fArr[gid] = blk[iid].f; blk[iid+1].fArr[gid] = blk[iid].f;

View File

@ -4878,7 +4878,7 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
"void barrier();" "void barrier();"
); );
#ifdef NV_EXTENSIONS #ifdef NV_EXTENSIONS
if ((profile != EEsProfile && version >= 450) || esBarrier) { if ((profile != EEsProfile && version >= 450) || (profile == EEsProfile && version >= 320)) {
stageBuiltins[EShLangMeshNV].append( stageBuiltins[EShLangMeshNV].append(
"void barrier();" "void barrier();"
); );
@ -4903,7 +4903,7 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
); );
} }
#ifdef NV_EXTENSIONS #ifdef NV_EXTENSIONS
if (profile != EEsProfile && version >= 450) { if ((profile != EEsProfile && version >= 450) || (profile == EEsProfile && version >= 320)) {
stageBuiltins[EShLangMeshNV].append( stageBuiltins[EShLangMeshNV].append(
"void memoryBarrierShared();" "void memoryBarrierShared();"
"void groupMemoryBarrier();" "void groupMemoryBarrier();"
@ -5094,7 +5094,7 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
} }
// Builtins for GL_NV_mesh_shader // Builtins for GL_NV_mesh_shader
if (profile != EEsProfile && version >= 450) { if ((profile != EEsProfile && version >= 450) || (profile == EEsProfile && version >= 320)) {
stageBuiltins[EShLangMeshNV].append( stageBuiltins[EShLangMeshNV].append(
"void writePackedPrimitiveIndices4x8NV(uint, uint);" "void writePackedPrimitiveIndices4x8NV(uint, uint);"
"\n"); "\n");
@ -5287,7 +5287,7 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
// //
//============================================================================ //============================================================================
if (profile != EEsProfile && version >= 450) { if ((profile != EEsProfile && version >= 450) || (profile == EEsProfile && version >= 320)) {
// per-vertex attributes // per-vertex attributes
stageBuiltins[EShLangMeshNV].append( stageBuiltins[EShLangMeshNV].append(
"out gl_MeshPerVertexNV {" "out gl_MeshPerVertexNV {"
@ -5328,17 +5328,8 @@ 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 highp int gl_DeviceIndex;" // GL_EXT_device_group
"in int gl_DrawIDARB;" // GL_ARB_shader_draw_parameters
"\n"); "\n");
if (version >= 460) {
stageBuiltins[EShLangMeshNV].append(
"in int gl_DrawID;"
);
}
stageBuiltins[EShLangTaskNV].append( stageBuiltins[EShLangTaskNV].append(
"out uint gl_TaskCountNV;" "out uint gl_TaskCountNV;"
@ -5350,15 +5341,28 @@ 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;"
"\n");
}
if (profile != EEsProfile && version >= 450) {
stageBuiltins[EShLangMeshNV].append(
"in highp int gl_DeviceIndex;" // GL_EXT_device_group "in highp int gl_DeviceIndex;" // GL_EXT_device_group
"in int gl_DrawIDARB;" // GL_ARB_shader_draw_parameters "in int gl_DrawIDARB;" // GL_ARB_shader_draw_parameters
"\n");
stageBuiltins[EShLangTaskNV].append(
"in highp int gl_DeviceIndex;" // GL_EXT_device_group
"in int gl_DrawIDARB;" // GL_ARB_shader_draw_parameters
"\n"); "\n");
if (version >= 460) { if (version >= 460) {
stageBuiltins[EShLangMeshNV].append(
"in int gl_DrawID;"
"\n");
stageBuiltins[EShLangTaskNV].append( stageBuiltins[EShLangTaskNV].append(
"in int gl_DrawID;" "in int gl_DrawID;"
); "\n");
} }
} }
#endif #endif
@ -7658,7 +7662,7 @@ void TBuiltIns::initialize(const TBuiltInResource &resources, int version, EProf
#ifdef NV_EXTENSIONS #ifdef NV_EXTENSIONS
// SPV_NV_mesh_shader // SPV_NV_mesh_shader
if (profile != EEsProfile && version >= 450) { if ((profile != EEsProfile && version >= 450) || (profile == EEsProfile && version >= 320)) {
snprintf(builtInConstant, maxSize, "const int gl_MaxMeshOutputVerticesNV = %d;", resources.maxMeshOutputVerticesNV); snprintf(builtInConstant, maxSize, "const int gl_MaxMeshOutputVerticesNV = %d;", resources.maxMeshOutputVerticesNV);
s.append(builtInConstant); s.append(builtInConstant);
@ -8633,7 +8637,7 @@ void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion
} }
break; break;
case EShLangMeshNV: case EShLangMeshNV:
if (profile != EEsProfile && version >= 450) { if ((profile != EEsProfile && version >= 450) || (profile == EEsProfile && version >= 320)) {
// Per-vertex builtins // Per-vertex builtins
BuiltInVariable("gl_MeshVerticesNV", "gl_Position", EbvPosition, symbolTable); BuiltInVariable("gl_MeshVerticesNV", "gl_Position", EbvPosition, symbolTable);
BuiltInVariable("gl_MeshVerticesNV", "gl_PointSize", EbvPointSize, symbolTable); BuiltInVariable("gl_MeshVerticesNV", "gl_PointSize", EbvPointSize, symbolTable);
@ -8681,7 +8685,9 @@ void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion
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);
symbolTable.setFunctionExtensions("groupMemoryBarrier", 1, &E_GL_NV_mesh_shader); symbolTable.setFunctionExtensions("groupMemoryBarrier", 1, &E_GL_NV_mesh_shader);
}
if (profile != EEsProfile && version >= 450) {
// GL_EXT_device_group // GL_EXT_device_group
symbolTable.setVariableExtensions("gl_DeviceIndex", 1, &E_GL_EXT_device_group); symbolTable.setVariableExtensions("gl_DeviceIndex", 1, &E_GL_EXT_device_group);
BuiltInVariable("gl_DeviceIndex", EbvDeviceIndex, symbolTable); BuiltInVariable("gl_DeviceIndex", EbvDeviceIndex, symbolTable);
@ -8743,7 +8749,7 @@ void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion
break; break;
case EShLangTaskNV: case EShLangTaskNV:
if (profile != EEsProfile && version >= 450) { if ((profile != EEsProfile && version >= 450) || (profile == EEsProfile && version >= 320)) {
symbolTable.setVariableExtensions("gl_TaskCountNV", 1, &E_GL_NV_mesh_shader); symbolTable.setVariableExtensions("gl_TaskCountNV", 1, &E_GL_NV_mesh_shader);
symbolTable.setVariableExtensions("gl_WorkGroupSize", 1, &E_GL_NV_mesh_shader); symbolTable.setVariableExtensions("gl_WorkGroupSize", 1, &E_GL_NV_mesh_shader);
symbolTable.setVariableExtensions("gl_WorkGroupID", 1, &E_GL_NV_mesh_shader); symbolTable.setVariableExtensions("gl_WorkGroupID", 1, &E_GL_NV_mesh_shader);
@ -8763,7 +8769,9 @@ void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion
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);
symbolTable.setFunctionExtensions("groupMemoryBarrier", 1, &E_GL_NV_mesh_shader); symbolTable.setFunctionExtensions("groupMemoryBarrier", 1, &E_GL_NV_mesh_shader);
}
if (profile != EEsProfile && version >= 450) {
// GL_EXT_device_group // GL_EXT_device_group
symbolTable.setVariableExtensions("gl_DeviceIndex", 1, &E_GL_EXT_device_group); symbolTable.setVariableExtensions("gl_DeviceIndex", 1, &E_GL_EXT_device_group);
BuiltInVariable("gl_DeviceIndex", EbvDeviceIndex, symbolTable); BuiltInVariable("gl_DeviceIndex", EbvDeviceIndex, symbolTable);
@ -9379,12 +9387,12 @@ void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion
} }
break; break;
case EShLangMeshNV: case EShLangMeshNV:
if (profile != EEsProfile && version >= 450) { if ((profile != EEsProfile && version >= 450) || (profile == EEsProfile && version >= 320)) {
symbolTable.relateToOperator("writePackedPrimitiveIndices4x8NV", EOpWritePackedPrimitiveIndices4x8NV); symbolTable.relateToOperator("writePackedPrimitiveIndices4x8NV", EOpWritePackedPrimitiveIndices4x8NV);
} }
// fall through // fall through
case EShLangTaskNV: case EShLangTaskNV:
if (profile != EEsProfile && version >= 450) { if ((profile != EEsProfile && version >= 450) || (profile == EEsProfile && version >= 320)) {
symbolTable.relateToOperator("memoryBarrierShared", EOpMemoryBarrierShared); symbolTable.relateToOperator("memoryBarrierShared", EOpMemoryBarrierShared);
symbolTable.relateToOperator("groupMemoryBarrier", EOpGroupMemoryBarrier); symbolTable.relateToOperator("groupMemoryBarrier", EOpGroupMemoryBarrier);
} }

View File

@ -3600,6 +3600,13 @@ void TParseContext::arraySizesCheck(const TSourceLoc& loc, const TQualifier& qua
extensionsTurnedOn(Num_AEP_tessellation_shader, AEP_tessellation_shader)) extensionsTurnedOn(Num_AEP_tessellation_shader, AEP_tessellation_shader))
return; return;
break; break;
#ifdef NV_EXTENSIONS
case EShLangMeshNV:
if (qualifier.storage == EvqVaryingOut)
if ((profile == EEsProfile && version >= 320) ||
extensionTurnedOn(E_GL_NV_mesh_shader))
return;
#endif
default: default:
break; break;
} }
@ -4460,6 +4467,12 @@ void TParseContext::finish()
if (profile != EEsProfile && version < 430) if (profile != EEsProfile && version < 430)
requireExtensions(getCurrentLoc(), 1, &E_GL_ARB_compute_shader, "compute shaders"); requireExtensions(getCurrentLoc(), 1, &E_GL_ARB_compute_shader, "compute shaders");
break; break;
#ifdef NV_EXTENSIONS
case EShLangTaskNV:
case EShLangMeshNV:
requireExtensions(getCurrentLoc(), 1, &E_GL_NV_mesh_shader, "mesh shaders");
break;
#endif
default: default:
break; break;
} }
@ -4963,12 +4976,14 @@ void TParseContext::setLayoutQualifier(const TSourceLoc& loc, TPublicType& publi
#ifdef NV_EXTENSIONS #ifdef NV_EXTENSIONS
case EShLangMeshNV: case EShLangMeshNV:
if (id == "max_vertices") { if (id == "max_vertices") {
requireExtensions(loc, 1, &E_GL_NV_mesh_shader, "max_vertices");
publicType.shaderQualifiers.vertices = value; publicType.shaderQualifiers.vertices = value;
if (value > resources.maxMeshOutputVerticesNV) if (value > resources.maxMeshOutputVerticesNV)
error(loc, "too large, must be less than gl_MaxMeshOutputVerticesNV", "max_vertices", ""); error(loc, "too large, must be less than gl_MaxMeshOutputVerticesNV", "max_vertices", "");
return; return;
} }
if (id == "max_primitives") { if (id == "max_primitives") {
requireExtensions(loc, 1, &E_GL_NV_mesh_shader, "max_primitives");
publicType.shaderQualifiers.primitives = value; publicType.shaderQualifiers.primitives = value;
if (value > resources.maxMeshOutputPrimitivesNV) if (value > resources.maxMeshOutputPrimitivesNV)
error(loc, "too large, must be less than gl_MaxMeshOutputPrimitivesNV", "max_primitives", ""); error(loc, "too large, must be less than gl_MaxMeshOutputPrimitivesNV", "max_primitives", "");
@ -4983,7 +4998,7 @@ void TParseContext::setLayoutQualifier(const TSourceLoc& loc, TPublicType& publi
if (id.compare(0, 11, "local_size_") == 0) { if (id.compare(0, 11, "local_size_") == 0) {
#ifdef NV_EXTENSIONS #ifdef NV_EXTENSIONS
if (language == EShLangMeshNV || language == EShLangTaskNV) { if (language == EShLangMeshNV || language == EShLangTaskNV) {
profileRequires(loc, ~EEsProfile, 450, E_GL_NV_mesh_shader, "gl_WorkGroupSize"); requireExtensions(loc, 1, &E_GL_NV_mesh_shader, "gl_WorkGroupSize");
} }
else else
#endif #endif

View File

@ -1591,8 +1591,9 @@ int TScanContext::tokenizeIdentifier()
case PERPRIMITIVENV: case PERPRIMITIVENV:
case PERVIEWNV: case PERVIEWNV:
case PERTASKNV: case PERTASKNV:
if (parseContext.profile != EEsProfile && if ((parseContext.profile != EEsProfile && parseContext.version >= 450) ||
(parseContext.version >= 450 || parseContext.extensionTurnedOn(E_GL_NV_mesh_shader))) (parseContext.profile == EEsProfile && parseContext.version >= 320) ||
parseContext.extensionTurnedOn(E_GL_NV_mesh_shader))
return keyword; return keyword;
return identifierOrType(); return identifierOrType();
#endif #endif

View File

@ -361,13 +361,16 @@ bool InitializeSymbolTables(TInfoSink& infoSink, TSymbolTable** commonTable, TS
InitializeStageSymbolTable(*builtInParseables, version, profile, spvVersion, EShLangMissNV, source, InitializeStageSymbolTable(*builtInParseables, version, profile, spvVersion, EShLangMissNV, source,
infoSink, commonTable, symbolTables); infoSink, commonTable, symbolTables);
} }
// check for mesh // check for mesh
if (profile != EEsProfile && version >= 450) if ((profile != EEsProfile && version >= 450) ||
(profile == EEsProfile && version >= 320))
InitializeStageSymbolTable(*builtInParseables, version, profile, spvVersion, EShLangMeshNV, source, InitializeStageSymbolTable(*builtInParseables, version, profile, spvVersion, EShLangMeshNV, source,
infoSink, commonTable, symbolTables); infoSink, commonTable, symbolTables);
// check for task // check for task
if (profile != EEsProfile && version >= 450) if ((profile != EEsProfile && version >= 450) ||
(profile == EEsProfile && version >= 320))
InitializeStageSymbolTable(*builtInParseables, version, profile, spvVersion, EShLangTaskNV, source, InitializeStageSymbolTable(*builtInParseables, version, profile, spvVersion, EShLangTaskNV, source,
infoSink, commonTable, symbolTables); infoSink, commonTable, symbolTables);
#endif #endif
@ -609,11 +612,11 @@ bool DeduceVersionProfile(TInfoSink& infoSink, EShLanguage stage, bool versionNo
break; break;
case EShLangMeshNV: case EShLangMeshNV:
case EShLangTaskNV: case EShLangTaskNV:
if ((profile == EEsProfile) || if ((profile == EEsProfile && version < 320) ||
(profile != EEsProfile && version < 450)) { (profile != EEsProfile && version < 450)) {
correct = false; correct = false;
infoSink.info.message(EPrefixError, "#version: mesh/task shaders require non-es profile with version 450 or above"); infoSink.info.message(EPrefixError, "#version: mesh/task shaders require es profile with version 320 or above, or non-es profile with version 450 or above");
version = 450; version = profile == EEsProfile ? 320 : 450;
} }
#endif #endif
default: default:

View File

@ -834,6 +834,23 @@ void TParseVersions::updateExtensionBehavior(const char* extension, TExtensionBe
} }
} }
#ifdef NV_EXTENSIONS
// Validate if extension name is used with correct shader stage.
bool TParseVersions::validateExtensionName(const TSourceLoc& loc, const char * const extension)
{
int lNumErrors = getNumErrors();
// GL_NV_mesh_shader extension is only allowed in task/mesh shaders
if (strcmp(extension, "GL_NV_mesh_shader") == 0)
requireStage(loc, (EShLanguageMask)(EShLangTaskNVMask | EShLangMeshNVMask),
"#extension GL_NV_mesh_shader");
if (getNumErrors() > lNumErrors)
return false;
return true;
}
#endif
// Call for any operation needing full GLSL integer data-type support. // Call for any operation needing full GLSL integer data-type support.
void TParseVersions::fullIntegerCheck(const TSourceLoc& loc, const char* op) void TParseVersions::fullIntegerCheck(const TSourceLoc& loc, const char* op)
{ {

View File

@ -1158,7 +1158,9 @@ interpolation_qualifier
| PERPRIMITIVENV { | PERPRIMITIVENV {
#ifdef NV_EXTENSIONS #ifdef NV_EXTENSIONS
parseContext.globalCheck($1.loc, "perprimitiveNV"); parseContext.globalCheck($1.loc, "perprimitiveNV");
parseContext.requireStage($1.loc, (EShLanguageMask)(EShLangFragmentMask | EShLangMeshNVMask), "perprimitiveNV");
parseContext.profileRequires($1.loc, ECoreProfile, 450, E_GL_NV_mesh_shader, "perprimitiveNV"); parseContext.profileRequires($1.loc, ECoreProfile, 450, E_GL_NV_mesh_shader, "perprimitiveNV");
parseContext.profileRequires($1.loc, EEsProfile, 320, E_GL_NV_mesh_shader, "perprimitiveNV");
$$.init($1.loc); $$.init($1.loc);
$$.qualifier.perPrimitiveNV = true; $$.qualifier.perPrimitiveNV = true;
#endif #endif
@ -1166,7 +1168,9 @@ interpolation_qualifier
| PERVIEWNV { | PERVIEWNV {
#ifdef NV_EXTENSIONS #ifdef NV_EXTENSIONS
parseContext.globalCheck($1.loc, "perviewNV"); parseContext.globalCheck($1.loc, "perviewNV");
parseContext.requireStage($1.loc, EShLangMeshNV, "perviewNV");
parseContext.profileRequires($1.loc, ECoreProfile, 450, E_GL_NV_mesh_shader, "perviewNV"); parseContext.profileRequires($1.loc, ECoreProfile, 450, E_GL_NV_mesh_shader, "perviewNV");
parseContext.profileRequires($1.loc, EEsProfile, 320, E_GL_NV_mesh_shader, "perviewNV");
$$.init($1.loc); $$.init($1.loc);
$$.qualifier.perViewNV = true; $$.qualifier.perViewNV = true;
#endif #endif
@ -1174,7 +1178,9 @@ interpolation_qualifier
| PERTASKNV { | PERTASKNV {
#ifdef NV_EXTENSIONS #ifdef NV_EXTENSIONS
parseContext.globalCheck($1.loc, "taskNV"); parseContext.globalCheck($1.loc, "taskNV");
parseContext.requireStage($1.loc, (EShLanguageMask)(EShLangTaskNVMask | EShLangMeshNVMask), "taskNV");
parseContext.profileRequires($1.loc, ECoreProfile, 450, E_GL_NV_mesh_shader, "taskNV"); parseContext.profileRequires($1.loc, ECoreProfile, 450, E_GL_NV_mesh_shader, "taskNV");
parseContext.profileRequires($1.loc, EEsProfile, 320, E_GL_NV_mesh_shader, "taskNV");
$$.init($1.loc); $$.init($1.loc);
$$.qualifier.perTaskNV = true; $$.qualifier.perTaskNV = true;
#endif #endif

File diff suppressed because it is too large Load Diff

View File

@ -103,6 +103,9 @@ public:
virtual void requireSpv(const TSourceLoc&, const char* op); virtual void requireSpv(const TSourceLoc&, const char* op);
virtual bool checkExtensionsRequested(const TSourceLoc&, int numExtensions, const char* const extensions[], const char* featureDesc); virtual bool checkExtensionsRequested(const TSourceLoc&, int numExtensions, const char* const extensions[], const char* featureDesc);
virtual void updateExtensionBehavior(const char* const extension, TExtensionBehavior); virtual void updateExtensionBehavior(const char* const extension, TExtensionBehavior);
#ifdef NV_EXTENSIONS
virtual bool validateExtensionName(const TSourceLoc&, const char* const extension);
#endif
virtual void C_DECL error(const TSourceLoc&, const char* szReason, const char* szToken, virtual void C_DECL error(const TSourceLoc&, const char* szReason, const char* szToken,
const char* szExtraInfoFormat, ...) = 0; const char* szExtraInfoFormat, ...) = 0;

View File

@ -874,6 +874,11 @@ int TPpContext::CPPextension(TPpToken* ppToken)
return token; return token;
} }
#ifdef NV_EXTENSIONS
if (!parseContext.validateExtensionName(ppToken->loc, extensionName))
return token;
#endif
parseContext.updateExtensionBehavior(line, extensionName, ppToken->name); parseContext.updateExtensionBehavior(line, extensionName, ppToken->name);
parseContext.notifyExtensionDirective(line, extensionName, ppToken->name); parseContext.notifyExtensionDirective(line, extensionName, ppToken->name);