Skip to content

Commit

Permalink
Allow compute derivative modes when the workgroup dimensions are spec…
Browse files Browse the repository at this point in the history
… constants
  • Loading branch information
jeffbolznv authored and arcady-lunarg committed Sep 12, 2024
1 parent f7f0f30 commit 708d560
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 11 deletions.
33 changes: 29 additions & 4 deletions Test/baseResults/spv.computeShaderDerivativesSpec.comp.out
Original file line number Diff line number Diff line change
@@ -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
33 changes: 29 additions & 4 deletions Test/baseResults/spv.computeShaderDerivativesSpec2.comp.out
Original file line number Diff line number Diff line change
@@ -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
9 changes: 6 additions & 3 deletions glslang/MachineIndependent/ParseHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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", "");
Expand Down

0 comments on commit 708d560

Please sign in to comment.