spirv: only set LocalSizeId mode when necessary
SPIR-V 1.6 added the LocalSizeId execution mode that allows using spec constants for setting the work-group size, however it does not deprecate the LocalSize mode. This change causes the LocalSizeId mode to only be used when at least one of the workgroup size is actually specified with a spec constant. Fixes #3200
This commit is contained in:
committed by
arcady-lunarg
parent
4ce1a1a68d
commit
48f9ed8b08
@@ -1741,23 +1741,31 @@ TGlslangToSpvTraverser::TGlslangToSpvTraverser(unsigned int spvVersion,
|
||||
}
|
||||
break;
|
||||
|
||||
case EShLangCompute:
|
||||
case EShLangCompute: {
|
||||
builder.addCapability(spv::CapabilityShader);
|
||||
if (glslangIntermediate->getSpv().spv >= glslang::EShTargetSpv_1_6) {
|
||||
std::vector<spv::Id> dimConstId;
|
||||
for (int dim = 0; dim < 3; ++dim) {
|
||||
bool specConst = (glslangIntermediate->getLocalSizeSpecId(dim) != glslang::TQualifier::layoutNotSet);
|
||||
dimConstId.push_back(builder.makeUintConstant(glslangIntermediate->getLocalSize(dim), specConst));
|
||||
if (specConst) {
|
||||
builder.addDecoration(dimConstId.back(), spv::DecorationSpecId,
|
||||
glslangIntermediate->getLocalSizeSpecId(dim));
|
||||
bool needSizeId = false;
|
||||
for (int dim = 0; dim < 3; ++dim) {
|
||||
if ((glslangIntermediate->getLocalSizeSpecId(dim) != glslang::TQualifier::layoutNotSet)) {
|
||||
needSizeId = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
builder.addExecutionModeId(shaderEntry, spv::ExecutionModeLocalSizeId, dimConstId);
|
||||
}
|
||||
if (glslangIntermediate->getSpv().spv >= glslang::EShTargetSpv_1_6 && needSizeId) {
|
||||
std::vector<spv::Id> dimConstId;
|
||||
for (int dim = 0; dim < 3; ++dim) {
|
||||
bool specConst = (glslangIntermediate->getLocalSizeSpecId(dim) != glslang::TQualifier::layoutNotSet);
|
||||
dimConstId.push_back(builder.makeUintConstant(glslangIntermediate->getLocalSize(dim), specConst));
|
||||
if (specConst) {
|
||||
builder.addDecoration(dimConstId.back(), spv::DecorationSpecId,
|
||||
glslangIntermediate->getLocalSizeSpecId(dim));
|
||||
needSizeId = true;
|
||||
}
|
||||
}
|
||||
builder.addExecutionModeId(shaderEntry, spv::ExecutionModeLocalSizeId, dimConstId);
|
||||
} else {
|
||||
builder.addExecutionMode(shaderEntry, spv::ExecutionModeLocalSize, glslangIntermediate->getLocalSize(0),
|
||||
glslangIntermediate->getLocalSize(1),
|
||||
glslangIntermediate->getLocalSize(2));
|
||||
builder.addExecutionMode(shaderEntry, spv::ExecutionModeLocalSize, glslangIntermediate->getLocalSize(0),
|
||||
glslangIntermediate->getLocalSize(1),
|
||||
glslangIntermediate->getLocalSize(2));
|
||||
}
|
||||
if (glslangIntermediate->getLayoutDerivativeModeNone() == glslang::LayoutDerivativeGroupQuads) {
|
||||
builder.addCapability(spv::CapabilityComputeDerivativeGroupQuadsNV);
|
||||
@@ -1769,6 +1777,7 @@ TGlslangToSpvTraverser::TGlslangToSpvTraverser(unsigned int spvVersion,
|
||||
builder.addExtension(spv::E_SPV_NV_compute_shader_derivatives);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case EShLangTessEvaluation:
|
||||
case EShLangTessControl:
|
||||
builder.addCapability(spv::CapabilityTessellation);
|
||||
|
||||
Reference in New Issue
Block a user