Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions SPIRV/GLSL.ext.KHR.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ static const char* const E_SPV_KHR_workgroup_memory_explicit_layout = "SPV_KHR_w
static const char* const E_SPV_KHR_subgroup_uniform_control_flow = "SPV_KHR_subgroup_uniform_control_flow";
static const char* const E_SPV_KHR_fragment_shader_barycentric = "SPV_KHR_fragment_shader_barycentric";
static const char* const E_SPV_KHR_quad_control = "SPV_KHR_quad_control";
static const char* const E_SPV_KHR_compute_shader_derivatives = "SPV_KHR_compute_shader_derivatives";
static const char* const E_SPV_AMD_shader_early_and_late_fragment_tests = "SPV_AMD_shader_early_and_late_fragment_tests";
static const char* const E_SPV_KHR_ray_tracing_position_fetch = "SPV_KHR_ray_tracing_position_fetch";
static const char* const E_SPV_KHR_cooperative_matrix = "SPV_KHR_cooperative_matrix";
Expand Down
41 changes: 30 additions & 11 deletions SPIRV/GlslangToSpv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,36 @@ struct OpDecorations {
void addNoContraction(spv::Builder& builder, spv::Id t) { builder.addDecoration(t, noContraction); }
void addNonUniform(spv::Builder& builder, spv::Id t) { builder.addDecoration(t, nonUniform); }
protected:
spv::Decoration noContraction;
spv::Decoration nonUniform;
spv::Decoration noContraction;
spv::Decoration nonUniform;
};

void addDerivativeGroupExecutionMode(spv::Builder& builder, const glslang::TIntermediate& intermediate,
spv::Function* shaderEntry)
{
if (intermediate.getLayoutDerivativeModeNone() == glslang::LayoutDerivativeGroupQuads) {
if (intermediate.getLayoutDerivativeExtension() == glslang::EdgKHR) {
builder.addCapability(spv::Capability::ComputeDerivativeGroupQuadsKHR);
builder.addExecutionMode(shaderEntry, spv::ExecutionMode::DerivativeGroupQuadsKHR);
builder.addExtension(spv::E_SPV_KHR_compute_shader_derivatives);
} else {
builder.addCapability(spv::Capability::ComputeDerivativeGroupQuadsNV);
builder.addExecutionMode(shaderEntry, spv::ExecutionMode::DerivativeGroupQuadsNV);
builder.addExtension(spv::E_SPV_NV_compute_shader_derivatives);
}
} else if (intermediate.getLayoutDerivativeModeNone() == glslang::LayoutDerivativeGroupLinear) {
if (intermediate.getLayoutDerivativeExtension() == glslang::EdgKHR) {
builder.addCapability(spv::Capability::ComputeDerivativeGroupLinearKHR);
builder.addExecutionMode(shaderEntry, spv::ExecutionMode::DerivativeGroupLinearKHR);
builder.addExtension(spv::E_SPV_KHR_compute_shader_derivatives);
} else {
builder.addCapability(spv::Capability::ComputeDerivativeGroupLinearNV);
builder.addExecutionMode(shaderEntry, spv::ExecutionMode::DerivativeGroupLinearNV);
builder.addExtension(spv::E_SPV_NV_compute_shader_derivatives);
}
}
}

} // namespace

//
Expand Down Expand Up @@ -1940,15 +1966,7 @@ TGlslangToSpvTraverser::TGlslangToSpvTraverser(unsigned int spvVersion,
glslangIntermediate->getLocalSize(2));
}
}
if (glslangIntermediate->getLayoutDerivativeModeNone() == glslang::LayoutDerivativeGroupQuads) {
builder.addCapability(spv::Capability::ComputeDerivativeGroupQuadsNV);
builder.addExecutionMode(shaderEntry, spv::ExecutionMode::DerivativeGroupQuadsNV);
builder.addExtension(spv::E_SPV_NV_compute_shader_derivatives);
} else if (glslangIntermediate->getLayoutDerivativeModeNone() == glslang::LayoutDerivativeGroupLinear) {
builder.addCapability(spv::Capability::ComputeDerivativeGroupLinearNV);
builder.addExecutionMode(shaderEntry, spv::ExecutionMode::DerivativeGroupLinearNV);
builder.addExtension(spv::E_SPV_NV_compute_shader_derivatives);
}
addDerivativeGroupExecutionMode(builder, *glslangIntermediate, shaderEntry);

