diff --git a/SPIRV/GLSL.ext.KHR.h b/SPIRV/GLSL.ext.KHR.h index de8896d16d..bfd4a33702 100644 --- a/SPIRV/GLSL.ext.KHR.h +++ b/SPIRV/GLSL.ext.KHR.h @@ -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"; diff --git a/SPIRV/GlslangToSpv.cpp b/SPIRV/GlslangToSpv.cpp index 9dbd527ddd..59957ff20f 100644 --- a/SPIRV/GlslangToSpv.cpp +++ b/SPIRV/GlslangToSpv.cpp @@ -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 // @@ -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); @@ -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()); diff --git a/SPIRV/doc.cpp b/SPIRV/doc.cpp index f81faefabd..c8aa255999 100644 --- a/SPIRV/doc.cpp +++ b/SPIRV/doc.cpp @@ -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"; @@ -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"; diff --git a/Test/baseResults/320.comp.out b/Test/baseResults/320.comp.out index 00865be412..307e3ec18a 100644 --- a/Test/baseResults/320.comp.out +++ b/Test/baseResults/320.comp.out @@ -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 diff --git a/Test/baseResults/spv.computeShaderDerivatives.comp.out b/Test/baseResults/spv.computeShaderDerivatives.comp.out index 789e05ea21..1e72fd7b48 100644 --- a/Test/baseResults/spv.computeShaderDerivatives.comp.out +++ b/Test/baseResults/spv.computeShaderDerivatives.comp.out @@ -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" diff --git a/Test/baseResults/spv.computeShaderDerivatives2.comp.out b/Test/baseResults/spv.computeShaderDerivatives2.comp.out index a520fc3e48..3afce246fb 100644 --- a/Test/baseResults/spv.computeShaderDerivatives2.comp.out +++ b/Test/baseResults/spv.computeShaderDerivatives2.comp.out @@ -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" diff --git a/Test/baseResults/spv.computeShaderDerivativesSpec.comp.out b/Test/baseResults/spv.computeShaderDerivativesSpec.comp.out index e4afc6f5c1..b008b157e1 100644 --- a/Test/baseResults/spv.computeShaderDerivativesSpec.comp.out +++ b/Test/baseResults/spv.computeShaderDerivativesSpec.comp.out @@ -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" diff --git a/Test/baseResults/spv.computeShaderDerivativesSpec2.comp.out b/Test/baseResults/spv.computeShaderDerivativesSpec2.comp.out index a3b38cafdd..5c31ea1fdd 100644 --- a/Test/baseResults/spv.computeShaderDerivativesSpec2.comp.out +++ b/Test/baseResults/spv.computeShaderDerivativesSpec2.comp.out @@ -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" diff --git a/Test/baseResults/spv.khrComputeShaderDerivatives.comp.out b/Test/baseResults/spv.khrComputeShaderDerivatives.comp.out new file mode 100644 index 0000000000..437608fc01 --- /dev/null +++ b/Test/baseResults/spv.khrComputeShaderDerivatives.comp.out @@ -0,0 +1,383 @@ +spv.khrComputeShaderDerivatives.comp +// Module Version 10400 +// Generated by (magic number): 8000b +// Id's are bound by 226 + + Capability Shader + Capability ImageQuery + Capability DerivativeControl + Capability ComputeDerivativeGroupQuadsKHR + Extension "SPV_KHR_compute_shader_derivatives" + 1: ExtInstImport "GLSL.std.450" + MemoryModel Logical GLSL450 + EntryPoint GLCompute 4 "main" 12 210 + ExecutionMode 4 LocalSize 2 2 1 + ExecutionMode 4 DerivativeGroupQuadsKHR + Source GLSL 450 + SourceExtension "GL_KHR_compute_shader_derivatives" + Name 4 "main" + Name 10 "block" + MemberName 10(block) 0 "fDerivativeX" + MemberName 10(block) 1 "fDerivativeY" + MemberName 10(block) 2 "fDerivativeWidth" + MemberName 10(block) 3 "fCoarseDerivativeX" + MemberName 10(block) 4 "fCoarseDerivativeY" + MemberName 10(block) 5 "fCoarseDerivativeWidth" + MemberName 10(block) 6 "fFineDerivativeX" + MemberName 10(block) 7 "fFineDerivativeY" + MemberName 10(block) 8 "fFineDerivativeWidth" + MemberName 10(block) 9 "fX" + MemberName 10(block) 10 "fY" + MemberName 10(block) 11 "v2DerivativeX" + MemberName 10(block) 12 "v2DerivativeY" + MemberName 10(block) 13 "v2DerivativeWidth" + MemberName 10(block) 14 "v2CoarseDerivativeX" + MemberName 10(block) 15 "v2CoarseDerivativeY" + MemberName 10(block) 16 "v2CoarseDerivativeWidth" + MemberName 10(block) 17 "v2FineDerivativeX" + MemberName 10(block) 18 "v2FineDerivativeY" + MemberName 10(block) 19 "v2FineDerivativeWidth" + MemberName 10(block) 20 "v2X" + MemberName 10(block) 21 "v2Y" + MemberName 10(block) 22 "v3DerivativeX" + MemberName 10(block) 23 "v3DerivativeY" + MemberName 10(block) 24 "v3DerivativeWidth" + MemberName 10(block) 25 "v3CoarseDerivativeX" + MemberName 10(block) 26 "v3CoarseDerivativeY" + MemberName 10(block) 27 "v3CoarseDerivativeWidth" + MemberName 10(block) 28 "v3FineDerivativeX" + MemberName 10(block) 29 "v3FineDerivativeY" + MemberName 10(block) 30 "v3FineDerivativeWidth" + MemberName 10(block) 31 "v3X" + MemberName 10(block) 32 "v3Y" + MemberName 10(block) 33 "v4DerivativeX" + MemberName 10(block) 34 "v4DerivativeY" + MemberName 10(block) 35 "v4DerivativeWidth" + MemberName 10(block) 36 "v4CoarseDerivativeX" + MemberName 10(block) 37 "v4CoarseDerivativeY" + MemberName 10(block) 38 "v4CoarseDerivativeWidth" + MemberName 10(block) 39 "v4FineDerivativeX" + MemberName 10(block) 40 "v4FineDerivativeY" + MemberName 10(block) 41 "v4FineDerivativeWidth" + MemberName 10(block) 42 "v4X" + MemberName 10(block) 43 "v4Y" + MemberName 10(block) 44 "color" + MemberName 10(block) 45 "lod" + Name 12 "" + Name 210 "tex" + Decorate 10(block) Block + MemberDecorate 10(block) 0 Offset 0 + MemberDecorate 10(block) 1 Offset 4 + MemberDecorate 10(block) 2 Offset 8 + MemberDecorate 10(block) 3 Offset 12 + MemberDecorate 10(block) 4 Offset 16 + MemberDecorate 10(block) 5 Offset 20 + MemberDecorate 10(block) 6 Offset 24 + MemberDecorate 10(block) 7 Offset 28 + MemberDecorate 10(block) 8 Offset 32 + MemberDecorate 10(block) 9 Offset 36 + MemberDecorate 10(block) 10 Offset 40 + MemberDecorate 10(block) 11 Offset 48 + MemberDecorate 10(block) 12 Offset 56 + MemberDecorate 10(block) 13 Offset 64 + MemberDecorate 10(block) 14 Offset 72 + MemberDecorate 10(block) 15 Offset 80 + MemberDecorate 10(block) 16 Offset 88 + MemberDecorate 10(block) 17 Offset 96 + MemberDecorate 10(block) 18 Offset 104 + MemberDecorate 10(block) 19 Offset 112 + MemberDecorate 10(block) 20 Offset 120 + MemberDecorate 10(block) 21 Offset 128 + MemberDecorate 10(block) 22 Offset 144 + MemberDecorate 10(block) 23 Offset 160 + MemberDecorate 10(block) 24 Offset 176 + MemberDecorate 10(block) 25 Offset 192 + MemberDecorate 10(block) 26 Offset 208 + MemberDecorate 10(block) 27 Offset 224 + MemberDecorate 10(block) 28 Offset 240 + MemberDecorate 10(block) 29 Offset 256 + MemberDecorate 10(block) 30 Offset 272 + MemberDecorate 10(block) 31 Offset 288 + MemberDecorate 10(block) 32 Offset 304 + MemberDecorate 10(block) 33 Offset 320 + MemberDecorate 10(block) 34 Offset 336 + MemberDecorate 10(block) 35 Offset 352 + MemberDecorate 10(block) 36 Offset 368 + MemberDecorate 10(block) 37 Offset 384 + MemberDecorate 10(block) 38 Offset 400 + MemberDecorate 10(block) 39 Offset 416 + MemberDecorate 10(block) 40 Offset 432 + MemberDecorate 10(block) 41 Offset 448 + MemberDecorate 10(block) 42 Offset 464 + MemberDecorate 10(block) 43 Offset 480 + MemberDecorate 10(block) 44 Offset 496 + MemberDecorate 10(block) 45 Offset 512 + Decorate 12 Binding 1 + Decorate 12 DescriptorSet 0 + Decorate 210(tex) Binding 0 + Decorate 210(tex) DescriptorSet 0 + Decorate 225 BuiltIn WorkgroupSize + 2: TypeVoid + 3: TypeFunction 2 + 6: TypeFloat 32 + 7: TypeVector 6(float) 2 + 8: TypeVector 6(float) 3 + 9: TypeVector 6(float) 4 + 10(block): TypeStruct 6(float) 6(float) 6(float) 6(float) 6(float) 6(float) 6(float) 6(float) 6(float) 6(float) 6(float) 7(fvec2) 7(fvec2) 7(fvec2) 7(fvec2) 7(fvec2) 7(fvec2) 7(fvec2) 7(fvec2) 7(fvec2) 7(fvec2) 7(fvec2) 8(fvec3) 8(fvec3) 8(fvec3) 8(fvec3) 8(fvec3) 8(fvec3) 8(fvec3) 8(fvec3) 8(fvec3) 8(fvec3) 8(fvec3) 9(fvec4) 9(fvec4) 9(fvec4) 9(fvec4) 9(fvec4) 9(fvec4) 9(fvec4) 9(fvec4) 9(fvec4) 9(fvec4) 9(fvec4) 9(fvec4) 7(fvec2) + 11: TypePointer StorageBuffer 10(block) + 12: 11(ptr) Variable StorageBuffer + 13: TypeInt 32 1 + 14: 13(int) Constant 0 + 15: 13(int) Constant 9 + 16: TypePointer StorageBuffer 6(float) + 21: 13(int) Constant 1 + 22: 13(int) Constant 10 + 27: 13(int) Constant 2 + 32: 13(int) Constant 3 + 37: 13(int) Constant 4 + 42: 13(int) Constant 5 + 47: 13(int) Constant 6 + 52: 13(int) Constant 7 + 57: 13(int) Constant 8 + 62: 13(int) Constant 11 + 63: 13(int) Constant 20 + 64: TypePointer StorageBuffer 7(fvec2) + 69: 13(int) Constant 12 + 70: 13(int) Constant 21 + 75: 13(int) Constant 13 + 80: 13(int) Constant 14 + 85: 13(int) Constant 15 + 90: 13(int) Constant 16 + 95: 13(int) Constant 17 + 100: 13(int) Constant 18 + 105: 13(int) Constant 19 + 110: 13(int) Constant 22 + 111: 13(int) Constant 31 + 112: TypePointer StorageBuffer 8(fvec3) + 117: 13(int) Constant 23 + 118: 13(int) Constant 32 + 123: 13(int) Constant 24 + 128: 13(int) Constant 25 + 133: 13(int) Constant 26 + 138: 13(int) Constant 27 + 143: 13(int) Constant 28 + 148: 13(int) Constant 29 + 153: 13(int) Constant 30 + 158: 13(int) Constant 33 + 159: 13(int) Constant 42 + 160: TypePointer StorageBuffer 9(fvec4) + 165: 13(int) Constant 34 + 166: 13(int) Constant 43 + 171: 13(int) Constant 35 + 176: 13(int) Constant 36 + 181: 13(int) Constant 37 + 186: 13(int) Constant 38 + 191: 13(int) Constant 39 + 196: 13(int) Constant 40 + 201: 13(int) Constant 41 + 206: 13(int) Constant 44 + 207: TypeImage 6(float) 2D sampled format:Unknown + 208: TypeSampledImage 207 + 209: TypePointer UniformConstant 208 + 210(tex): 209(ptr) Variable UniformConstant + 212: 6(float) Constant 1056964608 + 213: 7(fvec2) ConstantComposite 212 212 + 214: 6(float) Constant 1048576000 + 217: 13(int) Constant 45 + 221: TypeInt 32 0 + 222: TypeVector 221(int) 3 + 223: 221(int) Constant 2 + 224: 221(int) Constant 1 + 225: 222(ivec3) ConstantComposite 223 223 224 + 4(main): 2 Function None 3 + 5: Label + 17: 16(ptr) AccessChain 12 15 + 18: 6(float) Load 17 + 19: 6(float) DPdx 18 + 20: 16(ptr) AccessChain 12 14 + Store 20 19 + 23: 16(ptr) AccessChain 12 22 + 24: 6(float) Load 23 + 25: 6(float) DPdy 24 + 26: 16(ptr) AccessChain 12 21 + Store 26 25 + 28: 16(ptr) AccessChain 12 15 + 29: 6(float) Load 28 + 30: 6(float) Fwidth 29 + 31: 16(ptr) AccessChain 12 27 + Store 31 30 + 33: 16(ptr) AccessChain 12 15 + 34: 6(float) Load 33 + 35: 6(float) DPdxCoarse 34 + 36: 16(ptr) AccessChain 12 32 + Store 36 35 + 38: 16(ptr) AccessChain 12 22 + 39: 6(float) Load 38 + 40: 6(float) DPdyCoarse 39 + 41: 16(ptr) AccessChain 12 37 + Store 41 40 + 43: 16(ptr) AccessChain 12 15 + 44: 6(float) Load 43 + 45: 6(float) FwidthCoarse 44 + 46: 16(ptr) AccessChain 12 42 + Store 46 45 + 48: 16(ptr) AccessChain 12 15 + 49: 6(float) Load 48 + 50: 6(float) DPdxFine 49 + 51: 16(ptr) AccessChain 12 47 + Store 51 50 + 53: 16(ptr) AccessChain 12 22 + 54: 6(float) Load 53 + 55: 6(float) DPdyFine 54 + 56: 16(ptr) AccessChain 12 52 + Store 56 55 + 58: 16(ptr) AccessChain 12 15 + 59: 6(float) Load 58 + 60: 6(float) FwidthFine 59 + 61: 16(ptr) AccessChain 12 57 + Store 61 60 + 65: 64(ptr) AccessChain 12 63 + 66: 7(fvec2) Load 65 + 67: 7(fvec2) DPdx 66 + 68: 64(ptr) AccessChain 12 62 + Store 68 67 + 71: 64(ptr) AccessChain 12 70 + 72: 7(fvec2) Load 71 + 73: 7(fvec2) DPdy 72 + 74: 64(ptr) AccessChain 12 69 + Store 74 73 + 76: 64(ptr) AccessChain 12 63 + 77: 7(fvec2) Load 76 + 78: 7(fvec2) Fwidth 77 + 79: 64(ptr) AccessChain 12 75 + Store 79 78 + 81: 64(ptr) AccessChain 12 63 + 82: 7(fvec2) Load 81 + 83: 7(fvec2) DPdxCoarse 82 + 84: 64(ptr) AccessChain 12 80 + Store 84 83 + 86: 64(ptr) AccessChain 12 70 + 87: 7(fvec2) Load 86 + 88: 7(fvec2) DPdyCoarse 87 + 89: 64(ptr) AccessChain 12 85 + Store 89 88 + 91: 64(ptr) AccessChain 12 63 + 92: 7(fvec2) Load 91 + 93: 7(fvec2) FwidthCoarse 92 + 94: 64(ptr) AccessChain 12 90 + Store 94 93 + 96: 64(ptr) AccessChain 12 63 + 97: 7(fvec2) Load 96 + 98: 7(fvec2) DPdxFine 97 + 99: 64(ptr) AccessChain 12 95 + Store 99 98 + 101: 64(ptr) AccessChain 12 70 + 102: 7(fvec2) Load 101 + 103: 7(fvec2) DPdyFine 102 + 104: 64(ptr) AccessChain 12 100 + Store 104 103 + 106: 64(ptr) AccessChain 12 63 + 107: 7(fvec2) Load 106 + 108: 7(fvec2) FwidthFine 107 + 109: 64(ptr) AccessChain 12 105 + Store 109 108 + 113: 112(ptr) AccessChain 12 111 + 114: 8(fvec3) Load 113 + 115: 8(fvec3) DPdx 114 + 116: 112(ptr) AccessChain 12 110 + Store 116 115 + 119: 112(ptr) AccessChain 12 118 + 120: 8(fvec3) Load 119 + 121: 8(fvec3) DPdy 120 + 122: 112(ptr) AccessChain 12 117 + Store 122 121 + 124: 112(ptr) AccessChain 12 111 + 125: 8(fvec3) Load 124 + 126: 8(fvec3) Fwidth 125 + 127: 112(ptr) AccessChain 12 123 + Store 127 126 + 129: 112(ptr) AccessChain 12 111 + 130: 8(fvec3) Load 129 + 131: 8(fvec3) DPdxCoarse 130 + 132: 112(ptr) AccessChain 12 128 + Store 132 131 + 134: 112(ptr) AccessChain 12 118 + 135: 8(fvec3) Load 134 + 136: 8(fvec3) DPdyCoarse 135 + 137: 112(ptr) AccessChain 12 133 + Store 137 136 + 139: 112(ptr) AccessChain 12 111 + 140: 8(fvec3) Load 139 + 141: 8(fvec3) FwidthCoarse 140 + 142: 112(ptr) AccessChain 12 138 + Store 142 141 + 144: 112(ptr) AccessChain 12 111 + 145: 8(fvec3) Load 144 + 146: 8(fvec3) DPdxFine 145 + 147: 112(ptr) AccessChain 12 143 + Store 147 146 + 149: 112(ptr) AccessChain 12 118 + 150: 8(fvec3) Load 149 + 151: 8(fvec3) DPdyFine 150 + 152: 112(ptr) AccessChain 12 148 + Store 152 151 + 154: 112(ptr) AccessChain 12 111 + 155: 8(fvec3) Load 154 + 156: 8(fvec3) FwidthFine 155 + 157: 112(ptr) AccessChain 12 153 + Store 157 156 + 161: 160(ptr) AccessChain 12 159 + 162: 9(fvec4) Load 161 + 163: 9(fvec4) DPdx 162 + 164: 160(ptr) AccessChain 12 158 + Store 164 163 + 167: 160(ptr) AccessChain 12 166 + 168: 9(fvec4) Load 167 + 169: 9(fvec4) DPdy 168 + 170: 160(ptr) AccessChain 12 165 + Store 170 169 + 172: 160(ptr) AccessChain 12 159 + 173: 9(fvec4) Load 172 + 174: 9(fvec4) Fwidth 173 + 175: 160(ptr) AccessChain 12 171 + Store 175 174 + 177: 160(ptr) AccessChain 12 159 + 178: 9(fvec4) Load 177 + 179: 9(fvec4) DPdxCoarse 178 + 180: 160(ptr) AccessChain 12 176 + Store 180 179 + 182: 160(ptr) AccessChain 12 166 + 183: 9(fvec4) Load 182 + 184: 9(fvec4) DPdyCoarse 183 + 185: 160(ptr) AccessChain 12 181 + Store 185 184 + 187: 160(ptr) AccessChain 12 159 + 188: 9(fvec4) Load 187 + 189: 9(fvec4) FwidthCoarse 188 + 190: 160(ptr) AccessChain 12 186 + Store 190 189 + 192: 160(ptr) AccessChain 12 159 + 193: 9(fvec4) Load 192 + 194: 9(fvec4) DPdxFine 193 + 195: 160(ptr) AccessChain 12 191 + Store 195 194 + 197: 160(ptr) AccessChain 12 166 + 198: 9(fvec4) Load 197 + 199: 9(fvec4) DPdyFine 198 + 200: 160(ptr) AccessChain 12 196 + Store 200 199 + 202: 160(ptr) AccessChain 12 159 + 203: 9(fvec4) Load 202 + 204: 9(fvec4) FwidthFine 203 + 205: 160(ptr) AccessChain 12 201 + Store 205 204 + 211: 208 Load 210(tex) + 215: 9(fvec4) ImageSampleImplicitLod 211 213 Bias 214 + 216: 160(ptr) AccessChain 12 206 + Store 216 215 + 218: 208 Load 210(tex) + 219: 7(fvec2) ImageQueryLod 218 213 + 220: 64(ptr) AccessChain 12 217 + Store 220 219 + Return + FunctionEnd diff --git a/Test/baseResults/spv.khrComputeShaderDerivatives.mesh.out b/Test/baseResults/spv.khrComputeShaderDerivatives.mesh.out new file mode 100644 index 0000000000..704423cad9 --- /dev/null +++ b/Test/baseResults/spv.khrComputeShaderDerivatives.mesh.out @@ -0,0 +1,137 @@ +spv.khrComputeShaderDerivatives.mesh +// Module Version 10400 +// Generated by (magic number): 8000b +// Id's are bound by 73 + + Capability ImageQuery + Capability MeshShadingEXT + Capability ComputeDerivativeGroupLinearKHR + Extension "SPV_EXT_mesh_shader" + Extension "SPV_KHR_compute_shader_derivatives" + 1: ExtInstImport "GLSL.std.450" + MemoryModel Logical GLSL450 + EntryPoint MeshEXT 4 "main" 10 24 39 48 62 + ExecutionMode 4 LocalSize 4 1 1 + ExecutionMode 4 DerivativeGroupLinearKHR + ExecutionMode 4 OutputVertices 3 + ExecutionMode 4 OutputPrimitivesNV 1 + ExecutionMode 4 OutputTrianglesNV + Source GLSL 450 + SourceExtension "GL_EXT_mesh_shader" + SourceExtension "GL_KHR_compute_shader_derivatives" + Name 4 "main" + Name 8 "iid" + Name 10 "gl_LocalInvocationIndex" + Name 14 "localDx" + Name 20 "localLod" + Name 24 "tex" + Name 37 "Output" + MemberName 37(Output) 0 "lod" + Name 39 "outData" + Name 48 "gl_PrimitiveTriangleIndicesEXT" + Name 59 "gl_MeshPerVertexEXT" + MemberName 59(gl_MeshPerVertexEXT) 0 "gl_Position" + MemberName 59(gl_MeshPerVertexEXT) 1 "gl_PointSize" + MemberName 59(gl_MeshPerVertexEXT) 2 "gl_ClipDistance" + MemberName 59(gl_MeshPerVertexEXT) 3 "gl_CullDistance" + Name 62 "gl_MeshVerticesEXT" + Decorate 10(gl_LocalInvocationIndex) BuiltIn LocalInvocationIndex + Decorate 24(tex) Binding 0 + Decorate 24(tex) DescriptorSet 0 + Decorate 37(Output) Block + MemberDecorate 37(Output) 0 Offset 0 + Decorate 39(outData) Binding 1 + Decorate 39(outData) DescriptorSet 0 + Decorate 48(gl_PrimitiveTriangleIndicesEXT) BuiltIn PrimitiveTriangleIndicesEXT + Decorate 59(gl_MeshPerVertexEXT) Block + MemberDecorate 59(gl_MeshPerVertexEXT) 0 BuiltIn Position + MemberDecorate 59(gl_MeshPerVertexEXT) 1 BuiltIn PointSize + MemberDecorate 59(gl_MeshPerVertexEXT) 2 BuiltIn ClipDistance + MemberDecorate 59(gl_MeshPerVertexEXT) 3 BuiltIn CullDistance + Decorate 72 BuiltIn WorkgroupSize + 2: TypeVoid + 3: TypeFunction 2 + 6: TypeInt 32 0 + 7: TypePointer Function 6(int) + 9: TypePointer Input 6(int) +10(gl_LocalInvocationIndex): 9(ptr) Variable Input + 12: TypeFloat 32 + 13: TypePointer Function 12(float) + 18: TypeVector 12(float) 2 + 19: TypePointer Function 18(fvec2) + 21: TypeImage 12(float) 2D sampled format:Unknown + 22: TypeSampledImage 21 + 23: TypePointer UniformConstant 22 + 24(tex): 23(ptr) Variable UniformConstant + 26: 12(float) Constant 1056964608 + 27: 18(fvec2) ConstantComposite 26 26 + 30: 6(int) Constant 0 + 31: TypeBool + 35: 6(int) Constant 3 + 36: 6(int) Constant 1 + 37(Output): TypeStruct 18(fvec2) + 38: TypePointer StorageBuffer 37(Output) + 39(outData): 38(ptr) Variable StorageBuffer + 40: TypeInt 32 1 + 41: 40(int) Constant 0 + 43: TypePointer StorageBuffer 18(fvec2) + 45: TypeVector 6(int) 3 + 46: TypeArray 45(ivec3) 36 + 47: TypePointer Output 46 +48(gl_PrimitiveTriangleIndicesEXT): 47(ptr) Variable Output + 49: 6(int) Constant 2 + 50: 45(ivec3) ConstantComposite 30 36 49 + 51: TypePointer Output 45(ivec3) + 57: TypeVector 12(float) 4 + 58: TypeArray 12(float) 36 +59(gl_MeshPerVertexEXT): TypeStruct 57(fvec4) 12(float) 58 58 + 60: TypeArray 59(gl_MeshPerVertexEXT) 35 + 61: TypePointer Output 60 +62(gl_MeshVerticesEXT): 61(ptr) Variable Output + 69: TypePointer Output 57(fvec4) + 71: 6(int) Constant 4 + 72: 45(ivec3) ConstantComposite 71 36 36 + 4(main): 2 Function None 3 + 5: Label + 8(iid): 7(ptr) Variable Function + 14(localDx): 13(ptr) Variable Function + 20(localLod): 19(ptr) Variable Function + 11: 6(int) Load 10(gl_LocalInvocationIndex) + Store 8(iid) 11 + 15: 6(int) Load 8(iid) + 16: 12(float) ConvertUToF 15 + 17: 12(float) DPdx 16 + Store 14(localDx) 17 + 25: 22 Load 24(tex) + 28: 18(fvec2) ImageQueryLod 25 27 + Store 20(localLod) 28 + 29: 6(int) Load 8(iid) + 32: 31(bool) IEqual 29 30 + SelectionMerge 34 None + BranchConditional 32 33 34 + 33: Label + SetMeshOutputsEXT 35 36 + 42: 18(fvec2) Load 20(localLod) + 44: 43(ptr) AccessChain 39(outData) 41 + Store 44 42 + 52: 51(ptr) AccessChain 48(gl_PrimitiveTriangleIndicesEXT) 41 + Store 52 50 + Branch 34 + 34: Label + 53: 6(int) Load 8(iid) + 54: 31(bool) ULessThan 53 35 + SelectionMerge 56 None + BranchConditional 54 55 56 + 55: Label + 63: 6(int) Load 8(iid) + 64: 12(float) Load 14(localDx) + 65: 13(ptr) AccessChain 20(localLod) 30 + 66: 12(float) Load 65 + 67: 12(float) FAdd 64 66 + 68: 57(fvec4) CompositeConstruct 67 67 67 67 + 70: 69(ptr) AccessChain 62(gl_MeshVerticesEXT) 63 41 + Store 70 68 + Branch 56 + 56: Label + Return + FunctionEnd diff --git a/Test/baseResults/spv.khrComputeShaderDerivatives.task.out b/Test/baseResults/spv.khrComputeShaderDerivatives.task.out new file mode 100644 index 0000000000..3ba0f6c79a --- /dev/null +++ b/Test/baseResults/spv.khrComputeShaderDerivatives.task.out @@ -0,0 +1,74 @@ +spv.khrComputeShaderDerivatives.task +// Module Version 10400 +// Generated by (magic number): 8000b +// Id's are bound by 38 + + Capability MeshShadingEXT + Capability ComputeDerivativeGroupLinearKHR + Extension "SPV_EXT_mesh_shader" + Extension "SPV_KHR_compute_shader_derivatives" + 1: ExtInstImport "GLSL.std.450" + MemoryModel Logical GLSL450 + EntryPoint TaskEXT 4 "main" 11 25 + ExecutionMode 4 LocalSize 4 1 1 + ExecutionMode 4 DerivativeGroupLinearKHR + Source GLSL 450 + SourceExtension "GL_EXT_mesh_shader" + SourceExtension "GL_KHR_compute_shader_derivatives" + Name 4 "main" + Name 8 "value" + Name 11 "gl_LocalInvocationIndex" + Name 14 "localDx" + Name 23 "Output" + MemberName 23(Output) 0 "dx" + Name 25 "outData" + Decorate 11(gl_LocalInvocationIndex) BuiltIn LocalInvocationIndex + Decorate 23(Output) Block + MemberDecorate 23(Output) 0 Offset 0 + Decorate 25(outData) Binding 0 + Decorate 25(outData) DescriptorSet 0 + Decorate 37 BuiltIn WorkgroupSize + 2: TypeVoid + 3: TypeFunction 2 + 6: TypeFloat 32 + 7: TypePointer Function 6(float) + 9: TypeInt 32 0 + 10: TypePointer Input 9(int) +11(gl_LocalInvocationIndex): 10(ptr) Variable Input + 18: 9(int) Constant 0 + 19: TypeBool + 23(Output): TypeStruct 6(float) + 24: TypePointer StorageBuffer 23(Output) + 25(outData): 24(ptr) Variable StorageBuffer + 26: TypeInt 32 1 + 27: 26(int) Constant 0 + 29: TypePointer StorageBuffer 6(float) + 31: 9(int) Constant 2 + 32: 9(int) Constant 264 + 33: 9(int) Constant 1 + 35: TypeVector 9(int) 3 + 36: 9(int) Constant 4 + 37: 35(ivec3) ConstantComposite 36 33 33 + 4(main): 2 Function None 3 + 5: Label + 8(value): 7(ptr) Variable Function + 14(localDx): 7(ptr) Variable Function + 12: 9(int) Load 11(gl_LocalInvocationIndex) + 13: 6(float) ConvertUToF 12 + Store 8(value) 13 + 15: 6(float) Load 8(value) + 16: 6(float) DPdx 15 + Store 14(localDx) 16 + 17: 9(int) Load 11(gl_LocalInvocationIndex) + 20: 19(bool) IEqual 17 18 + SelectionMerge 22 None + BranchConditional 20 21 22 + 21: Label + 28: 6(float) Load 14(localDx) + 30: 29(ptr) AccessChain 25(outData) 27 + Store 30 28 + Branch 22 + 22: Label + ControlBarrier 31 31 32 + EmitMeshTasksEXT 33 33 33 + FunctionEnd diff --git a/Test/baseResults/spv.khrComputeShaderDerivatives2.comp.out b/Test/baseResults/spv.khrComputeShaderDerivatives2.comp.out new file mode 100644 index 0000000000..23c2025c41 --- /dev/null +++ b/Test/baseResults/spv.khrComputeShaderDerivatives2.comp.out @@ -0,0 +1,383 @@ +spv.khrComputeShaderDerivatives2.comp +// Module Version 10400 +// Generated by (magic number): 8000b +// Id's are bound by 226 + + Capability Shader + Capability ImageQuery + Capability DerivativeControl + Capability ComputeDerivativeGroupLinearKHR + Extension "SPV_KHR_compute_shader_derivatives" + 1: ExtInstImport "GLSL.std.450" + MemoryModel Logical GLSL450 + EntryPoint GLCompute 4 "main" 12 210 + ExecutionMode 4 LocalSize 2 2 1 + ExecutionMode 4 DerivativeGroupLinearKHR + Source GLSL 450 + SourceExtension "GL_KHR_compute_shader_derivatives" + Name 4 "main" + Name 10 "block" + MemberName 10(block) 0 "fDerivativeX" + MemberName 10(block) 1 "fDerivativeY" + MemberName 10(block) 2 "fDerivativeWidth" + MemberName 10(block) 3 "fCoarseDerivativeX" + MemberName 10(block) 4 "fCoarseDerivativeY" + MemberName 10(block) 5 "fCoarseDerivativeWidth" + MemberName 10(block) 6 "fFineDerivativeX" + MemberName 10(block) 7 "fFineDerivativeY" + MemberName 10(block) 8 "fFineDerivativeWidth" + MemberName 10(block) 9 "fX" + MemberName 10(block) 10 "fY" + MemberName 10(block) 11 "v2DerivativeX" + MemberName 10(block) 12 "v2DerivativeY" + MemberName 10(block) 13 "v2DerivativeWidth" + MemberName 10(block) 14 "v2CoarseDerivativeX" + MemberName 10(block) 15 "v2CoarseDerivativeY" + MemberName 10(block) 16 "v2CoarseDerivativeWidth" + MemberName 10(block) 17 "v2FineDerivativeX" + MemberName 10(block) 18 "v2FineDerivativeY" + MemberName 10(block) 19 "v2FineDerivativeWidth" + MemberName 10(block) 20 "v2X" + MemberName 10(block) 21 "v2Y" + MemberName 10(block) 22 "v3DerivativeX" + MemberName 10(block) 23 "v3DerivativeY" + MemberName 10(block) 24 "v3DerivativeWidth" + MemberName 10(block) 25 "v3CoarseDerivativeX" + MemberName 10(block) 26 "v3CoarseDerivativeY" + MemberName 10(block) 27 "v3CoarseDerivativeWidth" + MemberName 10(block) 28 "v3FineDerivativeX" + MemberName 10(block) 29 "v3FineDerivativeY" + MemberName 10(block) 30 "v3FineDerivativeWidth" + MemberName 10(block) 31 "v3X" + MemberName 10(block) 32 "v3Y" + MemberName 10(block) 33 "v4DerivativeX" + MemberName 10(block) 34 "v4DerivativeY" + MemberName 10(block) 35 "v4DerivativeWidth" + MemberName 10(block) 36 "v4CoarseDerivativeX" + MemberName 10(block) 37 "v4CoarseDerivativeY" + MemberName 10(block) 38 "v4CoarseDerivativeWidth" + MemberName 10(block) 39 "v4FineDerivativeX" + MemberName 10(block) 40 "v4FineDerivativeY" + MemberName 10(block) 41 "v4FineDerivativeWidth" + MemberName 10(block) 42 "v4X" + MemberName 10(block) 43 "v4Y" + MemberName 10(block) 44 "color" + MemberName 10(block) 45 "lod" + Name 12 "" + Name 210 "tex" + Decorate 10(block) Block + MemberDecorate 10(block) 0 Offset 0 + MemberDecorate 10(block) 1 Offset 4 + MemberDecorate 10(block) 2 Offset 8 + MemberDecorate 10(block) 3 Offset 12 + MemberDecorate 10(block) 4 Offset 16 + MemberDecorate 10(block) 5 Offset 20 + MemberDecorate 10(block) 6 Offset 24 + MemberDecorate 10(block) 7 Offset 28 + MemberDecorate 10(block) 8 Offset 32 + MemberDecorate 10(block) 9 Offset 36 + MemberDecorate 10(block) 10 Offset 40 + MemberDecorate 10(block) 11 Offset 48 + MemberDecorate 10(block) 12 Offset 56 + MemberDecorate 10(block) 13 Offset 64 + MemberDecorate 10(block) 14 Offset 72 + MemberDecorate 10(block) 15 Offset 80 + MemberDecorate 10(block) 16 Offset 88 + MemberDecorate 10(block) 17 Offset 96 + MemberDecorate 10(block) 18 Offset 104 + MemberDecorate 10(block) 19 Offset 112 + MemberDecorate 10(block) 20 Offset 120 + MemberDecorate 10(block) 21 Offset 128 + MemberDecorate 10(block) 22 Offset 144 + MemberDecorate 10(block) 23 Offset 160 + MemberDecorate 10(block) 24 Offset 176 + MemberDecorate 10(block) 25 Offset 192 + MemberDecorate 10(block) 26 Offset 208 + MemberDecorate 10(block) 27 Offset 224 + MemberDecorate 10(block) 28 Offset 240 + MemberDecorate 10(block) 29 Offset 256 + MemberDecorate 10(block) 30 Offset 272 + MemberDecorate 10(block) 31 Offset 288 + MemberDecorate 10(block) 32 Offset 304 + MemberDecorate 10(block) 33 Offset 320 + MemberDecorate 10(block) 34 Offset 336 + MemberDecorate 10(block) 35 Offset 352 + MemberDecorate 10(block) 36 Offset 368 + MemberDecorate 10(block) 37 Offset 384 + MemberDecorate 10(block) 38 Offset 400 + MemberDecorate 10(block) 39 Offset 416 + MemberDecorate 10(block) 40 Offset 432 + MemberDecorate 10(block) 41 Offset 448 + MemberDecorate 10(block) 42 Offset 464 + MemberDecorate 10(block) 43 Offset 480 + MemberDecorate 10(block) 44 Offset 496 + MemberDecorate 10(block) 45 Offset 512 + Decorate 12 Binding 1 + Decorate 12 DescriptorSet 0 + Decorate 210(tex) Binding 0 + Decorate 210(tex) DescriptorSet 0 + Decorate 225 BuiltIn WorkgroupSize + 2: TypeVoid + 3: TypeFunction 2 + 6: TypeFloat 32 + 7: TypeVector 6(float) 2 + 8: TypeVector 6(float) 3 + 9: TypeVector 6(float) 4 + 10(block): TypeStruct 6(float) 6(float) 6(float) 6(float) 6(float) 6(float) 6(float) 6(float) 6(float) 6(float) 6(float) 7(fvec2) 7(fvec2) 7(fvec2) 7(fvec2) 7(fvec2) 7(fvec2) 7(fvec2) 7(fvec2) 7(fvec2) 7(fvec2) 7(fvec2) 8(fvec3) 8(fvec3) 8(fvec3) 8(fvec3) 8(fvec3) 8(fvec3) 8(fvec3) 8(fvec3) 8(fvec3) 8(fvec3) 8(fvec3) 9(fvec4) 9(fvec4) 9(fvec4) 9(fvec4) 9(fvec4) 9(fvec4) 9(fvec4) 9(fvec4) 9(fvec4) 9(fvec4) 9(fvec4) 9(fvec4) 7(fvec2) + 11: TypePointer StorageBuffer 10(block) + 12: 11(ptr) Variable StorageBuffer + 13: TypeInt 32 1 + 14: 13(int) Constant 0 + 15: 13(int) Constant 9 + 16: TypePointer StorageBuffer 6(float) + 21: 13(int) Constant 1 + 22: 13(int) Constant 10 + 27: 13(int) Constant 2 + 32: 13(int) Constant 3 + 37: 13(int) Constant 4 + 42: 13(int) Constant 5 + 47: 13(int) Constant 6 + 52: 13(int) Constant 7 + 57: 13(int) Constant 8 + 62: 13(int) Constant 11 + 63: 13(int) Constant 20 + 64: TypePointer StorageBuffer 7(fvec2) + 69: 13(int) Constant 12 + 70: 13(int) Constant 21 + 75: 13(int) Constant 13 + 80: 13(int) Constant 14 + 85: 13(int) Constant 15 + 90: 13(int) Constant 16 + 95: 13(int) Constant 17 + 100: 13(int) Constant 18 + 105: 13(int) Constant 19 + 110: 13(int) Constant 22 + 111: 13(int) Constant 31 + 112: TypePointer StorageBuffer 8(fvec3) + 117: 13(int) Constant 23 + 118: 13(int) Constant 32 + 123: 13(int) Constant 24 + 128: 13(int) Constant 25 + 133: 13(int) Constant 26 + 138: 13(int) Constant 27 + 143: 13(int) Constant 28 + 148: 13(int) Constant 29 + 153: 13(int) Constant 30 + 158: 13(int) Constant 33 + 159: 13(int) Constant 42 + 160: TypePointer StorageBuffer 9(fvec4) + 165: 13(int) Constant 34 + 166: 13(int) Constant 43 + 171: 13(int) Constant 35 + 176: 13(int) Constant 36 + 181: 13(int) Constant 37 + 186: 13(int) Constant 38 + 191: 13(int) Constant 39 + 196: 13(int) Constant 40 + 201: 13(int) Constant 41 + 206: 13(int) Constant 44 + 207: TypeImage 6(float) 2D sampled format:Unknown + 208: TypeSampledImage 207 + 209: TypePointer UniformConstant 208 + 210(tex): 209(ptr) Variable UniformConstant + 212: 6(float) Constant 1056964608 + 213: 7(fvec2) ConstantComposite 212 212 + 214: 6(float) Constant 1048576000 + 217: 13(int) Constant 45 + 221: TypeInt 32 0 + 222: TypeVector 221(int) 3 + 223: 221(int) Constant 2 + 224: 221(int) Constant 1 + 225: 222(ivec3) ConstantComposite 223 223 224 + 4(main): 2 Function None 3 + 5: Label + 17: 16(ptr) AccessChain 12 15 + 18: 6(float) Load 17 + 19: 6(float) DPdx 18 + 20: 16(ptr) AccessChain 12 14 + Store 20 19 + 23: 16(ptr) AccessChain 12 22 + 24: 6(float) Load 23 + 25: 6(float) DPdy 24 + 26: 16(ptr) AccessChain 12 21 + Store 26 25 + 28: 16(ptr) AccessChain 12 15 + 29: 6(float) Load 28 + 30: 6(float) Fwidth 29 + 31: 16(ptr) AccessChain 12 27 + Store 31 30 + 33: 16(ptr) AccessChain 12 15 + 34: 6(float) Load 33 + 35: 6(float) DPdxCoarse 34 + 36: 16(ptr) AccessChain 12 32 + Store 36 35 + 38: 16(ptr) AccessChain 12 22 + 39: 6(float) Load 38 + 40: 6(float) DPdyCoarse 39 + 41: 16(ptr) AccessChain 12 37 + Store 41 40 + 43: 16(ptr) AccessChain 12 15 + 44: 6(float) Load 43 + 45: 6(float) FwidthCoarse 44 + 46: 16(ptr) AccessChain 12 42 + Store 46 45 + 48: 16(ptr) AccessChain 12 15 + 49: 6(float) Load 48 + 50: 6(float) DPdxFine 49 + 51: 16(ptr) AccessChain 12 47 + Store 51 50 + 53: 16(ptr) AccessChain 12 22 + 54: 6(float) Load 53 + 55: 6(float) DPdyFine 54 + 56: 16(ptr) AccessChain 12 52 + Store 56 55 + 58: 16(ptr) AccessChain 12 15 + 59: 6(float) Load 58 + 60: 6(float) FwidthFine 59 + 61: 16(ptr) AccessChain 12 57 + Store 61 60 + 65: 64(ptr) AccessChain 12 63 + 66: 7(fvec2) Load 65 + 67: 7(fvec2) DPdx 66 + 68: 64(ptr) AccessChain 12 62 + Store 68 67 + 71: 64(ptr) AccessChain 12 70 + 72: 7(fvec2) Load 71 + 73: 7(fvec2) DPdy 72 + 74: 64(ptr) AccessChain 12 69 + Store 74 73 + 76: 64(ptr) AccessChain 12 63 + 77: 7(fvec2) Load 76 + 78: 7(fvec2) Fwidth 77 + 79: 64(ptr) AccessChain 12 75 + Store 79 78 + 81: 64(ptr) AccessChain 12 63 + 82: 7(fvec2) Load 81 + 83: 7(fvec2) DPdxCoarse 82 + 84: 64(ptr) AccessChain 12 80 + Store 84 83 + 86: 64(ptr) AccessChain 12 70 + 87: 7(fvec2) Load 86 + 88: 7(fvec2) DPdyCoarse 87 + 89: 64(ptr) AccessChain 12 85 + Store 89 88 + 91: 64(ptr) AccessChain 12 63 + 92: 7(fvec2) Load 91 + 93: 7(fvec2) FwidthCoarse 92 + 94: 64(ptr) AccessChain 12 90 + Store 94 93 + 96: 64(ptr) AccessChain 12 63 + 97: 7(fvec2) Load 96 + 98: 7(fvec2) DPdxFine 97 + 99: 64(ptr) AccessChain 12 95 + Store 99 98 + 101: 64(ptr) AccessChain 12 70 + 102: 7(fvec2) Load 101 + 103: 7(fvec2) DPdyFine 102 + 104: 64(ptr) AccessChain 12 100 + Store 104 103 + 106: 64(ptr) AccessChain 12 63 + 107: 7(fvec2) Load 106 + 108: 7(fvec2) FwidthFine 107 + 109: 64(ptr) AccessChain 12 105 + Store 109 108 + 113: 112(ptr) AccessChain 12 111 + 114: 8(fvec3) Load 113 + 115: 8(fvec3) DPdx 114 + 116: 112(ptr) AccessChain 12 110 + Store 116 115 + 119: 112(ptr) AccessChain 12 118 + 120: 8(fvec3) Load 119 + 121: 8(fvec3) DPdy 120 + 122: 112(ptr) AccessChain 12 117 + Store 122 121 + 124: 112(ptr) AccessChain 12 111 + 125: 8(fvec3) Load 124 + 126: 8(fvec3) Fwidth 125 + 127: 112(ptr) AccessChain 12 123 + Store 127 126 + 129: 112(ptr) AccessChain 12 111 + 130: 8(fvec3) Load 129 + 131: 8(fvec3) DPdxCoarse 130 + 132: 112(ptr) AccessChain 12 128 + Store 132 131 + 134: 112(ptr) AccessChain 12 118 + 135: 8(fvec3) Load 134 + 136: 8(fvec3) DPdyCoarse 135 + 137: 112(ptr) AccessChain 12 133 + Store 137 136 + 139: 112(ptr) AccessChain 12 111 + 140: 8(fvec3) Load 139 + 141: 8(fvec3) FwidthCoarse 140 + 142: 112(ptr) AccessChain 12 138 + Store 142 141 + 144: 112(ptr) AccessChain 12 111 + 145: 8(fvec3) Load 144 + 146: 8(fvec3) DPdxFine 145 + 147: 112(ptr) AccessChain 12 143 + Store 147 146 + 149: 112(ptr) AccessChain 12 118 + 150: 8(fvec3) Load 149 + 151: 8(fvec3) DPdyFine 150 + 152: 112(ptr) AccessChain 12 148 + Store 152 151 + 154: 112(ptr) AccessChain 12 111 + 155: 8(fvec3) Load 154 + 156: 8(fvec3) FwidthFine 155 + 157: 112(ptr) AccessChain 12 153 + Store 157 156 + 161: 160(ptr) AccessChain 12 159 + 162: 9(fvec4) Load 161 + 163: 9(fvec4) DPdx 162 + 164: 160(ptr) AccessChain 12 158 + Store 164 163 + 167: 160(ptr) AccessChain 12 166 + 168: 9(fvec4) Load 167 + 169: 9(fvec4) DPdy 168 + 170: 160(ptr) AccessChain 12 165 + Store 170 169 + 172: 160(ptr) AccessChain 12 159 + 173: 9(fvec4) Load 172 + 174: 9(fvec4) Fwidth 173 + 175: 160(ptr) AccessChain 12 171 + Store 175 174 + 177: 160(ptr) AccessChain 12 159 + 178: 9(fvec4) Load 177 + 179: 9(fvec4) DPdxCoarse 178 + 180: 160(ptr) AccessChain 12 176 + Store 180 179 + 182: 160(ptr) AccessChain 12 166 + 183: 9(fvec4) Load 182 + 184: 9(fvec4) DPdyCoarse 183 + 185: 160(ptr) AccessChain 12 181 + Store 185 184 + 187: 160(ptr) AccessChain 12 159 + 188: 9(fvec4) Load 187 + 189: 9(fvec4) FwidthCoarse 188 + 190: 160(ptr) AccessChain 12 186 + Store 190 189 + 192: 160(ptr) AccessChain 12 159 + 193: 9(fvec4) Load 192 + 194: 9(fvec4) DPdxFine 193 + 195: 160(ptr) AccessChain 12 191 + Store 195 194 + 197: 160(ptr) AccessChain 12 166 + 198: 9(fvec4) Load 197 + 199: 9(fvec4) DPdyFine 198 + 200: 160(ptr) AccessChain 12 196 + Store 200 199 + 202: 160(ptr) AccessChain 12 159 + 203: 9(fvec4) Load 202 + 204: 9(fvec4) FwidthFine 203 + 205: 160(ptr) AccessChain 12 201 + Store 205 204 + 211: 208 Load 210(tex) + 215: 9(fvec4) ImageSampleImplicitLod 211 213 Bias 214 + 216: 160(ptr) AccessChain 12 206 + Store 216 215 + 218: 208 Load 210(tex) + 219: 7(fvec2) ImageQueryLod 218 213 + 220: 64(ptr) AccessChain 12 217 + Store 220 219 + Return + FunctionEnd diff --git a/Test/baseResults/spv.khrComputeShaderDerivativesBadSize.comp.out b/Test/baseResults/spv.khrComputeShaderDerivativesBadSize.comp.out new file mode 100644 index 0000000000..869c902ab1 --- /dev/null +++ b/Test/baseResults/spv.khrComputeShaderDerivativesBadSize.comp.out @@ -0,0 +1,6 @@ +spv.khrComputeShaderDerivativesBadSize.comp +ERROR: 0:5: 'derivative_group_quads' : requires local_size_x and local_size_y to be multiple of two +ERROR: 1 compilation errors. No code generated. + + +SPIR-V is not generated for failed compile or link diff --git a/Test/baseResults/spv.khrComputeShaderDerivativesBoth.comp.out b/Test/baseResults/spv.khrComputeShaderDerivativesBoth.comp.out new file mode 100644 index 0000000000..20e77550d6 --- /dev/null +++ b/Test/baseResults/spv.khrComputeShaderDerivativesBoth.comp.out @@ -0,0 +1,6 @@ +spv.khrComputeShaderDerivativesBoth.comp +ERROR: 0:5: 'derivative_group_quads* and derivative_group_linear*' : cannot be both specified +ERROR: 1 compilation errors. No code generated. + + +SPIR-V is not generated for failed compile or link diff --git a/Test/baseResults/spv.khrComputeShaderDerivativesMissingLayout.comp.out b/Test/baseResults/spv.khrComputeShaderDerivativesMissingLayout.comp.out new file mode 100644 index 0000000000..05011d9807 --- /dev/null +++ b/Test/baseResults/spv.khrComputeShaderDerivativesMissingLayout.comp.out @@ -0,0 +1,7 @@ +spv.khrComputeShaderDerivativesMissingLayout.comp +ERROR: 0:8: 'dFdx' : requires a derivative_group_quads* or derivative_group_linear* layout qualifier +ERROR: 0:10: 'GL_KHR_compute_shader_derivatives' : requires one of derivative_group_quadsKHR or derivative_group_linearKHR layout qualifiers +ERROR: 2 compilation errors. No code generated. + + +SPIR-V is not generated for failed compile or link diff --git a/Test/baseResults/spv.khrComputeShaderDerivativesNoLayout.comp.out b/Test/baseResults/spv.khrComputeShaderDerivativesNoLayout.comp.out new file mode 100644 index 0000000000..c29e5ee5c0 --- /dev/null +++ b/Test/baseResults/spv.khrComputeShaderDerivativesNoLayout.comp.out @@ -0,0 +1,6 @@ +spv.khrComputeShaderDerivativesNoLayout.comp +ERROR: 0:9: 'GL_KHR_compute_shader_derivatives' : requires one of derivative_group_quadsKHR or derivative_group_linearKHR layout qualifiers +ERROR: 1 compilation errors. No code generated. + + +SPIR-V is not generated for failed compile or link diff --git a/Test/spv.khrComputeShaderDerivatives.comp b/Test/spv.khrComputeShaderDerivatives.comp new file mode 100644 index 0000000000..7226d22021 --- /dev/null +++ b/Test/spv.khrComputeShaderDerivatives.comp @@ -0,0 +1,110 @@ +#version 450 +#extension GL_KHR_compute_shader_derivatives : require + +layout(local_size_x = 2, local_size_y = 2) in; +layout(derivative_group_quadsKHR) in; + +layout(binding = 0) uniform sampler2D tex; + +layout(binding = 1, std430) buffer block { + float fDerivativeX; + float fDerivativeY; + float fDerivativeWidth; + float fCoarseDerivativeX; + float fCoarseDerivativeY; + float fCoarseDerivativeWidth; + float fFineDerivativeX; + float fFineDerivativeY; + float fFineDerivativeWidth; + + float fX; + float fY; + + vec2 v2DerivativeX; + vec2 v2DerivativeY; + vec2 v2DerivativeWidth; + vec2 v2CoarseDerivativeX; + vec2 v2CoarseDerivativeY; + vec2 v2CoarseDerivativeWidth; + vec2 v2FineDerivativeX; + vec2 v2FineDerivativeY; + vec2 v2FineDerivativeWidth; + + vec2 v2X; + vec2 v2Y; + + vec3 v3DerivativeX; + vec3 v3DerivativeY; + vec3 v3DerivativeWidth; + vec3 v3CoarseDerivativeX; + vec3 v3CoarseDerivativeY; + vec3 v3CoarseDerivativeWidth; + vec3 v3FineDerivativeX; + vec3 v3FineDerivativeY; + vec3 v3FineDerivativeWidth; + + vec3 v3X; + vec3 v3Y; + + vec4 v4DerivativeX; + vec4 v4DerivativeY; + vec4 v4DerivativeWidth; + vec4 v4CoarseDerivativeX; + vec4 v4CoarseDerivativeY; + vec4 v4CoarseDerivativeWidth; + vec4 v4FineDerivativeX; + vec4 v4FineDerivativeY; + vec4 v4FineDerivativeWidth; + + vec4 v4X; + vec4 v4Y; + + vec4 color; + vec2 lod; +}; + +void main() +{ + fDerivativeX = dFdx(fX); + fDerivativeY = dFdy(fY); + fDerivativeWidth = fwidth(fX); + fCoarseDerivativeX = dFdxCoarse(fX); + fCoarseDerivativeY = dFdyCoarse(fY); + fCoarseDerivativeWidth = fwidthCoarse(fX); + fFineDerivativeX = dFdxFine(fX); + fFineDerivativeY = dFdyFine(fY); + fFineDerivativeWidth = fwidthFine(fX); + + v2DerivativeX = dFdx(v2X); + v2DerivativeY = dFdy(v2Y); + v2DerivativeWidth = fwidth(v2X); + v2CoarseDerivativeX = dFdxCoarse(v2X); + v2CoarseDerivativeY = dFdyCoarse(v2Y); + v2CoarseDerivativeWidth = fwidthCoarse(v2X); + v2FineDerivativeX = dFdxFine(v2X); + v2FineDerivativeY = dFdyFine(v2Y); + v2FineDerivativeWidth = fwidthFine(v2X); + + v3DerivativeX = dFdx(v3X); + v3DerivativeY = dFdy(v3Y); + v3DerivativeWidth = fwidth(v3X); + v3CoarseDerivativeX = dFdxCoarse(v3X); + v3CoarseDerivativeY = dFdyCoarse(v3Y); + v3CoarseDerivativeWidth = fwidthCoarse(v3X); + v3FineDerivativeX = dFdxFine(v3X); + v3FineDerivativeY = dFdyFine(v3Y); + v3FineDerivativeWidth = fwidthFine(v3X); + + v4DerivativeX = dFdx(v4X); + v4DerivativeY = dFdy(v4Y); + v4DerivativeWidth = fwidth(v4X); + v4CoarseDerivativeX = dFdxCoarse(v4X); + v4CoarseDerivativeY = dFdyCoarse(v4Y); + v4CoarseDerivativeWidth = fwidthCoarse(v4X); + v4FineDerivativeX = dFdxFine(v4X); + v4FineDerivativeY = dFdyFine(v4Y); + v4FineDerivativeWidth = fwidthFine(v4X); + + color = texture(tex, vec2(0.5), 0.25); + lod = textureQueryLod(tex, vec2(0.5)); +} diff --git a/Test/spv.khrComputeShaderDerivatives.mesh b/Test/spv.khrComputeShaderDerivatives.mesh new file mode 100644 index 0000000000..380a5a3ed7 --- /dev/null +++ b/Test/spv.khrComputeShaderDerivatives.mesh @@ -0,0 +1,31 @@ +#version 450 +#extension GL_EXT_mesh_shader : enable +#extension GL_KHR_compute_shader_derivatives : require + +layout(local_size_x = 4) in; +layout(derivative_group_linearKHR) in; + +layout(max_vertices = 3) out; +layout(max_primitives = 1) out; +layout(triangles) out; + +layout(binding = 0) uniform sampler2D tex; +layout(binding = 1, std430) buffer Output { + vec2 lod; +} outData; + +void main() +{ + uint iid = gl_LocalInvocationIndex; + float localDx = dFdx(float(iid)); + vec2 localLod = textureQueryLod(tex, vec2(0.5f)); + + if (iid == 0u) { + SetMeshOutputsEXT(3u, 1u); + outData.lod = localLod; + gl_PrimitiveTriangleIndicesEXT[0] = uvec3(0u, 1u, 2u); + } + + if (iid < 3u) + gl_MeshVerticesEXT[iid].gl_Position = vec4(localDx + localLod.x); +} diff --git a/Test/spv.khrComputeShaderDerivatives.task b/Test/spv.khrComputeShaderDerivatives.task new file mode 100644 index 0000000000..9f3e3f911a --- /dev/null +++ b/Test/spv.khrComputeShaderDerivatives.task @@ -0,0 +1,21 @@ +#version 450 +#extension GL_EXT_mesh_shader : enable +#extension GL_KHR_compute_shader_derivatives : require + +layout(local_size_x = 4) in; +layout(derivative_group_linearKHR) in; + +layout(binding = 0, std430) buffer Output { + float dx; +} outData; + +void main() +{ + float value = float(gl_LocalInvocationIndex); + float localDx = dFdx(value); + if (gl_LocalInvocationIndex == 0u) + outData.dx = localDx; + + barrier(); + EmitMeshTasksEXT(1u, 1u, 1u); +} diff --git a/Test/spv.khrComputeShaderDerivatives2.comp b/Test/spv.khrComputeShaderDerivatives2.comp new file mode 100644 index 0000000000..347536651b --- /dev/null +++ b/Test/spv.khrComputeShaderDerivatives2.comp @@ -0,0 +1,110 @@ +#version 450 +#extension GL_KHR_compute_shader_derivatives : require + +layout(local_size_x = 2, local_size_y = 2) in; +layout(derivative_group_linearKHR) in; + +layout(binding = 0) uniform sampler2D tex; + +layout(binding = 1, std430) buffer block { + float fDerivativeX; + float fDerivativeY; + float fDerivativeWidth; + float fCoarseDerivativeX; + float fCoarseDerivativeY; + float fCoarseDerivativeWidth; + float fFineDerivativeX; + float fFineDerivativeY; + float fFineDerivativeWidth; + + float fX; + float fY; + + vec2 v2DerivativeX; + vec2 v2DerivativeY; + vec2 v2DerivativeWidth; + vec2 v2CoarseDerivativeX; + vec2 v2CoarseDerivativeY; + vec2 v2CoarseDerivativeWidth; + vec2 v2FineDerivativeX; + vec2 v2FineDerivativeY; + vec2 v2FineDerivativeWidth; + + vec2 v2X; + vec2 v2Y; + + vec3 v3DerivativeX; + vec3 v3DerivativeY; + vec3 v3DerivativeWidth; + vec3 v3CoarseDerivativeX; + vec3 v3CoarseDerivativeY; + vec3 v3CoarseDerivativeWidth; + vec3 v3FineDerivativeX; + vec3 v3FineDerivativeY; + vec3 v3FineDerivativeWidth; + + vec3 v3X; + vec3 v3Y; + + vec4 v4DerivativeX; + vec4 v4DerivativeY; + vec4 v4DerivativeWidth; + vec4 v4CoarseDerivativeX; + vec4 v4CoarseDerivativeY; + vec4 v4CoarseDerivativeWidth; + vec4 v4FineDerivativeX; + vec4 v4FineDerivativeY; + vec4 v4FineDerivativeWidth; + + vec4 v4X; + vec4 v4Y; + + vec4 color; + vec2 lod; +}; + +void main() +{ + fDerivativeX = dFdx(fX); + fDerivativeY = dFdy(fY); + fDerivativeWidth = fwidth(fX); + fCoarseDerivativeX = dFdxCoarse(fX); + fCoarseDerivativeY = dFdyCoarse(fY); + fCoarseDerivativeWidth = fwidthCoarse(fX); + fFineDerivativeX = dFdxFine(fX); + fFineDerivativeY = dFdyFine(fY); + fFineDerivativeWidth = fwidthFine(fX); + + v2DerivativeX = dFdx(v2X); + v2DerivativeY = dFdy(v2Y); + v2DerivativeWidth = fwidth(v2X); + v2CoarseDerivativeX = dFdxCoarse(v2X); + v2CoarseDerivativeY = dFdyCoarse(v2Y); + v2CoarseDerivativeWidth = fwidthCoarse(v2X); + v2FineDerivativeX = dFdxFine(v2X); + v2FineDerivativeY = dFdyFine(v2Y); + v2FineDerivativeWidth = fwidthFine(v2X); + + v3DerivativeX = dFdx(v3X); + v3DerivativeY = dFdy(v3Y); + v3DerivativeWidth = fwidth(v3X); + v3CoarseDerivativeX = dFdxCoarse(v3X); + v3CoarseDerivativeY = dFdyCoarse(v3Y); + v3CoarseDerivativeWidth = fwidthCoarse(v3X); + v3FineDerivativeX = dFdxFine(v3X); + v3FineDerivativeY = dFdyFine(v3Y); + v3FineDerivativeWidth = fwidthFine(v3X); + + v4DerivativeX = dFdx(v4X); + v4DerivativeY = dFdy(v4Y); + v4DerivativeWidth = fwidth(v4X); + v4CoarseDerivativeX = dFdxCoarse(v4X); + v4CoarseDerivativeY = dFdyCoarse(v4Y); + v4CoarseDerivativeWidth = fwidthCoarse(v4X); + v4FineDerivativeX = dFdxFine(v4X); + v4FineDerivativeY = dFdyFine(v4Y); + v4FineDerivativeWidth = fwidthFine(v4X); + + color = texture(tex, vec2(0.5), 0.25); + lod = textureQueryLod(tex, vec2(0.5)); +} diff --git a/Test/spv.khrComputeShaderDerivativesBadSize.comp b/Test/spv.khrComputeShaderDerivativesBadSize.comp new file mode 100644 index 0000000000..7396d43c3a --- /dev/null +++ b/Test/spv.khrComputeShaderDerivativesBadSize.comp @@ -0,0 +1,9 @@ +#version 450 +#extension GL_KHR_compute_shader_derivatives : require + +layout(local_size_x = 3, local_size_y = 2) in; +layout(derivative_group_quadsKHR) in; + +void main() +{ +} diff --git a/Test/spv.khrComputeShaderDerivativesBoth.comp b/Test/spv.khrComputeShaderDerivativesBoth.comp new file mode 100644 index 0000000000..75fe7ee7de --- /dev/null +++ b/Test/spv.khrComputeShaderDerivativesBoth.comp @@ -0,0 +1,9 @@ +#version 450 +#extension GL_KHR_compute_shader_derivatives : require + +layout(local_size_x = 2, local_size_y = 2) in; +layout(derivative_group_quadsKHR, derivative_group_linearKHR) in; + +void main() +{ +} diff --git a/Test/spv.khrComputeShaderDerivativesMissingLayout.comp b/Test/spv.khrComputeShaderDerivativesMissingLayout.comp new file mode 100644 index 0000000000..226077b076 --- /dev/null +++ b/Test/spv.khrComputeShaderDerivativesMissingLayout.comp @@ -0,0 +1,9 @@ +#version 450 +#extension GL_KHR_compute_shader_derivatives : require + +layout(local_size_x = 2, local_size_y = 2) in; + +void main() +{ + float dx = dFdx(float(gl_LocalInvocationID.x)); +} diff --git a/Test/spv.khrComputeShaderDerivativesNoLayout.comp b/Test/spv.khrComputeShaderDerivativesNoLayout.comp new file mode 100644 index 0000000000..c3b64000e6 --- /dev/null +++ b/Test/spv.khrComputeShaderDerivativesNoLayout.comp @@ -0,0 +1,8 @@ +#version 450 +#extension GL_KHR_compute_shader_derivatives : require + +layout(local_size_x = 2, local_size_y = 2) in; + +void main() +{ +} diff --git a/glslang/Include/Types.h b/glslang/Include/Types.h index c6b89e0609..e2a75201e5 100644 --- a/glslang/Include/Types.h +++ b/glslang/Include/Types.h @@ -1342,6 +1342,12 @@ class TQualifier { } }; +enum TDerivativeGroupExtension { + EdgNone, + EdgNV, + EdgKHR, +}; + // Qualifiers that don't need to be kept per object. They have shader scope, not object scope. // So, they will not be part of TType, TQualifier, etc. struct TShaderQualifiers { @@ -1368,8 +1374,9 @@ struct TShaderQualifiers { int numViews; // multiview extenstions TInterlockOrdering interlockOrdering; 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 + bool layoutDerivativeGroupQuads; // true if a derivative_group_quads* layout is set + bool layoutDerivativeGroupLinear; // true if a derivative_group_linear* layout is set + TDerivativeGroupExtension derivativeGroupExtension; int primitives; // mesh shader "max_primitives"DerivativeGroupLinear; // true if layout derivative_group_linearNV set bool layoutPrimitiveCulling; // true if layout primitive_culling set bool layoutNonCoherentTileAttachmentReadQCOM; // fragment shaders -- per object @@ -1410,6 +1417,7 @@ struct TShaderQualifiers { layoutOverrideCoverage = false; layoutDerivativeGroupQuads = false; layoutDerivativeGroupLinear = false; + derivativeGroupExtension = EdgNone; layoutPrimitiveCulling = false; layoutNonCoherentTileAttachmentReadQCOM = false; layoutTileShadingRateQCOM[0] = 0; @@ -1481,6 +1489,8 @@ struct TShaderQualifiers { layoutDerivativeGroupQuads = src.layoutDerivativeGroupQuads; if (src.layoutDerivativeGroupLinear) layoutDerivativeGroupLinear = src.layoutDerivativeGroupLinear; + if (src.derivativeGroupExtension != EdgNone) + derivativeGroupExtension = src.derivativeGroupExtension; if (src.primitives != TQualifier::layoutNotSet) primitives = src.primitives; if (src.interlockOrdering != EioNone) diff --git a/glslang/MachineIndependent/Initialize.cpp b/glslang/MachineIndependent/Initialize.cpp index d4f87a413f..3a13b3a238 100644 --- a/glslang/MachineIndependent/Initialize.cpp +++ b/glslang/MachineIndependent/Initialize.cpp @@ -605,6 +605,23 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV // // Derivatives Functions. // + TString derivatives ( + "float dFdx(float p);" + "vec2 dFdx(vec2 p);" + "vec3 dFdx(vec3 p);" + "vec4 dFdx(vec4 p);" + + "float dFdy(float p);" + "vec2 dFdy(vec2 p);" + "vec3 dFdy(vec3 p);" + "vec4 dFdy(vec4 p);" + + "float fwidth(float p);" + "vec2 fwidth(vec2 p);" + "vec3 fwidth(vec3 p);" + "vec4 fwidth(vec4 p);" + ); + TString derivativeControls ( "float dFdxFine(float p);" "vec2 dFdxFine(vec2 p);" @@ -5824,15 +5841,34 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV "\n"); } - //E_SPV_NV_compute_shader_derivatives + // GL_KHR_compute_shader_derivatives / SPV_NV_compute_shader_derivatives if ((profile == EEsProfile && version >= 320) || (profile != EEsProfile && version >= 450)) { + if (profile != EEsProfile) { + stageBuiltins[EShLangCompute].append(derivatives); + stageBuiltins[EShLangTask].append(derivatives); + stageBuiltins[EShLangMesh].append(derivatives); + } + stageBuiltins[EShLangCompute].append(derivativeControls); stageBuiltins[EShLangCompute].append("\n"); + + if (profile != EEsProfile) { + stageBuiltins[EShLangTask].append(derivativeControls); + stageBuiltins[EShLangTask].append("\n"); + stageBuiltins[EShLangMesh].append(derivativeControls); + stageBuiltins[EShLangMesh].append("\n"); + } } if (profile != EEsProfile && version >= 450) { stageBuiltins[EShLangCompute].append(derivativesAndControl16bits); stageBuiltins[EShLangCompute].append(derivativesAndControl64bits); stageBuiltins[EShLangCompute].append("\n"); + stageBuiltins[EShLangTask].append(derivativesAndControl16bits); + stageBuiltins[EShLangTask].append(derivativesAndControl64bits); + stageBuiltins[EShLangTask].append("\n"); + stageBuiltins[EShLangMesh].append(derivativesAndControl16bits); + stageBuiltins[EShLangMesh].append(derivativesAndControl64bits); + stageBuiltins[EShLangMesh].append("\n"); } // Builtins for GL_NV_mesh_shader @@ -7488,7 +7524,7 @@ void TBuiltIns::addQueryFunctions(TSampler sampler, const TString& typeName, int } // - // textureQueryLod(), fragment stage only + // textureQueryLod() // Also enabled with extension GL_ARB_texture_query_lod // Extension GL_ARB_texture_query_lod says that textureQueryLOD() also exist at extension. @@ -7527,6 +7563,26 @@ void TBuiltIns::addQueryFunctions(TSampler sampler, const TString& typeName, int stageBuiltins[EShLangCompute].append(postfixes[dimMap[sampler.dim]]); } stageBuiltins[EShLangCompute].append(");\n"); + + stageBuiltins[EShLangTask].append(funcName[i]); + stageBuiltins[EShLangTask].append(typeName); + if (dimMap[sampler.dim] == 1) + stageBuiltins[EShLangTask].append(", float"); + else { + stageBuiltins[EShLangTask].append(", vec"); + stageBuiltins[EShLangTask].append(postfixes[dimMap[sampler.dim]]); + } + stageBuiltins[EShLangTask].append(");\n"); + + stageBuiltins[EShLangMesh].append(funcName[i]); + stageBuiltins[EShLangMesh].append(typeName); + if (dimMap[sampler.dim] == 1) + stageBuiltins[EShLangMesh].append(", float"); + else { + stageBuiltins[EShLangMesh].append(", vec"); + stageBuiltins[EShLangMesh].append(postfixes[dimMap[sampler.dim]]); + } + stageBuiltins[EShLangMesh].append(");\n"); } } @@ -8282,9 +8338,12 @@ void TBuiltIns::addGatherFunctions(TSampler sampler, const TString& typeName, in } s.append(");\n"); - if (bias) + if (bias) { stageBuiltins[EShLangFragment].append(s); - else + stageBuiltins[EShLangCompute].append(s); + stageBuiltins[EShLangTask].append(s); + stageBuiltins[EShLangMesh].append(s); + } else commonBuiltins.append(s); } } @@ -10181,15 +10240,28 @@ void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion } if ((profile != EEsProfile && version >= 450) || (profile == EEsProfile && version >= 320)) { - symbolTable.setFunctionExtensions("dFdx", 1, &E_GL_NV_compute_shader_derivatives); - symbolTable.setFunctionExtensions("dFdy", 1, &E_GL_NV_compute_shader_derivatives); - symbolTable.setFunctionExtensions("fwidth", 1, &E_GL_NV_compute_shader_derivatives); - symbolTable.setFunctionExtensions("dFdxFine", 1, &E_GL_NV_compute_shader_derivatives); - symbolTable.setFunctionExtensions("dFdyFine", 1, &E_GL_NV_compute_shader_derivatives); - symbolTable.setFunctionExtensions("fwidthFine", 1, &E_GL_NV_compute_shader_derivatives); - symbolTable.setFunctionExtensions("dFdxCoarse", 1, &E_GL_NV_compute_shader_derivatives); - symbolTable.setFunctionExtensions("dFdyCoarse", 1, &E_GL_NV_compute_shader_derivatives); - symbolTable.setFunctionExtensions("fwidthCoarse", 1, &E_GL_NV_compute_shader_derivatives); + const char* const derivativeExts[] = { E_GL_NV_compute_shader_derivatives, E_GL_KHR_compute_shader_derivatives }; + if (language == EShLangCompute) { + symbolTable.setFunctionExtensions("dFdx", 2, derivativeExts); + symbolTable.setFunctionExtensions("dFdy", 2, derivativeExts); + symbolTable.setFunctionExtensions("fwidth", 2, derivativeExts); + symbolTable.setFunctionExtensions("dFdxFine", 2, derivativeExts); + symbolTable.setFunctionExtensions("dFdyFine", 2, derivativeExts); + symbolTable.setFunctionExtensions("fwidthFine", 2, derivativeExts); + symbolTable.setFunctionExtensions("dFdxCoarse", 2, derivativeExts); + symbolTable.setFunctionExtensions("dFdyCoarse", 2, derivativeExts); + symbolTable.setFunctionExtensions("fwidthCoarse", 2, derivativeExts); + } else if (language == EShLangTask || language == EShLangMesh) { + symbolTable.setFunctionExtensions("dFdx", 1, &E_GL_KHR_compute_shader_derivatives); + symbolTable.setFunctionExtensions("dFdy", 1, &E_GL_KHR_compute_shader_derivatives); + symbolTable.setFunctionExtensions("fwidth", 1, &E_GL_KHR_compute_shader_derivatives); + symbolTable.setFunctionExtensions("dFdxFine", 1, &E_GL_KHR_compute_shader_derivatives); + symbolTable.setFunctionExtensions("dFdyFine", 1, &E_GL_KHR_compute_shader_derivatives); + symbolTable.setFunctionExtensions("fwidthFine", 1, &E_GL_KHR_compute_shader_derivatives); + symbolTable.setFunctionExtensions("dFdxCoarse", 1, &E_GL_KHR_compute_shader_derivatives); + symbolTable.setFunctionExtensions("dFdyCoarse", 1, &E_GL_KHR_compute_shader_derivatives); + symbolTable.setFunctionExtensions("fwidthCoarse", 1, &E_GL_KHR_compute_shader_derivatives); + } } if ((profile == EEsProfile && version >= 310) || diff --git a/glslang/MachineIndependent/ParseHelper.cpp b/glslang/MachineIndependent/ParseHelper.cpp index 99771e155a..d507a12324 100644 --- a/glslang/MachineIndependent/ParseHelper.cpp +++ b/glslang/MachineIndependent/ParseHelper.cpp @@ -61,7 +61,8 @@ TParseContext::TParseContext(TSymbolTable& symbolTable, TIntermediate& interm, b inMain(false), blockName(nullptr), limits(resources.limits), - atomicUintOffsets(nullptr), anyIndexLimits(false) + atomicUintOffsets(nullptr), anyIndexLimits(false), + khrDerivativeLayoutQualifierSpecified(false) { // decide whether precision qualifiers should be ignored or respected if (isEsProfile() || spvVersion.vulkan > 0) { @@ -2877,6 +2878,22 @@ void TParseContext::memorySemanticsCheck(const TSourceLoc& loc, const TFunction& // // Assumes there has been a semantically correct match to a built-in function prototype. // +void TParseContext::requireDerivativeLayout(const TSourceLoc& loc, const char* featureDesc) +{ + if (language != EShLangCompute && language != EShLangTask && language != EShLangMesh) + return; + + if (language == EShLangCompute) { + const char* const derivativeExts[] = { E_GL_NV_compute_shader_derivatives, E_GL_KHR_compute_shader_derivatives }; + requireExtensions(loc, 2, derivativeExts, featureDesc); + } else { + requireExtensions(loc, 1, &E_GL_KHR_compute_shader_derivatives, featureDesc); + } + + if (!intermediate.hasLayoutDerivativeModeNone()) + error(loc, "requires a derivative_group_quads* or derivative_group_linear* layout qualifier", featureDesc, ""); +} + void TParseContext::builtInOpCheck(const TSourceLoc& loc, const TFunction& fnCandidate, TIntermOperator& callNode) { // Set up convenience accessors to the argument(s). There is almost always @@ -2911,6 +2928,18 @@ void TParseContext::builtInOpCheck(const TSourceLoc& loc, const TFunction& fnCan }; switch (callNode.getOp()) { + case EOpDPdx: + case EOpDPdxFine: + case EOpDPdxCoarse: + case EOpDPdy: + case EOpDPdyFine: + case EOpDPdyCoarse: + case EOpFwidth: + case EOpFwidthFine: + case EOpFwidthCoarse: + requireDerivativeLayout(loc, fnCandidate.getName().c_str()); + break; + case EOpTextureGather: case EOpTextureGatherOffset: case EOpTextureGatherOffsets: @@ -2993,6 +3022,9 @@ void TParseContext::builtInOpCheck(const TSourceLoc& loc, const TFunction& fnCan case EOpTexture: case EOpTextureLod: { + if (callNode.getOp() == EOpTexture && fnCandidate.getParamCount() > 2) + requireDerivativeLayout(loc, (fnCandidate.getName() + " with bias argument").c_str()); + if ((fnCandidate.getParamCount() > 2) && ((*argp)[1]->getAsTyped()->getType().getBasicType() == EbtFloat) && ((*argp)[1]->getAsTyped()->getType().getVectorSize() == 4) && fnCandidate[0].type->getSampler().shadow) { featureString = fnCandidate.getName(); @@ -3020,6 +3052,12 @@ void TParseContext::builtInOpCheck(const TSourceLoc& loc, const TFunction& fnCan break; } + case EOpTextureProj: + case EOpSparseTexture: + case EOpTextureQueryLod: + requireDerivativeLayout(loc, fnCandidate.getName().c_str()); + break; + case EOpSparseTextureGather: case EOpSparseTextureGatherOffset: case EOpSparseTextureGatherOffsets: @@ -3101,6 +3139,10 @@ void TParseContext::builtInOpCheck(const TSourceLoc& loc, const TFunction& fnCan case EOpSparseTextureLodOffset: case EOpSparseTextureGradOffset: { + if (callNode.getOp() == EOpTextureOffset || callNode.getOp() == EOpTextureProjOffset || + callNode.getOp() == EOpSparseTextureOffset) + requireDerivativeLayout(loc, fnCandidate.getName().c_str()); + // Handle texture-offset limits checking // Pick which argument has to hold constant offsets int arg = -1; @@ -6639,6 +6681,12 @@ void TParseContext::finish() break; } + if (intermediate.IsRequestedExtension(E_GL_KHR_compute_shader_derivatives) && + !khrDerivativeLayoutQualifierSpecified) { + error(getCurrentLoc(), "requires one of derivative_group_quadsKHR or derivative_group_linearKHR layout qualifiers", + E_GL_KHR_compute_shader_derivatives, ""); + } + // Set default outputs for GL_NV_geometry_shader_passthrough if (language == EShLangGeometry && extensionTurnedOn(E_SPV_NV_geometry_shader_passthrough)) { if (intermediate.getOutputPrimitive() == ElgNone) { @@ -7012,17 +7060,32 @@ void TParseContext::setLayoutQualifier(const TSourceLoc& loc, TPublicType& publi } } - if (language == EShLangCompute) { + if (language == EShLangCompute || language == EShLangTask || language == EShLangMesh) { if (id.compare(0, 17, "derivative_group_") == 0) { - requireExtensions(loc, 1, &E_GL_NV_compute_shader_derivatives, "compute shader derivatives"); - if (id == "derivative_group_quadsnv") { + if (id == "derivative_group_quadsnv" || id == "derivative_group_linearnv") { + requireExtensions(loc, 1, &E_GL_NV_compute_shader_derivatives, "compute shader derivatives"); + if (language != EShLangCompute) { + error(loc, "can only apply to compute shaders", id.c_str(), ""); + return; + } + } else if (id == "derivative_group_quadskhr" || id == "derivative_group_linearkhr") { + requireExtensions(loc, 1, &E_GL_KHR_compute_shader_derivatives, "compute shader derivatives"); + khrDerivativeLayoutQualifierSpecified = true; + } + if (id == "derivative_group_quadsnv" || id == "derivative_group_quadskhr") { publicType.shaderQualifiers.layoutDerivativeGroupQuads = true; + publicType.shaderQualifiers.derivativeGroupExtension = + id == "derivative_group_quadsnv" ? EdgNV : EdgKHR; return; - } else if (id == "derivative_group_linearnv") { + } else if (id == "derivative_group_linearnv" || id == "derivative_group_linearkhr") { publicType.shaderQualifiers.layoutDerivativeGroupLinear = true; + publicType.shaderQualifiers.derivativeGroupExtension = + id == "derivative_group_linearnv" ? EdgNV : EdgKHR; return; } } + } + if (language == EShLangCompute) { if (id == "tile_attachmentqcom") { requireExtensions(loc, 1, &E_GL_QCOM_tile_shading, "tile shading QCOM"); publicType.qualifier.layoutTileAttachmentQCOM = true; @@ -11420,19 +11483,20 @@ void TParseContext::updateStandaloneQualifierDefaults(const TSourceLoc& loc, con if (publicType.shaderQualifiers.layoutDerivativeGroupQuads && publicType.shaderQualifiers.layoutDerivativeGroupLinear) { - error(loc, "cannot be both specified", "derivative_group_quadsNV and derivative_group_linearNV", ""); + error(loc, "cannot be both specified", "derivative_group_quads* and derivative_group_linear*", ""); } if (publicType.shaderQualifiers.layoutDerivativeGroupQuads) { if (publicType.qualifier.storage == EvqVaryingIn) { 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", ""); + error(loc, "requires local_size_x and local_size_y to be multiple of two", "derivative_group_quads", ""); else - intermediate.setLayoutDerivativeMode(LayoutDerivativeGroupQuads); + intermediate.setLayoutDerivativeMode(LayoutDerivativeGroupQuads, + publicType.shaderQualifiers.derivativeGroupExtension); } else - error(loc, "can only apply to 'in'", "derivative_group_quadsNV", ""); + error(loc, "can only apply to 'in'", "derivative_group_quads", ""); } if (publicType.shaderQualifiers.layoutDerivativeGroupLinear) { if (publicType.qualifier.storage == EvqVaryingIn) { @@ -11442,12 +11506,13 @@ void TParseContext::updateStandaloneQualifierDefaults(const TSourceLoc& loc, con (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", ""); + error(loc, "requires total group size to be multiple of four", "derivative_group_linear", ""); else - intermediate.setLayoutDerivativeMode(LayoutDerivativeGroupLinear); + intermediate.setLayoutDerivativeMode(LayoutDerivativeGroupLinear, + publicType.shaderQualifiers.derivativeGroupExtension); } else - error(loc, "can only apply to 'in'", "derivative_group_linearNV", ""); + error(loc, "can only apply to 'in'", "derivative_group_linear", ""); } // Check mesh out array sizes, once all the necessary out qualifiers are defined. if ((language == EShLangMesh) && diff --git a/glslang/MachineIndependent/ParseHelper.h b/glslang/MachineIndependent/ParseHelper.h index d1d322b8da..57f7ff390b 100644 --- a/glslang/MachineIndependent/ParseHelper.h +++ b/glslang/MachineIndependent/ParseHelper.h @@ -358,6 +358,7 @@ class TParseContext : public TParseContextBase { TIntermTyped* addOutputArgumentConversions(const TFunction&, TIntermAggregate&) const; TIntermTyped* addAssign(const TSourceLoc&, TOperator op, TIntermTyped* left, TIntermTyped* right); void builtInOpCheck(const TSourceLoc&, const TFunction&, TIntermOperator&); + void requireDerivativeLayout(const TSourceLoc&, const char* featureDesc); void nonOpBuiltInCheck(const TSourceLoc&, const TFunction&, TIntermAggregate&); void userFunctionCallCheck(const TSourceLoc&, TIntermAggregate&); void samplerConstructorLocationCheck(const TSourceLoc&, const char* token, TIntermNode*); @@ -584,6 +585,7 @@ class TParseContext : public TParseContextBase { TString currentCaller; // name of last function body entered (not valid when at global scope) int* atomicUintOffsets; // to become an array of the right size to hold an offset per binding point bool anyIndexLimits; + bool khrDerivativeLayoutQualifierSpecified; TIdSetType inductiveLoopIds; TVector needsIndexLimitationChecking; TStructRecord matrixFixRecord; diff --git a/glslang/MachineIndependent/Versions.cpp b/glslang/MachineIndependent/Versions.cpp index ce705a351c..8626b0f461 100644 --- a/glslang/MachineIndependent/Versions.cpp +++ b/glslang/MachineIndependent/Versions.cpp @@ -305,6 +305,7 @@ void TParseVersions::initializeExtensionBehavior() extensionBehavior[E_GL_NV_ray_tracing] = EBhDisable; extensionBehavior[E_GL_NV_ray_tracing_motion_blur] = EBhDisable; extensionBehavior[E_GL_NV_fragment_shader_barycentric] = EBhDisable; + extensionBehavior[E_GL_KHR_compute_shader_derivatives] = EBhDisable; extensionBehavior[E_GL_NV_compute_shader_derivatives] = EBhDisable; extensionBehavior[E_GL_NV_shader_texture_footprint] = EBhDisable; extensionBehavior[E_GL_NV_mesh_shader] = EBhDisable; @@ -600,6 +601,7 @@ void TParseVersions::getPreamble(std::string& preamble) "#define GL_NV_ray_tracing 1\n" "#define GL_NV_ray_tracing_motion_blur 1\n" "#define GL_NV_fragment_shader_barycentric 1\n" + "#define GL_KHR_compute_shader_derivatives 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" diff --git a/glslang/MachineIndependent/Versions.h b/glslang/MachineIndependent/Versions.h index bb17dc972d..7d4ea53a7d 100644 --- a/glslang/MachineIndependent/Versions.h +++ b/glslang/MachineIndependent/Versions.h @@ -280,6 +280,7 @@ const char* const E_GL_NV_shading_rate_image = "GL_NV_shading const char* const E_GL_NV_ray_tracing = "GL_NV_ray_tracing"; const char* const E_GL_NV_ray_tracing_motion_blur = "GL_NV_ray_tracing_motion_blur"; const char* const E_GL_NV_fragment_shader_barycentric = "GL_NV_fragment_shader_barycentric"; +const char* const E_GL_KHR_compute_shader_derivatives = "GL_KHR_compute_shader_derivatives"; 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"; diff --git a/glslang/MachineIndependent/localintermediate.h b/glslang/MachineIndependent/localintermediate.h index 209a724583..6cb1b30540 100644 --- a/glslang/MachineIndependent/localintermediate.h +++ b/glslang/MachineIndependent/localintermediate.h @@ -228,9 +228,9 @@ class TVariable; // Texture and Sampler transformation mode. // enum ComputeDerivativeMode { - LayoutDerivativeNone, // default layout as SPV_NV_compute_shader_derivatives not enabled - LayoutDerivativeGroupQuads, // derivative_group_quadsNV - LayoutDerivativeGroupLinear, // derivative_group_linearNV + LayoutDerivativeNone, + LayoutDerivativeGroupQuads, + LayoutDerivativeGroupLinear, }; // @@ -340,6 +340,7 @@ class TIntermediate { geoPassthroughEXT(false), numShaderRecordBlocks(0), computeDerivativeMode(LayoutDerivativeNone), + computeDerivativeExtension(EdgNone), primitives(TQualifier::layoutNotSet), numTaskNVBlocks(0), layoutPrimitiveCulling(false), @@ -984,9 +985,14 @@ class TIntermediate { bool getLayoutOverrideCoverage() const { return layoutOverrideCoverage; } void setGeoPassthroughEXT() { geoPassthroughEXT = true; } bool getGeoPassthroughEXT() const { return geoPassthroughEXT; } - void setLayoutDerivativeMode(ComputeDerivativeMode mode) { computeDerivativeMode = mode; } + void setLayoutDerivativeMode(ComputeDerivativeMode mode, TDerivativeGroupExtension extension) + { + computeDerivativeMode = mode; + computeDerivativeExtension = extension; + } bool hasLayoutDerivativeModeNone() const { return computeDerivativeMode != LayoutDerivativeNone; } ComputeDerivativeMode getLayoutDerivativeModeNone() const { return computeDerivativeMode; } + TDerivativeGroupExtension getLayoutDerivativeExtension() const { return computeDerivativeExtension; } void setLayoutPrimitiveCulling() { layoutPrimitiveCulling = true; } bool getLayoutPrimitiveCulling() const { return layoutPrimitiveCulling; } bool setPrimitives(int m) @@ -1287,6 +1293,7 @@ class TIntermediate { bool geoPassthroughEXT; int numShaderRecordBlocks; ComputeDerivativeMode computeDerivativeMode; + TDerivativeGroupExtension computeDerivativeExtension; int primitives; int numTaskNVBlocks; bool layoutPrimitiveCulling; diff --git a/gtests/Spv.FromFile.cpp b/gtests/Spv.FromFile.cpp index e9bcc4fe69..a49aff6a7a 100644 --- a/gtests/Spv.FromFile.cpp +++ b/gtests/Spv.FromFile.cpp @@ -807,6 +807,8 @@ INSTANTIATE_TEST_SUITE_P( "spv.WorkgroupMemoryExplicitLayout.std140.comp", "spv.WorkgroupMemoryExplicitLayout.std430.comp", "spv.WorkgroupMemoryExplicitLayout.scalar.comp", + "spv.khrComputeShaderDerivatives.comp", + "spv.khrComputeShaderDerivatives2.comp", // SPV_EXT_mesh_shader "spv.ext.meshShaderBuiltins.mesh", @@ -819,6 +821,8 @@ INSTANTIATE_TEST_SUITE_P( "spv.atomiAddEXT.task", "spv.460.subgroupEXT.task", "spv.460.subgroupEXT.mesh", + "spv.khrComputeShaderDerivatives.task", + "spv.khrComputeShaderDerivatives.mesh", // SPV_NV_shader_execution_reorder @@ -969,6 +973,10 @@ INSTANTIATE_TEST_SUITE_P( "samplerlessTextureFunctions.frag", "spv.intrinsicsFakeEnable.vert", "spv.specConstArrayCheck.vert", + "spv.khrComputeShaderDerivativesMissingLayout.comp", + "spv.khrComputeShaderDerivativesNoLayout.comp", + "spv.khrComputeShaderDerivativesBoth.comp", + "spv.khrComputeShaderDerivativesBadSize.comp", })), FileNameAsCustomTestSuffix );