Add-support-for-SPV_NV_mesh_shader

This commit is contained in:
Chao Chen 2018-09-19 11:41:59 -07:00
parent 3a1379667d
commit 3c3669904c
41 changed files with 6976 additions and 4237 deletions

View File

@ -33,7 +33,7 @@ enum Op;
enum Capability;
static const int GLSLextNVVersion = 100;
static const int GLSLextNVRevision = 8;
static const int GLSLextNVRevision = 9;
//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
//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

View File

@ -194,6 +194,9 @@ protected:
spv::Id createMiscOperation(glslang::TOperator op, spv::Decoration precision, spv::Id typeId, std::vector<spv::Id>& operands, glslang::TBasicType typeProxy);
spv::Id createNoArgOperation(glslang::TOperator op, spv::Decoration precision, spv::Id typeId);
spv::Id getSymbolId(const glslang::TIntermSymbol* node);
#ifdef NV_EXTENSIONS
void addMeshNVDecoration(spv::Id id, int member, const glslang::TQualifier & qualifier);
#endif
spv::Id createSpvConstant(const glslang::TIntermTyped&);
spv::Id createSpvConstantFromConstUnionArray(const glslang::TType& type, const glslang::TConstUnionArray&, int& nextConst, bool specConstant);
bool isTrivialLeaf(const glslang::TIntermTyped* node);
@ -272,6 +275,10 @@ spv::ExecutionModel TranslateExecutionModel(EShLanguage stage)
case EShLangGeometry: return spv::ExecutionModelGeometry;
case EShLangFragment: return spv::ExecutionModelFragment;
case EShLangCompute: return spv::ExecutionModelGLCompute;
#ifdef NV_EXTENSIONS
case EShLangTaskNV: return spv::ExecutionModelTaskNV;
case EShLangMeshNV: return spv::ExecutionModelMeshNV;
#endif
default:
assert(0);
return spv::ExecutionModelFragment;
@ -379,7 +386,15 @@ spv::Decoration TranslateLayoutDecoration(const glslang::TType& type, glslang::T
}
case glslang::EvqVaryingIn:
case glslang::EvqVaryingOut:
if (type.getQualifier().isTaskMemory()) {
switch (type.getQualifier().layoutPacking) {
case glslang::ElpShared: return spv::DecorationGLSLShared;
case glslang::ElpPacked: return spv::DecorationGLSLPacked;
default: break;
}
} else {
assert(type.getQualifier().layoutPacking == glslang::ElpNone);
}
return spv::DecorationMax;
default:
assert(0);
@ -619,6 +634,11 @@ spv::BuiltIn TGlslangToSpvTraverser::TranslateBuiltInDecoration(glslang::TBuiltI
return spv::BuiltInSampleMask;
case glslang::EbvLayer:
#ifdef NV_EXTENSIONS
if (glslangIntermediate->getStage() == EShLangMeshNV) {
return spv::BuiltInLayer;
}
#endif
builder.addCapability(spv::CapabilityGeometry);
if (glslangIntermediate->getStage() == EShLangVertex ||
glslangIntermediate->getStage() == EShLangTessControl ||
@ -835,6 +855,22 @@ spv::BuiltIn TGlslangToSpvTraverser::TranslateBuiltInDecoration(glslang::TBuiltI
builder.addExtension(spv::E_SPV_NV_fragment_shader_barycentric);
builder.addCapability(spv::CapabilityFragmentBarycentricNV);
return spv::BuiltInBaryCoordNoPerspNV;
case glslang::EbvTaskCountNV:
return spv::BuiltInTaskCountNV;
case glslang::EbvPrimitiveCountNV:
return spv::BuiltInPrimitiveCountNV;
case glslang::EbvPrimitiveIndicesNV:
return spv::BuiltInPrimitiveIndicesNV;
case glslang::EbvClipDistancePerViewNV:
return spv::BuiltInClipDistancePerViewNV;
case glslang::EbvCullDistancePerViewNV:
return spv::BuiltInCullDistancePerViewNV;
case glslang::EbvLayerPerViewNV:
return spv::BuiltInLayerPerViewNV;
case glslang::EbvMeshViewCountNV:
return spv::BuiltInMeshViewCountNV;
case glslang::EbvMeshViewIndicesNV:
return spv::BuiltInMeshViewIndicesNV;
#endif
default:
return spv::BuiltInMax;
@ -1110,6 +1146,14 @@ void InheritQualifiers(glslang::TQualifier& child, const glslang::TQualifier& pa
child.readonly = true;
if (parent.writeonly)
child.writeonly = true;
#ifdef NV_EXTENSIONS
if (parent.perPrimitiveNV)
child.perPrimitiveNV = true;
if (parent.perViewNV)
child.perViewNV = true;
if (parent.perTaskNV)
child.perTaskNV = true;
#endif
}
bool HasNonLayoutQualifiers(const glslang::TType& type, const glslang::TQualifier& qualifier)
@ -1313,6 +1357,30 @@ TGlslangToSpvTraverser::TGlslangToSpvTraverser(unsigned int spvVersion, const gl
#endif
break;
#ifdef NV_EXTENSIONS
case EShLangTaskNV:
case EShLangMeshNV:
builder.addCapability(spv::CapabilityMeshShadingNV);
builder.addExtension(spv::E_SPV_NV_mesh_shader);
builder.addExecutionMode(shaderEntry, spv::ExecutionModeLocalSize, glslangIntermediate->getLocalSize(0),
glslangIntermediate->getLocalSize(1),
glslangIntermediate->getLocalSize(2));
if (glslangIntermediate->getStage() == EShLangMeshNV) {
builder.addExecutionMode(shaderEntry, spv::ExecutionModeOutputVertices, glslangIntermediate->getVertices());
builder.addExecutionMode(shaderEntry, spv::ExecutionModeOutputPrimitivesNV, glslangIntermediate->getPrimitives());
switch (glslangIntermediate->getOutputPrimitive()) {
case glslang::ElgPoints: mode = spv::ExecutionModeOutputPoints; break;
case glslang::ElgLines: mode = spv::ExecutionModeOutputLinesNV; break;
case glslang::ElgTriangles: mode = spv::ExecutionModeOutputTrianglesNV; break;
default: mode = spv::ExecutionModeMax; break;
}
if (mode != spv::ExecutionModeMax)
builder.addExecutionMode(shaderEntry, (spv::ExecutionMode)mode);
}
break;
#endif
default:
break;
}
@ -2120,6 +2188,12 @@ bool TGlslangToSpvTraverser::visitAggregate(glslang::TVisit visit, glslang::TInt
atomic = true;
break;
#ifdef NV_EXTENSIONS
case glslang::EOpWritePackedPrimitiveIndices4x8NV:
noReturnValue = true;
break;
#endif
default:
break;
}
@ -2892,23 +2966,28 @@ spv::Id TGlslangToSpvTraverser::convertGlslangToSpvType(const glslang::TType& ty
//
bool TGlslangToSpvTraverser::filterMember(const glslang::TType& member)
{
#ifdef NV_EXTENSIONS
auto& extensions = glslangIntermediate->getRequestedExtensions();
if (member.getFieldName() == "gl_ViewportMask" &&
extensions.find("GL_NV_viewport_array2") == extensions.end())
return true;
if (member.getFieldName() == "gl_SecondaryViewportMaskNV" &&
extensions.find("GL_NV_stereo_view_rendering") == extensions.end())
return true;
if (member.getFieldName() == "gl_SecondaryPositionNV" &&
extensions.find("GL_NV_stereo_view_rendering") == extensions.end())
return true;
if (glslangIntermediate->getStage() != EShLangMeshNV) {
if (member.getFieldName() == "gl_ViewportMask" &&
extensions.find("GL_NV_viewport_array2") == extensions.end())
return true;
if (member.getFieldName() == "gl_PositionPerViewNV" &&
extensions.find("GL_NVX_multiview_per_view_attributes") == extensions.end())
return true;
if (member.getFieldName() == "gl_ViewportMaskPerViewNV" &&
extensions.find("GL_NVX_multiview_per_view_attributes") == extensions.end())
return true;
}
#endif
return false;
};
@ -3001,6 +3080,9 @@ void TGlslangToSpvTraverser::decorateStructType(const glslang::TType& type,
glslangIntermediate->getSource() == glslang::EShSourceHlsl) {
builder.addMemberDecoration(spvType, member, TranslateInterpolationDecoration(memberQualifier));
builder.addMemberDecoration(spvType, member, TranslateAuxiliaryStorageDecoration(memberQualifier));
#ifdef NV_EXTENSIONS
addMeshNVDecoration(spvType, member, memberQualifier);
#endif
}
}
builder.addMemberDecoration(spvType, member, TranslateInvariantDecoration(memberQualifier));
@ -3272,9 +3354,10 @@ glslang::TLayoutPacking TGlslangToSpvTraverser::getExplicitLayout(const glslang:
if (type.getBasicType() != glslang::EbtBlock)
return glslang::ElpNone;
// has to be a uniform or buffer block
// has to be a uniform or buffer block or task in/out blocks
if (type.getQualifier().storage != glslang::EvqUniform &&
type.getQualifier().storage != glslang::EvqBuffer)
type.getQualifier().storage != glslang::EvqBuffer &&
!type.getQualifier().isTaskMemory())
return glslang::ElpNone;
// return the layout to use
@ -3388,6 +3471,14 @@ void TGlslangToSpvTraverser::declareUseOfStructMember(const glslang::TTypeList&
case glslang::EbvSecondaryViewportMaskNV:
case glslang::EbvPositionPerViewNV:
case glslang::EbvViewportMaskPerViewNV:
case glslang::EbvTaskCountNV:
case glslang::EbvPrimitiveCountNV:
case glslang::EbvPrimitiveIndicesNV:
case glslang::EbvClipDistancePerViewNV:
case glslang::EbvCullDistancePerViewNV:
case glslang::EbvLayerPerViewNV:
case glslang::EbvMeshViewCountNV:
case glslang::EbvMeshViewIndicesNV:
#endif
// Generate the associated capability. Delegate to TranslateBuiltInDecoration.
// Alternately, we could just call this for any glslang built-in, since the
@ -6691,6 +6782,12 @@ spv::Id TGlslangToSpvTraverser::createMiscOperation(glslang::TOperator op, spv::
return 0;
}
break;
#ifdef NV_EXTENSIONS
case glslang::EOpWritePackedPrimitiveIndices4x8NV:
builder.createNoResultOp(spv::OpWritePackedPrimitiveIndices4x8NV, operands);
return 0;
#endif
default:
return 0;
}
@ -6888,6 +6985,9 @@ spv::Id TGlslangToSpvTraverser::getSymbolId(const glslang::TIntermSymbol* symbol
builder.addDecoration(id, TranslatePrecisionDecoration(symbol->getType()));
builder.addDecoration(id, TranslateInterpolationDecoration(symbol->getType().getQualifier()));
builder.addDecoration(id, TranslateAuxiliaryStorageDecoration(symbol->getType().getQualifier()));
#ifdef NV_EXTENSIONS
addMeshNVDecoration(id, /*member*/ -1, symbol->getType().getQualifier());
#endif
if (symbol->getType().getQualifier().hasSpecConstantId())
builder.addDecoration(id, spv::DecorationSpecId, symbol->getType().getQualifier().layoutSpecConstantId);
if (symbol->getQualifier().hasIndex())
@ -6994,6 +7094,28 @@ spv::Id TGlslangToSpvTraverser::getSymbolId(const glslang::TIntermSymbol* symbol
return id;
}
#ifdef NV_EXTENSIONS
// add per-primitive, per-view. per-task decorations to a struct member (member >= 0) or an object
void TGlslangToSpvTraverser::addMeshNVDecoration(spv::Id id, int member, const glslang::TQualifier& qualifier)
{
if (member >= 0) {
if (qualifier.perPrimitiveNV)
builder.addMemberDecoration(id, (unsigned)member, spv::DecorationPerPrimitiveNV);
if (qualifier.perViewNV)
builder.addMemberDecoration(id, (unsigned)member, spv::DecorationPerViewNV);
if (qualifier.perTaskNV)
builder.addMemberDecoration(id, (unsigned)member, spv::DecorationPerTaskNV);
} else {
if (qualifier.perPrimitiveNV)
builder.addDecoration(id, spv::DecorationPerPrimitiveNV);
if (qualifier.perViewNV)
builder.addDecoration(id, spv::DecorationPerViewNV);
if (qualifier.perTaskNV)
builder.addDecoration(id, spv::DecorationPerTaskNV);
}
}
#endif
// Make a full tree of instructions to build a SPIR-V specialization constant,
// or regular constant if possible.
//

View File

@ -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_viewport_array2, 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;
#endif
}
@ -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_SPV_NV_viewport_array2) == 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) {
case DecorationOverrideCoverageNV: return "OverrideCoverageNV";
case DecorationPassthroughNV: return "PassthroughNV";
case CapabilityGeometryShaderPassthroughNV: return "GeometryShaderPassthroughNV";
case DecorationViewportRelativeNV: return "ViewportRelativeNV";
// NV builtins
case BuiltInViewportMaskNV: return "ViewportMaskNV";
case CapabilityShaderViewportMaskNV: return "ShaderViewportMaskNV";
case DecorationSecondaryViewportRelativeNV: return "SecondaryViewportRelativeNV";
case BuiltInSecondaryPositionNV: return "SecondaryPositionNV";
case BuiltInSecondaryViewportMaskNV: return "SecondaryViewportMaskNV";
case CapabilityShaderStereoViewNV: return "ShaderStereoViewNV";
case BuiltInPositionPerViewNV: return "PositionPerViewNV";
case BuiltInViewportMaskPerViewNV: return "ViewportMaskPerViewNV";
case CapabilityPerViewAttributesNV: return "PerViewAttributesNV";
case CapabilityFragmentBarycentricNV: return "FragmentBarycentricNV";
case DecorationPerVertexNV: return "PerVertexNV";
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 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 DecorationPerPrimitiveNV: return "PerPrimitiveNV";
case DecorationPerViewNV: return "PerViewNV";
case DecorationPerTaskNV: return "PerTaskNV";
default: return "Bad";
}
}

View File

@ -98,6 +98,10 @@ const char* ExecutionModelString(int model)
case 4: return "Fragment";
case 5: return "GLCompute";
case 6: return "Kernel";
#ifdef NV_EXTENSIONS
case ExecutionModelTaskNV: return "TaskNV";
case ExecutionModelMeshNV: return "MeshNV";
#endif
default: return "Bad";
}
@ -168,6 +172,9 @@ const char* ExecutionModeString(int mode)
case 4446: return "PostDepthCoverage";
#ifdef NV_EXTENSIONS
case ExecutionModeOutputLinesNV: return "OutputLinesNV";
case ExecutionModeOutputPrimitivesNV: return "OutputPrimitivesNV";
case ExecutionModeOutputTrianglesNV: return "OutputTrianglesNV";
case ExecutionModeDerivativeGroupQuadsNV: return "DerivativeGroupQuadsNV";
case ExecutionModeDerivativeGroupLinearNV: return "DerivativeGroupLinearNV";
#endif
@ -260,6 +267,9 @@ const char* DecorationString(int decoration)
case DecorationPassthroughNV: return "PassthroughNV";
case DecorationViewportRelativeNV: return "ViewportRelativeNV";
case DecorationSecondaryViewportRelativeNV: return "SecondaryViewportRelativeNV";
case DecorationPerPrimitiveNV: return "PerPrimitiveNV";
case DecorationPerViewNV: return "PerViewNV";
case DecorationPerTaskNV: return "PerTaskNV";
case DecorationPerVertexNV: return "PerVertexNV";
#endif
@ -351,6 +361,18 @@ const char* BuiltInString(int builtIn)
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";
}
}
@ -838,6 +860,7 @@ const char* CapabilityString(int info)
case CapabilityComputeDerivativeGroupQuadsNV: return "ComputeDerivativeGroupQuadsNV";
case CapabilityComputeDerivativeGroupLinearNV: return "ComputeDerivativeGroupLinearNV";
case CapabilityFragmentBarycentricNV: return "FragmentBarycentricNV";
case CapabilityMeshShadingNV: return "MeshShadingNV";
#endif
case CapabilityFragmentFullyCoveredEXT: return "FragmentFullyCoveredEXT";
@ -1252,6 +1275,7 @@ const char* OpcodeString(int op)
#ifdef NV_EXTENSIONS
case OpGroupNonUniformPartitionNV: return "OpGroupNonUniformPartitionNV";
case OpImageSampleFootprintNV: return "OpImageSampleFootprintNV";
case OpWritePackedPrimitiveIndices4x8NV: return "OpWritePackedPrimitiveIndices4x8NV";
#endif
default:
@ -2598,12 +2622,16 @@ void Parameterize()
#ifdef NV_EXTENSIONS
InstructionDesc[OpGroupNonUniformPartitionNV].operands.push(OperandId, "X");
InstructionDesc[OpImageSampleFootprintNV].operands.push(OperandId, "'Sampled Image'");
InstructionDesc[OpImageSampleFootprintNV].operands.push(OperandId, "'Coordinate'");
InstructionDesc[OpImageSampleFootprintNV].operands.push(OperandId, "'Granularity'");
InstructionDesc[OpImageSampleFootprintNV].operands.push(OperandId, "'Coarse'");
InstructionDesc[OpImageSampleFootprintNV].operands.push(OperandImageOperands, "", true);
InstructionDesc[OpImageSampleFootprintNV].operands.push(OperandVariableIds, "", true);
InstructionDesc[OpWritePackedPrimitiveIndices4x8NV].operands.push(OperandId, "'Index Offset'");
InstructionDesc[OpWritePackedPrimitiveIndices4x8NV].operands.push(OperandId, "'Packed Indices'");
#endif
}

