Commit 3c366990 by Chao Chen

Add-support-for-SPV_NV_mesh_shader

parent 3a137966
...@@ -33,7 +33,7 @@ enum Op; ...@@ -33,7 +33,7 @@ enum Op;
enum Capability; enum Capability;
static const int GLSLextNVVersion = 100; static const int GLSLextNVVersion = 100;
static const int GLSLextNVRevision = 8; static const int GLSLextNVRevision = 9;
//SPV_NV_sample_mask_override_coverage //SPV_NV_sample_mask_override_coverage
const char* const E_SPV_NV_sample_mask_override_coverage = "SPV_NV_sample_mask_override_coverage"; const char* const E_SPV_NV_sample_mask_override_coverage = "SPV_NV_sample_mask_override_coverage";
...@@ -63,4 +63,7 @@ const char* const E_SPV_NV_compute_shader_derivatives = "SPV_NV_compute_shader_d ...@@ -63,4 +63,7 @@ const char* const E_SPV_NV_compute_shader_derivatives = "SPV_NV_compute_shader_d
//SPV_NV_shader_image_footprint //SPV_NV_shader_image_footprint
const char* const E_SPV_NV_shader_image_footprint = "SPV_NV_shader_image_footprint"; const char* const E_SPV_NV_shader_image_footprint = "SPV_NV_shader_image_footprint";
//SPV_NV_mesh_shader
const char* const E_SPV_NV_mesh_shader = "SPV_NV_mesh_shader";
#endif // #ifndef GLSLextNV_H #endif // #ifndef GLSLextNV_H
\ No newline at end of file
...@@ -511,7 +511,8 @@ void SpirvStream::disassembleInstruction(Id resultId, Id /*typeId*/, Op opCode, ...@@ -511,7 +511,8 @@ void SpirvStream::disassembleInstruction(Id resultId, Id /*typeId*/, Op opCode,
strcmp(spv::E_SPV_NV_geometry_shader_passthrough, name) == 0 || strcmp(spv::E_SPV_NV_geometry_shader_passthrough, name) == 0 ||
strcmp(spv::E_SPV_NV_viewport_array2, name) == 0 || strcmp(spv::E_SPV_NV_viewport_array2, name) == 0 ||
strcmp(spv::E_SPV_NVX_multiview_per_view_attributes, name) == 0 || strcmp(spv::E_SPV_NVX_multiview_per_view_attributes, name) == 0 ||
strcmp(spv::E_SPV_NV_fragment_shader_barycentric, name) == 0) { strcmp(spv::E_SPV_NV_fragment_shader_barycentric, name) == 0 ||
strcmp(spv::E_SPV_NV_mesh_shader, name) == 0) {
extInstSet = GLSLextNVInst; extInstSet = GLSLextNVInst;
#endif #endif
} }
...@@ -693,25 +694,44 @@ static const char* GLSLextNVGetDebugNames(const char* name, unsigned entrypoint) ...@@ -693,25 +694,44 @@ static const char* GLSLextNVGetDebugNames(const char* name, unsigned entrypoint)
strcmp(name, spv::E_ARB_shader_viewport_layer_array) == 0 || strcmp(name, spv::E_ARB_shader_viewport_layer_array) == 0 ||
strcmp(name, spv::E_SPV_NV_viewport_array2) == 0 || strcmp(name, spv::E_SPV_NV_viewport_array2) == 0 ||
strcmp(spv::E_SPV_NVX_multiview_per_view_attributes, name) == 0 || strcmp(spv::E_SPV_NVX_multiview_per_view_attributes, name) == 0 ||
strcmp(spv::E_SPV_NV_fragment_shader_barycentric, name) == 0) { strcmp(spv::E_SPV_NV_fragment_shader_barycentric, name) == 0 ||
strcmp(name, spv::E_SPV_NV_mesh_shader) == 0) {
switch (entrypoint) { switch (entrypoint) {
case DecorationOverrideCoverageNV: return "OverrideCoverageNV"; // NV builtins
case DecorationPassthroughNV: return "PassthroughNV";
case CapabilityGeometryShaderPassthroughNV: return "GeometryShaderPassthroughNV";
case DecorationViewportRelativeNV: return "ViewportRelativeNV";
case BuiltInViewportMaskNV: return "ViewportMaskNV"; case BuiltInViewportMaskNV: return "ViewportMaskNV";
case CapabilityShaderViewportMaskNV: return "ShaderViewportMaskNV";
case DecorationSecondaryViewportRelativeNV: return "SecondaryViewportRelativeNV";
case BuiltInSecondaryPositionNV: return "SecondaryPositionNV"; case BuiltInSecondaryPositionNV: return "SecondaryPositionNV";
case BuiltInSecondaryViewportMaskNV: return "SecondaryViewportMaskNV"; case BuiltInSecondaryViewportMaskNV: return "SecondaryViewportMaskNV";
case CapabilityShaderStereoViewNV: return "ShaderStereoViewNV";
case BuiltInPositionPerViewNV: return "PositionPerViewNV"; case BuiltInPositionPerViewNV: return "PositionPerViewNV";
case BuiltInViewportMaskPerViewNV: return "ViewportMaskPerViewNV"; case BuiltInViewportMaskPerViewNV: return "ViewportMaskPerViewNV";
case BuiltInBaryCoordNV: return "BaryCoordNV";
case BuiltInBaryCoordNoPerspNV: return "BaryCoordNoPerspNV";
case BuiltInTaskCountNV: return "TaskCountNV";
case BuiltInPrimitiveCountNV: return "PrimitiveCountNV";
case BuiltInPrimitiveIndicesNV: return "PrimitiveIndicesNV";
case BuiltInClipDistancePerViewNV: return "ClipDistancePerViewNV";
case BuiltInCullDistancePerViewNV: return "CullDistancePerViewNV";
case BuiltInLayerPerViewNV: return "LayerPerViewNV";
case BuiltInMeshViewCountNV: return "MeshViewCountNV";
case BuiltInMeshViewIndicesNV: return "MeshViewIndicesNV";
// NV Capabilities
case CapabilityGeometryShaderPassthroughNV: return "GeometryShaderPassthroughNV";
case CapabilityShaderViewportMaskNV: return "ShaderViewportMaskNV";
case CapabilityShaderStereoViewNV: return "ShaderStereoViewNV";
case CapabilityPerViewAttributesNV: return "PerViewAttributesNV"; case CapabilityPerViewAttributesNV: return "PerViewAttributesNV";
case CapabilityFragmentBarycentricNV: return "FragmentBarycentricNV"; case CapabilityFragmentBarycentricNV: return "FragmentBarycentricNV";
case CapabilityMeshShadingNV: return "MeshShadingNV";
// NV Decorations
case DecorationOverrideCoverageNV: return "OverrideCoverageNV";
case DecorationPassthroughNV: return "PassthroughNV";
case DecorationViewportRelativeNV: return "ViewportRelativeNV";
case DecorationSecondaryViewportRelativeNV: return "SecondaryViewportRelativeNV";
case DecorationPerVertexNV: return "PerVertexNV"; case DecorationPerVertexNV: return "PerVertexNV";
case BuiltInBaryCoordNV: return "BaryCoordNV"; case DecorationPerPrimitiveNV: return "PerPrimitiveNV";
case BuiltInBaryCoordNoPerspNV: return "BaryCoordNoPerspNV"; case DecorationPerViewNV: return "PerViewNV";
case DecorationPerTaskNV: return "PerTaskNV";
default: return "Bad"; default: return "Bad";
} }
} }
......
...@@ -98,6 +98,10 @@ const char* ExecutionModelString(int model) ...@@ -98,6 +98,10 @@ const char* ExecutionModelString(int model)
case 4: return "Fragment"; case 4: return "Fragment";
case 5: return "GLCompute"; case 5: return "GLCompute";
case 6: return "Kernel"; case 6: return "Kernel";
#ifdef NV_EXTENSIONS
case ExecutionModelTaskNV: return "TaskNV";
case ExecutionModelMeshNV: return "MeshNV";
#endif
default: return "Bad"; default: return "Bad";
} }
...@@ -168,6 +172,9 @@ const char* ExecutionModeString(int mode) ...@@ -168,6 +172,9 @@ const char* ExecutionModeString(int mode)
case 4446: return "PostDepthCoverage"; case 4446: return "PostDepthCoverage";
#ifdef NV_EXTENSIONS #ifdef NV_EXTENSIONS
case ExecutionModeOutputLinesNV: return "OutputLinesNV";
case ExecutionModeOutputPrimitivesNV: return "OutputPrimitivesNV";
case ExecutionModeOutputTrianglesNV: return "OutputTrianglesNV";
case ExecutionModeDerivativeGroupQuadsNV: return "DerivativeGroupQuadsNV"; case ExecutionModeDerivativeGroupQuadsNV: return "DerivativeGroupQuadsNV";
case ExecutionModeDerivativeGroupLinearNV: return "DerivativeGroupLinearNV"; case ExecutionModeDerivativeGroupLinearNV: return "DerivativeGroupLinearNV";
#endif #endif
...@@ -260,6 +267,9 @@ const char* DecorationString(int decoration) ...@@ -260,6 +267,9 @@ const char* DecorationString(int decoration)
case DecorationPassthroughNV: return "PassthroughNV"; case DecorationPassthroughNV: return "PassthroughNV";
case DecorationViewportRelativeNV: return "ViewportRelativeNV"; case DecorationViewportRelativeNV: return "ViewportRelativeNV";
case DecorationSecondaryViewportRelativeNV: return "SecondaryViewportRelativeNV"; case DecorationSecondaryViewportRelativeNV: return "SecondaryViewportRelativeNV";
case DecorationPerPrimitiveNV: return "PerPrimitiveNV";
case DecorationPerViewNV: return "PerViewNV";
case DecorationPerTaskNV: return "PerTaskNV";
case DecorationPerVertexNV: return "PerVertexNV"; case DecorationPerVertexNV: return "PerVertexNV";
#endif #endif
...@@ -351,6 +361,18 @@ const char* BuiltInString(int builtIn) ...@@ -351,6 +361,18 @@ const char* BuiltInString(int builtIn)
case 5264: return "FullyCoveredEXT"; case 5264: return "FullyCoveredEXT";
#ifdef NV_EXTENSIONS
case BuiltInTaskCountNV: return "TaskCountNV";
case BuiltInPrimitiveCountNV: return "PrimitiveCountNV";
case BuiltInPrimitiveIndicesNV: return "PrimitiveIndicesNV";
case BuiltInClipDistancePerViewNV: return "ClipDistancePerViewNV";
case BuiltInCullDistancePerViewNV: return "CullDistancePerViewNV";
case BuiltInLayerPerViewNV: return "LayerPerViewNV";
case BuiltInMeshViewCountNV: return "MeshViewCountNV";
case BuiltInMeshViewIndicesNV: return "MeshViewIndicesNV";
#endif
default: return "Bad"; default: return "Bad";
} }
} }
...@@ -838,6 +860,7 @@ const char* CapabilityString(int info) ...@@ -838,6 +860,7 @@ const char* CapabilityString(int info)
case CapabilityComputeDerivativeGroupQuadsNV: return "ComputeDerivativeGroupQuadsNV"; case CapabilityComputeDerivativeGroupQuadsNV: return "ComputeDerivativeGroupQuadsNV";
case CapabilityComputeDerivativeGroupLinearNV: return "ComputeDerivativeGroupLinearNV"; case CapabilityComputeDerivativeGroupLinearNV: return "ComputeDerivativeGroupLinearNV";
case CapabilityFragmentBarycentricNV: return "FragmentBarycentricNV"; case CapabilityFragmentBarycentricNV: return "FragmentBarycentricNV";
case CapabilityMeshShadingNV: return "MeshShadingNV";
#endif #endif
case CapabilityFragmentFullyCoveredEXT: return "FragmentFullyCoveredEXT"; case CapabilityFragmentFullyCoveredEXT: return "FragmentFullyCoveredEXT";
...@@ -1250,8 +1273,9 @@ const char* OpcodeString(int op) ...@@ -1250,8 +1273,9 @@ const char* OpcodeString(int op)
case OpMemberDecorateStringGOOGLE: return "OpMemberDecorateStringGOOGLE"; case OpMemberDecorateStringGOOGLE: return "OpMemberDecorateStringGOOGLE";
#ifdef NV_EXTENSIONS #ifdef NV_EXTENSIONS
case OpGroupNonUniformPartitionNV: return "OpGroupNonUniformPartitionNV"; case OpGroupNonUniformPartitionNV: return "OpGroupNonUniformPartitionNV";
case OpImageSampleFootprintNV: return "OpImageSampleFootprintNV"; case OpImageSampleFootprintNV: return "OpImageSampleFootprintNV";
case OpWritePackedPrimitiveIndices4x8NV: return "OpWritePackedPrimitiveIndices4x8NV";
#endif #endif
default: default:
...@@ -2598,12 +2622,16 @@ void Parameterize() ...@@ -2598,12 +2622,16 @@ void Parameterize()
#ifdef NV_EXTENSIONS #ifdef NV_EXTENSIONS
InstructionDesc[OpGroupNonUniformPartitionNV].operands.push(OperandId, "X"); InstructionDesc[OpGroupNonUniformPartitionNV].operands.push(OperandId, "X");
InstructionDesc[OpImageSampleFootprintNV].operands.push(OperandId, "'Sampled Image'"); InstructionDesc[OpImageSampleFootprintNV].operands.push(OperandId, "'Sampled Image'");
InstructionDesc[OpImageSampleFootprintNV].operands.push(OperandId, "'Coordinate'"); InstructionDesc[OpImageSampleFootprintNV].operands.push(OperandId, "'Coordinate'");
InstructionDesc[OpImageSampleFootprintNV].operands.push(OperandId, "'Granularity'"); InstructionDesc[OpImageSampleFootprintNV].operands.push(OperandId, "'Granularity'");
InstructionDesc[OpImageSampleFootprintNV].operands.push(OperandId, "'Coarse'"); InstructionDesc[OpImageSampleFootprintNV].operands.push(OperandId, "'Coarse'");
InstructionDesc[OpImageSampleFootprintNV].operands.push(OperandImageOperands, "", true); InstructionDesc[OpImageSampleFootprintNV].operands.push(OperandImageOperands, "", true);
InstructionDesc[OpImageSampleFootprintNV].operands.push(OperandVariableIds, "", true); InstructionDesc[OpImageSampleFootprintNV].operands.push(OperandVariableIds, "", true);
InstructionDesc[OpWritePackedPrimitiveIndices4x8NV].operands.push(OperandId, "'Index Offset'");
InstructionDesc[OpWritePackedPrimitiveIndices4x8NV].operands.push(OperandId, "'Packed Indices'");
#endif #endif
} }
......
...@@ -125,6 +125,18 @@ const TBuiltInResource DefaultTBuiltInResource = { ...@@ -125,6 +125,18 @@ const TBuiltInResource DefaultTBuiltInResource = {
/* .MaxCullDistances = */ 8, /* .MaxCullDistances = */ 8,
/* .MaxCombinedClipAndCullDistances = */ 8, /* .MaxCombinedClipAndCullDistances = */ 8,
/* .MaxSamples = */ 4, /* .MaxSamples = */ 4,
#ifdef NV_EXTENSIONS
/* .maxMeshOutputVerticesNV = */ 256,
/* .maxMeshOutputPrimitivesNV = */ 512,
/* .maxMeshWorkGroupSizeX_NV = */ 32,
/* .maxMeshWorkGroupSizeY_NV = */ 1,
/* .maxMeshWorkGroupSizeZ_NV = */ 1,
/* .maxTaskWorkGroupSizeX_NV = */ 32,
/* .maxTaskWorkGroupSizeY_NV = */ 1,
/* .maxTaskWorkGroupSizeZ_NV = */ 1,
/* .maxMeshViewCountNV = */ 4,
#endif
/* .limits = */ { /* .limits = */ {
/* .nonInductiveForLoops = */ 1, /* .nonInductiveForLoops = */ 1,
/* .whileLoops = */ 1, /* .whileLoops = */ 1,
...@@ -224,7 +236,17 @@ std::string GetDefaultTBuiltInResourceString() ...@@ -224,7 +236,17 @@ std::string GetDefaultTBuiltInResourceString()
<< "MaxCullDistances " << DefaultTBuiltInResource.maxCullDistances << "\n" << "MaxCullDistances " << DefaultTBuiltInResource.maxCullDistances << "\n"
<< "MaxCombinedClipAndCullDistances " << DefaultTBuiltInResource.maxCombinedClipAndCullDistances << "\n" << "MaxCombinedClipAndCullDistances " << DefaultTBuiltInResource.maxCombinedClipAndCullDistances << "\n"
<< "MaxSamples " << DefaultTBuiltInResource.maxSamples << "\n" << "MaxSamples " << DefaultTBuiltInResource.maxSamples << "\n"
#ifdef NV_EXTENSIONS
<< "MaxMeshOutputVerticesNV " << DefaultTBuiltInResource.maxMeshOutputVerticesNV << "\n"
<< "MaxMeshOutputPrimitivesNV " << DefaultTBuiltInResource.maxMeshOutputPrimitivesNV << "\n"
<< "MaxMeshWorkGroupSizeX_NV " << DefaultTBuiltInResource.maxMeshWorkGroupSizeX_NV << "\n"
<< "MaxMeshWorkGroupSizeY_NV " << DefaultTBuiltInResource.maxMeshWorkGroupSizeY_NV << "\n"
<< "MaxMeshWorkGroupSizeZ_NV " << DefaultTBuiltInResource.maxMeshWorkGroupSizeZ_NV << "\n"
<< "MaxTaskWorkGroupSizeX_NV " << DefaultTBuiltInResource.maxTaskWorkGroupSizeX_NV << "\n"
<< "MaxTaskWorkGroupSizeY_NV " << DefaultTBuiltInResource.maxTaskWorkGroupSizeY_NV << "\n"
<< "MaxTaskWorkGroupSizeZ_NV " << DefaultTBuiltInResource.maxTaskWorkGroupSizeZ_NV << "\n"
<< "MaxMeshViewCountNV " << DefaultTBuiltInResource.maxMeshViewCountNV << "\n"
#endif
<< "nonInductiveForLoops " << DefaultTBuiltInResource.limits.nonInductiveForLoops << "\n" << "nonInductiveForLoops " << DefaultTBuiltInResource.limits.nonInductiveForLoops << "\n"
<< "whileLoops " << DefaultTBuiltInResource.limits.whileLoops << "\n" << "whileLoops " << DefaultTBuiltInResource.limits.whileLoops << "\n"
<< "doWhileLoops " << DefaultTBuiltInResource.limits.doWhileLoops << "\n" << "doWhileLoops " << DefaultTBuiltInResource.limits.doWhileLoops << "\n"
...@@ -431,6 +453,26 @@ void DecodeResourceLimits(TBuiltInResource* resources, char* config) ...@@ -431,6 +453,26 @@ void DecodeResourceLimits(TBuiltInResource* resources, char* config)
resources->maxCombinedClipAndCullDistances = value; resources->maxCombinedClipAndCullDistances = value;
else if (tokenStr == "MaxSamples") else if (tokenStr == "MaxSamples")
resources->maxSamples = value; resources->maxSamples = value;
#ifdef NV_EXTENSIONS
else if (tokenStr == "MaxMeshOutputVerticesNV")
resources->maxMeshOutputVerticesNV = value;
else if (tokenStr == "MaxMeshOutputPrimitivesNV")
resources->maxMeshOutputPrimitivesNV = value;
else if (tokenStr == "MaxMeshWorkGroupSizeX_NV")
resources->maxMeshWorkGroupSizeX_NV = value;
else if (tokenStr == "MaxMeshWorkGroupSizeY_NV")
resources->maxMeshWorkGroupSizeY_NV = value;
else if (tokenStr == "MaxMeshWorkGroupSizeZ_NV")
resources->maxMeshWorkGroupSizeZ_NV = value;
else if (tokenStr == "MaxTaskWorkGroupSizeX_NV")
resources->maxTaskWorkGroupSizeX_NV = value;
else if (tokenStr == "MaxTaskWorkGroupSizeY_NV")
resources->maxTaskWorkGroupSizeY_NV = value;
else if (tokenStr == "MaxTaskWorkGroupSizeZ_NV")
resources->maxTaskWorkGroupSizeZ_NV = value;
else if (tokenStr == "MaxMeshViewCountNV")
resources->maxMeshViewCountNV = value;
#endif
else if (tokenStr == "nonInductiveForLoops") else if (tokenStr == "nonInductiveForLoops")
resources->limits.nonInductiveForLoops = (value != 0); resources->limits.nonInductiveForLoops = (value != 0);
else if (tokenStr == "whileLoops") else if (tokenStr == "whileLoops")
......
...@@ -244,6 +244,10 @@ const char* GetBinaryName(EShLanguage stage) ...@@ -244,6 +244,10 @@ const char* GetBinaryName(EShLanguage stage)
case EShLangGeometry: name = "geom.spv"; break; case EShLangGeometry: name = "geom.spv"; break;
case EShLangFragment: name = "frag.spv"; break; case EShLangFragment: name = "frag.spv"; break;
case EShLangCompute: name = "comp.spv"; break; case EShLangCompute: name = "comp.spv"; break;
#ifdef NV_EXTENSIONS
case EShLangMeshNV: name = "mesh.spv"; break;
case EShLangTaskNV: name = "task.spv"; break;
#endif
default: name = "unknown"; break; default: name = "unknown"; break;
} }
} else } else
...@@ -1250,6 +1254,12 @@ EShLanguage FindLanguage(const std::string& name, bool parseStageName) ...@@ -1250,6 +1254,12 @@ EShLanguage FindLanguage(const std::string& name, bool parseStageName)
return EShLangFragment; return EShLangFragment;
else if (stageName == "comp") else if (stageName == "comp")
return EShLangCompute; return EShLangCompute;
#ifdef NV_EXTENSIONS
else if (stageName == "mesh")
return EShLangMeshNV;
else if (stageName == "task")
return EShLangTaskNV;
#endif
usage(); usage();
return EShLangVertex; return EShLangVertex;
...@@ -1319,6 +1329,10 @@ void usage() ...@@ -1319,6 +1329,10 @@ void usage()
" .geom for a geometry shader\n" " .geom for a geometry shader\n"
" .frag for a fragment shader\n" " .frag for a fragment shader\n"
" .comp for a compute shader\n" " .comp for a compute shader\n"
#ifdef NV_EXTENSIONS
" .mesh for a mesh shader\n"
" .task for a task shader\n"
#endif
" .glsl for .vert.glsl, .tesc.glsl, ..., .comp.glsl compound suffixes\n" " .glsl for .vert.glsl, .tesc.glsl, ..., .comp.glsl compound suffixes\n"
" .hlsl for .vert.hlsl, .tesc.hlsl, ..., .comp.hlsl compound suffixes\n" " .hlsl for .vert.hlsl, .tesc.hlsl, ..., .comp.hlsl compound suffixes\n"
"\n" "\n"
......
spv.meshShaderPerViewUserDefined.mesh
// Module Version 10000
// Generated by (magic number): 80007
// Id's are bound by 90
Capability MeshShadingNV
Extension "SPV_NV_mesh_shader"
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint MeshNV 4 "main" 11 20 21 35 67
ExecutionMode 4 LocalSize 32 1 1
ExecutionMode 4 OutputVertices 81
ExecutionMode 4 OutputPrimitivesNV 32
ExecutionMode 4 OutputTrianglesNV
Source GLSL 450
SourceExtension "GL_NV_mesh_shader"
Name 4 "main"
Name 8 "iid"
Name 11 "gl_LocalInvocationID"
Name 16 "viewID"
Name 20 "gl_MeshViewIndicesNV"
Name 21 "gl_MeshViewCountNV"
Name 31 "block"
MemberName 31(block) 0 "color1"
MemberName 31(block) 1 "color2"
MemberName 31(block) 2 "color3"
MemberName 31(block) 3 "color4"
Name 35 "b"
Name 64 "perviewBlock"
MemberName 64(perviewBlock) 0 "color5"
MemberName 64(perviewBlock) 1 "color6"
MemberName 64(perviewBlock) 2 "color7"
MemberName 64(perviewBlock) 3 "color8"
Name 67 "b2"
Decorate 11(gl_LocalInvocationID) BuiltIn LocalInvocationId
Decorate 20(gl_MeshViewIndicesNV) BuiltIn MeshViewIndicesNV
Decorate 21(gl_MeshViewCountNV) BuiltIn MeshViewCountNV
MemberDecorate 31(block) 0 PerPrimitiveNV
MemberDecorate 31(block) 0 PerViewNV
MemberDecorate 31(block) 1 PerPrimitiveNV
MemberDecorate 31(block) 2 PerViewNV
Decorate 31(block) Block
Decorate 35(b) Location 0
MemberDecorate 64(perviewBlock) 0 PerPrimitiveNV
MemberDecorate 64(perviewBlock) 0 PerViewNV
MemberDecorate 64(perviewBlock) 1 PerPrimitiveNV
MemberDecorate 64(perviewBlock) 1 PerViewNV
MemberDecorate 64(perviewBlock) 2 PerViewNV
MemberDecorate 64(perviewBlock) 3 PerViewNV
Decorate 64(perviewBlock) Block
Decorate 67(b2) Location 10
Decorate 89 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: 6(int) Constant 4
18: TypeArray 6(int) 17
19: TypePointer Input 18
20(gl_MeshViewIndicesNV): 19(ptr) Variable Input
21(gl_MeshViewCountNV): 13(ptr) Variable Input
26: TypeFloat 32
27: TypeVector 26(float) 4
28: 6(int) Constant 3
29: TypeArray 27(fvec4) 28
30: TypeArray 29 17
31(block): TypeStruct 30 29 30 27(fvec4)
32: 6(int) Constant 81
33: TypeArray 31(block) 32
34: TypePointer Output 33
35(b): 34(ptr) Variable Output
37: TypeInt 32 1
38: 37(int) Constant 0
40: 37(int) Constant 2
41: 26(float) Constant 1065353216
42: 27(fvec4) ConstantComposite 41 41 41 41
43: TypePointer Output 27(fvec4)
46: 37(int) Constant 1
47: 26(float) Constant 1073741824
48: 27(fvec4) ConstantComposite 47 47 47 47
52: 26(float) Constant 1077936128
53: 27(fvec4) ConstantComposite 52 52 52 52
56: 37(int) Constant 3
57: 26(float) Constant 1082130432
58: 27(fvec4) ConstantComposite 57 57 57 57
60: 6(int) Constant 1
61: 6(int) Constant 264
62: 6(int) Constant 2
63: TypeArray 27(fvec4) 17
64(perviewBlock): TypeStruct 63 30 30 63
65: TypeArray 64(perviewBlock) 32
66: TypePointer Output 65
67(b2): 66(ptr) Variable Output
70: 26(float) Constant 1084227584
71: 27(fvec4) ConstantComposite 70 70 70 70
75: 26(float) Constant 1086324736
76: 27(fvec4) ConstantComposite 75 75 75 75
80: 26(float) Constant 1088421888
81: 27(fvec4) ConstantComposite 80 80 80 80
85: 26(float) Constant 1090519040
86: 27(fvec4) ConstantComposite 85 85 85 85
88: 6(int) Constant 32
89: 9(ivec3) ConstantComposite 88 60 60
4(main): 2 Function None 3
5: Label
8(iid): 7(ptr) Variable Function
16(viewID): 7(ptr) Variable Function
14: 13(ptr) AccessChain 11(gl_LocalInvocationID) 12
15: 6(int) Load 14
Store 8(iid) 15
22: 6(int) Load 21(gl_MeshViewCountNV)
23: 6(int) UMod 22 17
24: 13(ptr) AccessChain 20(gl_MeshViewIndicesNV) 23
25: 6(int) Load 24
Store 16(viewID) 25
36: 6(int) Load 8(iid)
39: 6(int) Load 16(viewID)
44: 43(ptr) AccessChain 35(b) 36 38 39 40
Store 44 42
45: 6(int) Load 8(iid)
49: 43(ptr) AccessChain 35(b) 45 46 46
Store 49 48
50: 6(int) Load 8(iid)
51: 6(int) Load 16(viewID)
54: 43(ptr) AccessChain 35(b) 50 40 51 40
Store 54 53
55: 6(int) Load 8(iid)
59: 43(ptr) AccessChain 35(b) 55 56
Store 59 58
MemoryBarrier 60 61
ControlBarrier 62 62 61
68: 6(int) Load 8(iid)
69: 6(int) Load 16(viewID)
72: 43(ptr) AccessChain 67(b2) 68 38 69
Store 72 71
73: 6(int) Load 8(iid)
74: 6(int) Load 16(viewID)
77: 43(ptr) AccessChain 67(b2) 73 46 74 46
Store 77 76
78: 6(int) Load 8(iid)
79: 6(int) Load 16(viewID)
82: 43(ptr) AccessChain 67(b2) 78 40 79 40
Store 82 81
83: 6(int) Load 8(iid)
84: 6(int) Load 16(viewID)
87: 43(ptr) AccessChain 67(b2) 83 56 84
Store 87 86
MemoryBarrier 60 61
ControlBarrier 62 62 61
Return
FunctionEnd
spv.meshShaderSharedMem.mesh
// Module Version 10000
// Generated by (magic number): 80007
// Id's are bound by 77
Capability StorageImageWriteWithoutFormat
Capability MeshShadingNV
Extension "SPV_NV_mesh_shader"
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint MeshNV 4 "main" 11 17
ExecutionMode 4 LocalSize 32 1 1
ExecutionMode 4 OutputVertices 81
ExecutionMode 4 OutputPrimitivesNV 32
ExecutionMode 4 OutputTrianglesNV
Source GLSL 450
SourceExtension "GL_NV_mesh_shader"
Name 4 "main"
Name 8 "iid"
Name 11 "gl_LocalInvocationID"
Name 16 "gid"
Name 17 "gl_WorkGroupID"
Name 20 "i"
Name 34 "mem"
Name 37 "block0"
MemberName 37(block0) 0 "uni_value"
Name 39 ""
Name 55 "uni_image"
Decorate 11(gl_LocalInvocationID) BuiltIn LocalInvocationId
Decorate 17(gl_WorkGroupID) BuiltIn WorkgroupId
MemberDecorate 37(block0) 0 Offset 0
Decorate 37(block0) Block
Decorate 39 DescriptorSet 0
Decorate 55(uni_image) DescriptorSet 0
Decorate 55(uni_image) NonReadable
Decorate 76 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
27: 6(int) Constant 10
28: TypeBool
30: TypeFloat 32
31: TypeVector 30(float) 4
32: TypeArray 31(fvec4) 27
33: TypePointer Workgroup 32
34(mem): 33(ptr) Variable Workgroup
37(block0): TypeStruct 6(int)
38: TypePointer Uniform 37(block0)
39: 38(ptr) Variable Uniform
40: TypeInt 32 1
41: 40(int) Constant 0
42: TypePointer Uniform 6(int)
48: TypePointer Workgroup 31(fvec4)
51: 40(int) Constant 1
53: TypeImage 30(float) 2D nonsampled format:Unknown
54: TypePointer UniformConstant 53
55(uni_image): 54(ptr) Variable UniformConstant
59: TypeVector 40(int) 2
69: 6(int) Constant 1
73: 6(int) Constant 264
74: 6(int) Constant 2
75: 6(int) Constant 32
76: 9(ivec3) ConstantComposite 75 69 69
4(main): 2 Function None 3
5: Label
8(iid): 7(ptr) Variable Function
16(gid): 7(ptr) Variable Function
20(i): 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
Store 20(i) 12
Branch 21
21: Label
LoopMerge 23 24 None
Branch 25
25: Label
26: 6(int) Load 20(i)
29: 28(bool) ULessThan 26 27
BranchConditional 29 22 23
22: Label
35: 6(int) Load 20(i)
36: 6(int) Load 20(i)
43: 42(ptr) AccessChain 39 41
44: 6(int) Load 43
45: 6(int) IAdd 36 44
46: 30(float) ConvertUToF 45
47: 31(fvec4) CompositeConstruct 46 46 46 46
49: 48(ptr) AccessChain 34(mem) 35
Store 49 47
Branch 24
24: Label
50: 6(int) Load 20(i)
52: 6(int) IAdd 50 51
Store 20(i) 52
Branch 21
23: Label
56: 53 Load 55(uni_image)
57: 6(int) Load 8(iid)
58: 40(int) Bitcast 57
60: 59(ivec2) CompositeConstruct 58 58
61: 6(int) Load 16(gid)
62: 48(ptr) AccessChain 34(mem) 61
63: 31(fvec4) Load 62
ImageWrite 56 60 63
64: 53 Load 55(uni_image)
65: 6(int) Load 8(iid)
66: 40(int) Bitcast 65
67: 59(ivec2) CompositeConstruct 66 66
68: 6(int) Load 16(gid)
70: 6(int) IAdd 68 69
71: 48(ptr) AccessChain 34(mem) 70
72: 31(fvec4) Load 71
ImageWrite 64 67 72
MemoryBarrier 69 73
ControlBarrier 74 74 73
Return
FunctionEnd
spv.meshShaderTaskMem.mesh
// Module Version 10000
// Generated by (magic number): 80007
// Id's are bound by 58
Capability MeshShadingNV
Extension "SPV_NV_mesh_shader"
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint MeshNV 4 "main" 11 22 30
ExecutionMode 4 LocalSize 32 1 1
ExecutionMode 4 OutputVertices 81
ExecutionMode 4 OutputPrimitivesNV 32
ExecutionMode 4 OutputTrianglesNV
Source GLSL 450
SourceExtension "GL_NV_mesh_shader"
Name 4 "main"
Name 8 "iid"
Name 11 "gl_LocalInvocationID"
Name 18 "outBlock"
MemberName 18(outBlock) 0 "gid5"
MemberName 18(outBlock) 1 "gid6"
Name 22 "myblk"
Name 28 "taskBlock"
MemberName 28(taskBlock) 0 "gid1"
MemberName 28(taskBlock) 1 "gid2"
Name 30 "mytask"
Name 36 "bufferBlock"
MemberName 36(bufferBlock) 0 "gid3"
MemberName 36(bufferBlock) 1 "gid4"
Name 38 "mybuf"
Decorate 11(gl_LocalInvocationID) BuiltIn LocalInvocationId
Decorate 18(outBlock) Block
Decorate 22(myblk) Location 0
Decorate 27 ArrayStride 4
MemberDecorate 28(taskBlock) 0 PerTaskNV
MemberDecorate 28(taskBlock) 0 Offset 0
MemberDecorate 28(taskBlock) 1 PerTaskNV
MemberDecorate 28(taskBlock) 1 Offset 16
Decorate 28(taskBlock) Block
Decorate 35 ArrayStride 4
MemberDecorate 36(bufferBlock) 0 Offset 0
MemberDecorate 36(bufferBlock) 1 Offset 16
Decorate 36(bufferBlock) BufferBlock
Decorate 38(mybuf) DescriptorSet 0
Decorate 57 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)
16: TypeFloat 32
17: TypeVector 16(float) 4
18(outBlock): TypeStruct 16(float) 17(fvec4)
19: 6(int) Constant 81
20: TypeArray 18(outBlock) 19
21: TypePointer Output 20
22(myblk): 21(ptr) Variable Output
24: TypeInt 32 1
25: 24(int) Constant 0
26: 6(int) Constant 2
27: TypeArray 16(float) 26
28(taskBlock): TypeStruct 27 17(fvec4)
29: TypePointer Input 28(taskBlock)
30(mytask): 29(ptr) Variable Input
31: 24(int) Constant 1
32: TypePointer Input 16(float)
35: TypeArray 16(float) 26
36(bufferBlock): TypeStruct 35 17(fvec4)
37: TypePointer Uniform 36(bufferBlock)
38(mybuf): 37(ptr) Variable Uniform
39: TypePointer Uniform 16(float)
43: TypePointer Output 16(float)
46: TypePointer Input 17(fvec4)
49: TypePointer Uniform 17(fvec4)
53: TypePointer Output 17(fvec4)
55: 6(int) Constant 32
56: 6(int) Constant 1
57: 9(ivec3) ConstantComposite 55 56 56
4(main): 2 Function None 3
5: Label
8(iid): 7(ptr) Variable Function
14: 13(ptr) AccessChain 11(gl_LocalInvocationID) 12
15: 6(int) Load 14
Store 8(iid) 15
23: 6(int) Load 8(iid)
33: 32(ptr) AccessChain 30(mytask) 25 31
34: 16(float) Load 33
40: 39(ptr) AccessChain 38(mybuf) 25 31
41: 16(float) Load 40
42: 16(float) FAdd 34 41
44: 43(ptr) AccessChain 22(myblk) 23 25
Store 44 42
45: 6(int) Load 8(iid)
47: 46(ptr) AccessChain 30(mytask) 31
48: 17(fvec4) Load 47
50: 49(ptr) AccessChain 38(mybuf) 31
51: 17(fvec4) Load 50
52: 17(fvec4) FAdd 48 51
54: 53(ptr) AccessChain 22(myblk) 45 31
Store 54 52
Return
FunctionEnd
spv.meshTaskShader.task
// Module Version 10000
// Generated by (magic number): 80007
// Id's are bound by 104
Capability StorageImageWriteWithoutFormat
Capability MeshShadingNV
Extension "SPV_NV_mesh_shader"
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint TaskNV 4 "main" 11 17 80 101
ExecutionMode 4 LocalSize 32 1 1
Source GLSL 450
SourceExtension "GL_NV_mesh_shader"
Name 4 "main"
Name 8 "iid"
Name 11 "gl_LocalInvocationID"
Name 16 "gid"
Name 17 "gl_WorkGroupID"
Name 20 "i"
Name 34 "mem"
Name 37 "block0"
MemberName 37(block0) 0 "uni_value"
Name 39 ""
Name 55 "uni_image"
Name 78 "Task"
MemberName 78(Task) 0 "dummy"
MemberName 78(Task) 1 "submesh"
Name 80 "mytask"
Name 101 "gl_TaskCountNV"
Decorate 11(gl_LocalInvocationID) BuiltIn LocalInvocationId
Decorate 17(gl_WorkGroupID) BuiltIn WorkgroupId
MemberDecorate 37(block0) 0 Offset 0
Decorate 37(block0) Block
Decorate 39 DescriptorSet 0
Decorate 55(uni_image) DescriptorSet 0
Decorate 55(uni_image) Binding 0
Decorate 55(uni_image) NonReadable
Decorate 77 ArrayStride 8
MemberDecorate 78(Task) 0 PerTaskNV
MemberDecorate 78(Task) 0 Offset 0
MemberDecorate 78(Task) 1 PerTaskNV
MemberDecorate 78(Task) 1 Offset 8
Decorate 78(Task) Block
Decorate 101(gl_TaskCountNV) BuiltIn TaskCountNV
Decorate 103 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
27: 6(int) Constant 10
28: TypeBool
30: TypeFloat 32
31: TypeVector 30(float) 4
32: TypeArray 31(fvec4) 27
33: TypePointer Workgroup 32
34(mem): 33(ptr) Variable Workgroup
37(block0): TypeStruct 6(int)
38: TypePointer Uniform 37(block0)
39: 38(ptr) Variable Uniform
40: TypeInt 32 1
41: 40(int) Constant 0
42: TypePointer Uniform 6(int)
48: TypePointer Workgroup 31(fvec4)
51: 40(int) Constant 1
53: TypeImage 30(float) 2D nonsampled format:Unknown
54: TypePointer UniformConstant 53
55(uni_image): 54(ptr) Variable UniformConstant
59: TypeVector 40(int) 2
69: 6(int) Constant 1
73: 6(int) Constant 264
74: 6(int) Constant 2
75: TypeVector 30(float) 2
76: 6(int) Constant 3
77: TypeArray 75(fvec2) 76
78(Task): TypeStruct 75(fvec2) 77
79: TypePointer Output 78(Task)
80(mytask): 79(ptr) Variable Output
81: 30(float) Constant 1106247680
82: 30(float) Constant 1106771968
83: 75(fvec2) ConstantComposite 81 82
84: TypePointer Output 75(fvec2)
86: 30(float) Constant 1107296256
87: 30(float) Constant 1107558400
88: 75(fvec2) ConstantComposite 86 87
90: 30(float) Constant 1107820544
91: 30(float) Constant 1108082688
92: 75(fvec2) ConstantComposite 90 91
94: 40(int) Constant 2
100: TypePointer Output 6(int)
101(gl_TaskCountNV): 100(ptr) Variable Output
102: 6(int) Constant 32
103: 9(ivec3) ConstantComposite 102 69 69
4(main): 2 Function None 3
5: Label
8(iid): 7(ptr) Variable Function
16(gid): 7(ptr) Variable Function
20(i): 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
Store 20(i) 12
Branch 21
21: Label
LoopMerge 23 24 None
Branch 25
25: Label
26: 6(int) Load 20(i)
29: 28(bool) ULessThan 26 27
BranchConditional 29 22 23
22: Label
35: 6(int) Load 20(i)
36: 6(int) Load 20(i)
43: 42(ptr) AccessChain 39 41
44: 6(int) Load 43
45: 6(int) IAdd 36 44
46: 30(float) ConvertUToF 45
47: 31(fvec4) CompositeConstruct 46 46 46 46
49: 48(ptr) AccessChain 34(mem) 35
Store 49 47
Branch 24
24: Label
50: 6(int) Load 20(i)
52: 6(int) IAdd 50 51
Store 20(i) 52
Branch 21
23: Label
56: 53 Load 55(uni_image)
57: 6(int) Load 8(iid)
58: 40(int) Bitcast 57
60: 59(ivec2) CompositeConstruct 58 58
61: 6(int) Load 16(gid)
62: 48(ptr) AccessChain 34(mem) 61
63: 31(fvec4) Load 62
ImageWrite 56 60 63
64: 53 Load 55(uni_image)
65: 6(int) Load 8(iid)
66: 40(int) Bitcast 65
67: 59(ivec2) CompositeConstruct 66 66
68: 6(int) Load 16(gid)
70: 6(int) IAdd 68 69
71: 48(ptr) AccessChain 34(mem) 70
72: 31(fvec4) Load 71
ImageWrite 64 67 72
MemoryBarrier 69 73
ControlBarrier 74 74 73
85: 84(ptr) AccessChain 80(mytask) 41
Store 85 83
89: 84(ptr) AccessChain 80(mytask) 51 41
Store 89 88
93: 84(ptr) AccessChain 80(mytask) 51 51
Store 93 92
95: 6(int) Load 16(gid)
96: 6(int) UMod 95 74
97: 84(ptr) AccessChain 80(mytask) 51 96
98: 75(fvec2) Load 97
99: 84(ptr) AccessChain 80(mytask) 51 94
Store 99 98
MemoryBarrier 69 73
ControlBarrier 74 74 73
Store 101(gl_TaskCountNV) 76
Return
FunctionEnd
...@@ -81,6 +81,15 @@ MaxTransformFeedbackInterleavedComponents 64 ...@@ -81,6 +81,15 @@ MaxTransformFeedbackInterleavedComponents 64
MaxCullDistances 8 MaxCullDistances 8
MaxCombinedClipAndCullDistances 8 MaxCombinedClipAndCullDistances 8
MaxSamples 4 MaxSamples 4
MaxMeshOutputVerticesNV 256
MaxMeshOutputPrimitivesNV 512
MaxMeshWorkGroupSizeX_NV 32
MaxMeshWorkGroupSizeY_NV 1
MaxMeshWorkGroupSizeZ_NV 1
MaxTaskWorkGroupSizeX_NV 32
MaxTaskWorkGroupSizeY_NV 1
MaxTaskWorkGroupSizeZ_NV 1
MaxMeshViewCountNV 4
nonInductiveForLoops 1 nonInductiveForLoops 1
whileLoops 1 whileLoops 1
doWhileLoops 1 doWhileLoops 1
......
#version 460
#define MAX_VER 81
#define MAX_PRIM 32
#define BARRIER() \
memoryBarrierShared(); \
barrier();
#extension GL_NV_mesh_shader : enable
layout(local_size_x = 32) in;
layout(max_vertices=MAX_VER) out;
layout(max_primitives=MAX_PRIM) out;
layout(triangles) out;
// test use of builtins in mesh shaders:
void main()
{
uint iid = gl_LocalInvocationID.x;
uint gid = gl_WorkGroupID.x;
gl_MeshVerticesNV[iid].gl_Position = vec4(1.0);
gl_MeshVerticesNV[iid].gl_PointSize = 2.0;
gl_MeshVerticesNV[iid].gl_ClipDistance[3] = 3.0;
gl_MeshVerticesNV[iid].gl_CullDistance[2] = 4.0;
BARRIER();
gl_MeshVerticesNV[iid+1].gl_Position = gl_MeshVerticesNV[iid].gl_Position;
gl_MeshVerticesNV[iid+1].gl_PointSize = gl_MeshVerticesNV[iid].gl_PointSize;
gl_MeshVerticesNV[iid+1].gl_ClipDistance[3] = gl_MeshVerticesNV[iid].gl_ClipDistance[3];
gl_MeshVerticesNV[iid+1].gl_CullDistance[2] = gl_MeshVerticesNV[iid].gl_CullDistance[2];
BARRIER();
gl_MeshPrimitivesNV[iid].gl_PrimitiveID = 6;
gl_MeshPrimitivesNV[iid].gl_Layer = 7;
gl_MeshPrimitivesNV[iid].gl_ViewportIndex = 8;
gl_MeshPrimitivesNV[iid].gl_ViewportMask[0] = 9;
BARRIER();
gl_MeshPrimitivesNV[iid+1].gl_PrimitiveID = gl_MeshPrimitivesNV[iid].gl_PrimitiveID;
gl_MeshPrimitivesNV[iid+1].gl_Layer = gl_MeshPrimitivesNV[iid].gl_Layer;
gl_MeshPrimitivesNV[iid+1].gl_ViewportIndex = gl_MeshPrimitivesNV[iid].gl_ViewportIndex;
gl_MeshPrimitivesNV[iid+1].gl_ViewportMask[0] = gl_MeshPrimitivesNV[iid].gl_ViewportMask[0];
BARRIER();
// should truncate 257 -> 1
gl_PrimitiveIndicesNV[0] = 257;
gl_PrimitiveIndicesNV[gid] = gl_PrimitiveIndicesNV[gid-1];
// writes 4 indices at offset gl_DrawID
writePackedPrimitiveIndices4x8NV(gl_DrawID, 0x01020304);
gl_PrimitiveCountNV = MAX_PRIM * 3;
BARRIER();
}
#version 450
#define MAX_VER 81
#define MAX_PRIM 32
#define MAX_VIEWS gl_MaxMeshViewCountNV
#define BARRIER() \
memoryBarrierShared(); \
barrier();
#extension GL_NV_mesh_shader : enable
layout(local_size_x = 32) in;
layout(max_vertices=MAX_VER) out;
layout(max_primitives=MAX_PRIM) out;
layout(triangles) out;
// test use of per-view builtin attributes
void main()
{
uint iid = gl_LocalInvocationID.x;
uint viewID = gl_MeshViewIndicesNV[gl_MeshViewCountNV%MAX_VIEWS];
gl_MeshVerticesNV[iid].gl_PositionPerViewNV[viewID] = vec4(1.0, 2.0, 3.0, 4.0);
gl_MeshVerticesNV[iid].gl_ClipDistancePerViewNV[viewID][2] = 5.0;
gl_MeshVerticesNV[iid].gl_CullDistancePerViewNV[viewID][3] = 6.0;
gl_MeshPrimitivesNV[iid].gl_LayerPerViewNV[viewID] = 7;
gl_MeshPrimitivesNV[iid].gl_ViewportMaskPerViewNV[viewID][0] = 8;
BARRIER();
gl_MeshVerticesNV[iid+1].gl_PositionPerViewNV[viewID] = gl_MeshVerticesNV[iid].gl_PositionPerViewNV[viewID];
gl_MeshVerticesNV[iid+1].gl_ClipDistancePerViewNV[viewID][2] = gl_MeshVerticesNV[iid].gl_ClipDistancePerViewNV[viewID][2];
gl_MeshVerticesNV[iid+1].gl_CullDistancePerViewNV[viewID][3] = gl_MeshVerticesNV[iid].gl_CullDistancePerViewNV[viewID][3];
gl_MeshPrimitivesNV[iid+1].gl_LayerPerViewNV[viewID] = gl_MeshPrimitivesNV[iid].gl_LayerPerViewNV[viewID];
gl_MeshPrimitivesNV[iid+1].gl_ViewportMaskPerViewNV[viewID][0] = gl_MeshPrimitivesNV[iid].gl_ViewportMaskPerViewNV[viewID][0];
BARRIER();
}
#version 450
#define MAX_VER 81
#define MAX_PRIM 32
#define MAX_VIEWS gl_MaxMeshViewCountNV
#define BARRIER() \
memoryBarrierShared(); \
barrier();
#extension GL_NV_mesh_shader : enable
layout(local_size_x = 32) in;
layout(max_vertices=MAX_VER) out;
layout(max_primitives=MAX_PRIM) out;
layout(triangles) out;
// test use of user-defined per-view attributes
// mix of single-view and per-view attributes
layout(location=0) out block {
perprimitiveNV perviewNV vec4 color1[][3]; // Implicitly sized
perprimitiveNV vec4 color2[3];
perviewNV vec4 color3[MAX_VIEWS][3]; // Explicitly sized
vec4 color4;
} b[];
// per-view block
perviewNV layout(location=10) out perviewBlock {
perprimitiveNV vec4 color5[]; // Implicitly sized
perprimitiveNV vec4 color6[MAX_VIEWS][3]; // Explicitly sized
vec4 color7[][3]; // Implicitly sized
vec4 color8[MAX_VIEWS]; // Explicitly sized
} b2[];
void main()
{
uint iid = gl_LocalInvocationID.x;
uint viewID = gl_MeshViewIndicesNV[gl_MeshViewCountNV%MAX_VIEWS];
b[iid].color1[viewID][2] = vec4(1.0);
b[iid].color2[1] = vec4(2.0);
b[iid].color3[viewID][2] = vec4(3.0);
b[iid].color4 = vec4(4.0);
BARRIER();
b2[iid].color5[viewID] = vec4(5.0);
b2[iid].color6[viewID][1] = vec4(6.0);
b2[iid].color7[viewID][2] = vec4(7.0);
b2[iid].color8[viewID] = vec4(8.0);
BARRIER();
}
#version 450
#define MAX_VER 81
#define MAX_PRIM 32
#define BARRIER() \
memoryBarrierShared(); \
barrier();
#extension GL_NV_mesh_shader : enable
layout(local_size_x = 32) in;
layout(max_vertices=MAX_VER) out;
layout(max_primitives=MAX_PRIM) out;
layout(triangles) out;
// test use of shared memory in mesh shaders:
writeonly uniform image2D uni_image;
uniform block0 {
uint uni_value;
};
shared vec4 mem[10];
void main()
{
uint iid = gl_LocalInvocationID.x;
uint gid = gl_WorkGroupID.x;
for (uint i = 0; i < 10; ++i) {
mem[i] = vec4(i+uni_value);
}
imageStore(uni_image, ivec2(iid), mem[gid]);
imageStore(uni_image, ivec2(iid), mem[gid+1]);
BARRIER();
}
#version 450
#define MAX_VER 81
#define MAX_PRIM 32
#define BARRIER() \
memoryBarrierShared(); \
barrier();
#extension GL_NV_mesh_shader : enable
layout(local_size_x = 32) in;
layout(max_vertices=MAX_VER) out;
layout(max_primitives=MAX_PRIM) out;
layout(triangles) out;
// test use of task memory in mesh shaders:
taskNV in taskBlock {
float gid1[2];
vec4 gid2;
} mytask;
buffer bufferBlock {
float gid3[2];
vec4 gid4;
} mybuf;
layout(location=0) out outBlock {
float gid5;
vec4 gid6;
} myblk[];
void main()
{
uint iid = gl_LocalInvocationID.x;
myblk[iid].gid5 = mytask.gid1[1] + mybuf.gid3[1];
myblk[iid].gid6 = mytask.gid2 + mybuf.gid4;
}
#version 450
#define MAX_VER 81
#define MAX_PRIM 32
#define BARRIER() \
memoryBarrierShared(); \
barrier();
#extension GL_NV_mesh_shader : enable
layout(local_size_x = 32) in;
layout(max_vertices=MAX_VER) out;
layout(max_primitives=MAX_PRIM) out;
layout(triangles) out;
// test use of user defined interface out blocks:
// per-primitive block
perprimitiveNV layout(location=0) out myblock {
float f;
float fArr[4];
vec3 pos;
vec4 posArr[4];
mat4 m;
mat3 mArr[2];
} blk[];
// per-vertex block
layout(location=20) out myblock2 {
float f;
vec4 pos;
mat4 m;
} blk2[];
void main()
{
uint iid = gl_LocalInvocationID.x;
uint gid = gl_WorkGroupID.x;
blk[iid].f = 11.0;
blk[iid+1].fArr[gid] = blk[iid].f;
blk[iid/2].pos.yzx = vec3(14.0, 15.0, 13.0);
blk[iid*2].posArr[1].yzw = blk[iid/2].pos;
blk[iid/4].m[2].wzyx = vec4(13.0, 14.0, 15.0, 16.0);
blk[iid].mArr[0][1][1] = blk[iid/4].m[2].w;
blk[iid*4].mArr[1][gid] = vec3(17.0, 18.0, 19.0);
BARRIER();
blk2[iid].f = blk2[iid-1].f + 20.0;
blk2[iid].pos = vec4(21.0, 22.0, 23.0, 24.0);
blk2[iid+1].m[gid] = blk2[iid].pos;
blk2[iid+1].m[gid][2] = 29.0;
blk2[iid+2].m[3] = blk2[iid+1].m[gid];
BARRIER();
}
#version 450
#define BARRIER() \
memoryBarrierShared(); \
barrier();
#extension GL_NV_mesh_shader : enable
layout(local_size_x = 32) in;
// test use of shared memory in task shaders:
layout(binding=0) writeonly uniform image2D uni_image;
uniform block0 {
uint uni_value;
};
shared vec4 mem[10];
// test use of task memory in task shaders:
taskNV out Task {
vec2 dummy;
vec2 submesh[3];
} mytask;
void main()
{
uint iid = gl_LocalInvocationID.x;
uint gid = gl_WorkGroupID.x;
// 1. shared memory load and stores
for (uint i = 0; i < 10; ++i) {
mem[i] = vec4(i + uni_value);
}
imageStore(uni_image, ivec2(iid), mem[gid]);
imageStore(uni_image, ivec2(iid), mem[gid+1]);
BARRIER();
// 2. task memory stores
mytask.dummy = vec2(30.0, 31.0);
mytask.submesh[0] = vec2(32.0, 33.0);
mytask.submesh[1] = vec2(34.0, 35.0);
mytask.submesh[2] = mytask.submesh[gid%2];
BARRIER();
// 3. set task count
gl_TaskCountNV = 3;
}
...@@ -229,6 +229,14 @@ enum TBuiltInVariable { ...@@ -229,6 +229,14 @@ enum TBuiltInVariable {
EbvFragFullyCoveredNV, EbvFragFullyCoveredNV,
EbvBaryCoordNV, EbvBaryCoordNV,
EbvBaryCoordNoPerspNV, EbvBaryCoordNoPerspNV,
EbvTaskCountNV,
EbvPrimitiveCountNV,
EbvPrimitiveIndicesNV,
EbvClipDistancePerViewNV,
EbvCullDistancePerViewNV,
EbvLayerPerViewNV,
EbvMeshViewCountNV,
EbvMeshViewIndicesNV,
#endif #endif
// HLSL built-ins that live only temporarily, until they get remapped // HLSL built-ins that live only temporarily, until they get remapped
...@@ -369,6 +377,14 @@ __inline const char* GetBuiltInVariableString(TBuiltInVariable v) ...@@ -369,6 +377,14 @@ __inline const char* GetBuiltInVariableString(TBuiltInVariable v)
case EbvFragFullyCoveredNV: return "FragFullyCoveredNV"; case EbvFragFullyCoveredNV: return "FragFullyCoveredNV";
case EbvBaryCoordNV: return "BaryCoordNV"; case EbvBaryCoordNV: return "BaryCoordNV";
case EbvBaryCoordNoPerspNV: return "BaryCoordNoPerspNV"; case EbvBaryCoordNoPerspNV: return "BaryCoordNoPerspNV";
case EbvTaskCountNV: return "TaskCountNV";
case EbvPrimitiveCountNV: return "PrimitiveCountNV";
case EbvPrimitiveIndicesNV: return "PrimitiveIndicesNV";
case EbvClipDistancePerViewNV: return "ClipDistancePerViewNV";
case EbvCullDistancePerViewNV: return "CullDistancePerViewNV";
case EbvLayerPerViewNV: return "LayerPerViewNV";
case EbvMeshViewCountNV: return "MeshViewCountNV";
case EbvMeshViewIndicesNV: return "MeshViewIndicesNV";
#endif #endif
default: return "unknown built-in variable"; default: return "unknown built-in variable";
} }
......
...@@ -133,6 +133,17 @@ struct TBuiltInResource { ...@@ -133,6 +133,17 @@ struct TBuiltInResource {
int maxCullDistances; int maxCullDistances;
int maxCombinedClipAndCullDistances; int maxCombinedClipAndCullDistances;
int maxSamples; int maxSamples;
#ifdef NV_EXTENSIONS
int maxMeshOutputVerticesNV;
int maxMeshOutputPrimitivesNV;
int maxMeshWorkGroupSizeX_NV;
int maxMeshWorkGroupSizeY_NV;
int maxMeshWorkGroupSizeZ_NV;
int maxTaskWorkGroupSizeX_NV;
int maxTaskWorkGroupSizeY_NV;
int maxTaskWorkGroupSizeZ_NV;
int maxMeshViewCountNV;
#endif
TLimits limits; TLimits limits;
}; };
......
...@@ -459,6 +459,9 @@ public: ...@@ -459,6 +459,9 @@ public:
#endif #endif
#ifdef NV_EXTENSIONS #ifdef NV_EXTENSIONS
pervertexNV = false; pervertexNV = false;
perPrimitiveNV = false;
perViewNV = false;
perTaskNV = false;
#endif #endif
} }
...@@ -506,6 +509,9 @@ public: ...@@ -506,6 +509,9 @@ public:
#endif #endif
#ifdef NV_EXTENSIONS #ifdef NV_EXTENSIONS
bool pervertexNV : 1; bool pervertexNV : 1;
bool perPrimitiveNV : 1;
bool perViewNV : 1;
bool perTaskNV : 1;
#endif #endif
bool patch : 1; bool patch : 1;
bool sample : 1; bool sample : 1;
...@@ -620,6 +626,33 @@ public: ...@@ -620,6 +626,33 @@ public:
} }
} }
bool isPerPrimitive() const
{
#ifdef NV_EXTENSIONS
return perPrimitiveNV;
#else
return false;
#endif
}
bool isPerView() const
{
#ifdef NV_EXTENSIONS
return perViewNV;
#else
return false;
#endif
}
bool isTaskMemory() const
{
#ifdef NV_EXTENSIONS
return perTaskNV;
#else
return false;
#endif
}
bool isIo() const bool isIo() const
{ {
switch (storage) { switch (storage) {
...@@ -672,6 +705,8 @@ public: ...@@ -672,6 +705,8 @@ public:
#ifdef NV_EXTENSIONS #ifdef NV_EXTENSIONS
case EShLangFragment: case EShLangFragment:
return pervertexNV && isPipeInput(); return pervertexNV && isPipeInput();
case EShLangMeshNV:
return ! perTaskNV && isPipeOutput();
#endif #endif
default: default:
...@@ -1053,7 +1088,7 @@ struct TShaderQualifiers { ...@@ -1053,7 +1088,7 @@ struct TShaderQualifiers {
bool pixelCenterInteger; // fragment shader bool pixelCenterInteger; // fragment shader
bool originUpperLeft; // fragment shader bool originUpperLeft; // fragment shader
int invocations; int invocations;
int vertices; // both for tessellation "vertices" and geometry "max_vertices" int vertices; // for tessellation "vertices", geometry & mesh "max_vertices"
TVertexSpacing spacing; TVertexSpacing spacing;
TVertexOrder order; TVertexOrder order;
bool pointMode; bool pointMode;
...@@ -1069,6 +1104,7 @@ struct TShaderQualifiers { ...@@ -1069,6 +1104,7 @@ struct TShaderQualifiers {
bool layoutOverrideCoverage; // true if layout override_coverage set bool layoutOverrideCoverage; // true if layout override_coverage set
bool layoutDerivativeGroupQuads; // true if layout derivative_group_quadsNV set bool layoutDerivativeGroupQuads; // true if layout derivative_group_quadsNV set
bool layoutDerivativeGroupLinear; // true if layout derivative_group_linearNV set bool layoutDerivativeGroupLinear; // true if layout derivative_group_linearNV set
int primitives; // mesh shader "max_primitives"DerivativeGroupLinear; // true if layout derivative_group_linearNV set
#endif #endif
void init() void init()
...@@ -1093,10 +1129,10 @@ struct TShaderQualifiers { ...@@ -1093,10 +1129,10 @@ struct TShaderQualifiers {
blendEquation = false; blendEquation = false;
numViews = TQualifier::layoutNotSet; numViews = TQualifier::layoutNotSet;
#ifdef NV_EXTENSIONS #ifdef NV_EXTENSIONS
layoutOverrideCoverage = false; layoutOverrideCoverage = false;
layoutDerivativeGroupQuads = false; layoutDerivativeGroupQuads = false;
layoutDerivativeGroupLinear = false; layoutDerivativeGroupLinear = false;
primitives = TQualifier::layoutNotSet;
#endif #endif
} }
...@@ -1145,6 +1181,8 @@ struct TShaderQualifiers { ...@@ -1145,6 +1181,8 @@ struct TShaderQualifiers {
layoutDerivativeGroupQuads = src.layoutDerivativeGroupQuads; layoutDerivativeGroupQuads = src.layoutDerivativeGroupQuads;
if (src.layoutDerivativeGroupLinear) if (src.layoutDerivativeGroupLinear)
layoutDerivativeGroupLinear = src.layoutDerivativeGroupLinear; layoutDerivativeGroupLinear = src.layoutDerivativeGroupLinear;
if (src.primitives != TQualifier::layoutNotSet)
primitives = src.primitives;
#endif #endif
} }
}; };
...@@ -1751,6 +1789,12 @@ public: ...@@ -1751,6 +1789,12 @@ public:
#ifdef NV_EXTENSIONS #ifdef NV_EXTENSIONS
if (qualifier.pervertexNV) if (qualifier.pervertexNV)
appendStr(" pervertexNV"); appendStr(" pervertexNV");
if (qualifier.perPrimitiveNV)
appendStr(" perprimitiveNV");
if (qualifier.perViewNV)
appendStr(" perviewNV");
if (qualifier.perTaskNV)
appendStr(" taskNV");
#endif #endif
if (qualifier.patch) if (qualifier.patch)
appendStr(" patch"); appendStr(" patch");
......
...@@ -893,6 +893,9 @@ enum TOperator { ...@@ -893,6 +893,9 @@ enum TOperator {
EOpFindLSB, EOpFindLSB,
EOpFindMSB, EOpFindMSB,
#ifdef NV_EXTENSIONS
EOpWritePackedPrimitiveIndices4x8NV,
#endif
// //
// HLSL operations // HLSL operations
// //
......
...@@ -298,8 +298,8 @@ public: ...@@ -298,8 +298,8 @@ public:
void fixIoArraySize(const TSourceLoc&, TType&); void fixIoArraySize(const TSourceLoc&, TType&);
void ioArrayCheck(const TSourceLoc&, const TType&, const TString& identifier); void ioArrayCheck(const TSourceLoc&, const TType&, const TString& identifier);
void handleIoResizeArrayAccess(const TSourceLoc&, TIntermTyped* base); void handleIoResizeArrayAccess(const TSourceLoc&, TIntermTyped* base);
void checkIoArraysConsistency(const TSourceLoc&, bool tailOnly = false); void checkIoArraysConsistency(const TSourceLoc&, bool tailOnly = false, bool isPerPrimitive = false);
int getIoArrayImplicitSize() const; int getIoArrayImplicitSize(bool isPerPrimitive = false) const;
void checkIoArrayConsistency(const TSourceLoc&, int requiredSize, const char* feature, TType&, const TString&); void checkIoArrayConsistency(const TSourceLoc&, int requiredSize, const char* feature, TType&, const TString&);
TIntermTyped* handleBinaryMath(const TSourceLoc&, const char* str, TOperator op, TIntermTyped* left, TIntermTyped* right); TIntermTyped* handleBinaryMath(const TSourceLoc&, const char* str, TOperator op, TIntermTyped* left, TIntermTyped* right);
...@@ -423,6 +423,9 @@ public: ...@@ -423,6 +423,9 @@ public:
// Determine loop control from attributes // Determine loop control from attributes
void handleLoopAttributes(const TAttributes& attributes, TIntermNode*); void handleLoopAttributes(const TAttributes& attributes, TIntermNode*);
#ifdef NV_EXTENSIONS
void resizeMeshViewDimension(const TSourceLoc&, TType&);
#endif
protected: protected:
void nonInitConstCheck(const TSourceLoc&, TString& identifier, TType& type); void nonInitConstCheck(const TSourceLoc&, TString& identifier, TType& type);
void inheritGlobalDefaults(TQualifier& dst) const; void inheritGlobalDefaults(TQualifier& dst) const;
......
...@@ -700,6 +700,12 @@ void TScanContext::fillInKeywordMap() ...@@ -700,6 +700,12 @@ void TScanContext::fillInKeywordMap()
(*KeywordMap)["resource"] = RESOURCE; (*KeywordMap)["resource"] = RESOURCE;
(*KeywordMap)["superp"] = SUPERP; (*KeywordMap)["superp"] = SUPERP;
#ifdef NV_EXTENSIONS
(*KeywordMap)["perprimitiveNV"] = PERPRIMITIVENV;
(*KeywordMap)["perviewNV"] = PERVIEWNV;
(*KeywordMap)["taskNV"] = PERTASKNV;
#endif
ReservedSet = new std::unordered_set<const char*, str_hash, str_eq>; ReservedSet = new std::unordered_set<const char*, str_hash, str_eq>;
ReservedSet->insert("common"); ReservedSet->insert("common");
...@@ -1565,6 +1571,16 @@ int TScanContext::tokenizeIdentifier() ...@@ -1565,6 +1571,16 @@ int TScanContext::tokenizeIdentifier()
return identifierOrReserved(reserved); return identifierOrReserved(reserved);
} }
#ifdef NV_EXTENSIONS
case PERPRIMITIVENV:
case PERVIEWNV:
case PERTASKNV:
if (parseContext.profile != EEsProfile &&
(parseContext.version >= 450 || parseContext.extensionTurnedOn(E_GL_NV_mesh_shader)))
return keyword;
return identifierOrType();
#endif
default: default:
parseContext.infoSink.info.message(EPrefixInternalError, "Unknown glslang keyword", loc); parseContext.infoSink.info.message(EPrefixInternalError, "Unknown glslang keyword", loc);
return 0; return 0;
......
...@@ -347,6 +347,18 @@ bool InitializeSymbolTables(TInfoSink& infoSink, TSymbolTable** commonTable, TS ...@@ -347,6 +347,18 @@ bool InitializeSymbolTables(TInfoSink& infoSink, TSymbolTable** commonTable, TS
InitializeStageSymbolTable(*builtInParseables, version, profile, spvVersion, EShLangCompute, source, InitializeStageSymbolTable(*builtInParseables, version, profile, spvVersion, EShLangCompute, source,
infoSink, commonTable, symbolTables); infoSink, commonTable, symbolTables);
#ifdef NV_EXTENSIONS
// check for mesh
if (profile != EEsProfile && version >= 450)
InitializeStageSymbolTable(*builtInParseables, version, profile, spvVersion, EShLangMeshNV, source,
infoSink, commonTable, symbolTables);
// check for task
if (profile != EEsProfile && version >= 450)
InitializeStageSymbolTable(*builtInParseables, version, profile, spvVersion, EShLangTaskNV, source,
infoSink, commonTable, symbolTables);
#endif
return true; return true;
} }
...@@ -570,6 +582,16 @@ bool DeduceVersionProfile(TInfoSink& infoSink, EShLanguage stage, bool versionNo ...@@ -570,6 +582,16 @@ bool DeduceVersionProfile(TInfoSink& infoSink, EShLanguage stage, bool versionNo
version = profile == EEsProfile ? 310 : 420; version = profile == EEsProfile ? 310 : 420;
} }
break; break;
#ifdef NV_EXTENSIONS
case EShLangMeshNV:
case EShLangTaskNV:
if ((profile == EEsProfile) ||
(profile != EEsProfile && version < 450)) {
correct = false;
infoSink.info.message(EPrefixError, "#version: mesh/task shaders require non-es profile with version 450 or above");
version = 450;
}
#endif
default: default:
break; break;
} }
......
...@@ -238,6 +238,7 @@ void TParseVersions::initializeExtensionBehavior() ...@@ -238,6 +238,7 @@ void TParseVersions::initializeExtensionBehavior()
extensionBehavior[E_GL_NV_fragment_shader_barycentric] = EBhDisable; extensionBehavior[E_GL_NV_fragment_shader_barycentric] = EBhDisable;
extensionBehavior[E_GL_NV_compute_shader_derivatives] = EBhDisable; extensionBehavior[E_GL_NV_compute_shader_derivatives] = EBhDisable;
extensionBehavior[E_GL_NV_shader_texture_footprint] = EBhDisable; extensionBehavior[E_GL_NV_shader_texture_footprint] = EBhDisable;
extensionBehavior[E_GL_NV_mesh_shader] = EBhDisable;
#endif #endif
// AEP // AEP
...@@ -411,6 +412,7 @@ void TParseVersions::getPreamble(std::string& preamble) ...@@ -411,6 +412,7 @@ void TParseVersions::getPreamble(std::string& preamble)
"#define GL_NV_fragment_shader_barycentric 1\n" "#define GL_NV_fragment_shader_barycentric 1\n"
"#define GL_NV_compute_shader_derivatives 1\n" "#define GL_NV_compute_shader_derivatives 1\n"
"#define GL_NV_shader_texture_footprint 1\n" "#define GL_NV_shader_texture_footprint 1\n"
"#define GL_NV_mesh_shader 1\n"
#endif #endif
"#define GL_KHX_shader_explicit_arithmetic_types 1\n" "#define GL_KHX_shader_explicit_arithmetic_types 1\n"
"#define GL_KHX_shader_explicit_arithmetic_types_int8 1\n" "#define GL_KHX_shader_explicit_arithmetic_types_int8 1\n"
...@@ -498,6 +500,10 @@ const char* StageName(EShLanguage stage) ...@@ -498,6 +500,10 @@ const char* StageName(EShLanguage stage)
case EShLangGeometry: return "geometry"; case EShLangGeometry: return "geometry";
case EShLangFragment: return "fragment"; case EShLangFragment: return "fragment";
case EShLangCompute: return "compute"; case EShLangCompute: return "compute";
#ifdef NV_EXTENSIONS
case EShLangMeshNV: return "mesh";
case EShLangTaskNV: return "task";
#endif
default: return "unknown stage"; default: return "unknown stage";
} }
} }
......
...@@ -210,6 +210,8 @@ const char* const E_GL_NV_shader_subgroup_partitioned = "GL_NV_shader_ ...@@ -210,6 +210,8 @@ const char* const E_GL_NV_shader_subgroup_partitioned = "GL_NV_shader_
const char* const E_GL_NV_fragment_shader_barycentric = "GL_NV_fragment_shader_barycentric"; const char* const E_GL_NV_fragment_shader_barycentric = "GL_NV_fragment_shader_barycentric";
const char* const E_GL_NV_compute_shader_derivatives = "GL_NV_compute_shader_derivatives"; const char* const E_GL_NV_compute_shader_derivatives = "GL_NV_compute_shader_derivatives";
const char* const E_GL_NV_shader_texture_footprint = "GL_NV_shader_texture_footprint"; const char* const E_GL_NV_shader_texture_footprint = "GL_NV_shader_texture_footprint";
const char* const E_GL_NV_mesh_shader = "GL_NV_mesh_shader";
// Arrays of extensions for the above viewportEXTs duplications // Arrays of extensions for the above viewportEXTs duplications
const char* const viewportEXTs[] = { E_GL_ARB_shader_viewport_layer_array, E_GL_NV_viewport_array2 }; const char* const viewportEXTs[] = { E_GL_ARB_shader_viewport_layer_array, E_GL_NV_viewport_array2 };
......
...@@ -146,7 +146,7 @@ extern int yylex(YYSTYPE*, TParseContext&); ...@@ -146,7 +146,7 @@ extern int yylex(YYSTYPE*, TParseContext&);
%token <lex> F16VEC2 F16VEC3 F16VEC4 F16MAT2 F16MAT3 F16MAT4 %token <lex> F16VEC2 F16VEC3 F16VEC4 F16MAT2 F16MAT3 F16MAT4
%token <lex> F32VEC2 F32VEC3 F32VEC4 F32MAT2 F32MAT3 F32MAT4 %token <lex> F32VEC2 F32VEC3 F32VEC4 F32MAT2 F32MAT3 F32MAT4
%token <lex> F64VEC2 F64VEC3 F64VEC4 F64MAT2 F64MAT3 F64MAT4 %token <lex> F64VEC2 F64VEC3 F64VEC4 F64MAT2 F64MAT3 F64MAT4
%token <lex> NOPERSPECTIVE FLAT SMOOTH LAYOUT EXPLICITINTERPAMD PERVERTEXNV %token <lex> NOPERSPECTIVE FLAT SMOOTH LAYOUT EXPLICITINTERPAMD PERVERTEXNV PERPRIMITIVENV PERVIEWNV PERTASKNV
%token <lex> MAT2X2 MAT2X3 MAT2X4 %token <lex> MAT2X2 MAT2X3 MAT2X4
%token <lex> MAT3X2 MAT3X3 MAT3X4 %token <lex> MAT3X2 MAT3X3 MAT3X4
...@@ -1154,6 +1154,30 @@ interpolation_qualifier ...@@ -1154,6 +1154,30 @@ interpolation_qualifier
$$.qualifier.pervertexNV = true; $$.qualifier.pervertexNV = true;
#endif #endif
} }
| PERPRIMITIVENV {
#ifdef NV_EXTENSIONS
parseContext.globalCheck($1.loc, "perprimitiveNV");
parseContext.profileRequires($1.loc, ECoreProfile, 450, E_GL_NV_mesh_shader, "perprimitiveNV");
$$.init($1.loc);
$$.qualifier.perPrimitiveNV = true;
#endif
}
| PERVIEWNV {
#ifdef NV_EXTENSIONS
parseContext.globalCheck($1.loc, "perviewNV");
parseContext.profileRequires($1.loc, ECoreProfile, 450, E_GL_NV_mesh_shader, "perviewNV");
$$.init($1.loc);
$$.qualifier.perViewNV = true;
#endif
}
| PERTASKNV {
#ifdef NV_EXTENSIONS
parseContext.globalCheck($1.loc, "taskNV");
parseContext.profileRequires($1.loc, ECoreProfile, 450, E_GL_NV_mesh_shader, "taskNV");
$$.init($1.loc);
$$.qualifier.perTaskNV = true;
#endif
}
; ;
layout_qualifier layout_qualifier
...@@ -1319,7 +1343,11 @@ storage_qualifier ...@@ -1319,7 +1343,11 @@ storage_qualifier
parseContext.globalCheck($1.loc, "shared"); parseContext.globalCheck($1.loc, "shared");
parseContext.profileRequires($1.loc, ECoreProfile | ECompatibilityProfile, 430, E_GL_ARB_compute_shader, "shared"); parseContext.profileRequires($1.loc, ECoreProfile | ECompatibilityProfile, 430, E_GL_ARB_compute_shader, "shared");
parseContext.profileRequires($1.loc, EEsProfile, 310, 0, "shared"); parseContext.profileRequires($1.loc, EEsProfile, 310, 0, "shared");
#ifdef NV_EXTENSIONS
parseContext.requireStage($1.loc, (EShLanguageMask)(EShLangComputeMask | EShLangMeshNVMask | EShLangTaskNVMask), "shared");
#else
parseContext.requireStage($1.loc, EShLangCompute, "shared"); parseContext.requireStage($1.loc, EShLangCompute, "shared");
#endif
$$.init($1.loc); $$.init($1.loc);
$$.qualifier.storage = EvqShared; $$.qualifier.storage = EvqShared;
} }
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -1048,6 +1048,10 @@ bool TOutputTraverser::visitAggregate(TVisit /* visit */, TIntermAggregate* node ...@@ -1048,6 +1048,10 @@ bool TOutputTraverser::visitAggregate(TVisit /* visit */, TIntermAggregate* node
case EOpSubpassLoad: out.debug << "subpassLoad"; break; case EOpSubpassLoad: out.debug << "subpassLoad"; break;
case EOpSubpassLoadMS: out.debug << "subpassLoadMS"; break; case EOpSubpassLoadMS: out.debug << "subpassLoadMS"; break;
#ifdef NV_EXTENSIONS
case EOpWritePackedPrimitiveIndices4x8NV: out.debug << "writePackedPrimitiveIndices4x8NV"; break;
#endif
default: out.debug.message(EPrefixError, "Bad aggregation op"); default: out.debug.message(EPrefixError, "Bad aggregation op");
} }
...@@ -1451,6 +1455,16 @@ void TIntermediate::output(TInfoSink& infoSink, bool tree) ...@@ -1451,6 +1455,16 @@ void TIntermediate::output(TInfoSink& infoSink, bool tree)
} }
break; break;
#ifdef NV_EXTENSIONS
case EShLangMeshNV:
infoSink.debug << "max_vertices = " << vertices << "\n";
infoSink.debug << "max_primitives = " << primitives << "\n";
infoSink.debug << "output primitive = " << TQualifier::getGeometryString(outputPrimitive) << "\n";
// Fall through
case EShLangTaskNV:
// Fall through
#endif
case EShLangCompute: case EShLangCompute:
infoSink.debug << "local_size = (" << localSize[0] << ", " << localSize[1] << ", " << localSize[2] << ")\n"; infoSink.debug << "local_size = (" << localSize[0] << ", " << localSize[1] << ", " << localSize[2] << ")\n";
{ {
......
...@@ -141,13 +141,27 @@ void TIntermediate::mergeModes(TInfoSink& infoSink, TIntermediate& unit) ...@@ -141,13 +141,27 @@ void TIntermediate::mergeModes(TInfoSink& infoSink, TIntermediate& unit)
if (vertices == TQualifier::layoutNotSet) if (vertices == TQualifier::layoutNotSet)
vertices = unit.vertices; vertices = unit.vertices;
else if (vertices != unit.vertices) { else if (vertices != unit.vertices) {
if (language == EShLangGeometry) if (language == EShLangGeometry
#ifdef NV_EXTENSIONS
|| language == EShLangMeshNV
#endif
)
error(infoSink, "Contradictory layout max_vertices values"); error(infoSink, "Contradictory layout max_vertices values");
else if (language == EShLangTessControl) else if (language == EShLangTessControl)
error(infoSink, "Contradictory layout vertices values"); error(infoSink, "Contradictory layout vertices values");
else else
assert(0); assert(0);
} }
#ifdef NV_EXTENSIONS
if (primitives == TQualifier::layoutNotSet)
primitives = unit.primitives;
else if (primitives != unit.primitives) {
if (language == EShLangMeshNV)
error(infoSink, "Contradictory layout max_primitives values");
else
assert(0);
}
#endif
if (inputPrimitive == ElgNone) if (inputPrimitive == ElgNone)
inputPrimitive = unit.inputPrimitive; inputPrimitive = unit.inputPrimitive;
...@@ -266,6 +280,10 @@ void TIntermediate::mergeTrees(TInfoSink& infoSink, TIntermediate& unit) ...@@ -266,6 +280,10 @@ void TIntermediate::mergeTrees(TInfoSink& infoSink, TIntermediate& unit)
// Getting this far means we have two existing trees to merge... // Getting this far means we have two existing trees to merge...
#ifdef NV_EXTENSIONS
numTaskNVBlocks += unit.numTaskNVBlocks;
#endif
// Get the top-level globals of each unit // Get the top-level globals of each unit
TIntermSequence& globals = treeRoot->getAsAggregate()->getSequence(); TIntermSequence& globals = treeRoot->getAsAggregate()->getSequence();
TIntermSequence& unitGlobals = unit.treeRoot->getAsAggregate()->getSequence(); TIntermSequence& unitGlobals = unit.treeRoot->getAsAggregate()->getSequence();
...@@ -690,6 +708,22 @@ void TIntermediate::finalCheck(TInfoSink& infoSink, bool keepUncalled) ...@@ -690,6 +708,22 @@ void TIntermediate::finalCheck(TInfoSink& infoSink, bool keepUncalled)
break; break;
case EShLangCompute: case EShLangCompute:
break; break;
#ifdef NV_EXTENSIONS
case EShLangMeshNV:
if (outputPrimitive == ElgNone)
error(infoSink, "At least one shader must specify an output layout primitive");
if (vertices == TQualifier::layoutNotSet)
error(infoSink, "At least one shader must specify a layout(max_vertices = value)");
if (primitives == TQualifier::layoutNotSet)
error(infoSink, "At least one shader must specify a layout(max_primitives = value)");
// fall through
case EShLangTaskNV:
if (numTaskNVBlocks > 1)
error(infoSink, "Only one taskNV interface block is allowed per shader");
break;
#endif
default: default:
error(infoSink, "Unknown Stage."); error(infoSink, "Unknown Stage.");
break; break;
...@@ -960,7 +994,7 @@ int TIntermediate::addUsedLocation(const TQualifier& qualifier, const TType& typ ...@@ -960,7 +994,7 @@ int TIntermediate::addUsedLocation(const TQualifier& qualifier, const TType& typ
return -1; return -1;
int size; int size;
if (qualifier.isUniformOrBuffer()) { if (qualifier.isUniformOrBuffer() || qualifier.isTaskMemory()) {
if (type.isSizedArray()) if (type.isSizedArray())
size = type.getCumulativeArraySize(); size = type.getCumulativeArraySize();
else else
...@@ -1111,10 +1145,19 @@ int TIntermediate::computeTypeLocationSize(const TType& type, EShLanguage stage) ...@@ -1111,10 +1145,19 @@ int TIntermediate::computeTypeLocationSize(const TType& type, EShLanguage stage)
// TODO: perf: this can be flattened by using getCumulativeArraySize(), and a deref that discards all arrayness // TODO: perf: this can be flattened by using getCumulativeArraySize(), and a deref that discards all arrayness
// TODO: are there valid cases of having an unsized array with a location? If so, running this code too early. // TODO: are there valid cases of having an unsized array with a location? If so, running this code too early.
TType elementType(type, 0); TType elementType(type, 0);
if (type.isSizedArray()) if (type.isSizedArray()
#ifdef NV_EXTENSIONS
&& !type.getQualifier().isPerView()
#endif
)
return type.getOuterArraySize() * computeTypeLocationSize(elementType, stage); return type.getOuterArraySize() * computeTypeLocationSize(elementType, stage);
else else {
#ifdef NV_EXTENSIONS
// unset perViewNV attributes for arrayed per-view outputs: "perviewNV vec4 v[MAX_VIEWS][3];"
elementType.getQualifier().perViewNV = false;
#endif
return computeTypeLocationSize(elementType, stage); return computeTypeLocationSize(elementType, stage);
}
} }
// "The locations consumed by block and structure members are determined by applying the rules above // "The locations consumed by block and structure members are determined by applying the rules above
......
...@@ -237,6 +237,8 @@ public: ...@@ -237,6 +237,8 @@ public:
layoutOverrideCoverage(false), layoutOverrideCoverage(false),
geoPassthroughEXT(false), geoPassthroughEXT(false),
computeDerivativeMode(LayoutDerivativeNone), computeDerivativeMode(LayoutDerivativeNone),
primitives(TQualifier::layoutNotSet),
numTaskNVBlocks(0),
#endif #endif
autoMapBindings(false), autoMapBindings(false),
autoMapLocations(false), autoMapLocations(false),
...@@ -427,6 +429,10 @@ public: ...@@ -427,6 +429,10 @@ public:
int getNumEntryPoints() const { return numEntryPoints; } int getNumEntryPoints() const { return numEntryPoints; }
int getNumErrors() const { return numErrors; } int getNumErrors() const { return numErrors; }
void addPushConstantCount() { ++numPushConstants; } void addPushConstantCount() { ++numPushConstants; }
#ifdef NV_EXTENSIONS
void addTaskNVCount() { ++numTaskNVBlocks; }
#endif
bool isRecursive() const { return recursive; } bool isRecursive() const { return recursive; }
TIntermSymbol* addSymbol(const TVariable&); TIntermSymbol* addSymbol(const TVariable&);
...@@ -636,6 +642,14 @@ public: ...@@ -636,6 +642,14 @@ public:
bool getGeoPassthroughEXT() const { return geoPassthroughEXT; } bool getGeoPassthroughEXT() const { return geoPassthroughEXT; }
void setLayoutDerivativeMode(ComputeDerivativeMode mode) { computeDerivativeMode = mode; } void setLayoutDerivativeMode(ComputeDerivativeMode mode) { computeDerivativeMode = mode; }
ComputeDerivativeMode getLayoutDerivativeModeNone() const { return computeDerivativeMode; } ComputeDerivativeMode getLayoutDerivativeModeNone() const { return computeDerivativeMode; }
bool setPrimitives(int m)
{
if (primitives != TQualifier::layoutNotSet)
return primitives == m;
primitives = m;
return true;
}
int getPrimitives() const { return primitives; }
#endif #endif
const char* addSemanticName(const TString& name) const char* addSemanticName(const TString& name)
...@@ -740,6 +754,8 @@ protected: ...@@ -740,6 +754,8 @@ protected:
bool layoutOverrideCoverage; bool layoutOverrideCoverage;
bool geoPassthroughEXT; bool geoPassthroughEXT;
ComputeDerivativeMode computeDerivativeMode; ComputeDerivativeMode computeDerivativeMode;
int primitives;
int numTaskNVBlocks;
#endif #endif
// Base shift values // Base shift values
......
...@@ -94,6 +94,10 @@ typedef enum { ...@@ -94,6 +94,10 @@ typedef enum {
EShLangGeometry, EShLangGeometry,
EShLangFragment, EShLangFragment,
EShLangCompute, EShLangCompute,
#ifdef NV_EXTENSIONS
EShLangTaskNV,
EShLangMeshNV,
#endif
EShLangCount, EShLangCount,
} EShLanguage; // would be better as stage, but this is ancient now } EShLanguage; // would be better as stage, but this is ancient now
...@@ -104,6 +108,10 @@ typedef enum { ...@@ -104,6 +108,10 @@ typedef enum {
EShLangGeometryMask = (1 << EShLangGeometry), EShLangGeometryMask = (1 << EShLangGeometry),
EShLangFragmentMask = (1 << EShLangFragment), EShLangFragmentMask = (1 << EShLangFragment),
EShLangComputeMask = (1 << EShLangCompute), EShLangComputeMask = (1 << EShLangCompute),
#ifdef NV_EXTENSIONS
EShLangTaskNVMask = (1 << EShLangTaskNV),
EShLangMeshNVMask = (1 << EShLangMeshNV),
#endif
} EShLanguageMask; } EShLanguageMask;
namespace glslang { namespace glslang {
......
...@@ -506,6 +506,13 @@ INSTANTIATE_TEST_CASE_P( ...@@ -506,6 +506,13 @@ INSTANTIATE_TEST_CASE_P(
"spv.computeShaderDerivatives.comp", "spv.computeShaderDerivatives.comp",
"spv.computeShaderDerivatives2.comp", "spv.computeShaderDerivatives2.comp",
"spv.shaderImageFootprint.frag", "spv.shaderImageFootprint.frag",
"spv.meshShaderBuiltins.mesh",
"spv.meshShaderUserDefined.mesh",
"spv.meshShaderPerViewBuiltins.mesh",
"spv.meshShaderPerViewUserDefined.mesh",
"spv.meshShaderSharedMem.mesh",
"spv.meshShaderTaskMem.mesh",
"spv.meshTaskShader.task",
})), })),
FileNameAsCustomTestSuffix FileNameAsCustomTestSuffix
); );
......
...@@ -60,6 +60,12 @@ EShLanguage GetShaderStage(const std::string& stage) ...@@ -60,6 +60,12 @@ EShLanguage GetShaderStage(const std::string& stage)
return EShLangFragment; return EShLangFragment;
} else if (stage == "comp") { } else if (stage == "comp") {
return EShLangCompute; return EShLangCompute;
#ifdef NV_EXTENSIONS
} else if (stage == "task") {
return EShLangTaskNV;
} else if (stage == "mesh") {
return EShLangMeshNV;
#endif
} else { } else {
assert(0 && "Unknown shader stage"); assert(0 && "Unknown shader stage");
return EShLangCount; return EShLangCount;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment