Allow compute derivative modes when the workgroup dimensions are spec constants

This commit is contained in:
Jeff Bolz 2024-09-12 12:25:07 -05:00 committed by arcady-lunarg
parent f7f0f3067c
commit 708d560c23
3 changed files with 64 additions and 11 deletions

View File

@ -1,6 +1,31 @@
spv.computeShaderDerivativesSpec.comp
ERROR: 0:5: 'derivative_group_quadsNV' : requires local_size_x and local_size_y to be multiple of two
ERROR: 1 compilation errors. No code generated.
// Module Version 10000
// Generated by (magic number): 8000b
// Id's are bound by 12
SPIR-V is not generated for failed compile or link
Capability Shader
Capability ComputeDerivativeGroupQuadsNV
Extension "SPV_NV_compute_shader_derivatives"
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint GLCompute 4 "main"
ExecutionMode 4 LocalSize 1 1 1
ExecutionMode 4 DerivativeGroupQuadsNV
Source GLSL 450
SourceExtension "GL_NV_compute_shader_derivatives"
Name 4 "main"
Decorate 7 SpecId 0
Decorate 8 SpecId 1
Decorate 11 BuiltIn WorkgroupSize
2: TypeVoid
3: TypeFunction 2
6: TypeInt 32 0
7: 6(int) SpecConstant 1
8: 6(int) SpecConstant 1
9: 6(int) Constant 1
10: TypeVector 6(int) 3
11: 10(ivec3) SpecConstantComposite 7 8 9
4(main): 2 Function None 3
5: Label
Return
FunctionEnd

View File

@ -1,6 +1,31 @@
spv.computeShaderDerivativesSpec2.comp
ERROR: 0:5: 'derivative_group_linearNV' : requires total group size to be multiple of four
ERROR: 1 compilation errors. No code generated.
// Module Version 10000
// Generated by (magic number): 8000b
// Id's are bound by 12
SPIR-V is not generated for failed compile or link
Capability Shader
Capability ComputeDerivativeGroupLinearNV
Extension "SPV_NV_compute_shader_derivatives"
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint GLCompute 4 "main"
ExecutionMode 4 LocalSize 1 1 1
ExecutionMode 4 DerivativeGroupLinearNV
Source ESSL 320
SourceExtension "GL_NV_compute_shader_derivatives"
Name 4 "main"
Decorate 7 SpecId 0
Decorate 8 SpecId 1
Decorate 11 BuiltIn WorkgroupSize
2: TypeVoid
3: TypeFunction 2
6: TypeInt 32 0
7: 6(int) SpecConstant 1
8: 6(int) SpecConstant 1
9: 6(int) Constant 1
10: TypeVector 6(int) 3
11: 10(ivec3) SpecConstantComposite 7 8 9
4(main): 2 Function None 3
5: Label
Return
FunctionEnd

View File

@ -9924,8 +9924,8 @@ void TParseContext::updateStandaloneQualifierDefaults(const TSourceLoc& loc, con
if (publicType.shaderQualifiers.layoutDerivativeGroupQuads) {
if (publicType.qualifier.storage == EvqVaryingIn) {
if ((intermediate.getLocalSize(0) & 1) ||
(intermediate.getLocalSize(1) & 1))
if ((intermediate.getLocalSizeSpecId(0) == TQualifier::layoutNotSet && (intermediate.getLocalSize(0) & 1)) ||
(intermediate.getLocalSizeSpecId(1) == TQualifier::layoutNotSet && (intermediate.getLocalSize(1) & 1)))
error(loc, "requires local_size_x and local_size_y to be multiple of two", "derivative_group_quadsNV", "");
else
intermediate.setLayoutDerivativeMode(LayoutDerivativeGroupQuads);
@ -9935,7 +9935,10 @@ void TParseContext::updateStandaloneQualifierDefaults(const TSourceLoc& loc, con
}
if (publicType.shaderQualifiers.layoutDerivativeGroupLinear) {
if (publicType.qualifier.storage == EvqVaryingIn) {
if((intermediate.getLocalSize(0) *
if (intermediate.getLocalSizeSpecId(0) == TQualifier::layoutNotSet &&
intermediate.getLocalSizeSpecId(1) == TQualifier::layoutNotSet &&
intermediate.getLocalSizeSpecId(2) == TQualifier::layoutNotSet &&
(intermediate.getLocalSize(0) *
intermediate.getLocalSize(1) *
intermediate.getLocalSize(2)) % 4 != 0)
error(loc, "requires total group size to be multiple of four", "derivative_group_linearNV", "");