View File

@ -125,6 +125,18 @@ const TBuiltInResource DefaultTBuiltInResource = {
/* .MaxCullDistances = */ 8,
/* .MaxCombinedClipAndCullDistances = */ 8,
/* .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 = */ {
/* .nonInductiveForLoops = */ 1,
/* .whileLoops = */ 1,
@ -224,7 +236,17 @@ std::string GetDefaultTBuiltInResourceString()
<< "MaxCullDistances " << DefaultTBuiltInResource.maxCullDistances << "\n"
<< "MaxCombinedClipAndCullDistances " << DefaultTBuiltInResource.maxCombinedClipAndCullDistances << "\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"
<< "whileLoops " << DefaultTBuiltInResource.limits.whileLoops << "\n"
<< "doWhileLoops " << DefaultTBuiltInResource.limits.doWhileLoops << "\n"
@ -431,6 +453,26 @@ void DecodeResourceLimits(TBuiltInResource* resources, char* config)
resources->maxCombinedClipAndCullDistances = value;
else if (tokenStr == "MaxSamples")
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")
resources->limits.nonInductiveForLoops = (value != 0);
else if (tokenStr == "whileLoops")

View File

@ -244,6 +244,10 @@ const char* GetBinaryName(EShLanguage stage)
case EShLangGeometry: name = "geom.spv"; break;
case EShLangFragment: name = "frag.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;
}
} else
@ -1250,6 +1254,12 @@ EShLanguage FindLanguage(const std::string& name, bool parseStageName)
return EShLangFragment;
else if (stageName == "comp")
return EShLangCompute;
#ifdef NV_EXTENSIONS
else if (stageName == "mesh")
return EShLangMeshNV;
else if (stageName == "task")
return EShLangTaskNV;
#endif
usage();
return EShLangVertex;
@ -1319,6 +1329,10 @@ void usage()
" .geom for a geometry shader\n"
" .frag for a fragment 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"
" .hlsl for .vert.hlsl, .tesc.hlsl, ..., .comp.hlsl compound suffixes\n"
"\n"

View File

@ -0,0 +1,259 @@
spv.meshShaderBuiltins.mesh
// Module Version 10000
// Generated by (magic number): 80007
// Id's are bound by 147
Capability ClipDistance
Capability CullDistance
Capability MultiViewport
Capability DrawParameters
Capability ShaderViewportMaskNV
Capability MeshShadingNV
Extension "SPV_KHR_shader_draw_parameters"
Extension "SPV_NV_mesh_shader"
Extension "SPV_NV_viewport_array2"
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint MeshNV 4 "main" 11 17 34 89 129 140 144
ExecutionMode 4 LocalSize 32 1 1
ExecutionMode 4 OutputVertices 81
ExecutionMode 4 OutputPrimitivesNV 32
ExecutionMode 4 OutputTrianglesNV
Source GLSL 460
SourceExtension "GL_NV_mesh_shader"
Name 4 "main"
Name 8 "iid"
Name 11 "gl_LocalInvocationID"
Name 16 "gid"
Name 17 "gl_WorkGroupID"
Name 30 "gl_MeshPerVertexNV"
MemberName 30(gl_MeshPerVertexNV) 0 "gl_Position"
MemberName 30(gl_MeshPerVertexNV) 1 "gl_PointSize"
MemberName 30(gl_MeshPerVertexNV) 2 "gl_ClipDistance"
MemberName 30(gl_MeshPerVertexNV) 3 "gl_CullDistance"
MemberName 30(gl_MeshPerVertexNV) 4 "gl_PositionPerViewNV"
MemberName 30(gl_MeshPerVertexNV) 5 "gl_ClipDistancePerViewNV"
MemberName 30(gl_MeshPerVertexNV) 6 "gl_CullDistancePerViewNV"
Name 34 "gl_MeshVerticesNV"
Name 85 "gl_MeshPerPrimitiveNV"
MemberName 85(gl_MeshPerPrimitiveNV) 0 "gl_PrimitiveID"
MemberName 85(gl_MeshPerPrimitiveNV) 1 "gl_Layer"
MemberName 85(gl_MeshPerPrimitiveNV) 2 "gl_ViewportIndex"
MemberName 85(gl_MeshPerPrimitiveNV) 3 "gl_ViewportMask"
MemberName 85(gl_MeshPerPrimitiveNV) 4 "gl_LayerPerViewNV"
MemberName 85(gl_MeshPerPrimitiveNV) 5 "gl_ViewportMaskPerViewNV"
Name 89 "gl_MeshPrimitivesNV"
Name 129 "gl_PrimitiveIndicesNV"
Name 140 "gl_DrawID"
Name 144 "gl_PrimitiveCountNV"
Decorate 11(gl_LocalInvocationID) BuiltIn LocalInvocationId
Decorate 17(gl_WorkGroupID) BuiltIn WorkgroupId
MemberDecorate 30(gl_MeshPerVertexNV) 0 BuiltIn Position
MemberDecorate 30(gl_MeshPerVertexNV) 1 BuiltIn PointSize
MemberDecorate 30(gl_MeshPerVertexNV) 2 BuiltIn ClipDistance
MemberDecorate 30(gl_MeshPerVertexNV) 3 BuiltIn CullDistance
MemberDecorate 30(gl_MeshPerVertexNV) 4 PerViewNV
MemberDecorate 30(gl_MeshPerVertexNV) 4 BuiltIn PositionPerViewNV
MemberDecorate 30(gl_MeshPerVertexNV) 5 PerViewNV
MemberDecorate 30(gl_MeshPerVertexNV) 5 BuiltIn ClipDistancePerViewNV
MemberDecorate 30(gl_MeshPerVertexNV) 6 PerViewNV
MemberDecorate 30(gl_MeshPerVertexNV) 6 BuiltIn CullDistancePerViewNV
Decorate 30(gl_MeshPerVertexNV) Block
MemberDecorate 85(gl_MeshPerPrimitiveNV) 0 PerPrimitiveNV
MemberDecorate 85(gl_MeshPerPrimitiveNV) 0 BuiltIn PrimitiveId
MemberDecorate 85(gl_MeshPerPrimitiveNV) 1 PerPrimitiveNV
MemberDecorate 85(gl_MeshPerPrimitiveNV) 1 BuiltIn Layer
MemberDecorate 85(gl_MeshPerPrimitiveNV) 2 PerPrimitiveNV
MemberDecorate 85(gl_MeshPerPrimitiveNV) 2 BuiltIn ViewportIndex
MemberDecorate 85(gl_MeshPerPrimitiveNV) 3 PerPrimitiveNV
MemberDecorate 85(gl_MeshPerPrimitiveNV) 3 BuiltIn ViewportMaskNV
MemberDecorate 85(gl_MeshPerPrimitiveNV) 4 PerPrimitiveNV
MemberDecorate 85(gl_MeshPerPrimitiveNV) 4 PerViewNV
MemberDecorate 85(gl_MeshPerPrimitiveNV) 4 BuiltIn LayerPerViewNV
MemberDecorate 85(gl_MeshPerPrimitiveNV) 5 PerPrimitiveNV
MemberDecorate 85(gl_MeshPerPrimitiveNV) 5 PerViewNV
MemberDecorate 85(gl_MeshPerPrimitiveNV) 5 BuiltIn ViewportMaskPerViewNV
Decorate 85(gl_MeshPerPrimitiveNV) Block
Decorate 129(gl_PrimitiveIndicesNV) BuiltIn PrimitiveIndicesNV
Decorate 140(gl_DrawID) BuiltIn DrawIndex
Decorate 144(gl_PrimitiveCountNV) BuiltIn PrimitiveCountNV
Decorate 146 BuiltIn WorkgroupSize
2: TypeVoid
3: TypeFunction 2
6: TypeInt 32 0
7: TypePointer Function 6(int)
9: TypeVector 6(int) 3
10: TypePointer Input 9(ivec3)
11(gl_LocalInvocationID): 10(ptr) Variable Input
12: 6(int) Constant 0
13: TypePointer Input 6(int)
17(gl_WorkGroupID): 10(ptr) Variable Input
20: TypeFloat 32
21: TypeVector 20(float) 4
22: 6(int) Constant 4
23: TypeArray 20(float) 22
24: 6(int) Constant 3
25: TypeArray 20(float) 24
26: TypeArray 21(fvec4) 22
27: 6(int) Constant 8
28: TypeArray 20(float) 27
29: TypeArray 28 22
30(gl_MeshPerVertexNV): TypeStruct 21(fvec4) 20(float) 23 25 26 29 29
31: 6(int) Constant 81
32: TypeArray 30(gl_MeshPerVertexNV) 31
33: TypePointer Output 32
34(gl_MeshVerticesNV): 33(ptr) Variable Output
36: TypeInt 32 1
37: 36(int) Constant 0
38: 20(float) Constant 1065353216
39: 21(fvec4) ConstantComposite 38 38 38 38
40: TypePointer Output 21(fvec4)
43: 36(int) Constant 1
44: 20(float) Constant 1073741824
45: TypePointer Output 20(float)
48: 36(int) Constant 2
49: 36(int) Constant 3
50: 20(float) Constant 1077936128
53: 20(float) Constant 1082130432
55: 6(int) Constant 1
56: 6(int) Constant 264
57: 6(int) Constant 2
82: TypeArray 36(int) 55
83: TypeArray 36(int) 22
84: TypeArray 82 22
85(gl_MeshPerPrimitiveNV): TypeStruct 36(int) 36(int) 36(int) 82 83 84
86: 6(int) Constant 32
87: TypeArray 85(gl_MeshPerPrimitiveNV) 86
88: TypePointer Output 87
89(gl_MeshPrimitivesNV): 88(ptr) Variable Output
91: 36(int) Constant 6
92: TypePointer Output 36(int)
95: 36(int) Constant 7
98: 36(int) Constant 8
101: 36(int) Constant 9
127: TypeArray 6(int) 31
128: TypePointer Output 127
129(gl_PrimitiveIndicesNV): 128(ptr) Variable Output
130: 6(int) Constant 257
131: TypePointer Output 6(int)
139: TypePointer Input 36(int)
140(gl_DrawID): 139(ptr) Variable Input
143: 6(int) Constant 16909060
144(gl_PrimitiveCountNV): 131(ptr) Variable Output
145: 6(int) Constant 96
146: 9(ivec3) ConstantComposite 86 55 55
4(main): 2 Function None 3
5: Label
8(iid): 7(ptr) Variable Function
16(gid): 7(ptr) Variable Function
14: 13(ptr) AccessChain 11(gl_LocalInvocationID) 12
15: 6(int) Load 14
Store 8(iid) 15
18: 13(ptr) AccessChain 17(gl_WorkGroupID) 12
19: 6(int) Load 18
Store 16(gid) 19
35: 6(int) Load 8(iid)
41: 40(ptr) AccessChain 34(gl_MeshVerticesNV) 35 37
Store 41 39
42: 6(int) Load 8(iid)
46: 45(ptr) AccessChain 34(gl_MeshVerticesNV) 42 43
Store 46 44
47: 6(int) Load 8(iid)
51: 45(ptr) AccessChain 34(gl_MeshVerticesNV) 47 48 49
Store 51 50
52: 6(int) Load 8(iid)
54: 45(ptr) AccessChain 34(gl_MeshVerticesNV) 52 49 48
Store 54 53
MemoryBarrier 55 56
ControlBarrier 57 57 56
58: 6(int) Load 8(iid)
59: 6(int) IAdd 58 55
60: 6(int) Load 8(iid)
61: 40(ptr) AccessChain 34(gl_MeshVerticesNV) 60 37
62: 21(fvec4) Load 61
63: 40(ptr) AccessChain 34(gl_MeshVerticesNV) 59 37
Store 63 62
64: 6(int) Load 8(iid)
65: 6(int) IAdd 64 55
66: 6(int) Load 8(iid)
67: 45(ptr) AccessChain 34(gl_MeshVerticesNV) 66 43
68: 20(float) Load 67
69: 45(ptr) AccessChain 34(gl_MeshVerticesNV) 65 43
Store 69 68
70: 6(int) Load 8(iid)
71: 6(int) IAdd 70 55
72: 6(int) Load 8(iid)
73: 45(ptr) AccessChain 34(gl_MeshVerticesNV) 72 48 49
74: 20(float) Load 73
75: 45(ptr) AccessChain 34(gl_MeshVerticesNV) 71 48 49
Store 75 74
76: 6(int) Load 8(iid)
77: 6(int) IAdd 76 55
78: 6(int) Load 8(iid)
79: 45(ptr) AccessChain 34(gl_MeshVerticesNV) 78 49 48
80: 20(float) Load 79
81: 45(ptr) AccessChain 34(gl_MeshVerticesNV) 77 49 48
Store 81 80
MemoryBarrier 55 56
ControlBarrier 57 57 56
90: 6(int) Load 8(iid)
93: 92(ptr) AccessChain 89(gl_MeshPrimitivesNV) 90 37
Store 93 91
94: 6(int) Load 8(iid)
96: 92(ptr) AccessChain 89(gl_MeshPrimitivesNV) 94 43
Store 96 95
97: 6(int) Load 8(iid)
99: 92(ptr) AccessChain 89(gl_MeshPrimitivesNV) 97 48
Store 99 98
100: 6(int) Load 8(iid)
102: 92(ptr) AccessChain 89(gl_MeshPrimitivesNV) 100 49 37
Store 102 101
MemoryBarrier 55 56
ControlBarrier 57 57 56
103: 6(int) Load 8(iid)
104: 6(int) IAdd 103 55
105: 6(int) Load 8(iid)
106: 92(ptr) AccessChain 89(gl_MeshPrimitivesNV) 105 37
107: 36(int) Load 106
108: 92(ptr) AccessChain 89(gl_MeshPrimitivesNV) 104 37
Store 108 107
109: 6(int) Load 8(iid)
110: 6(int) IAdd 109 55
111: 6(int) Load 8(iid)
112: 92(ptr) AccessChain 89(gl_MeshPrimitivesNV) 111 43
113: 36(int) Load 112
114: 92(ptr) AccessChain 89(gl_MeshPrimitivesNV) 110 43
Store 114 113
115: 6(int) Load 8(iid)
116: 6(int) IAdd 115 55
117: 6(int) Load 8(iid)
118: 92(ptr) AccessChain 89(gl_MeshPrimitivesNV) 117 48
119: 36(int) Load 118
120: 92(ptr) AccessChain 89(gl_MeshPrimitivesNV) 116 48
Store 120 119
121: 6(int) Load 8(iid)
122: 6(int) IAdd 121 55
123: 6(int) Load 8(iid)
124: 92(ptr) AccessChain 89(gl_MeshPrimitivesNV) 123 49 37
125: 36(int) Load 124
126: 92(ptr) AccessChain 89(gl_MeshPrimitivesNV) 122 49 37
Store 126 125
MemoryBarrier 55 56
ControlBarrier 57 57 56
132: 131(ptr) AccessChain 129(gl_PrimitiveIndicesNV) 37
Store 132 130
133: 6(int) Load 16(gid)
134: 6(int) Load 16(gid)
135: 6(int) ISub 134 55
136: 131(ptr) AccessChain 129(gl_PrimitiveIndicesNV) 135
137: 6(int) Load 136
138: 131(ptr) AccessChain 129(gl_PrimitiveIndicesNV) 133
Store 138 137
141: 36(int) Load 140(gl_DrawID)
142: 6(int) Bitcast 141
143: 142 WritePackedPrimitiveIndices4x8NV
Store 144(gl_PrimitiveCountNV) 145
MemoryBarrier 55 56
ControlBarrier 57 57 56
Return
FunctionEnd