if (glslangIntermediate->getNonCoherentTileAttachmentReadQCOM()) {
builder.addCapability(spv::Capability::TileShadingQCOM);
Expand Down Expand Up @@ -2085,6 +2103,7 @@ TGlslangToSpvTraverser::TGlslangToSpvTraverser(unsigned int spvVersion,
glslangIntermediate->getLocalSize(1),
glslangIntermediate->getLocalSize(2));
}
addDerivativeGroupExecutionMode(builder, *glslangIntermediate, shaderEntry);
if (glslangIntermediate->getStage() == EShLangMesh) {
builder.addExecutionMode(shaderEntry, spv::ExecutionMode::OutputVertices,
glslangIntermediate->getVertices());
Expand Down
13 changes: 9 additions & 4 deletions SPIRV/doc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,11 @@ const char* ExecutionModeString(int mode)
case (int)ExecutionMode::OutputLinesNV: return "OutputLinesNV";
case (int)ExecutionMode::OutputPrimitivesNV: return "OutputPrimitivesNV";
case (int)ExecutionMode::OutputTrianglesNV: return "OutputTrianglesNV";
case (int)ExecutionMode::DerivativeGroupQuadsNV: return "DerivativeGroupQuadsNV";
case (int)ExecutionMode::DerivativeGroupLinearNV: return "DerivativeGroupLinearNV";

// DerivativeGroupQuadsKHR is an alias of DerivativeGroupQuadsNV
case (int)ExecutionMode::DerivativeGroupQuadsKHR: return "DerivativeGroupQuadsKHR";
// DerivativeGroupLinearKHR is an alias of DerivativeGroupLinearNV
case (int)ExecutionMode::DerivativeGroupLinearKHR: return "DerivativeGroupLinearKHR";

case (int)ExecutionMode::PixelInterlockOrderedEXT: return "PixelInterlockOrderedEXT";
case (int)ExecutionMode::PixelInterlockUnorderedEXT: return "PixelInterlockUnorderedEXT";
Expand Down Expand Up @@ -1037,8 +1040,10 @@ const char* CapabilityString(int info)
case (int)Capability::RayTracingOpacityMicromapEXT: return "RayTracingOpacityMicromapEXT";
case (int)Capability::RayTracingDisplacementMicromapNV: return "RayTracingDisplacementMicromapNV";
case (int)Capability::RayQueryPositionFetchKHR: return "RayQueryPositionFetchKHR";
case (int)Capability::ComputeDerivativeGroupQuadsNV: return "ComputeDerivativeGroupQuadsNV";
case (int)Capability::ComputeDerivativeGroupLinearNV: return "ComputeDerivativeGroupLinearNV";
// ComputeDerivativeGroupQuadsKHR is an alias of ComputeDerivativeGroupQuadsNV
case (int)Capability::ComputeDerivativeGroupQuadsKHR: return "ComputeDerivativeGroupQuadsKHR";
// ComputeDerivativeGroupLinearKHR is an alias of ComputeDerivativeGroupLinearNV
case (int)Capability::ComputeDerivativeGroupLinearKHR: return "ComputeDerivativeGroupLinearKHR";
case (int)Capability::FragmentBarycentricKHR: return "FragmentBarycentricKHR";
case (int)Capability::MeshShadingNV: return "MeshShadingNV";
case (int)Capability::ImageFootprintNV: return "ImageFootprintNV";
Expand Down
74 changes: 64 additions & 10 deletions Test/baseResults/320.comp.out
Original file line number Diff line number Diff line change
@@ -1,14 +1,68 @@
320.comp
ERROR: 0:8: 'dFdx' : required extension not requested: GL_NV_compute_shader_derivatives
ERROR: 0:9: 'dFdy' : required extension not requested: GL_NV_compute_shader_derivatives
ERROR: 0:10: 'fwidth' : required extension not requested: GL_NV_compute_shader_derivatives
ERROR: 0:11: 'dFdxCoarse' : required extension not requested: GL_NV_compute_shader_derivatives
ERROR: 0:12: 'dFdyCoarse' : required extension not requested: GL_NV_compute_shader_derivatives
ERROR: 0:13: 'fwidthCoarse' : required extension not requested: GL_NV_compute_shader_derivatives
ERROR: 0:14: 'dFdxFine' : required extension not requested: GL_NV_compute_shader_derivatives
ERROR: 0:15: 'dFdyFine' : required extension not requested: GL_NV_compute_shader_derivatives
ERROR: 0:16: 'fwidthFine' : required extension not requested: GL_NV_compute_shader_derivatives
ERROR: 9 compilation errors. No code generated.
ERROR: 0:8: 'dFdx' : required extension not requested: Possible extensions include:
GL_NV_compute_shader_derivatives
GL_KHR_compute_shader_derivatives
ERROR: 0:8: 'dFdx' : required extension not requested: Possible extensions include:
GL_NV_compute_shader_derivatives
GL_KHR_compute_shader_derivatives
ERROR: 0:8: 'dFdx' : requires a derivative_group_quads* or derivative_group_linear* layout qualifier
ERROR: 0:9: 'dFdy' : required extension not requested: Possible extensions include:
GL_NV_compute_shader_derivatives
GL_KHR_compute_shader_derivatives
ERROR: 0:9: 'dFdy' : required extension not requested: Possible extensions include:
GL_NV_compute_shader_derivatives
GL_KHR_compute_shader_derivatives
ERROR: 0:9: 'dFdy' : requires a derivative_group_quads* or derivative_group_linear* layout qualifier
ERROR: 0:10: 'fwidth' : required extension not requested: Possible extensions include:
GL_NV_compute_shader_derivatives
GL_KHR_compute_shader_derivatives
ERROR: 0:10: 'fwidth' : required extension not requested: Possible extensions include:
GL_NV_compute_shader_derivatives
GL_KHR_compute_shader_derivatives
ERROR: 0:10: 'fwidth' : requires a derivative_group_quads* or derivative_group_linear* layout qualifier
ERROR: 0:11: 'dFdxCoarse' : required extension not requested: Possible extensions include:
GL_NV_compute_shader_derivatives
GL_KHR_compute_shader_derivatives
ERROR: 0:11: 'dFdxCoarse' : required extension not requested: Possible extensions include:
GL_NV_compute_shader_derivatives
GL_KHR_compute_shader_derivatives
ERROR: 0:11: 'dFdxCoarse' : requires a derivative_group_quads* or derivative_group_linear* layout qualifier
ERROR: 0:12: 'dFdyCoarse' : required extension not requested: Possible extensions include:
GL_NV_compute_shader_derivatives
GL_KHR_compute_shader_derivatives
ERROR: 0:12: 'dFdyCoarse' : required extension not requested: Possible extensions include:
GL_NV_compute_shader_derivatives
GL_KHR_compute_shader_derivatives
ERROR: 0:12: 'dFdyCoarse' : requires a derivative_group_quads* or derivative_group_linear* layout qualifier
ERROR: 0:13: 'fwidthCoarse' : required extension not requested: Possible extensions include:
GL_NV_compute_shader_derivatives
GL_KHR_compute_shader_derivatives
ERROR: 0:13: 'fwidthCoarse' : required extension not requested: Possible extensions include:
GL_NV_compute_shader_derivatives
GL_KHR_compute_shader_derivatives
ERROR: 0:13: 'fwidthCoarse' : requires a derivative_group_quads* or derivative_group_linear* layout qualifier
ERROR: 0:14: 'dFdxFine' : required extension not requested: Possible extensions include:
GL_NV_compute_shader_derivatives
GL_KHR_compute_shader_derivatives
ERROR: 0:14: 'dFdxFine' : required extension not requested: Possible extensions include:
GL_NV_compute_shader_derivatives
GL_KHR_compute_shader_derivatives
ERROR: 0:14: 'dFdxFine' : requires a derivative_group_quads* or derivative_group_linear* layout qualifier
ERROR: 0:15: 'dFdyFine' : required extension not requested: Possible extensions include:
GL_NV_compute_shader_derivatives
GL_KHR_compute_shader_derivatives
ERROR: 0:15: 'dFdyFine' : required extension not requested: Possible extensions include:
GL_NV_compute_shader_derivatives
GL_KHR_compute_shader_derivatives
ERROR: 0:15: 'dFdyFine' : requires a derivative_group_quads* or derivative_group_linear* layout qualifier
ERROR: 0:16: 'fwidthFine' : required extension not requested: Possible extensions include:
GL_NV_compute_shader_derivatives
GL_KHR_compute_shader_derivatives
ERROR: 0:16: 'fwidthFine' : required extension not requested: Possible extensions include:
GL_NV_compute_shader_derivatives
GL_KHR_compute_shader_derivatives
ERROR: 0:16: 'fwidthFine' : requires a derivative_group_quads* or derivative_group_linear* layout qualifier
ERROR: 27 compilation errors. No code generated.


Shader version: 320
Expand Down
4 changes: 2 additions & 2 deletions Test/baseResults/spv.computeShaderDerivatives.comp.out
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ spv.computeShaderDerivatives.comp

Capability Shader
Capability DerivativeControl
Capability ComputeDerivativeGroupQuadsNV
Capability ComputeDerivativeGroupQuadsKHR
Extension "SPV_NV_compute_shader_derivatives"
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint GLCompute 4 "main"
ExecutionMode 4 LocalSize 2 4 1
ExecutionMode 4 DerivativeGroupQuadsNV
ExecutionMode 4 DerivativeGroupQuadsKHR
Source GLSL 450
SourceExtension "GL_NV_compute_shader_derivatives"
Name 4 "main"
Expand Down
4 changes: 2 additions & 2 deletions Test/baseResults/spv.computeShaderDerivatives2.comp.out
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ spv.computeShaderDerivatives2.comp

Capability Shader
Capability DerivativeControl
Capability ComputeDerivativeGroupLinearNV
Capability ComputeDerivativeGroupLinearKHR
Extension "SPV_NV_compute_shader_derivatives"
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint GLCompute 4 "main"
ExecutionMode 4 LocalSize 2 4 1
ExecutionMode 4 DerivativeGroupLinearNV
ExecutionMode 4 DerivativeGroupLinearKHR
Source ESSL 320
SourceExtension "GL_NV_compute_shader_derivatives"
Name 4 "main"
Expand Down
4 changes: 2 additions & 2 deletions Test/baseResults/spv.computeShaderDerivativesSpec.comp.out
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ spv.computeShaderDerivativesSpec.comp
// Id's are bound by 12

Capability Shader
Capability ComputeDerivativeGroupQuadsNV
Capability ComputeDerivativeGroupQuadsKHR
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
ExecutionMode 4 DerivativeGroupQuadsKHR
Source GLSL 450
SourceExtension "GL_NV_compute_shader_derivatives"
Name 4 "main"
Expand Down
4 changes: 2 additions & 2 deletions Test/baseResults/spv.computeShaderDerivativesSpec2.comp.out
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ spv.computeShaderDerivativesSpec2.comp
// Id's are bound by 12

Capability Shader
Capability ComputeDerivativeGroupLinearNV
Capability ComputeDerivativeGroupLinearKHR
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
ExecutionMode 4 DerivativeGroupLinearKHR
Source ESSL 320
SourceExtension "GL_NV_compute_shader_derivatives"
Name 4 "main"
Expand Down
Loading