View File

@ -0,0 +1,212 @@
spv.meshShaderPerViewBuiltins.mesh
// Module Version 10000
// Generated by (magic number): 80007
// Id's are bound by 124
Capability MultiViewport
Capability PerViewAttributesNV
Capability MeshShadingNV
Extension "SPV_NVX_multiview_per_view_attributes"
Extension "SPV_NV_mesh_shader"
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint MeshNV 4 "main" 11 20 21 38 70
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 34 "gl_MeshPerVertexNV"
MemberName 34(gl_MeshPerVertexNV) 0 "gl_Position"
MemberName 34(gl_MeshPerVertexNV) 1 "gl_PointSize"
MemberName 34(gl_MeshPerVertexNV) 2 "gl_ClipDistance"
MemberName 34(gl_MeshPerVertexNV) 3 "gl_CullDistance"
MemberName 34(gl_MeshPerVertexNV) 4 "gl_PositionPerViewNV"
MemberName 34(gl_MeshPerVertexNV) 5 "gl_ClipDistancePerViewNV"
MemberName 34(gl_MeshPerVertexNV) 6 "gl_CullDistancePerViewNV"
Name 38 "gl_MeshVerticesNV"
Name 66 "gl_MeshPerPrimitiveNV"
MemberName 66(gl_MeshPerPrimitiveNV) 0 "gl_PrimitiveID"
MemberName 66(gl_MeshPerPrimitiveNV) 1 "gl_Layer"
MemberName 66(gl_MeshPerPrimitiveNV) 2 "gl_ViewportIndex"
MemberName 66(gl_MeshPerPrimitiveNV) 3 "gl_ViewportMask"
MemberName 66(gl_MeshPerPrimitiveNV) 4 "gl_LayerPerViewNV"
MemberName 66(gl_MeshPerPrimitiveNV) 5 "gl_ViewportMaskPerViewNV"
Name 70 "gl_MeshPrimitivesNV"
Decorate 11(gl_LocalInvocationID) BuiltIn LocalInvocationId
Decorate 20(gl_MeshViewIndicesNV) BuiltIn MeshViewIndicesNV
Decorate 21(gl_MeshViewCountNV) BuiltIn MeshViewCountNV
MemberDecorate 34(gl_MeshPerVertexNV) 0 BuiltIn Position
MemberDecorate 34(gl_MeshPerVertexNV) 1 BuiltIn PointSize
MemberDecorate 34(gl_MeshPerVertexNV) 2 BuiltIn ClipDistance
MemberDecorate 34(gl_MeshPerVertexNV) 3 BuiltIn CullDistance
MemberDecorate 34(gl_MeshPerVertexNV) 4 PerViewNV
MemberDecorate 34(gl_MeshPerVertexNV) 4 BuiltIn PositionPerViewNV
MemberDecorate 34(gl_MeshPerVertexNV) 5 PerViewNV
MemberDecorate 34(gl_MeshPerVertexNV) 5 BuiltIn ClipDistancePerViewNV
MemberDecorate 34(gl_MeshPerVertexNV) 6 PerViewNV
MemberDecorate 34(gl_MeshPerVertexNV) 6 BuiltIn CullDistancePerViewNV
Decorate 34(gl_MeshPerVertexNV) Block
MemberDecorate 66(gl_MeshPerPrimitiveNV) 0 PerPrimitiveNV
MemberDecorate 66(gl_MeshPerPrimitiveNV) 0 BuiltIn PrimitiveId
MemberDecorate 66(gl_MeshPerPrimitiveNV) 1 PerPrimitiveNV
MemberDecorate 66(gl_MeshPerPrimitiveNV) 1 BuiltIn Layer
MemberDecorate 66(gl_MeshPerPrimitiveNV) 2 PerPrimitiveNV
MemberDecorate 66(gl_MeshPerPrimitiveNV) 2 BuiltIn ViewportIndex
MemberDecorate 66(gl_MeshPerPrimitiveNV) 3 PerPrimitiveNV
MemberDecorate 66(gl_MeshPerPrimitiveNV) 3 BuiltIn ViewportMaskNV
MemberDecorate 66(gl_MeshPerPrimitiveNV) 4 PerPrimitiveNV
MemberDecorate 66(gl_MeshPerPrimitiveNV) 4 PerViewNV
MemberDecorate 66(gl_MeshPerPrimitiveNV) 4 BuiltIn LayerPerViewNV
MemberDecorate 66(gl_MeshPerPrimitiveNV) 5 PerPrimitiveNV
MemberDecorate 66(gl_MeshPerPrimitiveNV) 5 PerViewNV
MemberDecorate 66(gl_MeshPerPrimitiveNV) 5 BuiltIn ViewportMaskPerViewNV
Decorate 66(gl_MeshPerPrimitiveNV) Block
Decorate 123 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 1
29: TypeArray 26(float) 28
30: TypeArray 27(fvec4) 17
31: 6(int) Constant 8
32: TypeArray 26(float) 31
33: TypeArray 32 17
34(gl_MeshPerVertexNV): TypeStruct 27(fvec4) 26(float) 29 29 30 33 33
35: 6(int) Constant 81
36: TypeArray 34(gl_MeshPerVertexNV) 35
37: TypePointer Output 36
38(gl_MeshVerticesNV): 37(ptr) Variable Output
40: TypeInt 32 1
41: 40(int) Constant 4
43: 26(float) Constant 1065353216
44: 26(float) Constant 1073741824
45: 26(float) Constant 1077936128
46: 26(float) Constant 1082130432
47: 27(fvec4) ConstantComposite 43 44 45 46
48: TypePointer Output 27(fvec4)
51: 40(int) Constant 5
53: 40(int) Constant 2
54: 26(float) Constant 1084227584
55: TypePointer Output 26(float)
58: 40(int) Constant 6
60: 40(int) Constant 3
61: 26(float) Constant 1086324736
63: TypeArray 40(int) 28
64: TypeArray 40(int) 17
65: TypeArray 63 17
66(gl_MeshPerPrimitiveNV): TypeStruct 40(int) 40(int) 40(int) 63 64 65
67: 6(int) Constant 32
68: TypeArray 66(gl_MeshPerPrimitiveNV) 67
69: TypePointer Output 68
70(gl_MeshPrimitivesNV): 69(ptr) Variable Output
73: 40(int) Constant 7
74: TypePointer Output 40(int)
78: 40(int) Constant 0
79: 40(int) Constant 8
81: 6(int) Constant 264
82: 6(int) Constant 2
123: 9(ivec3) ConstantComposite 67 28 28
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
39: 6(int) Load 8(iid)
42: 6(int) Load 16(viewID)
49: 48(ptr) AccessChain 38(gl_MeshVerticesNV) 39 41 42
Store 49 47
50: 6(int) Load 8(iid)
52: 6(int) Load 16(viewID)
56: 55(ptr) AccessChain 38(gl_MeshVerticesNV) 50 51 52 53
Store 56 54
57: 6(int) Load 8(iid)
59: 6(int) Load 16(viewID)
62: 55(ptr) AccessChain 38(gl_MeshVerticesNV) 57 58 59 60
Store 62 61
71: 6(int) Load 8(iid)
72: 6(int) Load 16(viewID)
75: 74(ptr) AccessChain 70(gl_MeshPrimitivesNV) 71 41 72
Store 75 73
76: 6(int) Load 8(iid)
77: 6(int) Load 16(viewID)
80: 74(ptr) AccessChain 70(gl_MeshPrimitivesNV) 76 51 77 78
Store 80 79
MemoryBarrier 28 81
ControlBarrier 82 82 81
83: 6(int) Load 8(iid)
84: 6(int) IAdd 83 28
85: 6(int) Load 16(viewID)
86: 6(int) Load 8(iid)
87: 6(int) Load 16(viewID)
88: 48(ptr) AccessChain 38(gl_MeshVerticesNV) 86 41 87
89: 27(fvec4) Load 88
90: 48(ptr) AccessChain 38(gl_MeshVerticesNV) 84 41 85
Store 90 89
91: 6(int) Load 8(iid)
92: 6(int) IAdd 91 28
93: 6(int) Load 16(viewID)
94: 6(int) Load 8(iid)
95: 6(int) Load 16(viewID)
96: 55(ptr) AccessChain 38(gl_MeshVerticesNV) 94 51 95 53
97: 26(float) Load 96
98: 55(ptr) AccessChain 38(gl_MeshVerticesNV) 92 51 93 53
Store 98 97
99: 6(int) Load 8(iid)
100: 6(int) IAdd 99 28
101: 6(int) Load 16(viewID)
102: 6(int) Load 8(iid)
103: 6(int) Load 16(viewID)
104: 55(ptr) AccessChain 38(gl_MeshVerticesNV) 102 58 103 60
105: 26(float) Load 104
106: 55(ptr) AccessChain 38(gl_MeshVerticesNV) 100 58 101 60
Store 106 105
107: 6(int) Load 8(iid)
108: 6(int) IAdd 107 28
109: 6(int) Load 16(viewID)
110: 6(int) Load 8(iid)
111: 6(int) Load 16(viewID)
112: 74(ptr) AccessChain 70(gl_MeshPrimitivesNV) 110 41 111
113: 40(int) Load 112
114: 74(ptr) AccessChain 70(gl_MeshPrimitivesNV) 108 41 109
Store 114 113
115: 6(int) Load 8(iid)
116: 6(int) IAdd 115 28
117: 6(int) Load 16(viewID)
118: 6(int) Load 8(iid)
119: 6(int) Load 16(viewID)
120: 74(ptr) AccessChain 70(gl_MeshPrimitivesNV) 118 51 119 78
121: 40(int) Load 120
122: 74(ptr) AccessChain 70(gl_MeshPrimitivesNV) 116 51 117 78
Store 122 121
MemoryBarrier 28 81
ControlBarrier 82 82 81
Return
FunctionEnd

View File

@ -0,0 +1,156 @@
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

View File

@ -0,0 +1,128 @@
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

View File

@ -0,0 +1,107 @@
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

View File

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

View File

@ -0,0 +1,172 @@
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

View File

@ -81,6 +81,15 @@ MaxTransformFeedbackInterleavedComponents 64
MaxCullDistances 8
MaxCombinedClipAndCullDistances 8
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
whileLoops 1
doWhileLoops 1

View File

@ -0,0 +1,63 @@
#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();
}

View File

@ -0,0 +1,42 @@
#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();
}

View File

@ -0,0 +1,56 @@
#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();
}

View File

@ -0,0 +1,39 @@
#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();
}

View File

@ -0,0 +1,41 @@
#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;
}

View File

@ -0,0 +1,59 @@
#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();
}

View File

@ -0,0 +1,49 @@
#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;
}

View File

@ -229,6 +229,14 @@ enum TBuiltInVariable {
EbvFragFullyCoveredNV,
EbvBaryCoordNV,
EbvBaryCoordNoPerspNV,
EbvTaskCountNV,
EbvPrimitiveCountNV,
EbvPrimitiveIndicesNV,
EbvClipDistancePerViewNV,
EbvCullDistancePerViewNV,
EbvLayerPerViewNV,
EbvMeshViewCountNV,
EbvMeshViewIndicesNV,
#endif
// HLSL built-ins that live only temporarily, until they get remapped
@ -369,6 +377,14 @@ __inline const char* GetBuiltInVariableString(TBuiltInVariable v)
case EbvFragFullyCoveredNV: return "FragFullyCoveredNV";
case EbvBaryCoordNV: return "BaryCoordNV";
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
default: return "unknown built-in variable";
}

View File

@ -133,6 +133,17 @@ struct TBuiltInResource {
int maxCullDistances;
int maxCombinedClipAndCullDistances;
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;
};

View File

@ -459,6 +459,9 @@ public:
#endif
#ifdef NV_EXTENSIONS
pervertexNV = false;
perPrimitiveNV = false;
perViewNV = false;
perTaskNV = false;
#endif
}
@ -506,6 +509,9 @@ public:
#endif
#ifdef NV_EXTENSIONS
bool pervertexNV : 1;
bool perPrimitiveNV : 1;
bool perViewNV : 1;
bool perTaskNV : 1;
#endif
bool patch : 1;
bool sample : 1;
@ -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
{
switch (storage) {
@ -672,6 +705,8 @@ public:
#ifdef NV_EXTENSIONS
case EShLangFragment:
return pervertexNV && isPipeInput();
case EShLangMeshNV:
return ! perTaskNV && isPipeOutput();
#endif
default:
@ -1053,7 +1088,7 @@ struct TShaderQualifiers {
bool pixelCenterInteger; // fragment shader
bool originUpperLeft; // fragment shader
int invocations;
int vertices; // both for tessellation "vertices" and geometry "max_vertices"
int vertices; // for tessellation "vertices", geometry & mesh "max_vertices"
TVertexSpacing spacing;
TVertexOrder order;
bool pointMode;
@ -1069,6 +1104,7 @@ struct TShaderQualifiers {
bool layoutOverrideCoverage; // true if layout override_coverage set
bool layoutDerivativeGroupQuads; // true if layout derivative_group_quadsNV 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
void init()
@ -1096,7 +1132,7 @@ struct TShaderQualifiers {
layoutOverrideCoverage = false;
layoutDerivativeGroupQuads = false;
layoutDerivativeGroupLinear = false;
primitives = TQualifier::layoutNotSet;
#endif
}
@ -1145,6 +1181,8 @@ struct TShaderQualifiers {
layoutDerivativeGroupQuads = src.layoutDerivativeGroupQuads;
if (src.layoutDerivativeGroupLinear)
layoutDerivativeGroupLinear = src.layoutDerivativeGroupLinear;
if (src.primitives != TQualifier::layoutNotSet)
primitives = src.primitives;
#endif
}
};
@ -1751,6 +1789,12 @@ public:
#ifdef NV_EXTENSIONS
if (qualifier.pervertexNV)
appendStr(" pervertexNV");
if (qualifier.perPrimitiveNV)
appendStr(" perprimitiveNV");
if (qualifier.perViewNV)
appendStr(" perviewNV");
if (qualifier.perTaskNV)
appendStr(" taskNV");
#endif
if (qualifier.patch)
appendStr(" patch");

View File

@ -893,6 +893,9 @@ enum TOperator {
EOpFindLSB,
EOpFindMSB,
#ifdef NV_EXTENSIONS
EOpWritePackedPrimitiveIndices4x8NV,
#endif
//
// HLSL operations
//

View File

@ -2941,6 +2941,16 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
"\n"
);
#ifdef NV_EXTENSIONS
stageBuiltins[EShLangMeshNV].append(
"void subgroupMemoryBarrierShared();"
"\n"
);
stageBuiltins[EShLangTaskNV].append(
"void subgroupMemoryBarrierShared();"
"\n"
);
#endif
}
if (profile != EEsProfile && version >= 460) {
@ -4867,6 +4877,16 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
stageBuiltins[EShLangCompute].append(
"void barrier();"
);
#ifdef NV_EXTENSIONS
if ((profile != EEsProfile && version >= 450) || esBarrier) {
stageBuiltins[EShLangMeshNV].append(
"void barrier();"
);
stageBuiltins[EShLangTaskNV].append(
"void barrier();"
);
}
#endif
if ((profile != EEsProfile && version >= 130) || esBarrier)
commonBuiltins.append(
"void memoryBarrier();"
@ -4882,6 +4902,18 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
"void groupMemoryBarrier();"
);
}
#ifdef NV_EXTENSIONS
if (profile != EEsProfile && version >= 450) {
stageBuiltins[EShLangMeshNV].append(
"void memoryBarrierShared();"
"void groupMemoryBarrier();"
);
stageBuiltins[EShLangTaskNV].append(
"void memoryBarrierShared();"
"void groupMemoryBarrier();"
);
}
#endif
commonBuiltins.append("void controlBarrier(int, int, int, int);\n"
"void memoryBarrier(int, int, int);\n");
@ -5039,6 +5071,13 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
stageBuiltins[EShLangCompute].append(derivativesAndControl64bits);
stageBuiltins[EShLangCompute].append("\n");
}
// Builtins for GL_NV_mesh_shader
if (profile != EEsProfile && version >= 450) {
stageBuiltins[EShLangMeshNV].append(
"void writePackedPrimitiveIndices4x8NV(uint, uint);"
"\n");
}
#endif
//============================================================================
@ -5220,6 +5259,89 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
"\n");
}
#ifdef NV_EXTENSIONS
//============================================================================
//
// Define the interface to the mesh/task shader.
//
//============================================================================
if (profile != EEsProfile && version >= 450) {
// per-vertex attributes
stageBuiltins[EShLangMeshNV].append(
"out gl_MeshPerVertexNV {"
"vec4 gl_Position;"
"float gl_PointSize;"
"float gl_ClipDistance[];"
"float gl_CullDistance[];"
"perviewNV vec4 gl_PositionPerViewNV[];"
"perviewNV float gl_ClipDistancePerViewNV[][8];"
"perviewNV float gl_CullDistancePerViewNV[][8];"
"} gl_MeshVerticesNV[];"
);
// per-primitive attributes
stageBuiltins[EShLangMeshNV].append(
"perprimitiveNV out gl_MeshPerPrimitiveNV {"
"int gl_PrimitiveID;"
"int gl_Layer;"
"int gl_ViewportIndex;"
"int gl_ViewportMask[];"
"perviewNV int gl_LayerPerViewNV[];"
"perviewNV int gl_ViewportMaskPerViewNV[][1];"
"} gl_MeshPrimitivesNV[];"
);
stageBuiltins[EShLangMeshNV].append(
"out uint gl_PrimitiveCountNV;"
"out uint gl_PrimitiveIndicesNV[];"
"in uint gl_MeshViewCountNV;"
"in uint gl_MeshViewIndicesNV[4];"
"const highp uvec3 gl_WorkGroupSize = uvec3(1,1,1);"
"in highp uvec3 gl_WorkGroupID;"
"in highp uvec3 gl_LocalInvocationID;"
"in highp uvec3 gl_GlobalInvocationID;"
"in highp uint gl_LocalInvocationIndex;"
"in highp int gl_DeviceIndex;" // GL_EXT_device_group
"in int gl_DrawIDARB;" // GL_ARB_shader_draw_parameters
"\n");
if (version >= 460) {
stageBuiltins[EShLangMeshNV].append(
"in int gl_DrawID;"
);
}
stageBuiltins[EShLangTaskNV].append(
"out uint gl_TaskCountNV;"
"const highp uvec3 gl_WorkGroupSize = uvec3(1,1,1);"
"in highp uvec3 gl_WorkGroupID;"
"in highp uvec3 gl_LocalInvocationID;"
"in highp uvec3 gl_GlobalInvocationID;"
"in highp uint gl_LocalInvocationIndex;"
"in highp int gl_DeviceIndex;" // GL_EXT_device_group
"in int gl_DrawIDARB;" // GL_ARB_shader_draw_parameters
"\n");
if (version >= 460) {
stageBuiltins[EShLangTaskNV].append(
"in int gl_DrawID;"
);
}
}
#endif
//============================================================================
//
// Define the interface to the vertex shader.
@ -5889,6 +6011,10 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
stageBuiltins[EShLangGeometry] .append(ballotDecls);
stageBuiltins[EShLangCompute] .append(ballotDecls);
stageBuiltins[EShLangFragment] .append(fragmentBallotDecls);
#ifdef NV_EXTENSIONS
stageBuiltins[EShLangMeshNV] .append(ballotDecls);
stageBuiltins[EShLangTaskNV] .append(ballotDecls);
#endif
}
if ((profile != EEsProfile && version >= 140) ||
@ -5925,11 +6051,25 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
stageBuiltins[EShLangGeometry] .append(ballotDecls);
stageBuiltins[EShLangCompute] .append(ballotDecls);
stageBuiltins[EShLangFragment] .append(fragmentBallotDecls);
#ifdef NV_EXTENSIONS
stageBuiltins[EShLangMeshNV] .append(ballotDecls);
stageBuiltins[EShLangTaskNV] .append(ballotDecls);
#endif
stageBuiltins[EShLangCompute].append(
"highp in uint gl_NumSubgroups;"
"highp in uint gl_SubgroupID;"
"\n");
#ifdef NV_EXTENSIONS
stageBuiltins[EShLangMeshNV].append(
"highp in uint gl_NumSubgroups;"
"highp in uint gl_SubgroupID;"
"\n");
stageBuiltins[EShLangTaskNV].append(
"highp in uint gl_NumSubgroups;"
"highp in uint gl_SubgroupID;"
"\n");
#endif
}
if (version >= 300 /* both ES and non-ES */) {
@ -7398,6 +7538,31 @@ void TBuiltIns::initialize(const TBuiltInResource &resources, int version, EProf
}
#endif
#ifdef NV_EXTENSIONS
// SPV_NV_mesh_shader
if (profile != EEsProfile && version >= 450) {
snprintf(builtInConstant, maxSize, "const int gl_MaxMeshOutputVerticesNV = %d;", resources.maxMeshOutputVerticesNV);
s.append(builtInConstant);
snprintf(builtInConstant, maxSize, "const int gl_MaxMeshOutputPrimitivesNV = %d;", resources.maxMeshOutputPrimitivesNV);
s.append(builtInConstant);
snprintf(builtInConstant, maxSize, "const ivec3 gl_MaxMeshWorkGroupSizeNV = ivec3(%d,%d,%d);", resources.maxMeshWorkGroupSizeX_NV,
resources.maxMeshWorkGroupSizeY_NV,
resources.maxMeshWorkGroupSizeZ_NV);
s.append(builtInConstant);
snprintf(builtInConstant, maxSize, "const ivec3 gl_MaxTaskWorkGroupSizeNV = ivec3(%d,%d,%d);", resources.maxTaskWorkGroupSizeX_NV,
resources.maxTaskWorkGroupSizeY_NV,
resources.maxTaskWorkGroupSizeZ_NV);
s.append(builtInConstant);
snprintf(builtInConstant, maxSize, "const int gl_MaxMeshViewCountNV = %d;", resources.maxMeshViewCountNV);
s.append(builtInConstant);
s.append("\n");
}
#endif
s.append("\n");
}
@ -8265,7 +8430,7 @@ void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion
BuiltInVariable("gl_SubGroupSizeARB", EbvSubGroupSize, symbolTable);
}
// GL_ARB_shader_ballot
// GL_KHR_shader_subgroup
if (spvVersion.vulkan > 0) {
symbolTable.setVariableExtensions("gl_SubgroupSize", 1, &E_GL_KHR_shader_subgroup_basic);
symbolTable.setVariableExtensions("gl_SubgroupInvocationID", 1, &E_GL_KHR_shader_subgroup_basic);
@ -8304,6 +8469,200 @@ void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion
}
break;
#ifdef NV_EXTENSIONS
case EShLangMeshNV:
if (profile != EEsProfile && version >= 450) {
// Per-vertex builtins
BuiltInVariable("gl_MeshVerticesNV", "gl_Position", EbvPosition, symbolTable);
BuiltInVariable("gl_MeshVerticesNV", "gl_PointSize", EbvPointSize, symbolTable);
BuiltInVariable("gl_MeshVerticesNV", "gl_ClipDistance", EbvClipDistance, symbolTable);
BuiltInVariable("gl_MeshVerticesNV", "gl_CullDistance", EbvCullDistance, symbolTable);
// Per-view builtins
BuiltInVariable("gl_MeshVerticesNV", "gl_PositionPerViewNV", EbvPositionPerViewNV, symbolTable);
BuiltInVariable("gl_MeshVerticesNV", "gl_ClipDistancePerViewNV", EbvClipDistancePerViewNV, symbolTable);
BuiltInVariable("gl_MeshVerticesNV", "gl_CullDistancePerViewNV", EbvCullDistancePerViewNV, symbolTable);
// Per-primitive builtins
BuiltInVariable("gl_MeshPrimitivesNV", "gl_PrimitiveID", EbvPrimitiveId, symbolTable);
BuiltInVariable("gl_MeshPrimitivesNV", "gl_Layer", EbvLayer, symbolTable);
BuiltInVariable("gl_MeshPrimitivesNV", "gl_ViewportIndex", EbvViewportIndex, symbolTable);
BuiltInVariable("gl_MeshPrimitivesNV", "gl_ViewportMask", EbvViewportMaskNV, symbolTable);
// Per-view builtins
BuiltInVariable("gl_MeshPrimitivesNV", "gl_LayerPerViewNV", EbvLayerPerViewNV, symbolTable);
BuiltInVariable("gl_MeshPrimitivesNV", "gl_ViewportMaskPerViewNV", EbvViewportMaskPerViewNV, symbolTable);
symbolTable.setVariableExtensions("gl_PrimitiveCountNV", 1, &E_GL_NV_mesh_shader);
symbolTable.setVariableExtensions("gl_PrimitiveIndicesNV", 1, &E_GL_NV_mesh_shader);
symbolTable.setVariableExtensions("gl_MeshViewCountNV", 1, &E_GL_NV_mesh_shader);
symbolTable.setVariableExtensions("gl_MeshViewIndicesNV", 1, &E_GL_NV_mesh_shader);
symbolTable.setVariableExtensions("gl_WorkGroupSize", 1, &E_GL_NV_mesh_shader);
symbolTable.setVariableExtensions("gl_WorkGroupID", 1, &E_GL_NV_mesh_shader);
symbolTable.setVariableExtensions("gl_LocalInvocationID", 1, &E_GL_NV_mesh_shader);
symbolTable.setVariableExtensions("gl_GlobalInvocationID", 1, &E_GL_NV_mesh_shader);
symbolTable.setVariableExtensions("gl_LocalInvocationIndex", 1, &E_GL_NV_mesh_shader);
BuiltInVariable("gl_PrimitiveCountNV", EbvPrimitiveCountNV, symbolTable);
BuiltInVariable("gl_PrimitiveIndicesNV", EbvPrimitiveIndicesNV, symbolTable);
BuiltInVariable("gl_MeshViewCountNV", EbvMeshViewCountNV, symbolTable);
BuiltInVariable("gl_MeshViewIndicesNV", EbvMeshViewIndicesNV, symbolTable);
BuiltInVariable("gl_WorkGroupSize", EbvWorkGroupSize, symbolTable);
BuiltInVariable("gl_WorkGroupID", EbvWorkGroupId, symbolTable);
BuiltInVariable("gl_LocalInvocationID", EbvLocalInvocationId, symbolTable);
BuiltInVariable("gl_GlobalInvocationID", EbvGlobalInvocationId, symbolTable);
BuiltInVariable("gl_LocalInvocationIndex", EbvLocalInvocationIndex, symbolTable);
symbolTable.setVariableExtensions("gl_MaxMeshOutputVerticesNV", 1, &E_GL_NV_mesh_shader);
symbolTable.setVariableExtensions("gl_MaxMeshOutputPrimitivesNV", 1, &E_GL_NV_mesh_shader);
symbolTable.setVariableExtensions("gl_MaxMeshWorkGroupSizeNV", 1, &E_GL_NV_mesh_shader);
symbolTable.setVariableExtensions("gl_MaxMeshViewCountNV", 1, &E_GL_NV_mesh_shader);
symbolTable.setFunctionExtensions("barrier", 1, &E_GL_NV_mesh_shader);
symbolTable.setFunctionExtensions("memoryBarrierShared", 1, &E_GL_NV_mesh_shader);
symbolTable.setFunctionExtensions("groupMemoryBarrier", 1, &E_GL_NV_mesh_shader);
// GL_EXT_device_group
symbolTable.setVariableExtensions("gl_DeviceIndex", 1, &E_GL_EXT_device_group);
BuiltInVariable("gl_DeviceIndex", EbvDeviceIndex, symbolTable);
// GL_ARB_shader_draw_parameters
symbolTable.setVariableExtensions("gl_DrawIDARB", 1, &E_GL_ARB_shader_draw_parameters);
BuiltInVariable("gl_DrawIDARB", EbvDrawId, symbolTable);
if (version >= 460) {
BuiltInVariable("gl_DrawID", EbvDrawId, symbolTable);
}
// GL_ARB_shader_ballot
symbolTable.setVariableExtensions("gl_SubGroupSizeARB", 1, &E_GL_ARB_shader_ballot);
symbolTable.setVariableExtensions("gl_SubGroupInvocationARB", 1, &E_GL_ARB_shader_ballot);
symbolTable.setVariableExtensions("gl_SubGroupEqMaskARB", 1, &E_GL_ARB_shader_ballot);
symbolTable.setVariableExtensions("gl_SubGroupGeMaskARB", 1, &E_GL_ARB_shader_ballot);
symbolTable.setVariableExtensions("gl_SubGroupGtMaskARB", 1, &E_GL_ARB_shader_ballot);
symbolTable.setVariableExtensions("gl_SubGroupLeMaskARB", 1, &E_GL_ARB_shader_ballot);
symbolTable.setVariableExtensions("gl_SubGroupLtMaskARB", 1, &E_GL_ARB_shader_ballot);
BuiltInVariable("gl_SubGroupInvocationARB", EbvSubGroupInvocation, symbolTable);
BuiltInVariable("gl_SubGroupEqMaskARB", EbvSubGroupEqMask, symbolTable);
BuiltInVariable("gl_SubGroupGeMaskARB", EbvSubGroupGeMask, symbolTable);
BuiltInVariable("gl_SubGroupGtMaskARB", EbvSubGroupGtMask, symbolTable);
BuiltInVariable("gl_SubGroupLeMaskARB", EbvSubGroupLeMask, symbolTable);
BuiltInVariable("gl_SubGroupLtMaskARB", EbvSubGroupLtMask, symbolTable);
if (spvVersion.vulkan > 0)
// Treat "gl_SubGroupSizeARB" as shader input instead of uniform for Vulkan
SpecialQualifier("gl_SubGroupSizeARB", EvqVaryingIn, EbvSubGroupSize, symbolTable);
else
BuiltInVariable("gl_SubGroupSizeARB", EbvSubGroupSize, symbolTable);
}
// GL_KHR_shader_subgroup
if (spvVersion.vulkan > 0) {
symbolTable.setVariableExtensions("gl_NumSubgroups", 1, &E_GL_KHR_shader_subgroup_basic);
symbolTable.setVariableExtensions("gl_SubgroupID", 1, &E_GL_KHR_shader_subgroup_basic);
symbolTable.setVariableExtensions("gl_SubgroupSize", 1, &E_GL_KHR_shader_subgroup_basic);
symbolTable.setVariableExtensions("gl_SubgroupInvocationID", 1, &E_GL_KHR_shader_subgroup_basic);
symbolTable.setVariableExtensions("gl_SubgroupEqMask", 1, &E_GL_KHR_shader_subgroup_ballot);
symbolTable.setVariableExtensions("gl_SubgroupGeMask", 1, &E_GL_KHR_shader_subgroup_ballot);
symbolTable.setVariableExtensions("gl_SubgroupGtMask", 1, &E_GL_KHR_shader_subgroup_ballot);
symbolTable.setVariableExtensions("gl_SubgroupLeMask", 1, &E_GL_KHR_shader_subgroup_ballot);
symbolTable.setVariableExtensions("gl_SubgroupLtMask", 1, &E_GL_KHR_shader_subgroup_ballot);
BuiltInVariable("gl_NumSubgroups", EbvNumSubgroups, symbolTable);
BuiltInVariable("gl_SubgroupID", EbvSubgroupID, symbolTable);
BuiltInVariable("gl_SubgroupSize", EbvSubgroupSize2, symbolTable);
BuiltInVariable("gl_SubgroupInvocationID", EbvSubgroupInvocation2, symbolTable);
BuiltInVariable("gl_SubgroupEqMask", EbvSubgroupEqMask2, symbolTable);
BuiltInVariable("gl_SubgroupGeMask", EbvSubgroupGeMask2, symbolTable);
BuiltInVariable("gl_SubgroupGtMask", EbvSubgroupGtMask2, symbolTable);
BuiltInVariable("gl_SubgroupLeMask", EbvSubgroupLeMask2, symbolTable);
BuiltInVariable("gl_SubgroupLtMask", EbvSubgroupLtMask2, symbolTable);
symbolTable.setFunctionExtensions("subgroupMemoryBarrierShared", 1, &E_GL_KHR_shader_subgroup_basic);
}
break;
case EShLangTaskNV:
if (profile != EEsProfile && version >= 450) {
symbolTable.setVariableExtensions("gl_TaskCountNV", 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_LocalInvocationID", 1, &E_GL_NV_mesh_shader);
symbolTable.setVariableExtensions("gl_GlobalInvocationID", 1, &E_GL_NV_mesh_shader);
symbolTable.setVariableExtensions("gl_LocalInvocationIndex", 1, &E_GL_NV_mesh_shader);
BuiltInVariable("gl_TaskCountNV", EbvTaskCountNV, symbolTable);
BuiltInVariable("gl_WorkGroupSize", EbvWorkGroupSize, symbolTable);
BuiltInVariable("gl_WorkGroupID", EbvWorkGroupId, symbolTable);
BuiltInVariable("gl_LocalInvocationID", EbvLocalInvocationId, symbolTable);
BuiltInVariable("gl_GlobalInvocationID", EbvGlobalInvocationId, symbolTable);
BuiltInVariable("gl_LocalInvocationIndex", EbvLocalInvocationIndex, symbolTable);
symbolTable.setVariableExtensions("gl_MaxTaskWorkGroupSizeNV", 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("groupMemoryBarrier", 1, &E_GL_NV_mesh_shader);
// GL_EXT_device_group
symbolTable.setVariableExtensions("gl_DeviceIndex", 1, &E_GL_EXT_device_group);
BuiltInVariable("gl_DeviceIndex", EbvDeviceIndex, symbolTable);
// GL_ARB_shader_draw_parameters
symbolTable.setVariableExtensions("gl_DrawIDARB", 1, &E_GL_ARB_shader_draw_parameters);
BuiltInVariable("gl_DrawIDARB", EbvDrawId, symbolTable);
if (version >= 460) {
BuiltInVariable("gl_DrawID", EbvDrawId, symbolTable);
}
// GL_ARB_shader_ballot
symbolTable.setVariableExtensions("gl_SubGroupSizeARB", 1, &E_GL_ARB_shader_ballot);
symbolTable.setVariableExtensions("gl_SubGroupInvocationARB", 1, &E_GL_ARB_shader_ballot);
symbolTable.setVariableExtensions("gl_SubGroupEqMaskARB", 1, &E_GL_ARB_shader_ballot);
symbolTable.setVariableExtensions("gl_SubGroupGeMaskARB", 1, &E_GL_ARB_shader_ballot);
symbolTable.setVariableExtensions("gl_SubGroupGtMaskARB", 1, &E_GL_ARB_shader_ballot);
symbolTable.setVariableExtensions("gl_SubGroupLeMaskARB", 1, &E_GL_ARB_shader_ballot);
symbolTable.setVariableExtensions("gl_SubGroupLtMaskARB", 1, &E_GL_ARB_shader_ballot);
BuiltInVariable("gl_SubGroupInvocationARB", EbvSubGroupInvocation, symbolTable);
BuiltInVariable("gl_SubGroupEqMaskARB", EbvSubGroupEqMask, symbolTable);
BuiltInVariable("gl_SubGroupGeMaskARB", EbvSubGroupGeMask, symbolTable);
BuiltInVariable("gl_SubGroupGtMaskARB", EbvSubGroupGtMask, symbolTable);
BuiltInVariable("gl_SubGroupLeMaskARB", EbvSubGroupLeMask, symbolTable);
BuiltInVariable("gl_SubGroupLtMaskARB", EbvSubGroupLtMask, symbolTable);
if (spvVersion.vulkan > 0)
// Treat "gl_SubGroupSizeARB" as shader input instead of uniform for Vulkan
SpecialQualifier("gl_SubGroupSizeARB", EvqVaryingIn, EbvSubGroupSize, symbolTable);
else
BuiltInVariable("gl_SubGroupSizeARB", EbvSubGroupSize, symbolTable);
}
// GL_KHR_shader_subgroup
if (spvVersion.vulkan > 0) {
symbolTable.setVariableExtensions("gl_NumSubgroups", 1, &E_GL_KHR_shader_subgroup_basic);
symbolTable.setVariableExtensions("gl_SubgroupID", 1, &E_GL_KHR_shader_subgroup_basic);
symbolTable.setVariableExtensions("gl_SubgroupSize", 1, &E_GL_KHR_shader_subgroup_basic);
symbolTable.setVariableExtensions("gl_SubgroupInvocationID", 1, &E_GL_KHR_shader_subgroup_basic);
symbolTable.setVariableExtensions("gl_SubgroupEqMask", 1, &E_GL_KHR_shader_subgroup_ballot);
symbolTable.setVariableExtensions("gl_SubgroupGeMask", 1, &E_GL_KHR_shader_subgroup_ballot);
symbolTable.setVariableExtensions("gl_SubgroupGtMask", 1, &E_GL_KHR_shader_subgroup_ballot);
symbolTable.setVariableExtensions("gl_SubgroupLeMask", 1, &E_GL_KHR_shader_subgroup_ballot);
symbolTable.setVariableExtensions("gl_SubgroupLtMask", 1, &E_GL_KHR_shader_subgroup_ballot);
BuiltInVariable("gl_NumSubgroups", EbvNumSubgroups, symbolTable);
BuiltInVariable("gl_SubgroupID", EbvSubgroupID, symbolTable);
BuiltInVariable("gl_SubgroupSize", EbvSubgroupSize2, symbolTable);
BuiltInVariable("gl_SubgroupInvocationID", EbvSubgroupInvocation2, symbolTable);
BuiltInVariable("gl_SubgroupEqMask", EbvSubgroupEqMask2, symbolTable);
BuiltInVariable("gl_SubgroupGeMask", EbvSubgroupGeMask2, symbolTable);
BuiltInVariable("gl_SubgroupGtMask", EbvSubgroupGtMask2, symbolTable);
BuiltInVariable("gl_SubgroupLeMask", EbvSubgroupLeMask2, symbolTable);
BuiltInVariable("gl_SubgroupLtMask", EbvSubgroupLtMask2, symbolTable);
symbolTable.setFunctionExtensions("subgroupMemoryBarrierShared", 1, &E_GL_KHR_shader_subgroup_basic);
}
break;
#endif
default:
assert(false && "Language not supported");
break;
@ -8840,6 +9199,20 @@ void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion
#endif
break;
#ifdef NV_EXTENSIONS
case EShLangMeshNV:
if (profile != EEsProfile && version >= 450) {
symbolTable.relateToOperator("writePackedPrimitiveIndices4x8NV", EOpWritePackedPrimitiveIndices4x8NV);
}
// fall through
case EShLangTaskNV:
if (profile != EEsProfile && version >= 450) {
symbolTable.relateToOperator("memoryBarrierShared", EOpMemoryBarrierShared);
symbolTable.relateToOperator("groupMemoryBarrier", EOpGroupMemoryBarrier);
}
break;
#endif
default:
assert(false && "Language not supported");
}

View File

@ -491,7 +491,8 @@ void TParseContext::makeEditable(TSymbol*& symbol)
ioArraySymbolResizeList.push_back(symbol);
}
// Return true if this is a geometry shader input array or tessellation control output array.
// Return true if this is a geometry shader input array or tessellation control output array
// or mesh shader output array.
bool TParseContext::isIoResizeArray(const TType& type) const
{
return type.isArray() &&
@ -499,7 +500,9 @@ bool TParseContext::isIoResizeArray(const TType& type) const
(language == EShLangTessControl && type.getQualifier().storage == EvqVaryingOut && ! type.getQualifier().patch)
#ifdef NV_EXTENSIONS
||
(language == EShLangFragment && type.getQualifier().storage == EvqVaryingIn && type.getQualifier().pervertexNV)
(language == EShLangFragment && type.getQualifier().storage == EvqVaryingIn && type.getQualifier().pervertexNV) ||
(language == EShLangMeshNV && type.getQualifier().storage == EvqVaryingOut && !type.getQualifier().perTaskNV)
#endif
);
}
@ -551,7 +554,7 @@ void TParseContext::handleIoResizeArrayAccess(const TSourceLoc& /*loc*/, TInterm
// fix array size, if it can be fixed and needs to be fixed (will allow variable indexing)
if (symbolNode->getType().isUnsizedArray()) {
int newSize = getIoArrayImplicitSize();
int newSize = getIoArrayImplicitSize(symbolNode->getType().getQualifier().isPerPrimitive());
if (newSize > 0)
symbolNode->getWritableType().changeOuterArraySize(newSize);
}
@ -565,9 +568,9 @@ void TParseContext::handleIoResizeArrayAccess(const TSourceLoc& /*loc*/, TInterm
// Types without an array size will be given one.
// Types already having a size that is wrong will get an error.
//
void TParseContext::checkIoArraysConsistency(const TSourceLoc& loc, bool tailOnly)
void TParseContext::checkIoArraysConsistency(const TSourceLoc& loc, bool tailOnly, bool isPerPrimitive)
{
int requiredSize = getIoArrayImplicitSize();
int requiredSize = getIoArrayImplicitSize(isPerPrimitive);
if (requiredSize == 0)
return;
@ -581,6 +584,11 @@ void TParseContext::checkIoArraysConsistency(const TSourceLoc& loc, bool tailOnl
)
feature = "vertices";
#ifdef NV_EXTENSIONS
else if (language == EShLangMeshNV) {
feature = isPerPrimitive ? "max_primitives" : "max_vertices";
}
#endif
else
feature = "unknown";
@ -593,7 +601,7 @@ void TParseContext::checkIoArraysConsistency(const TSourceLoc& loc, bool tailOnl
checkIoArrayConsistency(loc, requiredSize, feature, ioArraySymbolResizeList[i]->getWritableType(), ioArraySymbolResizeList[i]->getName());
}
int TParseContext::getIoArrayImplicitSize() const
int TParseContext::getIoArrayImplicitSize(bool isPerPrimitive) const
{
if (language == EShLangGeometry)
return TQualifier::mapGeometryToSize(intermediate.getInputPrimitive());
@ -602,6 +610,13 @@ int TParseContext::getIoArrayImplicitSize() const
#ifdef NV_EXTENSIONS
else if (language == EShLangFragment)
return 3; //Number of vertices for Fragment shader is always three.
else if (language == EShLangMeshNV) {
if (isPerPrimitive) {
return intermediate.getPrimitives() != TQualifier::layoutNotSet ? intermediate.getPrimitives() : 0;
} else {
return intermediate.getVertices() != TQualifier::layoutNotSet ? intermediate.getVertices() : 0;
}
}
#endif
else
@ -622,6 +637,8 @@ void TParseContext::checkIoArrayConsistency(const TSourceLoc& loc, int requiredS
if (type.getOuterArraySize() > requiredSize)
error(loc, " cannot be greater than 3 for pervertexNV", feature, name.c_str());
}
else if (language == EShLangMeshNV)
error(loc, "inconsistent output array size of", feature, name.c_str());
#endif
else
assert(0);
@ -1322,8 +1339,15 @@ TIntermTyped* TParseContext::handleLengthMethod(const TSourceLoc& loc, TFunction
// without actually redeclaring the array. (It is an error to use a member before the
// redeclaration, but not an error to use the array name itself.)
const TString& name = intermNode->getAsSymbolNode()->getName();
if (name == "gl_in" || name == "gl_out")
length = getIoArrayImplicitSize();
if (name == "gl_in" || name == "gl_out"
#ifdef NV_EXTENSIONS
|| name == "gl_MeshVerticesNV"
|| name == "gl_MeshPrimitivesNV"
#endif
)
{
length = getIoArrayImplicitSize(type.getQualifier().isPerPrimitive());
}
}
if (length == 0) {
if (intermNode->getAsSymbolNode() && isIoResizeArray(type))
@ -3070,6 +3094,11 @@ void TParseContext::globalQualifierTypeCheck(const TSourceLoc& loc, const TQuali
if (qualifier.patch && qualifier.isInterpolation())
error(loc, "cannot use interpolation qualifiers with patch", "patch", "");
#ifdef NV_EXTENSIONS
if (qualifier.perTaskNV && publicType.basicType != EbtBlock)
error(loc, "taskNV variables can be declared only as blocks", "taskNV", "");
#endif
if (qualifier.storage == EvqVaryingIn) {
switch (language) {
case EShLangVertex:
@ -3257,6 +3286,11 @@ void TParseContext::mergeQualifiers(const TSourceLoc& loc, TQualifier& dst, cons
MERGE_SINGLETON(nopersp);
#ifdef AMD_EXTENSIONS
MERGE_SINGLETON(explicitInterp);
#endif
#ifdef NV_EXTENSIONS
MERGE_SINGLETON(perPrimitiveNV);
MERGE_SINGLETON(perViewNV);
MERGE_SINGLETON(perTaskNV);
#endif
MERGE_SINGLETON(patch);
MERGE_SINGLETON(sample);
@ -3599,7 +3633,7 @@ void TParseContext::declareArray(const TSourceLoc& loc, const TString& identifie
if (! symbolTable.atBuiltInLevel()) {
if (isIoResizeArray(type)) {
ioArraySymbolResizeList.push_back(symbol);
checkIoArraysConsistency(loc, true);
checkIoArraysConsistency(loc, true, type.getQualifier().isPerPrimitive());
} else
fixIoArraySize(loc, symbol->getWritableType());
}
@ -3652,7 +3686,7 @@ void TParseContext::declareArray(const TSourceLoc& loc, const TString& identifie
existingType.updateArraySizes(type);
if (isIoResizeArray(type))
checkIoArraysConsistency(loc);
checkIoArraysConsistency(loc, false, type.getQualifier().isPerPrimitive());
}
// Policy and error check for needing a runtime sized array.
@ -3688,6 +3722,28 @@ bool TParseContext::isRuntimeLength(const TIntermTyped& base) const
return false;
}
#ifdef NV_EXTENSIONS
// Fix mesh view output array dimension
void TParseContext::resizeMeshViewDimension(const TSourceLoc& loc, TType& type)
{
// see if member is a per-view attribute
if (type.getQualifier().isPerView()) {
// since we don't have the maxMeshViewCountNV set during parsing builtins, we hardcode the value
int maxViewCount = parsingBuiltins ? 4 : resources.maxMeshViewCountNV;
if (! type.isArray()) {
error(loc, "requires an view array dimension", "perviewNV", "");
}
else if (!type.isUnsizedArray() && type.getOuterArraySize() != maxViewCount) {
error(loc, "mesh view output array size must be gl_MaxMeshViewCountNV or implicitly sized", "[]", "");
}
else if (type.isUnsizedArray()) {
type.changeOuterArraySize(maxViewCount);
}
}
}
#endif
// Returns true if the first argument to the #line directive is the line number for the next line.
//
// Desktop, pre-version 3.30: "After processing this directive
@ -3878,7 +3934,12 @@ void TParseContext::redeclareBuiltinBlock(const TSourceLoc& loc, TTypeList& newT
profileRequires(loc, EEsProfile, 320, Num_AEP_shader_io_blocks, AEP_shader_io_blocks, feature);
profileRequires(loc, ~EEsProfile, 410, E_GL_ARB_separate_shader_objects, feature);
if (blockName != "gl_PerVertex" && blockName != "gl_PerFragment") {
if (blockName != "gl_PerVertex" && blockName != "gl_PerFragment"
#ifdef NV_EXTENSIONS
&& blockName != "gl_MeshPerVertexNV" && blockName != "gl_MeshPerPrimitiveNV"
#endif
)
{
error(loc, "cannot redeclare block: ", "block declaration", blockName.c_str());
return;
}
@ -4054,7 +4115,7 @@ void TParseContext::redeclareBuiltinBlock(const TSourceLoc& loc, TTypeList& newT
// Tracking for implicit sizing of array
if (isIoResizeArray(block->getType())) {
ioArraySymbolResizeList.push_back(block);
checkIoArraysConsistency(loc, true);
checkIoArraysConsistency(loc, true, block->getType().getQualifier().isPerPrimitive());
} else if (block->getType().isArray())
fixIoArraySize(loc, block->getWritableType());
@ -4471,24 +4532,36 @@ void TParseContext::setLayoutQualifier(const TSourceLoc& loc, TPublicType& publi
publicType.qualifier.layoutPushConstant = true;
return;
}
if (language == EShLangGeometry || language == EShLangTessEvaluation) {
if (language == EShLangGeometry || language == EShLangTessEvaluation
#ifdef NV_EXTENSIONS
|| language == EShLangMeshNV
#endif
) {
if (id == TQualifier::getGeometryString(ElgTriangles)) {
publicType.shaderQualifiers.geometry = ElgTriangles;
return;
}
if (language == EShLangGeometry) {
if (language == EShLangGeometry
#ifdef NV_EXTENSIONS
|| language == EShLangMeshNV
#endif
) {
if (id == TQualifier::getGeometryString(ElgPoints)) {
publicType.shaderQualifiers.geometry = ElgPoints;
return;
}
if (id == TQualifier::getGeometryString(ElgLineStrip)) {
publicType.shaderQualifiers.geometry = ElgLineStrip;
return;
}
if (id == TQualifier::getGeometryString(ElgLines)) {
publicType.shaderQualifiers.geometry = ElgLines;
return;
}
#ifdef NV_EXTENSIONS
if (language == EShLangGeometry)
#endif
{
if (id == TQualifier::getGeometryString(ElgLineStrip)) {
publicType.shaderQualifiers.geometry = ElgLineStrip;
return;
}
if (id == TQualifier::getGeometryString(ElgLinesAdjacency)) {
publicType.shaderQualifiers.geometry = ElgLinesAdjacency;
return;
@ -4509,6 +4582,7 @@ void TParseContext::setLayoutQualifier(const TSourceLoc& loc, TPublicType& publi
return;
}
#endif
}
} else {
assert(language == EShLangTessEvaluation);
@ -4863,10 +4937,37 @@ void TParseContext::setLayoutQualifier(const TSourceLoc& loc, TPublicType& publi
}
break;
#ifdef NV_EXTENSIONS
case EShLangMeshNV:
if (id == "max_vertices") {
publicType.shaderQualifiers.vertices = value;
if (value > resources.maxMeshOutputVerticesNV)
error(loc, "too large, must be less than gl_MaxMeshOutputVerticesNV", "max_vertices", "");
return;
}
if (id == "max_primitives") {
publicType.shaderQualifiers.primitives = value;
if (value > resources.maxMeshOutputPrimitivesNV)
error(loc, "too large, must be less than gl_MaxMeshOutputPrimitivesNV", "max_primitives", "");
return;
}
// Fall through
case EShLangTaskNV:
// Fall through
#endif
case EShLangCompute:
if (id.compare(0, 11, "local_size_") == 0) {
#ifdef NV_EXTENSIONS
if (language == EShLangMeshNV || language == EShLangTaskNV) {
profileRequires(loc, ~EEsProfile, 450, E_GL_NV_mesh_shader, "gl_WorkGroupSize");
}
else
#endif
{
profileRequires(loc, EEsProfile, 310, 0, "gl_WorkGroupSize");
profileRequires(loc, ~EEsProfile, 430, E_GL_ARB_compute_shader, "gl_WorkGroupSize");
}
if (id.size() == 12 && value == 0) {
error(loc, "must be at least 1", id.c_str(), "");
return;
@ -5013,9 +5114,10 @@ void TParseContext::layoutObjectCheck(const TSourceLoc& loc, const TSymbol& symb
switch (qualifier.storage) {
case EvqVaryingIn:
case EvqVaryingOut:
if (type.getBasicType() != EbtBlock ||
if (!type.getQualifier().isTaskMemory() &&
(type.getBasicType() != EbtBlock ||
(!(*type.getStruct())[0].type->getQualifier().hasLocation() &&
(*type.getStruct())[0].type->getQualifier().builtIn == EbvNone))
(*type.getStruct())[0].type->getQualifier().builtIn == EbvNone)))
error(loc, "SPIR-V requires location for user input/output", "location", "");
break;
default:
@ -5104,6 +5206,10 @@ void TParseContext::layoutTypeCheck(const TSourceLoc& loc, const TType& type)
case EvqVaryingOut:
if (type.getBasicType() == EbtBlock)
profileRequires(loc, ECoreProfile | ECompatibilityProfile, 440, E_GL_ARB_enhanced_layouts, "location qualifier on in/out block");
#ifdef NV_EXTENSIONS
if (type.getQualifier().isTaskMemory())
error(loc, "cannot apply to taskNV in/out blocks", "location", "");
#endif
break;
case EvqUniform:
case EvqBuffer:
@ -5355,7 +5461,7 @@ void TParseContext::layoutQualifierCheck(const TSourceLoc& loc, const TQualifier
}
if (qualifier.hasBinding()) {
if (! qualifier.isUniformOrBuffer())
if (! qualifier.isUniformOrBuffer() && !qualifier.isTaskMemory())
error(loc, "requires uniform or buffer storage qualifier", "binding", "");
}
if (qualifier.hasStream()) {
@ -5367,7 +5473,7 @@ void TParseContext::layoutQualifierCheck(const TSourceLoc& loc, const TQualifier
error(loc, "can only be used on an output", "xfb layout qualifier", "");
}
if (qualifier.hasUniformLayout()) {
if (! qualifier.isUniformOrBuffer()) {
if (! qualifier.isUniformOrBuffer() && !qualifier.isTaskMemory()) {
if (qualifier.hasMatrix() || qualifier.hasPacking())
error(loc, "matrix or packing qualifiers can only be used on a uniform or buffer", "layout", "");
if (qualifier.hasOffset() || qualifier.hasAlign())
@ -5408,13 +5514,25 @@ void TParseContext::checkNoShaderLayouts(const TSourceLoc& loc, const TShaderQua
error(loc, message, "local_size id", "");
}
if (shaderQualifiers.vertices != TQualifier::layoutNotSet) {
if (language == EShLangGeometry)
if (language == EShLangGeometry
#ifdef NV_EXTENSIONS
|| language == EShLangMeshNV
#endif
)
error(loc, message, "max_vertices", "");
else if (language == EShLangTessControl)
error(loc, message, "vertices", "");
else
assert(0);
}
#ifdef NV_EXTENSIONS
if (shaderQualifiers.primitives != TQualifier::layoutNotSet) {
if (language == EShLangMeshNV)
error(loc, message, "max_primitives", "");
else
assert(0);
}
#endif
if (shaderQualifiers.blendEquation)
error(loc, message, "blend equation", "");
if (shaderQualifiers.numViews != TQualifier::layoutNotSet)
@ -6445,6 +6563,14 @@ void TParseContext::declareBlock(const TSourceLoc& loc, TTypeList& typeList, con
if (memberQualifier.storage != EvqTemporary && memberQualifier.storage != EvqGlobal && memberQualifier.storage != currentBlockQualifier.storage)
error(memberLoc, "member storage qualifier cannot contradict block storage qualifier", memberType.getFieldName().c_str(), "");
memberQualifier.storage = currentBlockQualifier.storage;
#ifdef NV_EXTENSIONS
if (currentBlockQualifier.perPrimitiveNV)
memberQualifier.perPrimitiveNV = currentBlockQualifier.perPrimitiveNV;
if (currentBlockQualifier.perViewNV)
memberQualifier.perViewNV = currentBlockQualifier.perViewNV;
if (currentBlockQualifier.perTaskNV)
memberQualifier.perTaskNV = currentBlockQualifier.perTaskNV;
#endif
if ((currentBlockQualifier.storage == EvqUniform || currentBlockQualifier.storage == EvqBuffer) && (memberQualifier.isInterpolation() || memberQualifier.isAuxiliary()))
error(memberLoc, "member of uniform or buffer block cannot have an auxiliary or interpolation qualifier", memberType.getFieldName().c_str(), "");
if (memberType.isArray())
@ -6490,6 +6616,12 @@ void TParseContext::declareBlock(const TSourceLoc& loc, TTypeList& typeList, con
if (currentBlockQualifier.layoutPushConstant && !currentBlockQualifier.hasPacking())
currentBlockQualifier.layoutPacking = ElpStd430;
#ifdef NV_EXTENSIONS
// Special case for "taskNV in/out", which has a default of std430,
if (currentBlockQualifier.perTaskNV && !currentBlockQualifier.hasPacking())
currentBlockQualifier.layoutPacking = ElpStd430;
#endif
// fix and check for member layout qualifiers
mergeObjectLayoutQualifiers(defaultQualification, currentBlockQualifier, true);
@ -6504,6 +6636,9 @@ void TParseContext::declareBlock(const TSourceLoc& loc, TTypeList& typeList, con
bool memberWithLocation = false;
bool memberWithoutLocation = false;
#ifdef NV_EXTENSIONS
bool memberWithPerViewQualifier = false;
#endif
for (unsigned int member = 0; member < typeList.size(); ++member) {
TQualifier& memberQualifier = typeList[member].type->getQualifier();
const TSourceLoc& memberLoc = typeList[member].loc;
@ -6547,6 +6682,12 @@ void TParseContext::declareBlock(const TSourceLoc& loc, TTypeList& typeList, con
error(memberLoc, "can only be used with std140 or std430 layout packing", "offset/align", "");
}
#ifdef NV_EXTENSIONS
if (memberQualifier.isPerView()) {
memberWithPerViewQualifier = true;
}
#endif
TQualifier newMemberQualification = defaultQualification;
mergeQualifiers(memberLoc, newMemberQualification, memberQualifier, false);
memberQualifier = newMemberQualification;
@ -6561,6 +6702,14 @@ void TParseContext::declareBlock(const TSourceLoc& loc, TTypeList& typeList, con
for (unsigned int member = 0; member < typeList.size(); ++member)
layoutTypeCheck(typeList[member].loc, *typeList[member].type);
#ifdef NV_EXTENSIONS
if (memberWithPerViewQualifier) {
for (unsigned int member = 0; member < typeList.size(); ++member) {
resizeMeshViewDimension(typeList[member].loc, *typeList[member].type);
}
}
#endif
// reverse merge, so that currentBlockQualifier now has all layout information
// (can't use defaultQualification directly, it's missing other non-layout-default-class qualifiers)
mergeObjectLayoutQualifiers(currentBlockQualifier, defaultQualification, true);
@ -6624,7 +6773,7 @@ void TParseContext::declareBlock(const TSourceLoc& loc, TTypeList& typeList, con
// fix up
if (isIoResizeArray(blockType)) {
ioArraySymbolResizeList.push_back(&variable);
checkIoArraysConsistency(loc, true);
checkIoArraysConsistency(loc, true, blockType.getQualifier().isPerPrimitive());
} else
fixIoArraySize(loc, variable.getWritableType());
@ -6652,16 +6801,39 @@ void TParseContext::blockStageIoCheck(const TSourceLoc& loc, const TQualifier& q
profileRequires(loc, ~EEsProfile, 150, E_GL_ARB_separate_shader_objects, "input block");
// It is a compile-time error to have an input block in a vertex shader or an output block in a fragment shader
// "Compute shaders do not permit user-defined input variables..."
requireStage(loc, (EShLanguageMask)(EShLangTessControlMask|EShLangTessEvaluationMask|EShLangGeometryMask|EShLangFragmentMask), "input block");
if (language == EShLangFragment)
requireStage(loc, (EShLanguageMask)(EShLangTessControlMask|EShLangTessEvaluationMask|EShLangGeometryMask|EShLangFragmentMask
#ifdef NV_EXTENSIONS
|EShLangMeshNVMask
#endif
), "input block");
if (language == EShLangFragment) {
profileRequires(loc, EEsProfile, 320, Num_AEP_shader_io_blocks, AEP_shader_io_blocks, "fragment input block");
}
#ifdef NV_EXTENSIONS
else if (language == EShLangMeshNV && ! qualifier.isTaskMemory()) {
error(loc, "input blocks cannot be used in a mesh shader", "out", "");
}
#endif
break;
case EvqVaryingOut:
profileRequires(loc, ~EEsProfile, 150, E_GL_ARB_separate_shader_objects, "output block");
requireStage(loc, (EShLanguageMask)(EShLangVertexMask|EShLangTessControlMask|EShLangTessEvaluationMask|EShLangGeometryMask), "output block");
requireStage(loc, (EShLanguageMask)(EShLangVertexMask|EShLangTessControlMask|EShLangTessEvaluationMask|EShLangGeometryMask
#ifdef NV_EXTENSIONS
|EShLangMeshNVMask|EShLangTaskNVMask
#endif
), "output block");
// ES 310 can have a block before shader_io is turned on, so skip this test for built-ins
if (language == EShLangVertex && ! parsingBuiltins)
if (language == EShLangVertex && ! parsingBuiltins) {
profileRequires(loc, EEsProfile, 320, Num_AEP_shader_io_blocks, AEP_shader_io_blocks, "vertex output block");
}
#ifdef NV_EXTENSIONS
else if (language == EShLangMeshNV && qualifier.isTaskMemory()) {
error(loc, "can only use on input blocks in mesh shader", "taskNV", "");
}
else if (language == EShLangTaskNV && ! qualifier.isTaskMemory()) {
error(loc, "output blocks cannot be used in a task shader", "out", "");
}
#endif
break;
default:
error(loc, "only uniform, buffer, in, or out blocks are supported", blockName->c_str(), "");
@ -6699,6 +6871,10 @@ void TParseContext::blockQualifierCheck(const TSourceLoc& loc, const TQualifier&
error(loc, "cannot use invariant qualifier on an interface block", "invariant", "");
if (qualifier.layoutPushConstant)
intermediate.addPushConstantCount();
#ifdef NV_EXTENSIONS
if (qualifier.perTaskNV)
intermediate.addTaskNVCount();
#endif
}
//
@ -6784,7 +6960,7 @@ void TParseContext::fixBlockXfbOffsets(TQualifier& qualifier, TTypeList& typeLis
//
void TParseContext::fixBlockUniformOffsets(TQualifier& qualifier, TTypeList& typeList)
{
if (! qualifier.isUniformOrBuffer())
if (!qualifier.isUniformOrBuffer() && !qualifier.isTaskMemory())
return;
if (qualifier.layoutPacking != ElpStd140 && qualifier.layoutPacking != ElpStd430)
return;
@ -6916,7 +7092,11 @@ void TParseContext::invariantCheck(const TSourceLoc& loc, const TQualifier& qual
void TParseContext::updateStandaloneQualifierDefaults(const TSourceLoc& loc, const TPublicType& publicType)
{
if (publicType.shaderQualifiers.vertices != TQualifier::layoutNotSet) {
#ifdef NV_EXTENSIONS
assert(language == EShLangTessControl || language == EShLangGeometry || language == EShLangMeshNV);
#else
assert(language == EShLangTessControl || language == EShLangGeometry);
#endif
const char* id = (language == EShLangTessControl) ? "vertices" : "max_vertices";
if (publicType.qualifier.storage != EvqVaryingOut)
@ -6927,6 +7107,17 @@ void TParseContext::updateStandaloneQualifierDefaults(const TSourceLoc& loc, con
if (language == EShLangTessControl)
checkIoArraysConsistency(loc);
}
#ifdef NV_EXTENSIONS
if (publicType.shaderQualifiers.primitives != TQualifier::layoutNotSet) {
assert(language == EShLangMeshNV);
const char* id = "max_primitives";
if (publicType.qualifier.storage != EvqVaryingOut)
error(loc, "can only apply to 'out'", id, "");
if (! intermediate.setPrimitives(publicType.shaderQualifiers.primitives))
error(loc, "cannot change previously set layout value", id, "");
}
#endif
if (publicType.shaderQualifiers.invocations != TQualifier::layoutNotSet) {
if (publicType.qualifier.storage != EvqVaryingIn)
error(loc, "can only apply to 'in'", "invocations", "");
@ -6943,6 +7134,12 @@ void TParseContext::updateStandaloneQualifierDefaults(const TSourceLoc& loc, con
case ElgTrianglesAdjacency:
case ElgQuads:
case ElgIsolines:
#ifdef NV_EXTENSIONS
if (language == EShLangMeshNV) {
error(loc, "cannot apply to input", TQualifier::getGeometryString(publicType.shaderQualifiers.geometry), "");
break;
}
#endif
if (intermediate.setInputPrimitive(publicType.shaderQualifiers.geometry)) {
if (language == EShLangGeometry)
checkIoArraysConsistency(loc);
@ -6954,6 +7151,15 @@ void TParseContext::updateStandaloneQualifierDefaults(const TSourceLoc& loc, con
}
} else if (publicType.qualifier.storage == EvqVaryingOut) {
switch (publicType.shaderQualifiers.geometry) {
#ifdef NV_EXTENSIONS
case ElgLines:
case ElgTriangles:
if (language != EShLangMeshNV) {
error(loc, "cannot apply to 'out'", TQualifier::getGeometryString(publicType.shaderQualifiers.geometry), "");
break;
}
#endif
// Fall through
case ElgPoints:
case ElgLineStrip:
case ElgTriangleStrip:
@ -6993,6 +7199,7 @@ void TParseContext::updateStandaloneQualifierDefaults(const TSourceLoc& loc, con
error(loc, "cannot change previously set size", "local_size", "");
else {
int max = 0;
if (language == EShLangCompute) {
switch (i) {
case 0: max = resources.maxComputeWorkGroupSizeX; break;
case 1: max = resources.maxComputeWorkGroupSizeY; break;
@ -7001,6 +7208,32 @@ void TParseContext::updateStandaloneQualifierDefaults(const TSourceLoc& loc, con
}
if (intermediate.getLocalSize(i) > (unsigned int)max)
error(loc, "too large; see gl_MaxComputeWorkGroupSize", "local_size", "");
}
#ifdef NV_EXTENSIONS
else if (language == EShLangMeshNV) {
switch (i) {
case 0: max = resources.maxMeshWorkGroupSizeX_NV; break;
case 1: max = resources.maxMeshWorkGroupSizeY_NV; break;
case 2: max = resources.maxMeshWorkGroupSizeZ_NV; break;
default: break;
}
if (intermediate.getLocalSize(i) > (unsigned int)max)
error(loc, "too large; see gl_MaxMeshWorkGroupSizeNV", "local_size", "");
}
else if (language == EShLangTaskNV) {
switch (i) {
case 0: max = resources.maxTaskWorkGroupSizeX_NV; break;
case 1: max = resources.maxTaskWorkGroupSizeY_NV; break;
case 2: max = resources.maxTaskWorkGroupSizeZ_NV; break;
default: break;
}
if (intermediate.getLocalSize(i) > (unsigned int)max)
error(loc, "too large; see gl_MaxTaskWorkGroupSizeNV", "local_size", "");
}
#endif
else {
assert(0);
}
// Fix the existing constant gl_WorkGroupSize with this new information.
TVariable* workGroupSize = getEditableVariable("gl_WorkGroupSize");

View File

@ -298,8 +298,8 @@ public:
void fixIoArraySize(const TSourceLoc&, TType&);
void ioArrayCheck(const TSourceLoc&, const TType&, const TString& identifier);
void handleIoResizeArrayAccess(const TSourceLoc&, TIntermTyped* base);
void checkIoArraysConsistency(const TSourceLoc&, bool tailOnly = false);
int getIoArrayImplicitSize() const;
void checkIoArraysConsistency(const TSourceLoc&, bool tailOnly = false, bool isPerPrimitive = false);
int getIoArrayImplicitSize(bool isPerPrimitive = false) const;
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);
@ -423,6 +423,9 @@ public:
// Determine loop control from attributes
void handleLoopAttributes(const TAttributes& attributes, TIntermNode*);
#ifdef NV_EXTENSIONS
void resizeMeshViewDimension(const TSourceLoc&, TType&);
#endif
protected:
void nonInitConstCheck(const TSourceLoc&, TString& identifier, TType& type);
void inheritGlobalDefaults(TQualifier& dst) const;

View File

@ -700,6 +700,12 @@ void TScanContext::fillInKeywordMap()
(*KeywordMap)["resource"] = RESOURCE;
(*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->insert("common");
@ -1565,6 +1571,16 @@ int TScanContext::tokenizeIdentifier()
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:
parseContext.infoSink.info.message(EPrefixInternalError, "Unknown glslang keyword", loc);
return 0;

View File

@ -347,6 +347,18 @@ bool InitializeSymbolTables(TInfoSink& infoSink, TSymbolTable** commonTable, TS
InitializeStageSymbolTable(*builtInParseables, version, profile, spvVersion, EShLangCompute, source,
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;
}
@ -570,6 +582,16 @@ bool DeduceVersionProfile(TInfoSink& infoSink, EShLanguage stage, bool versionNo
version = profile == EEsProfile ? 310 : 420;
}
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:
break;
}

View File

@ -238,6 +238,7 @@ void TParseVersions::initializeExtensionBehavior()
extensionBehavior[E_GL_NV_fragment_shader_barycentric] = EBhDisable;
extensionBehavior[E_GL_NV_compute_shader_derivatives] = EBhDisable;
extensionBehavior[E_GL_NV_shader_texture_footprint] = EBhDisable;
extensionBehavior[E_GL_NV_mesh_shader] = EBhDisable;
#endif
// AEP
@ -411,6 +412,7 @@ void TParseVersions::getPreamble(std::string& preamble)
"#define GL_NV_fragment_shader_barycentric 1\n"
"#define GL_NV_compute_shader_derivatives 1\n"
"#define GL_NV_shader_texture_footprint 1\n"
"#define GL_NV_mesh_shader 1\n"
#endif
"#define GL_KHX_shader_explicit_arithmetic_types 1\n"
"#define GL_KHX_shader_explicit_arithmetic_types_int8 1\n"
@ -498,6 +500,10 @@ const char* StageName(EShLanguage stage)
case EShLangGeometry: return "geometry";
case EShLangFragment: return "fragment";
case EShLangCompute: return "compute";
#ifdef NV_EXTENSIONS
case EShLangMeshNV: return "mesh";
case EShLangTaskNV: return "task";
#endif
default: return "unknown stage";
}
}

View File

@ -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_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_mesh_shader = "GL_NV_mesh_shader";
// Arrays of extensions for the above viewportEXTs duplications
const char* const viewportEXTs[] = { E_GL_ARB_shader_viewport_layer_array, E_GL_NV_viewport_array2 };

View File

@ -146,7 +146,7 @@ extern int yylex(YYSTYPE*, TParseContext&);
%token <lex> F16VEC2 F16VEC3 F16VEC4 F16MAT2 F16MAT3 F16MAT4
%token <lex> F32VEC2 F32VEC3 F32VEC4 F32MAT2 F32MAT3 F32MAT4
%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> MAT3X2 MAT3X3 MAT3X4
@ -1152,6 +1152,30 @@ interpolation_qualifier
parseContext.profileRequires($1.loc, EEsProfile, 0, E_GL_NV_fragment_shader_barycentric, "fragment shader barycentric");
$$.init($1.loc);
$$.qualifier.pervertexNV = true;
#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
}
;
@ -1319,7 +1343,11 @@ storage_qualifier
parseContext.globalCheck($1.loc, "shared");
parseContext.profileRequires($1.loc, ECoreProfile | ECompatibilityProfile, 430, E_GL_ARB_compute_shader, "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");
#endif
$$.init($1.loc);
$$.qualifier.storage = EvqShared;
}

File diff suppressed because it is too large Load Diff

View File

@ -165,280 +165,283 @@ extern int yydebug;
LAYOUT = 375,
EXPLICITINTERPAMD = 376,
PERVERTEXNV = 377,
MAT2X2 = 378,
MAT2X3 = 379,
MAT2X4 = 380,
MAT3X2 = 381,
MAT3X3 = 382,
MAT3X4 = 383,
MAT4X2 = 384,
MAT4X3 = 385,
MAT4X4 = 386,
DMAT2X2 = 387,
DMAT2X3 = 388,
DMAT2X4 = 389,
DMAT3X2 = 390,
DMAT3X3 = 391,
DMAT3X4 = 392,
DMAT4X2 = 393,
DMAT4X3 = 394,
DMAT4X4 = 395,
F16MAT2X2 = 396,
F16MAT2X3 = 397,
F16MAT2X4 = 398,
F16MAT3X2 = 399,
F16MAT3X3 = 400,
F16MAT3X4 = 401,
F16MAT4X2 = 402,
F16MAT4X3 = 403,
F16MAT4X4 = 404,
F32MAT2X2 = 405,
F32MAT2X3 = 406,
F32MAT2X4 = 407,
F32MAT3X2 = 408,
F32MAT3X3 = 409,
F32MAT3X4 = 410,
F32MAT4X2 = 411,
F32MAT4X3 = 412,
F32MAT4X4 = 413,
F64MAT2X2 = 414,
F64MAT2X3 = 415,
F64MAT2X4 = 416,
F64MAT3X2 = 417,
F64MAT3X3 = 418,
F64MAT3X4 = 419,
F64MAT4X2 = 420,
F64MAT4X3 = 421,
F64MAT4X4 = 422,
ATOMIC_UINT = 423,
SAMPLER1D = 424,
SAMPLER2D = 425,
SAMPLER3D = 426,
SAMPLERCUBE = 427,
SAMPLER1DSHADOW = 428,
SAMPLER2DSHADOW = 429,
SAMPLERCUBESHADOW = 430,
SAMPLER1DARRAY = 431,
SAMPLER2DARRAY = 432,
SAMPLER1DARRAYSHADOW = 433,
SAMPLER2DARRAYSHADOW = 434,
ISAMPLER1D = 435,
ISAMPLER2D = 436,
ISAMPLER3D = 437,
ISAMPLERCUBE = 438,
ISAMPLER1DARRAY = 439,
ISAMPLER2DARRAY = 440,
USAMPLER1D = 441,
USAMPLER2D = 442,
USAMPLER3D = 443,
USAMPLERCUBE = 444,
USAMPLER1DARRAY = 445,
USAMPLER2DARRAY = 446,
SAMPLER2DRECT = 447,
SAMPLER2DRECTSHADOW = 448,
ISAMPLER2DRECT = 449,
USAMPLER2DRECT = 450,
SAMPLERBUFFER = 451,
ISAMPLERBUFFER = 452,
USAMPLERBUFFER = 453,
SAMPLERCUBEARRAY = 454,
SAMPLERCUBEARRAYSHADOW = 455,
ISAMPLERCUBEARRAY = 456,
USAMPLERCUBEARRAY = 457,
SAMPLER2DMS = 458,
ISAMPLER2DMS = 459,
USAMPLER2DMS = 460,
SAMPLER2DMSARRAY = 461,
ISAMPLER2DMSARRAY = 462,
USAMPLER2DMSARRAY = 463,
SAMPLEREXTERNALOES = 464,
F16SAMPLER1D = 465,
F16SAMPLER2D = 466,
F16SAMPLER3D = 467,
F16SAMPLER2DRECT = 468,
F16SAMPLERCUBE = 469,
F16SAMPLER1DARRAY = 470,
F16SAMPLER2DARRAY = 471,
F16SAMPLERCUBEARRAY = 472,
F16SAMPLERBUFFER = 473,
F16SAMPLER2DMS = 474,
F16SAMPLER2DMSARRAY = 475,
F16SAMPLER1DSHADOW = 476,
F16SAMPLER2DSHADOW = 477,
F16SAMPLER1DARRAYSHADOW = 478,
F16SAMPLER2DARRAYSHADOW = 479,
F16SAMPLER2DRECTSHADOW = 480,
F16SAMPLERCUBESHADOW = 481,
F16SAMPLERCUBEARRAYSHADOW = 482,
SAMPLER = 483,
SAMPLERSHADOW = 484,
TEXTURE1D = 485,
TEXTURE2D = 486,
TEXTURE3D = 487,
TEXTURECUBE = 488,
TEXTURE1DARRAY = 489,
TEXTURE2DARRAY = 490,
ITEXTURE1D = 491,
ITEXTURE2D = 492,
ITEXTURE3D = 493,
ITEXTURECUBE = 494,
ITEXTURE1DARRAY = 495,
ITEXTURE2DARRAY = 496,
UTEXTURE1D = 497,
UTEXTURE2D = 498,
UTEXTURE3D = 499,
UTEXTURECUBE = 500,
UTEXTURE1DARRAY = 501,
UTEXTURE2DARRAY = 502,
TEXTURE2DRECT = 503,
ITEXTURE2DRECT = 504,
UTEXTURE2DRECT = 505,
TEXTUREBUFFER = 506,
ITEXTUREBUFFER = 507,
UTEXTUREBUFFER = 508,
TEXTURECUBEARRAY = 509,
ITEXTURECUBEARRAY = 510,
UTEXTURECUBEARRAY = 511,
TEXTURE2DMS = 512,
ITEXTURE2DMS = 513,
UTEXTURE2DMS = 514,
TEXTURE2DMSARRAY = 515,
ITEXTURE2DMSARRAY = 516,
UTEXTURE2DMSARRAY = 517,
F16TEXTURE1D = 518,
F16TEXTURE2D = 519,
F16TEXTURE3D = 520,
F16TEXTURE2DRECT = 521,
F16TEXTURECUBE = 522,
F16TEXTURE1DARRAY = 523,
F16TEXTURE2DARRAY = 524,
F16TEXTURECUBEARRAY = 525,
F16TEXTUREBUFFER = 526,
F16TEXTURE2DMS = 527,
F16TEXTURE2DMSARRAY = 528,
SUBPASSINPUT = 529,
SUBPASSINPUTMS = 530,
ISUBPASSINPUT = 531,
ISUBPASSINPUTMS = 532,
USUBPASSINPUT = 533,
USUBPASSINPUTMS = 534,
F16SUBPASSINPUT = 535,
F16SUBPASSINPUTMS = 536,
IMAGE1D = 537,
IIMAGE1D = 538,
UIMAGE1D = 539,
IMAGE2D = 540,
IIMAGE2D = 541,
UIMAGE2D = 542,
IMAGE3D = 543,
IIMAGE3D = 544,
UIMAGE3D = 545,
IMAGE2DRECT = 546,
IIMAGE2DRECT = 547,
UIMAGE2DRECT = 548,
IMAGECUBE = 549,
IIMAGECUBE = 550,
UIMAGECUBE = 551,
IMAGEBUFFER = 552,
IIMAGEBUFFER = 553,
UIMAGEBUFFER = 554,
IMAGE1DARRAY = 555,
IIMAGE1DARRAY = 556,
UIMAGE1DARRAY = 557,
IMAGE2DARRAY = 558,
IIMAGE2DARRAY = 559,
UIMAGE2DARRAY = 560,
IMAGECUBEARRAY = 561,
IIMAGECUBEARRAY = 562,
UIMAGECUBEARRAY = 563,
IMAGE2DMS = 564,
IIMAGE2DMS = 565,
UIMAGE2DMS = 566,
IMAGE2DMSARRAY = 567,
IIMAGE2DMSARRAY = 568,
UIMAGE2DMSARRAY = 569,
F16IMAGE1D = 570,
F16IMAGE2D = 571,
F16IMAGE3D = 572,
F16IMAGE2DRECT = 573,
F16IMAGECUBE = 574,
F16IMAGE1DARRAY = 575,
F16IMAGE2DARRAY = 576,
F16IMAGECUBEARRAY = 577,
F16IMAGEBUFFER = 578,
F16IMAGE2DMS = 579,
F16IMAGE2DMSARRAY = 580,
STRUCT = 581,
VOID = 582,
WHILE = 583,
IDENTIFIER = 584,
TYPE_NAME = 585,
FLOATCONSTANT = 586,
DOUBLECONSTANT = 587,
INT16CONSTANT = 588,
UINT16CONSTANT = 589,
INT32CONSTANT = 590,
UINT32CONSTANT = 591,
INTCONSTANT = 592,
UINTCONSTANT = 593,
INT64CONSTANT = 594,
UINT64CONSTANT = 595,
BOOLCONSTANT = 596,
FLOAT16CONSTANT = 597,
LEFT_OP = 598,
RIGHT_OP = 599,
INC_OP = 600,
DEC_OP = 601,
LE_OP = 602,
GE_OP = 603,
EQ_OP = 604,
NE_OP = 605,
AND_OP = 606,
OR_OP = 607,
XOR_OP = 608,
MUL_ASSIGN = 609,
DIV_ASSIGN = 610,
ADD_ASSIGN = 611,
MOD_ASSIGN = 612,
LEFT_ASSIGN = 613,
RIGHT_ASSIGN = 614,
AND_ASSIGN = 615,
XOR_ASSIGN = 616,
OR_ASSIGN = 617,
SUB_ASSIGN = 618,
LEFT_PAREN = 619,
RIGHT_PAREN = 620,
LEFT_BRACKET = 621,
RIGHT_BRACKET = 622,
LEFT_BRACE = 623,
RIGHT_BRACE = 624,
DOT = 625,
COMMA = 626,
COLON = 627,
EQUAL = 628,
SEMICOLON = 629,
BANG = 630,
DASH = 631,
TILDE = 632,
PLUS = 633,
STAR = 634,
SLASH = 635,
PERCENT = 636,
LEFT_ANGLE = 637,
RIGHT_ANGLE = 638,
VERTICAL_BAR = 639,
CARET = 640,
AMPERSAND = 641,
QUESTION = 642,
INVARIANT = 643,
PRECISE = 644,
HIGH_PRECISION = 645,
MEDIUM_PRECISION = 646,
LOW_PRECISION = 647,
PRECISION = 648,
PACKED = 649,
RESOURCE = 650,
SUPERP = 651
PERPRIMITIVENV = 378,
PERVIEWNV = 379,
PERTASKNV = 380,
MAT2X2 = 381,
MAT2X3 = 382,
MAT2X4 = 383,
MAT3X2 = 384,
MAT3X3 = 385,
MAT3X4 = 386,
MAT4X2 = 387,
MAT4X3 = 388,
MAT4X4 = 389,
DMAT2X2 = 390,
DMAT2X3 = 391,
DMAT2X4 = 392,
DMAT3X2 = 393,
DMAT3X3 = 394,
DMAT3X4 = 395,
DMAT4X2 = 396,
DMAT4X3 = 397,
DMAT4X4 = 398,
F16MAT2X2 = 399,
F16MAT2X3 = 400,
F16MAT2X4 = 401,
F16MAT3X2 = 402,
F16MAT3X3 = 403,
F16MAT3X4 = 404,
F16MAT4X2 = 405,
F16MAT4X3 = 406,
F16MAT4X4 = 407,
F32MAT2X2 = 408,
F32MAT2X3 = 409,
F32MAT2X4 = 410,
F32MAT3X2 = 411,
F32MAT3X3 = 412,
F32MAT3X4 = 413,
F32MAT4X2 = 414,
F32MAT4X3 = 415,
F32MAT4X4 = 416,
F64MAT2X2 = 417,
F64MAT2X3 = 418,
F64MAT2X4 = 419,
F64MAT3X2 = 420,
F64MAT3X3 = 421,
F64MAT3X4 = 422,
F64MAT4X2 = 423,
F64MAT4X3 = 424,
F64MAT4X4 = 425,
ATOMIC_UINT = 426,
SAMPLER1D = 427,
SAMPLER2D = 428,
SAMPLER3D = 429,
SAMPLERCUBE = 430,
SAMPLER1DSHADOW = 431,
SAMPLER2DSHADOW = 432,
SAMPLERCUBESHADOW = 433,
SAMPLER1DARRAY = 434,
SAMPLER2DARRAY = 435,
SAMPLER1DARRAYSHADOW = 436,
SAMPLER2DARRAYSHADOW = 437,
ISAMPLER1D = 438,
ISAMPLER2D = 439,
ISAMPLER3D = 440,
ISAMPLERCUBE = 441,
ISAMPLER1DARRAY = 442,
ISAMPLER2DARRAY = 443,
USAMPLER1D = 444,
USAMPLER2D = 445,
USAMPLER3D = 446,
USAMPLERCUBE = 447,
USAMPLER1DARRAY = 448,
USAMPLER2DARRAY = 449,
SAMPLER2DRECT = 450,
SAMPLER2DRECTSHADOW = 451,
ISAMPLER2DRECT = 452,
USAMPLER2DRECT = 453,
SAMPLERBUFFER = 454,
ISAMPLERBUFFER = 455,
USAMPLERBUFFER = 456,
SAMPLERCUBEARRAY = 457,
SAMPLERCUBEARRAYSHADOW = 458,
ISAMPLERCUBEARRAY = 459,
USAMPLERCUBEARRAY = 460,
SAMPLER2DMS = 461,
ISAMPLER2DMS = 462,
USAMPLER2DMS = 463,
SAMPLER2DMSARRAY = 464,
ISAMPLER2DMSARRAY = 465,
USAMPLER2DMSARRAY = 466,
SAMPLEREXTERNALOES = 467,
F16SAMPLER1D = 468,
F16SAMPLER2D = 469,
F16SAMPLER3D = 470,
F16SAMPLER2DRECT = 471,
F16SAMPLERCUBE = 472,
F16SAMPLER1DARRAY = 473,
F16SAMPLER2DARRAY = 474,
F16SAMPLERCUBEARRAY = 475,
F16SAMPLERBUFFER = 476,
F16SAMPLER2DMS = 477,
F16SAMPLER2DMSARRAY = 478,
F16SAMPLER1DSHADOW = 479,
F16SAMPLER2DSHADOW = 480,
F16SAMPLER1DARRAYSHADOW = 481,
F16SAMPLER2DARRAYSHADOW = 482,
F16SAMPLER2DRECTSHADOW = 483,
F16SAMPLERCUBESHADOW = 484,
F16SAMPLERCUBEARRAYSHADOW = 485,
SAMPLER = 486,
SAMPLERSHADOW = 487,
TEXTURE1D = 488,
TEXTURE2D = 489,
TEXTURE3D = 490,
TEXTURECUBE = 491,
TEXTURE1DARRAY = 492,
TEXTURE2DARRAY = 493,
ITEXTURE1D = 494,
ITEXTURE2D = 495,
ITEXTURE3D = 496,
ITEXTURECUBE = 497,
ITEXTURE1DARRAY = 498,
ITEXTURE2DARRAY = 499,
UTEXTURE1D = 500,
UTEXTURE2D = 501,
UTEXTURE3D = 502,
UTEXTURECUBE = 503,
UTEXTURE1DARRAY = 504,
UTEXTURE2DARRAY = 505,
TEXTURE2DRECT = 506,
ITEXTURE2DRECT = 507,
UTEXTURE2DRECT = 508,
TEXTUREBUFFER = 509,
ITEXTUREBUFFER = 510,
UTEXTUREBUFFER = 511,
TEXTURECUBEARRAY = 512,
ITEXTURECUBEARRAY = 513,
UTEXTURECUBEARRAY = 514,
TEXTURE2DMS = 515,
ITEXTURE2DMS = 516,
UTEXTURE2DMS = 517,
TEXTURE2DMSARRAY = 518,
ITEXTURE2DMSARRAY = 519,
UTEXTURE2DMSARRAY = 520,
F16TEXTURE1D = 521,
F16TEXTURE2D = 522,
F16TEXTURE3D = 523,
F16TEXTURE2DRECT = 524,
F16TEXTURECUBE = 525,
F16TEXTURE1DARRAY = 526,
F16TEXTURE2DARRAY = 527,
F16TEXTURECUBEARRAY = 528,
F16TEXTUREBUFFER = 529,
F16TEXTURE2DMS = 530,
F16TEXTURE2DMSARRAY = 531,
SUBPASSINPUT = 532,
SUBPASSINPUTMS = 533,
ISUBPASSINPUT = 534,
ISUBPASSINPUTMS = 535,
USUBPASSINPUT = 536,
USUBPASSINPUTMS = 537,
F16SUBPASSINPUT = 538,
F16SUBPASSINPUTMS = 539,
IMAGE1D = 540,
IIMAGE1D = 541,
UIMAGE1D = 542,
IMAGE2D = 543,
IIMAGE2D = 544,
UIMAGE2D = 545,
IMAGE3D = 546,
IIMAGE3D = 547,
UIMAGE3D = 548,
IMAGE2DRECT = 549,
IIMAGE2DRECT = 550,
UIMAGE2DRECT = 551,
IMAGECUBE = 552,
IIMAGECUBE = 553,
UIMAGECUBE = 554,
IMAGEBUFFER = 555,
IIMAGEBUFFER = 556,
UIMAGEBUFFER = 557,
IMAGE1DARRAY = 558,
IIMAGE1DARRAY = 559,
UIMAGE1DARRAY = 560,
IMAGE2DARRAY = 561,
IIMAGE2DARRAY = 562,
UIMAGE2DARRAY = 563,
IMAGECUBEARRAY = 564,
IIMAGECUBEARRAY = 565,
UIMAGECUBEARRAY = 566,
IMAGE2DMS = 567,
IIMAGE2DMS = 568,
UIMAGE2DMS = 569,
IMAGE2DMSARRAY = 570,
IIMAGE2DMSARRAY = 571,
UIMAGE2DMSARRAY = 572,
F16IMAGE1D = 573,
F16IMAGE2D = 574,
F16IMAGE3D = 575,
F16IMAGE2DRECT = 576,
F16IMAGECUBE = 577,
F16IMAGE1DARRAY = 578,
F16IMAGE2DARRAY = 579,
F16IMAGECUBEARRAY = 580,
F16IMAGEBUFFER = 581,
F16IMAGE2DMS = 582,
F16IMAGE2DMSARRAY = 583,
STRUCT = 584,
VOID = 585,
WHILE = 586,
IDENTIFIER = 587,
TYPE_NAME = 588,
FLOATCONSTANT = 589,
DOUBLECONSTANT = 590,
INT16CONSTANT = 591,
UINT16CONSTANT = 592,
INT32CONSTANT = 593,
UINT32CONSTANT = 594,
INTCONSTANT = 595,
UINTCONSTANT = 596,
INT64CONSTANT = 597,
UINT64CONSTANT = 598,
BOOLCONSTANT = 599,
FLOAT16CONSTANT = 600,
LEFT_OP = 601,
RIGHT_OP = 602,
INC_OP = 603,
DEC_OP = 604,
LE_OP = 605,
GE_OP = 606,
EQ_OP = 607,
NE_OP = 608,
AND_OP = 609,
OR_OP = 610,
XOR_OP = 611,
MUL_ASSIGN = 612,
DIV_ASSIGN = 613,
ADD_ASSIGN = 614,
MOD_ASSIGN = 615,
LEFT_ASSIGN = 616,
RIGHT_ASSIGN = 617,
AND_ASSIGN = 618,
XOR_ASSIGN = 619,
OR_ASSIGN = 620,
SUB_ASSIGN = 621,
LEFT_PAREN = 622,
RIGHT_PAREN = 623,
LEFT_BRACKET = 624,
RIGHT_BRACKET = 625,
LEFT_BRACE = 626,
RIGHT_BRACE = 627,
DOT = 628,
COMMA = 629,
COLON = 630,
EQUAL = 631,
SEMICOLON = 632,
BANG = 633,
DASH = 634,
TILDE = 635,
PLUS = 636,
STAR = 637,
SLASH = 638,
PERCENT = 639,
LEFT_ANGLE = 640,
RIGHT_ANGLE = 641,
VERTICAL_BAR = 642,
CARET = 643,
AMPERSAND = 644,
QUESTION = 645,
INVARIANT = 646,
PRECISE = 647,
HIGH_PRECISION = 648,
MEDIUM_PRECISION = 649,
LOW_PRECISION = 650,
PRECISION = 651,
PACKED = 652,
RESOURCE = 653,
SUPERP = 654
};
#endif
@ -482,7 +485,7 @@ union YYSTYPE
};
} interm;
#line 486 "MachineIndependent/glslang_tab.cpp.h" /* yacc.c:1909 */
#line 489 "MachineIndependent/glslang_tab.cpp.h" /* yacc.c:1909 */
};
typedef union YYSTYPE YYSTYPE;

View File

@ -1048,6 +1048,10 @@ bool TOutputTraverser::visitAggregate(TVisit /* visit */, TIntermAggregate* node
case EOpSubpassLoad: out.debug << "subpassLoad"; 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");
}
@ -1451,6 +1455,16 @@ void TIntermediate::output(TInfoSink& infoSink, bool tree)
}
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:
infoSink.debug << "local_size = (" << localSize[0] << ", " << localSize[1] << ", " << localSize[2] << ")\n";
{

View File

@ -141,13 +141,27 @@ void TIntermediate::mergeModes(TInfoSink& infoSink, TIntermediate& unit)
if (vertices == TQualifier::layoutNotSet)
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");
else if (language == EShLangTessControl)
error(infoSink, "Contradictory layout vertices values");
else
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)
inputPrimitive = unit.inputPrimitive;
@ -266,6 +280,10 @@ void TIntermediate::mergeTrees(TInfoSink& infoSink, TIntermediate& unit)
// 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
TIntermSequence& globals = treeRoot->getAsAggregate()->getSequence();
TIntermSequence& unitGlobals = unit.treeRoot->getAsAggregate()->getSequence();
@ -690,6 +708,22 @@ void TIntermediate::finalCheck(TInfoSink& infoSink, bool keepUncalled)
break;
case EShLangCompute:
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:
error(infoSink, "Unknown Stage.");
break;
@ -960,7 +994,7 @@ int TIntermediate::addUsedLocation(const TQualifier& qualifier, const TType& typ
return -1;
int size;
if (qualifier.isUniformOrBuffer()) {
if (qualifier.isUniformOrBuffer() || qualifier.isTaskMemory()) {
if (type.isSizedArray())
size = type.getCumulativeArraySize();
else
@ -1111,11 +1145,20 @@ 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: are there valid cases of having an unsized array with a location? If so, running this code too early.
TType elementType(type, 0);
if (type.isSizedArray())
if (type.isSizedArray()
#ifdef NV_EXTENSIONS
&& !type.getQualifier().isPerView()
#endif
)
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);
}
}
// "The locations consumed by block and structure members are determined by applying the rules above
// recursively..."

View File

@ -237,6 +237,8 @@ public:
layoutOverrideCoverage(false),
geoPassthroughEXT(false),
computeDerivativeMode(LayoutDerivativeNone),
primitives(TQualifier::layoutNotSet),
numTaskNVBlocks(0),
#endif
autoMapBindings(false),
autoMapLocations(false),
@ -427,6 +429,10 @@ public:
int getNumEntryPoints() const { return numEntryPoints; }
int getNumErrors() const { return numErrors; }
void addPushConstantCount() { ++numPushConstants; }
#ifdef NV_EXTENSIONS
void addTaskNVCount() { ++numTaskNVBlocks; }
#endif
bool isRecursive() const { return recursive; }
TIntermSymbol* addSymbol(const TVariable&);
@ -636,6 +642,14 @@ public:
bool getGeoPassthroughEXT() const { return geoPassthroughEXT; }
void setLayoutDerivativeMode(ComputeDerivativeMode mode) { computeDerivativeMode = mode; }
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
const char* addSemanticName(const TString& name)
@ -740,6 +754,8 @@ protected:
bool layoutOverrideCoverage;
bool geoPassthroughEXT;
ComputeDerivativeMode computeDerivativeMode;
int primitives;
int numTaskNVBlocks;
#endif
// Base shift values

View File

@ -94,6 +94,10 @@ typedef enum {
EShLangGeometry,
EShLangFragment,
EShLangCompute,
#ifdef NV_EXTENSIONS
EShLangTaskNV,
EShLangMeshNV,
#endif
EShLangCount,
} EShLanguage; // would be better as stage, but this is ancient now
@ -104,6 +108,10 @@ typedef enum {
EShLangGeometryMask = (1 << EShLangGeometry),
EShLangFragmentMask = (1 << EShLangFragment),
EShLangComputeMask = (1 << EShLangCompute),
#ifdef NV_EXTENSIONS
EShLangTaskNVMask = (1 << EShLangTaskNV),
EShLangMeshNVMask = (1 << EShLangMeshNV),
#endif
} EShLanguageMask;
namespace glslang {

View File

@ -506,6 +506,13 @@ INSTANTIATE_TEST_CASE_P(
"spv.computeShaderDerivatives.comp",
"spv.computeShaderDerivatives2.comp",
"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
);

View File

@ -60,6 +60,12 @@ EShLanguage GetShaderStage(const std::string& stage)
return EShLangFragment;
} else if (stage == "comp") {
return EShLangCompute;
#ifdef NV_EXTENSIONS
} else if (stage == "task") {
return EShLangTaskNV;
} else if (stage == "mesh") {
return EShLangMeshNV;
#endif
} else {
assert(0 && "Unknown shader stage");
return EShLangCount;