From db8719ae079665ffab564c614b8614e56f325aea Mon Sep 17 00:00:00 2001 From: Wooyoung Kim Date: Mon, 21 Aug 2023 17:14:52 -0700 Subject: [PATCH] extension: GL_QCOM_image_processing support --- BUILD.gn | 1 + SPIRV/GLSL.ext.QCOM.h | 41 ++++++ SPIRV/GlslangToSpv.cpp | 51 +++++++ SPIRV/SpvBuilder.h | 1 + SPIRV/SpvPostProcess.cpp | 1 + SPIRV/disassemble.cpp | 1 + SPIRV/doc.cpp | 43 +++++- SPIRV/spirv.hpp | 13 ++ .../spv.tpipBlockMatchSAD.frag.out | 123 +++++++++++++++++ .../spv.tpipBlockMatchSSD.frag.out | 123 +++++++++++++++++ Test/baseResults/spv.tpipBoxFilter.frag.out | 81 +++++++++++ .../spv.tpipSampleWeighted.frag.out | 84 ++++++++++++ .../spv.tpipTextureArrays.frag.out | 128 ++++++++++++++++++ Test/spv.tpipBlockMatchSAD.frag | 38 ++++++ Test/spv.tpipBlockMatchSSD.frag | 38 ++++++ Test/spv.tpipBoxFilter.frag | 32 +++++ Test/spv.tpipSampleWeighted.frag | 32 +++++ Test/spv.tpipTextureArrays.frag | 40 ++++++ glslang/Include/intermediate.h | 6 + glslang/MachineIndependent/Initialize.cpp | 34 ++++- glslang/MachineIndependent/Versions.cpp | 7 + glslang/MachineIndependent/Versions.h | 2 + gtests/Spv.FromFile.cpp | 22 +++ known_good.json | 2 +- 24 files changed, 939 insertions(+), 5 deletions(-) create mode 100644 SPIRV/GLSL.ext.QCOM.h create mode 100644 Test/baseResults/spv.tpipBlockMatchSAD.frag.out create mode 100644 Test/baseResults/spv.tpipBlockMatchSSD.frag.out create mode 100644 Test/baseResults/spv.tpipBoxFilter.frag.out create mode 100644 Test/baseResults/spv.tpipSampleWeighted.frag.out create mode 100644 Test/baseResults/spv.tpipTextureArrays.frag.out create mode 100644 Test/spv.tpipBlockMatchSAD.frag create mode 100644 Test/spv.tpipBlockMatchSSD.frag create mode 100644 Test/spv.tpipBoxFilter.frag create mode 100644 Test/spv.tpipSampleWeighted.frag create mode 100644 Test/spv.tpipTextureArrays.frag diff --git a/BUILD.gn b/BUILD.gn index 85a4bed2e..0bb0d42ec 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -124,6 +124,7 @@ template("glslang_sources_common") { "SPIRV/GLSL.ext.KHR.h", "SPIRV/GLSL.ext.NV.h", "SPIRV/GLSL.ext.ARM.h", + "SPIRV/GLSL.ext.QCOM.h", "SPIRV/GLSL.std.450.h", "SPIRV/GlslangToSpv.cpp", "SPIRV/GlslangToSpv.h", diff --git a/SPIRV/GLSL.ext.QCOM.h b/SPIRV/GLSL.ext.QCOM.h new file mode 100644 index 000000000..f13bb6935 --- /dev/null +++ b/SPIRV/GLSL.ext.QCOM.h @@ -0,0 +1,41 @@ +/* +** Copyright (c) 2021 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a copy +** of this software and/or associated documentation files (the "Materials"), +** to deal in the Materials without restriction, including without limitation +** the rights to use, copy, modify, merge, publish, distribute, sublicense, +** and/or sell copies of the Materials, and to permit persons to whom the +** Materials are furnished to do so, subject to the following conditions: +** +** The above copyright notice and this permission notice shall be included in +** all copies or substantial portions of the Materials. +** +** MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS KHRONOS +** STANDARDS. THE UNMODIFIED, NORMATIVE VERSIONS OF KHRONOS SPECIFICATIONS AND +** HEADER INFORMATION ARE LOCATED AT https://www.khronos.org/registry/ +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +** OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +** THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +** FROM,OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS +** IN THE MATERIALS. +*/ + +#ifndef GLSLextQCOM_H +#define GLSLextQCOM_H + +enum BuiltIn; +enum Decoration; +enum Op; +enum Capability; + +static const int GLSLextQCOMVersion = 100; +static const int GLSLextQCOMRevision = 1; + +//SPV_QCOM_image_processing +const char* const E_SPV_QCOM_image_processing = "SPV_QCOM_image_processing"; + +#endif // #ifndef GLSLextQCOM_H diff --git a/SPIRV/GlslangToSpv.cpp b/SPIRV/GlslangToSpv.cpp index a3047cbd4..395315a17 100755 --- a/SPIRV/GlslangToSpv.cpp +++ b/SPIRV/GlslangToSpv.cpp @@ -50,6 +50,7 @@ namespace spv { #include "GLSL.ext.AMD.h" #include "GLSL.ext.NV.h" #include "GLSL.ext.ARM.h" + #include "GLSL.ext.QCOM.h" #include "NonSemanticDebugPrintf.h" } @@ -220,6 +221,7 @@ protected: spv::Id createNoArgOperation(glslang::TOperator op, spv::Decoration precision, spv::Id typeId); spv::Id getSymbolId(const glslang::TIntermSymbol* node); void addMeshNVDecoration(spv::Id id, int member, const glslang::TQualifier & qualifier); + void addImageProcessingQCOMDecoration(spv::Id id, spv::Decoration decor); spv::Id createSpvConstant(const glslang::TIntermTyped&); spv::Id createSpvConstantFromConstUnionArray(const glslang::TType& type, const glslang::TConstUnionArray&, int& nextConst, bool specConstant); @@ -3276,6 +3278,20 @@ bool TGlslangToSpvTraverser::visitAggregate(glslang::TVisit visit, glslang::TInt noReturnValue = true; break; + case glslang::EOpImageSampleWeightedQCOM: + builder.addCapability(spv::CapabilityTextureSampleWeightedQCOM); + builder.addExtension(spv::E_SPV_QCOM_image_processing); + break; + case glslang::EOpImageBoxFilterQCOM: + builder.addCapability(spv::CapabilityTextureBoxFilterQCOM); + builder.addExtension(spv::E_SPV_QCOM_image_processing); + break; + case glslang::EOpImageBlockMatchSADQCOM: + case glslang::EOpImageBlockMatchSSDQCOM: + builder.addCapability(spv::CapabilityTextureBlockMatchQCOM); + builder.addExtension(spv::E_SPV_QCOM_image_processing); + break; + case glslang::EOpDebugPrintf: noReturnValue = true; break; @@ -9023,6 +9039,27 @@ spv::Id TGlslangToSpvTraverser::createMiscOperation(glslang::TOperator op, spv:: return 0; } + + case glslang::EOpImageSampleWeightedQCOM: + typeId = builder.makeVectorType(builder.makeFloatType(32), 4); + opCode = spv::OpImageSampleWeightedQCOM; + addImageProcessingQCOMDecoration(operands[2], spv::DecorationWeightTextureQCOM); + break; + case glslang::EOpImageBoxFilterQCOM: + typeId = builder.makeVectorType(builder.makeFloatType(32), 4); + opCode = spv::OpImageBoxFilterQCOM; + break; + case glslang::EOpImageBlockMatchSADQCOM: + typeId = builder.makeVectorType(builder.makeFloatType(32), 4); + opCode = spv::OpImageBlockMatchSADQCOM; + addImageProcessingQCOMDecoration(operands[0], spv::DecorationBlockMatchTextureQCOM); + addImageProcessingQCOMDecoration(operands[2], spv::DecorationBlockMatchTextureQCOM); + break; + case glslang::EOpImageBlockMatchSSDQCOM: + typeId = builder.makeVectorType(builder.makeFloatType(32), 4); + opCode = spv::OpImageBlockMatchSSDQCOM; + addImageProcessingQCOMDecoration(operands[0], spv::DecorationBlockMatchTextureQCOM); + addImageProcessingQCOMDecoration(operands[2], spv::DecorationBlockMatchTextureQCOM); break; default: return 0; @@ -9568,6 +9605,20 @@ void TGlslangToSpvTraverser::addMeshNVDecoration(spv::Id id, int member, const g } } +void TGlslangToSpvTraverser::addImageProcessingQCOMDecoration(spv::Id id, spv::Decoration decor) +{ + spv::Op opc = builder.getOpCode(id); + if (opc == spv::OpSampledImage) { + id = builder.getIdOperand(id, 0); + opc = builder.getOpCode(id); + } + + if (opc == spv::OpLoad) { + spv::Id texid = builder.getIdOperand(id, 0); + builder.addDecoration(texid, decor); + } +} + // Make a full tree of instructions to build a SPIR-V specialization constant, // or regular constant if possible. // diff --git a/SPIRV/SpvBuilder.h b/SPIRV/SpvBuilder.h index 1f38e7899..79d2681f1 100644 --- a/SPIRV/SpvBuilder.h +++ b/SPIRV/SpvBuilder.h @@ -261,6 +261,7 @@ public: ImageFormat getImageTypeFormat(Id typeId) const { return (ImageFormat)module.getInstruction(typeId)->getImmediateOperand(6); } Id getResultingAccessChainType() const; + Id getIdOperand(Id resultId, int idx) { return module.getInstruction(resultId)->getIdOperand(idx); } bool isPointer(Id resultId) const { return isPointerType(getTypeId(resultId)); } bool isScalar(Id resultId) const { return isScalarType(getTypeId(resultId)); } diff --git a/SPIRV/SpvPostProcess.cpp b/SPIRV/SpvPostProcess.cpp index c4be36552..50fb793b4 100644 --- a/SPIRV/SpvPostProcess.cpp +++ b/SPIRV/SpvPostProcess.cpp @@ -53,6 +53,7 @@ namespace spv { #include "GLSL.ext.AMD.h" #include "GLSL.ext.NV.h" #include "GLSL.ext.ARM.h" + #include "GLSL.ext.QCOM.h" } namespace spv { diff --git a/SPIRV/disassemble.cpp b/SPIRV/disassemble.cpp index 479f4a64e..c5e961cf0 100644 --- a/SPIRV/disassemble.cpp +++ b/SPIRV/disassemble.cpp @@ -56,6 +56,7 @@ namespace spv { #include "GLSL.ext.NV.h" #include "GLSL.ext.ARM.h" #include "NonSemanticShaderDebugInfo100.h" + #include "GLSL.ext.QCOM.h" } } const char* GlslStd450DebugNames[spv::GLSLstd450Count]; diff --git a/SPIRV/doc.cpp b/SPIRV/doc.cpp index b7f0053dd..417e6e08a 100755 --- a/SPIRV/doc.cpp +++ b/SPIRV/doc.cpp @@ -55,6 +55,7 @@ namespace spv { #include "GLSL.ext.AMD.h" #include "GLSL.ext.NV.h" #include "GLSL.ext.ARM.h" + #include "GLSL.ext.QCOM.h" } } @@ -311,7 +312,9 @@ const char* DecorationString(int decoration) case DecorationCeiling: default: return "Bad"; - case DecorationExplicitInterpAMD: return "ExplicitInterpAMD"; + case DecorationWeightTextureQCOM: return "DecorationWeightTextureQCOM"; + case DecorationBlockMatchTextureQCOM: return "DecorationBlockMatchTextureQCOM"; + case DecorationExplicitInterpAMD: return "ExplicitInterpAMD"; case DecorationOverrideCoverageNV: return "OverrideCoverageNV"; case DecorationPassthroughNV: return "PassthroughNV"; case DecorationViewportRelativeNV: return "ViewportRelativeNV"; @@ -1040,6 +1043,11 @@ const char* CapabilityString(int info) case CapabilityCoreBuiltinsARM: return "CoreBuiltinsARM"; case CapabilityShaderInvocationReorderNV: return "ShaderInvocationReorderNV"; + + case CapabilityTextureSampleWeightedQCOM: return "TextureSampleWeightedQCOM"; + case CapabilityTextureBoxFilterQCOM: return "TextureBoxFilterQCOM"; + case CapabilityTextureBlockMatchQCOM: return "TextureBlockMatchQCOM"; + default: return "Bad"; } } @@ -1538,6 +1546,11 @@ const char* OpcodeString(int op) case OpDepthAttachmentReadEXT: return "OpDepthAttachmentReadEXT"; case OpStencilAttachmentReadEXT: return "OpStencilAttachmentReadEXT"; + case OpImageSampleWeightedQCOM: return "OpImageSampleWeightedQCOM"; + case OpImageBoxFilterQCOM: return "OpImageBoxFilterQCOM"; + case OpImageBlockMatchSADQCOM: return "OpImageBlockMatchSADQCOM"; + case OpImageBlockMatchSSDQCOM: return "OpImageBlockMatchSSDQCOM"; + default: return "Bad"; } @@ -3339,6 +3352,34 @@ void Parameterize() InstructionDesc[OpColorAttachmentReadEXT].operands.push(OperandId, "'Sample'", true); InstructionDesc[OpStencilAttachmentReadEXT].operands.push(OperandId, "'Sample'", true); InstructionDesc[OpDepthAttachmentReadEXT].operands.push(OperandId, "'Sample'", true); + + InstructionDesc[OpImageSampleWeightedQCOM].operands.push(OperandId, "'source texture'"); + InstructionDesc[OpImageSampleWeightedQCOM].operands.push(OperandId, "'texture coordinates'"); + InstructionDesc[OpImageSampleWeightedQCOM].operands.push(OperandId, "'weights texture'"); + InstructionDesc[OpImageSampleWeightedQCOM].operands.push(OperandImageOperands, "", true); + InstructionDesc[OpImageSampleWeightedQCOM].setResultAndType(true, true); + + InstructionDesc[OpImageBoxFilterQCOM].operands.push(OperandId, "'source texture'"); + InstructionDesc[OpImageBoxFilterQCOM].operands.push(OperandId, "'texture coordinates'"); + InstructionDesc[OpImageBoxFilterQCOM].operands.push(OperandId, "'box size'"); + InstructionDesc[OpImageBoxFilterQCOM].operands.push(OperandImageOperands, "", true); + InstructionDesc[OpImageBoxFilterQCOM].setResultAndType(true, true); + + InstructionDesc[OpImageBlockMatchSADQCOM].operands.push(OperandId, "'target texture'"); + InstructionDesc[OpImageBlockMatchSADQCOM].operands.push(OperandId, "'target coordinates'"); + InstructionDesc[OpImageBlockMatchSADQCOM].operands.push(OperandId, "'reference texture'"); + InstructionDesc[OpImageBlockMatchSADQCOM].operands.push(OperandId, "'reference coordinates'"); + InstructionDesc[OpImageBlockMatchSADQCOM].operands.push(OperandId, "'block size'"); + InstructionDesc[OpImageBlockMatchSADQCOM].operands.push(OperandImageOperands, "", true); + InstructionDesc[OpImageBlockMatchSADQCOM].setResultAndType(true, true); + + InstructionDesc[OpImageBlockMatchSSDQCOM].operands.push(OperandId, "'target texture'"); + InstructionDesc[OpImageBlockMatchSSDQCOM].operands.push(OperandId, "'target coordinates'"); + InstructionDesc[OpImageBlockMatchSSDQCOM].operands.push(OperandId, "'reference texture'"); + InstructionDesc[OpImageBlockMatchSSDQCOM].operands.push(OperandId, "'reference coordinates'"); + InstructionDesc[OpImageBlockMatchSSDQCOM].operands.push(OperandId, "'block size'"); + InstructionDesc[OpImageBlockMatchSSDQCOM].operands.push(OperandImageOperands, "", true); + InstructionDesc[OpImageBlockMatchSSDQCOM].setResultAndType(true, true); }); } diff --git a/SPIRV/spirv.hpp b/SPIRV/spirv.hpp index 4fb721ef1..bdc96fa39 100644 --- a/SPIRV/spirv.hpp +++ b/SPIRV/spirv.hpp @@ -513,6 +513,8 @@ enum Decoration { DecorationMaxByteOffsetId = 47, DecorationNoSignedWrap = 4469, DecorationNoUnsignedWrap = 4470, + DecorationWeightTextureQCOM = 4487, + DecorationBlockMatchTextureQCOM = 4488, DecorationExplicitInterpAMD = 4999, DecorationOverrideCoverageNV = 5248, DecorationPassthroughNV = 5250, @@ -1023,6 +1025,9 @@ enum Capability { CapabilityRayQueryKHR = 4472, CapabilityRayTraversalPrimitiveCullingKHR = 4478, CapabilityRayTracingKHR = 4479, + CapabilityTextureSampleWeightedQCOM = 4484, + CapabilityTextureBoxFilterQCOM = 4485, + CapabilityTextureBlockMatchQCOM = 4486, CapabilityFloat16ImageAMD = 5008, CapabilityImageGatherBiasLodAMD = 5009, CapabilityFragmentMaskAMD = 5010, @@ -1678,6 +1683,10 @@ enum Op { OpRayQueryConfirmIntersectionKHR = 4476, OpRayQueryProceedKHR = 4477, OpRayQueryGetIntersectionTypeKHR = 4479, + OpImageSampleWeightedQCOM = 4480, + OpImageBoxFilterQCOM = 4481, + OpImageBlockMatchSSDQCOM = 4482, + OpImageBlockMatchSADQCOM = 4483, OpGroupIAddNonUniformAMD = 5000, OpGroupFAddNonUniformAMD = 5001, OpGroupFMinNonUniformAMD = 5002, @@ -2395,6 +2404,10 @@ inline void HasResultAndType(Op opcode, bool *hasResult, bool *hasResultType) { case OpRayQueryConfirmIntersectionKHR: *hasResult = false; *hasResultType = false; break; case OpRayQueryProceedKHR: *hasResult = true; *hasResultType = true; break; case OpRayQueryGetIntersectionTypeKHR: *hasResult = true; *hasResultType = true; break; + case OpImageSampleWeightedQCOM: *hasResult = true; *hasResultType = true; break; + case OpImageBoxFilterQCOM: *hasResult = true; *hasResultType = true; break; + case OpImageBlockMatchSSDQCOM: *hasResult = true; *hasResultType = true; break; + case OpImageBlockMatchSADQCOM: *hasResult = true; *hasResultType = true; break; case OpGroupIAddNonUniformAMD: *hasResult = true; *hasResultType = true; break; case OpGroupFAddNonUniformAMD: *hasResult = true; *hasResultType = true; break; case OpGroupFMinNonUniformAMD: *hasResult = true; *hasResultType = true; break; diff --git a/Test/baseResults/spv.tpipBlockMatchSAD.frag.out b/Test/baseResults/spv.tpipBlockMatchSAD.frag.out new file mode 100644 index 000000000..a807d9238 --- /dev/null +++ b/Test/baseResults/spv.tpipBlockMatchSAD.frag.out @@ -0,0 +1,123 @@ +spv.tpipBlockMatchSAD.frag +// Module Version 10000 +// Generated by (magic number): 8000b +// Id's are bound by 72 + + Capability Shader + Capability TextureBlockMatchQCOM + Extension "SPV_QCOM_image_processing" + 1: ExtInstImport "GLSL.std.450" + MemoryModel Logical GLSL450 + EntryPoint Fragment 4 "main" 13 41 + ExecutionMode 4 OriginUpperLeft + Source GLSL 450 + SourceExtension "GL_QCOM_image_processing" + Name 4 "main" + Name 9 "tgt_coords" + Name 13 "v_texcoord" + Name 26 "ref_coords" + Name 37 "blockSize" + Name 41 "fragColor" + Name 44 "tex2D_src1" + Name 48 "samp" + Name 53 "tex2D_src2" + Name 61 "target_samp" + Name 64 "ref_samp" + Name 71 "tex2DArray_weights" + Decorate 13(v_texcoord) Location 0 + Decorate 41(fragColor) Location 0 + Decorate 44(tex2D_src1) DescriptorSet 0 + Decorate 44(tex2D_src1) Binding 1 + Decorate 48(samp) DescriptorSet 0 + Decorate 48(samp) Binding 3 + Decorate 53(tex2D_src2) DescriptorSet 0 + Decorate 53(tex2D_src2) Binding 2 + Decorate 44(tex2D_src1) DecorationBlockMatchTextureQCOM + Decorate 53(tex2D_src2) DecorationBlockMatchTextureQCOM + Decorate 61(target_samp) DescriptorSet 0 + Decorate 61(target_samp) Binding 4 + Decorate 64(ref_samp) DescriptorSet 0 + Decorate 64(ref_samp) Binding 5 + Decorate 61(target_samp) DecorationBlockMatchTextureQCOM + Decorate 64(ref_samp) DecorationBlockMatchTextureQCOM + Decorate 71(tex2DArray_weights) DescriptorSet 0 + Decorate 71(tex2DArray_weights) Binding 0 + 2: TypeVoid + 3: TypeFunction 2 + 6: TypeInt 32 0 + 7: TypeVector 6(int) 2 + 8: TypePointer Function 7(ivec2) + 10: TypeFloat 32 + 11: TypeVector 10(float) 4 + 12: TypePointer Input 11(fvec4) + 13(v_texcoord): 12(ptr) Variable Input + 14: 6(int) Constant 0 + 15: TypePointer Input 10(float) + 19: TypePointer Function 6(int) + 21: 6(int) Constant 1 + 27: 6(int) Constant 2 + 32: 6(int) Constant 3 + 38: 6(int) Constant 4 + 39: 7(ivec2) ConstantComposite 38 38 + 40: TypePointer Output 11(fvec4) + 41(fragColor): 40(ptr) Variable Output + 42: TypeImage 10(float) 2D sampled format:Unknown + 43: TypePointer UniformConstant 42 + 44(tex2D_src1): 43(ptr) Variable UniformConstant + 46: TypeSampler + 47: TypePointer UniformConstant 46 + 48(samp): 47(ptr) Variable UniformConstant + 50: TypeSampledImage 42 + 53(tex2D_src2): 43(ptr) Variable UniformConstant + 60: TypePointer UniformConstant 50 + 61(target_samp): 60(ptr) Variable UniformConstant + 64(ref_samp): 60(ptr) Variable UniformConstant + 69: TypeImage 10(float) 2D array sampled format:Unknown + 70: TypePointer UniformConstant 69 +71(tex2DArray_weights): 70(ptr) Variable UniformConstant + 4(main): 2 Function None 3 + 5: Label + 9(tgt_coords): 8(ptr) Variable Function + 26(ref_coords): 8(ptr) Variable Function + 37(blockSize): 8(ptr) Variable Function + 16: 15(ptr) AccessChain 13(v_texcoord) 14 + 17: 10(float) Load 16 + 18: 6(int) ConvertFToU 17 + 20: 19(ptr) AccessChain 9(tgt_coords) 14 + Store 20 18 + 22: 15(ptr) AccessChain 13(v_texcoord) 21 + 23: 10(float) Load 22 + 24: 6(int) ConvertFToU 23 + 25: 19(ptr) AccessChain 9(tgt_coords) 14 + Store 25 24 + 28: 15(ptr) AccessChain 13(v_texcoord) 27 + 29: 10(float) Load 28 + 30: 6(int) ConvertFToU 29 + 31: 19(ptr) AccessChain 26(ref_coords) 14 + Store 31 30 + 33: 15(ptr) AccessChain 13(v_texcoord) 32 + 34: 10(float) Load 33 + 35: 6(int) ConvertFToU 34 + 36: 19(ptr) AccessChain 26(ref_coords) 21 + Store 36 35 + Store 37(blockSize) 39 + 45: 42 Load 44(tex2D_src1) + 49: 46 Load 48(samp) + 51: 50 SampledImage 45 49 + 52: 7(ivec2) Load 9(tgt_coords) + 54: 42 Load 53(tex2D_src2) + 55: 46 Load 48(samp) + 56: 50 SampledImage 54 55 + 57: 7(ivec2) Load 26(ref_coords) + 58: 7(ivec2) Load 37(blockSize) + 59: 11(fvec4) ImageBlockMatchSADQCOM 51 52 56 57 58 + Store 41(fragColor) 59 + 62: 50 Load 61(target_samp) + 63: 7(ivec2) Load 9(tgt_coords) + 65: 50 Load 64(ref_samp) + 66: 7(ivec2) Load 26(ref_coords) + 67: 7(ivec2) Load 37(blockSize) + 68: 11(fvec4) ImageBlockMatchSADQCOM 62 63 65 66 67 + Store 41(fragColor) 68 + Return + FunctionEnd diff --git a/Test/baseResults/spv.tpipBlockMatchSSD.frag.out b/Test/baseResults/spv.tpipBlockMatchSSD.frag.out new file mode 100644 index 000000000..e7ac73b63 --- /dev/null +++ b/Test/baseResults/spv.tpipBlockMatchSSD.frag.out @@ -0,0 +1,123 @@ +spv.tpipBlockMatchSSD.frag +// Module Version 10000 +// Generated by (magic number): 8000b +// Id's are bound by 72 + + Capability Shader + Capability TextureBlockMatchQCOM + Extension "SPV_QCOM_image_processing" + 1: ExtInstImport "GLSL.std.450" + MemoryModel Logical GLSL450 + EntryPoint Fragment 4 "main" 13 41 + ExecutionMode 4 OriginUpperLeft + Source GLSL 450 + SourceExtension "GL_QCOM_image_processing" + Name 4 "main" + Name 9 "tgt_coords" + Name 13 "v_texcoord" + Name 26 "ref_coords" + Name 37 "blockSize" + Name 41 "fragColor" + Name 44 "tex2D_src1" + Name 48 "samp" + Name 53 "tex2D_src2" + Name 61 "target_samp" + Name 64 "ref_samp" + Name 71 "tex2DArray_weights" + Decorate 13(v_texcoord) Location 0 + Decorate 41(fragColor) Location 0 + Decorate 44(tex2D_src1) DescriptorSet 0 + Decorate 44(tex2D_src1) Binding 1 + Decorate 48(samp) DescriptorSet 0 + Decorate 48(samp) Binding 3 + Decorate 53(tex2D_src2) DescriptorSet 0 + Decorate 53(tex2D_src2) Binding 2 + Decorate 44(tex2D_src1) DecorationBlockMatchTextureQCOM + Decorate 53(tex2D_src2) DecorationBlockMatchTextureQCOM + Decorate 61(target_samp) DescriptorSet 0 + Decorate 61(target_samp) Binding 4 + Decorate 64(ref_samp) DescriptorSet 0 + Decorate 64(ref_samp) Binding 5 + Decorate 61(target_samp) DecorationBlockMatchTextureQCOM + Decorate 64(ref_samp) DecorationBlockMatchTextureQCOM + Decorate 71(tex2DArray_weights) DescriptorSet 0 + Decorate 71(tex2DArray_weights) Binding 0 + 2: TypeVoid + 3: TypeFunction 2 + 6: TypeInt 32 0 + 7: TypeVector 6(int) 2 + 8: TypePointer Function 7(ivec2) + 10: TypeFloat 32 + 11: TypeVector 10(float) 4 + 12: TypePointer Input 11(fvec4) + 13(v_texcoord): 12(ptr) Variable Input + 14: 6(int) Constant 0 + 15: TypePointer Input 10(float) + 19: TypePointer Function 6(int) + 21: 6(int) Constant 1 + 27: 6(int) Constant 2 + 32: 6(int) Constant 3 + 38: 6(int) Constant 4 + 39: 7(ivec2) ConstantComposite 38 38 + 40: TypePointer Output 11(fvec4) + 41(fragColor): 40(ptr) Variable Output + 42: TypeImage 10(float) 2D sampled format:Unknown + 43: TypePointer UniformConstant 42 + 44(tex2D_src1): 43(ptr) Variable UniformConstant + 46: TypeSampler + 47: TypePointer UniformConstant 46 + 48(samp): 47(ptr) Variable UniformConstant + 50: TypeSampledImage 42 + 53(tex2D_src2): 43(ptr) Variable UniformConstant + 60: TypePointer UniformConstant 50 + 61(target_samp): 60(ptr) Variable UniformConstant + 64(ref_samp): 60(ptr) Variable UniformConstant + 69: TypeImage 10(float) 2D array sampled format:Unknown + 70: TypePointer UniformConstant 69 +71(tex2DArray_weights): 70(ptr) Variable UniformConstant + 4(main): 2 Function None 3 + 5: Label + 9(tgt_coords): 8(ptr) Variable Function + 26(ref_coords): 8(ptr) Variable Function + 37(blockSize): 8(ptr) Variable Function + 16: 15(ptr) AccessChain 13(v_texcoord) 14 + 17: 10(float) Load 16 + 18: 6(int) ConvertFToU 17 + 20: 19(ptr) AccessChain 9(tgt_coords) 14 + Store 20 18 + 22: 15(ptr) AccessChain 13(v_texcoord) 21 + 23: 10(float) Load 22 + 24: 6(int) ConvertFToU 23 + 25: 19(ptr) AccessChain 9(tgt_coords) 14 + Store 25 24 + 28: 15(ptr) AccessChain 13(v_texcoord) 27 + 29: 10(float) Load 28 + 30: 6(int) ConvertFToU 29 + 31: 19(ptr) AccessChain 26(ref_coords) 14 + Store 31 30 + 33: 15(ptr) AccessChain 13(v_texcoord) 32 + 34: 10(float) Load 33 + 35: 6(int) ConvertFToU 34 + 36: 19(ptr) AccessChain 26(ref_coords) 21 + Store 36 35 + Store 37(blockSize) 39 + 45: 42 Load 44(tex2D_src1) + 49: 46 Load 48(samp) + 51: 50 SampledImage 45 49 + 52: 7(ivec2) Load 9(tgt_coords) + 54: 42 Load 53(tex2D_src2) + 55: 46 Load 48(samp) + 56: 50 SampledImage 54 55 + 57: 7(ivec2) Load 26(ref_coords) + 58: 7(ivec2) Load 37(blockSize) + 59: 11(fvec4) ImageBlockMatchSSDQCOM 51 52 56 57 58 + Store 41(fragColor) 59 + 62: 50 Load 61(target_samp) + 63: 7(ivec2) Load 9(tgt_coords) + 65: 50 Load 64(ref_samp) + 66: 7(ivec2) Load 26(ref_coords) + 67: 7(ivec2) Load 37(blockSize) + 68: 11(fvec4) ImageBlockMatchSSDQCOM 62 63 65 66 67 + Store 41(fragColor) 68 + Return + FunctionEnd diff --git a/Test/baseResults/spv.tpipBoxFilter.frag.out b/Test/baseResults/spv.tpipBoxFilter.frag.out new file mode 100644 index 000000000..5620a8162 --- /dev/null +++ b/Test/baseResults/spv.tpipBoxFilter.frag.out @@ -0,0 +1,81 @@ +spv.tpipBoxFilter.frag +// Module Version 10000 +// Generated by (magic number): 8000b +// Id's are bound by 43 + + Capability Shader + Capability TextureBoxFilterQCOM + Extension "SPV_QCOM_image_processing" + 1: ExtInstImport "GLSL.std.450" + MemoryModel Logical GLSL450 + EntryPoint Fragment 4 "main" 15 27 + ExecutionMode 4 OriginUpperLeft + Source GLSL 450 + SourceExtension "GL_QCOM_image_processing" + Name 4 "main" + Name 9 "boxSize" + Name 15 "fragColor" + Name 18 "tex2D_src1" + Name 22 "samp" + Name 27 "v_texcoord" + Name 33 "tex_samp" + Name 41 "tex2DArray_weights" + Name 42 "tex2D_src2" + Decorate 15(fragColor) Location 0 + Decorate 18(tex2D_src1) DescriptorSet 0 + Decorate 18(tex2D_src1) Binding 1 + Decorate 22(samp) DescriptorSet 0 + Decorate 22(samp) Binding 3 + Decorate 27(v_texcoord) Location 0 + Decorate 33(tex_samp) DescriptorSet 0 + Decorate 33(tex_samp) Binding 4 + Decorate 41(tex2DArray_weights) DescriptorSet 0 + Decorate 41(tex2DArray_weights) Binding 0 + Decorate 42(tex2D_src2) DescriptorSet 0 + Decorate 42(tex2D_src2) Binding 2 + 2: TypeVoid + 3: TypeFunction 2 + 6: TypeFloat 32 + 7: TypeVector 6(float) 2 + 8: TypePointer Function 7(fvec2) + 10: 6(float) Constant 1075838976 + 11: 6(float) Constant 1083179008 + 12: 7(fvec2) ConstantComposite 10 11 + 13: TypeVector 6(float) 4 + 14: TypePointer Output 13(fvec4) + 15(fragColor): 14(ptr) Variable Output + 16: TypeImage 6(float) 2D sampled format:Unknown + 17: TypePointer UniformConstant 16 + 18(tex2D_src1): 17(ptr) Variable UniformConstant + 20: TypeSampler + 21: TypePointer UniformConstant 20 + 22(samp): 21(ptr) Variable UniformConstant + 24: TypeSampledImage 16 + 26: TypePointer Input 13(fvec4) + 27(v_texcoord): 26(ptr) Variable Input + 32: TypePointer UniformConstant 24 + 33(tex_samp): 32(ptr) Variable UniformConstant + 39: TypeImage 6(float) 2D array sampled format:Unknown + 40: TypePointer UniformConstant 39 +41(tex2DArray_weights): 40(ptr) Variable UniformConstant + 42(tex2D_src2): 17(ptr) Variable UniformConstant + 4(main): 2 Function None 3 + 5: Label + 9(boxSize): 8(ptr) Variable Function + Store 9(boxSize) 12 + 19: 16 Load 18(tex2D_src1) + 23: 20 Load 22(samp) + 25: 24 SampledImage 19 23 + 28: 13(fvec4) Load 27(v_texcoord) + 29: 7(fvec2) VectorShuffle 28 28 0 1 + 30: 7(fvec2) Load 9(boxSize) + 31: 13(fvec4) ImageBoxFilterQCOM 25 29 30 + Store 15(fragColor) 31 + 34: 24 Load 33(tex_samp) + 35: 13(fvec4) Load 27(v_texcoord) + 36: 7(fvec2) VectorShuffle 35 35 0 1 + 37: 7(fvec2) Load 9(boxSize) + 38: 13(fvec4) ImageBoxFilterQCOM 34 36 37 + Store 15(fragColor) 38 + Return + FunctionEnd diff --git a/Test/baseResults/spv.tpipSampleWeighted.frag.out b/Test/baseResults/spv.tpipSampleWeighted.frag.out new file mode 100644 index 000000000..bf108742d --- /dev/null +++ b/Test/baseResults/spv.tpipSampleWeighted.frag.out @@ -0,0 +1,84 @@ +spv.tpipSampleWeighted.frag +// Module Version 10000 +// Generated by (magic number): 8000b +// Id's are bound by 43 + + Capability Shader + Capability TextureSampleWeightedQCOM + Extension "SPV_QCOM_image_processing" + 1: ExtInstImport "GLSL.std.450" + MemoryModel Logical GLSL450 + EntryPoint Fragment 4 "main" 9 21 + ExecutionMode 4 OriginUpperLeft + Source GLSL 450 + SourceExtension "GL_QCOM_image_processing" + Name 4 "main" + Name 9 "fragColor" + Name 12 "tex2D_src1" + Name 16 "samp" + Name 21 "v_texcoord" + Name 27 "tex2DArray_weights" + Name 34 "tex_samp" + Name 39 "tex_samp_array" + Name 42 "tex2D_src2" + Decorate 9(fragColor) Location 0 + Decorate 12(tex2D_src1) DescriptorSet 0 + Decorate 12(tex2D_src1) Binding 1 + Decorate 16(samp) DescriptorSet 0 + Decorate 16(samp) Binding 3 + Decorate 21(v_texcoord) Location 0 + Decorate 27(tex2DArray_weights) DescriptorSet 0 + Decorate 27(tex2DArray_weights) Binding 0 + Decorate 27(tex2DArray_weights) DecorationWeightTextureQCOM + Decorate 34(tex_samp) DescriptorSet 0 + Decorate 34(tex_samp) Binding 4 + Decorate 39(tex_samp_array) DescriptorSet 0 + Decorate 39(tex_samp_array) Binding 5 + Decorate 39(tex_samp_array) DecorationWeightTextureQCOM + Decorate 42(tex2D_src2) DescriptorSet 0 + Decorate 42(tex2D_src2) Binding 2 + 2: TypeVoid + 3: TypeFunction 2 + 6: TypeFloat 32 + 7: TypeVector 6(float) 4 + 8: TypePointer Output 7(fvec4) + 9(fragColor): 8(ptr) Variable Output + 10: TypeImage 6(float) 2D sampled format:Unknown + 11: TypePointer UniformConstant 10 + 12(tex2D_src1): 11(ptr) Variable UniformConstant + 14: TypeSampler + 15: TypePointer UniformConstant 14 + 16(samp): 15(ptr) Variable UniformConstant + 18: TypeSampledImage 10 + 20: TypePointer Input 7(fvec4) + 21(v_texcoord): 20(ptr) Variable Input + 22: TypeVector 6(float) 2 + 25: TypeImage 6(float) 2D array sampled format:Unknown + 26: TypePointer UniformConstant 25 +27(tex2DArray_weights): 26(ptr) Variable UniformConstant + 30: TypeSampledImage 25 + 33: TypePointer UniformConstant 18 + 34(tex_samp): 33(ptr) Variable UniformConstant + 38: TypePointer UniformConstant 30 +39(tex_samp_array): 38(ptr) Variable UniformConstant + 42(tex2D_src2): 11(ptr) Variable UniformConstant + 4(main): 2 Function None 3 + 5: Label + 13: 10 Load 12(tex2D_src1) + 17: 14 Load 16(samp) + 19: 18 SampledImage 13 17 + 23: 7(fvec4) Load 21(v_texcoord) + 24: 22(fvec2) VectorShuffle 23 23 0 1 + 28: 25 Load 27(tex2DArray_weights) + 29: 14 Load 16(samp) + 31: 30 SampledImage 28 29 + 32: 7(fvec4) ImageSampleWeightedQCOM 19 24 31 + Store 9(fragColor) 32 + 35: 18 Load 34(tex_samp) + 36: 7(fvec4) Load 21(v_texcoord) + 37: 22(fvec2) VectorShuffle 36 36 0 1 + 40: 30 Load 39(tex_samp_array) + 41: 7(fvec4) ImageSampleWeightedQCOM 35 37 40 + Store 9(fragColor) 41 + Return + FunctionEnd diff --git a/Test/baseResults/spv.tpipTextureArrays.frag.out b/Test/baseResults/spv.tpipTextureArrays.frag.out new file mode 100644 index 000000000..28b63f571 --- /dev/null +++ b/Test/baseResults/spv.tpipTextureArrays.frag.out @@ -0,0 +1,128 @@ +spv.tpipTextureArrays.frag +// Module Version 10000 +// Generated by (magic number): 8000b +// Id's are bound by 84 + + Capability Shader + Capability TextureBlockMatchQCOM + Extension "SPV_QCOM_image_processing" + 1: ExtInstImport "GLSL.std.450" + MemoryModel Logical GLSL450 + EntryPoint Fragment 4 "main" 13 46 + ExecutionMode 4 OriginUpperLeft + Source GLSL 450 + SourceExtension "GL_QCOM_image_processing" + Name 4 "main" + Name 9 "tgt_coords" + Name 13 "v_texcoord" + Name 26 "ref_coords" + Name 37 "blockSize" + Name 40 "ii" + Name 46 "fragColor" + Name 51 "samplers" + Name 60 "tex2D_srcs" + Name 67 "samp" + Decorate 13(v_texcoord) Location 0 + Decorate 46(fragColor) Location 0 + Decorate 51(samplers) DescriptorSet 0 + Decorate 51(samplers) Binding 5 + Decorate 60(tex2D_srcs) DescriptorSet 0 + Decorate 60(tex2D_srcs) Binding 4 + Decorate 67(samp) DescriptorSet 0 + Decorate 67(samp) Binding 3 + Decorate 55 DecorationBlockMatchTextureQCOM + Decorate 63 DecorationBlockMatchTextureQCOM + Decorate 74 DecorationBlockMatchTextureQCOM + Decorate 79 DecorationBlockMatchTextureQCOM + 2: TypeVoid + 3: TypeFunction 2 + 6: TypeInt 32 0 + 7: TypeVector 6(int) 2 + 8: TypePointer Function 7(ivec2) + 10: TypeFloat 32 + 11: TypeVector 10(float) 4 + 12: TypePointer Input 11(fvec4) + 13(v_texcoord): 12(ptr) Variable Input + 14: 6(int) Constant 0 + 15: TypePointer Input 10(float) + 19: TypePointer Function 6(int) + 21: 6(int) Constant 1 + 27: 6(int) Constant 2 + 32: 6(int) Constant 3 + 38: 6(int) Constant 4 + 39: 7(ivec2) ConstantComposite 38 38 + 43: 6(int) Constant 8 + 45: TypePointer Output 11(fvec4) + 46(fragColor): 45(ptr) Variable Output + 47: TypeImage 10(float) 2D sampled format:Unknown + 48: TypeSampledImage 47 + 49: TypeArray 48 32 + 50: TypePointer UniformConstant 49 + 51(samplers): 50(ptr) Variable UniformConstant + 52: TypeInt 32 1 + 53: 52(int) Constant 0 + 54: TypePointer UniformConstant 48 + 58: TypeArray 47 43 + 59: TypePointer UniformConstant 58 + 60(tex2D_srcs): 59(ptr) Variable UniformConstant + 62: TypePointer UniformConstant 47 + 65: TypeSampler + 66: TypePointer UniformConstant 65 + 67(samp): 66(ptr) Variable UniformConstant + 73: 52(int) Constant 1 + 4(main): 2 Function None 3 + 5: Label + 9(tgt_coords): 8(ptr) Variable Function + 26(ref_coords): 8(ptr) Variable Function + 37(blockSize): 8(ptr) Variable Function + 40(ii): 19(ptr) Variable Function + 16: 15(ptr) AccessChain 13(v_texcoord) 14 + 17: 10(float) Load 16 + 18: 6(int) ConvertFToU 17 + 20: 19(ptr) AccessChain 9(tgt_coords) 14 + Store 20 18 + 22: 15(ptr) AccessChain 13(v_texcoord) 21 + 23: 10(float) Load 22 + 24: 6(int) ConvertFToU 23 + 25: 19(ptr) AccessChain 9(tgt_coords) 14 + Store 25 24 + 28: 15(ptr) AccessChain 13(v_texcoord) 27 + 29: 10(float) Load 28 + 30: 6(int) ConvertFToU 29 + 31: 19(ptr) AccessChain 26(ref_coords) 14 + Store 31 30 + 33: 15(ptr) AccessChain 13(v_texcoord) 32 + 34: 10(float) Load 33 + 35: 6(int) ConvertFToU 34 + 36: 19(ptr) AccessChain 26(ref_coords) 21 + Store 36 35 + Store 37(blockSize) 39 + 41: 19(ptr) AccessChain 9(tgt_coords) 14 + 42: 6(int) Load 41 + 44: 6(int) UMod 42 43 + Store 40(ii) 44 + 55: 54(ptr) AccessChain 51(samplers) 53 + 56: 48 Load 55 + 57: 7(ivec2) Load 9(tgt_coords) + 61: 6(int) Load 40(ii) + 63: 62(ptr) AccessChain 60(tex2D_srcs) 61 + 64: 47 Load 63 + 68: 65 Load 67(samp) + 69: 48 SampledImage 64 68 + 70: 7(ivec2) Load 26(ref_coords) + 71: 7(ivec2) Load 37(blockSize) + 72: 11(fvec4) ImageBlockMatchSSDQCOM 56 57 69 70 71 + Store 46(fragColor) 72 + 74: 62(ptr) AccessChain 60(tex2D_srcs) 73 + 75: 47 Load 74 + 76: 65 Load 67(samp) + 77: 48 SampledImage 75 76 + 78: 7(ivec2) Load 9(tgt_coords) + 79: 54(ptr) AccessChain 51(samplers) 73 + 80: 48 Load 79 + 81: 7(ivec2) Load 26(ref_coords) + 82: 7(ivec2) Load 37(blockSize) + 83: 11(fvec4) ImageBlockMatchSADQCOM 77 78 80 81 82 + Store 46(fragColor) 83 + Return + FunctionEnd diff --git a/Test/spv.tpipBlockMatchSAD.frag b/Test/spv.tpipBlockMatchSAD.frag new file mode 100644 index 000000000..832f59d49 --- /dev/null +++ b/Test/spv.tpipBlockMatchSAD.frag @@ -0,0 +1,38 @@ +#version 450 +#extension GL_QCOM_image_processing : require + +precision highp float; + +// fragment shader inputs and outputs +layout (location = 0) in vec4 v_texcoord; + +layout (location = 0) out vec4 fragColor; + +// fragment shader resources +layout(set = 0, binding = 0) uniform texture2DArray tex2DArray_weights; +layout(set = 0, binding = 1) uniform texture2D tex2D_src1; +layout(set = 0, binding = 2) uniform texture2D tex2D_src2; +layout(set = 0, binding = 3) uniform sampler samp; +layout(set = 0, binding = 4) uniform sampler2D target_samp; +layout(set = 0, binding = 5) uniform sampler2D ref_samp; + +void main() +{ + + uvec2 tgt_coords; tgt_coords.x = uint(v_texcoord.x); tgt_coords.x = uint(v_texcoord.y); + uvec2 ref_coords; ref_coords.x = uint(v_texcoord.z); ref_coords.y = uint(v_texcoord.w); + uvec2 blockSize = uvec2(4, 4); + fragColor = textureBlockMatchSADQCOM( + sampler2D(tex2D_src1, samp), // target texture + tgt_coords, // target coords + sampler2D(tex2D_src2, samp), // reference texture + ref_coords, // reference coords + blockSize); // block size + fragColor = textureBlockMatchSADQCOM( + target_samp, // target texture + tgt_coords, // target coords + ref_samp, // reference texture + ref_coords, // reference coords + blockSize); // block size +} + diff --git a/Test/spv.tpipBlockMatchSSD.frag b/Test/spv.tpipBlockMatchSSD.frag new file mode 100644 index 000000000..aa3ff2a95 --- /dev/null +++ b/Test/spv.tpipBlockMatchSSD.frag @@ -0,0 +1,38 @@ +#version 450 +#extension GL_QCOM_image_processing : require + +precision highp float; + +// fragment shader inputs and outputs +layout (location = 0) in vec4 v_texcoord; + +layout (location = 0) out vec4 fragColor; + +// fragment shader resources +layout(set = 0, binding = 0) uniform texture2DArray tex2DArray_weights; +layout(set = 0, binding = 1) uniform texture2D tex2D_src1; +layout(set = 0, binding = 2) uniform texture2D tex2D_src2; +layout(set = 0, binding = 3) uniform sampler samp; +layout(set = 0, binding = 4) uniform sampler2D target_samp; +layout(set = 0, binding = 5) uniform sampler2D ref_samp; + +void main() +{ + + uvec2 tgt_coords; tgt_coords.x = uint(v_texcoord.x); tgt_coords.x = uint(v_texcoord.y); + uvec2 ref_coords; ref_coords.x = uint(v_texcoord.z); ref_coords.y = uint(v_texcoord.w); + uvec2 blockSize = uvec2(4, 4); + fragColor = textureBlockMatchSSDQCOM( + sampler2D(tex2D_src1, samp), // target texture + tgt_coords, // target coords + sampler2D(tex2D_src2, samp), // reference texture + ref_coords, // reference coords + blockSize); // block size + fragColor = textureBlockMatchSSDQCOM( + target_samp, // target texture + tgt_coords, // target coords + ref_samp, // reference texture + ref_coords, // reference coords + blockSize); // block size +} + diff --git a/Test/spv.tpipBoxFilter.frag b/Test/spv.tpipBoxFilter.frag new file mode 100644 index 000000000..d86d531e2 --- /dev/null +++ b/Test/spv.tpipBoxFilter.frag @@ -0,0 +1,32 @@ +#version 450 +#extension GL_QCOM_image_processing : require + +precision highp float; + +// fragment shader inputs and outputs +layout (location = 0) in vec4 v_texcoord; + +layout (location = 0) out vec4 fragColor; + +// fragment shader resources +layout(set = 0, binding = 0) uniform texture2DArray tex2DArray_weights; +layout(set = 0, binding = 1) uniform texture2D tex2D_src1; +layout(set = 0, binding = 2) uniform texture2D tex2D_src2; +layout(set = 0, binding = 3) uniform sampler samp; +layout(set = 0, binding = 4) uniform sampler2D tex_samp; + +void main() +{ + + vec2 boxSize = vec2(2.5, 4.5); + fragColor = textureBoxFilterQCOM( + sampler2D(tex2D_src1, samp), // source texture + v_texcoord.xy, // tex coords + boxSize); // box size + fragColor = textureBoxFilterQCOM( + tex_samp, // combined source texture + v_texcoord.xy, // tex coords + boxSize); // box size + +} + diff --git a/Test/spv.tpipSampleWeighted.frag b/Test/spv.tpipSampleWeighted.frag new file mode 100644 index 000000000..0d1002893 --- /dev/null +++ b/Test/spv.tpipSampleWeighted.frag @@ -0,0 +1,32 @@ +#version 450 +#extension GL_QCOM_image_processing : require + +precision highp float; + +// fragment shader inputs and outputs +layout (location = 0) in vec4 v_texcoord; + +layout (location = 0) out vec4 fragColor; + +// fragment shader resources +layout(set = 0, binding = 0) uniform texture2DArray tex2DArray_weights; +layout(set = 0, binding = 1) uniform texture2D tex2D_src1; +layout(set = 0, binding = 2) uniform texture2D tex2D_src2; +layout(set = 0, binding = 3) uniform sampler samp; +layout(set = 0, binding = 4) uniform sampler2D tex_samp; +layout(set = 0, binding = 5) uniform sampler2DArray tex_samp_array; + +void main() +{ + + fragColor = textureWeightedQCOM( + sampler2D(tex2D_src1, samp), // source texture + v_texcoord.xy, // tex coords + sampler2DArray(tex2DArray_weights, samp)); // weight texture + fragColor = textureWeightedQCOM( + tex_samp, // combined source texture + v_texcoord.xy, // tex coords + tex_samp_array); // combined weight texture + +} + diff --git a/Test/spv.tpipTextureArrays.frag b/Test/spv.tpipTextureArrays.frag new file mode 100644 index 000000000..332acb318 --- /dev/null +++ b/Test/spv.tpipTextureArrays.frag @@ -0,0 +1,40 @@ +#version 450 +#extension GL_QCOM_image_processing : require + +precision highp float; + +// fragment shader inputs and outputs +layout (location = 0) in vec4 v_texcoord; + +layout (location = 0) out vec4 fragColor; + +// fragment shader resources +layout(set = 0, binding = 3) uniform sampler samp; + + +layout(set = 0, binding = 4) uniform texture2D tex2D_srcs[8]; +layout(set = 0, binding = 5) uniform sampler2D samplers[3]; + +void main() +{ + + uvec2 tgt_coords; tgt_coords.x = uint(v_texcoord.x); tgt_coords.x = uint(v_texcoord.y); + uvec2 ref_coords; ref_coords.x = uint(v_texcoord.z); ref_coords.y = uint(v_texcoord.w); + uvec2 blockSize = uvec2(4, 4); + uint ii = tgt_coords.x % 8; + fragColor = textureBlockMatchSSDQCOM( + samplers[0], // target texture + tgt_coords, // target coords + sampler2D(tex2D_srcs[ii], samp), // reference texture + ref_coords, // reference coords + blockSize); // block size + + fragColor = textureBlockMatchSADQCOM( + sampler2D(tex2D_srcs[1], samp), // target texture + tgt_coords, // target coords + samplers[1], // reference texture + ref_coords, // reference coords + blockSize); // block size + +} + diff --git a/glslang/Include/intermediate.h b/glslang/Include/intermediate.h index b002ce889..604f08b6e 100644 --- a/glslang/Include/intermediate.h +++ b/glslang/Include/intermediate.h @@ -1100,6 +1100,12 @@ enum TOperator { // Shader tile image ops EOpStencilAttachmentReadEXT, // Fragment only EOpDepthAttachmentReadEXT, // Fragment only + + // Image processing + EOpImageSampleWeightedQCOM, + EOpImageBoxFilterQCOM, + EOpImageBlockMatchSADQCOM, + EOpImageBlockMatchSSDQCOM, }; class TIntermTraverser; diff --git a/glslang/MachineIndependent/Initialize.cpp b/glslang/MachineIndependent/Initialize.cpp index 3c7aaea3f..c23bda163 100755 --- a/glslang/MachineIndependent/Initialize.cpp +++ b/glslang/MachineIndependent/Initialize.cpp @@ -4135,6 +4135,18 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV } + // QCOM_image_processing + if ((profile == EEsProfile && version >= 310) || + (profile != EEsProfile && version >= 140)) { + commonBuiltins.append( + "vec4 textureWeightedQCOM(sampler2D, vec2, sampler2DArray);" + "vec4 textureWeightedQCOM(sampler2D, vec2, sampler1DArray);" + "vec4 textureBoxFilterQCOM(sampler2D, vec2, vec2);" + "vec4 textureBlockMatchSADQCOM(sampler2D, uvec2, sampler2D, uvec2, uvec2);" + "vec4 textureBlockMatchSSDQCOM(sampler2D, uvec2, sampler2D, uvec2, uvec2);" + "\n"); + } + //============================================================================ // // Prototypes for built-in functions seen by vertex shaders only. @@ -4624,7 +4636,7 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV "uvec4 fragmentFetchAMD(usubpassInputMS, uint);" "\n"); - } + } // Builtins for GL_NV_ray_tracing/GL_NV_ray_tracing_motion_blur/GL_EXT_ray_tracing/GL_EXT_ray_query/ // GL_NV_shader_invocation_reorder/GL_KHR_ray_tracing_position_Fetch @@ -8095,7 +8107,7 @@ void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion BuiltInVariable("gl_ViewIndex", EbvViewIndex, symbolTable); } - if (profile != EEsProfile) { + if (profile != EEsProfile) { BuiltInVariable("gl_SubGroupInvocationARB", EbvSubGroupInvocation, symbolTable); BuiltInVariable("gl_SubGroupEqMaskARB", EbvSubGroupEqMask, symbolTable); BuiltInVariable("gl_SubGroupGeMaskARB", EbvSubGroupGeMask, symbolTable); @@ -8725,6 +8737,14 @@ void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion symbolTable.setFunctionExtensions("stencilAttachmentReadEXT", 1, &E_GL_EXT_shader_tile_image); symbolTable.setFunctionExtensions("depthAttachmentReadEXT", 1, &E_GL_EXT_shader_tile_image); symbolTable.setFunctionExtensions("colorAttachmentReadEXT", 1, &E_GL_EXT_shader_tile_image); + + if ((profile == EEsProfile && version >= 310) || + (profile != EEsProfile && version >= 140)) { + symbolTable.setFunctionExtensions("textureWeightedQCOM", 1, &E_GL_QCOM_image_processing); + symbolTable.setFunctionExtensions("textureBoxFilterQCOM", 1, &E_GL_QCOM_image_processing); + symbolTable.setFunctionExtensions("textureBlockMatchSADQCOM", 1, &E_GL_QCOM_image_processing); + symbolTable.setFunctionExtensions("textureBlockMatchSSDQCOM", 1, &E_GL_QCOM_image_processing); + } break; case EShLangCompute: @@ -9890,6 +9910,14 @@ void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion symbolTable.relateToOperator("shadow2DEXT", EOpTexture); symbolTable.relateToOperator("shadow2DProjEXT", EOpTextureProj); } + + if ((profile == EEsProfile && version >= 310) || + (profile != EEsProfile && version >= 140)) { + symbolTable.relateToOperator("textureWeightedQCOM", EOpImageSampleWeightedQCOM); + symbolTable.relateToOperator("textureBoxFilterQCOM", EOpImageBoxFilterQCOM); + symbolTable.relateToOperator("textureBlockMatchSADQCOM", EOpImageBlockMatchSADQCOM); + symbolTable.relateToOperator("textureBlockMatchSSDQCOM", EOpImageBlockMatchSSDQCOM); + } } switch(language) { @@ -10030,7 +10058,7 @@ void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion if (profile != EEsProfile && version >= 460) { symbolTable.relateToOperator("reportIntersectionNV", EOpReportIntersection); symbolTable.relateToOperator("reportIntersectionEXT", EOpReportIntersection); - } + } break; case EShLangAnyHit: if (profile != EEsProfile && version >= 460) { diff --git a/glslang/MachineIndependent/Versions.cpp b/glslang/MachineIndependent/Versions.cpp index 40cf3ed81..38cbf3e1f 100644 --- a/glslang/MachineIndependent/Versions.cpp +++ b/glslang/MachineIndependent/Versions.cpp @@ -307,6 +307,9 @@ void TParseVersions::initializeExtensionBehavior() // ARM extensionBehavior[E_GL_ARM_shader_core_builtins] = EBhDisable; + // QCOM + extensionBehavior[E_GL_QCOM_image_processing] = EBhDisable; + // AEP extensionBehavior[E_GL_ANDROID_extension_pack_es31a] = EBhDisable; extensionBehavior[E_GL_KHR_blend_equation_advanced] = EBhDisable; @@ -431,6 +434,8 @@ void TParseVersions::getPreamble(std::string& preamble) "#define GL_OES_texture_buffer 1\n" "#define GL_OES_texture_cube_map_array 1\n" "#define GL_EXT_shader_non_constant_global_initializers 1\n" + + "#define GL_QCOM_image_processing 1\n" ; if (version >= 300) { @@ -555,6 +560,8 @@ void TParseVersions::getPreamble(std::string& preamble) "#define GL_NV_integer_cooperative_matrix 1\n" "#define GL_NV_shader_invocation_reorder 1\n" + "#define GL_QCOM_image_processing 1\n" + "#define GL_EXT_shader_explicit_arithmetic_types 1\n" "#define GL_EXT_shader_explicit_arithmetic_types_int8 1\n" "#define GL_EXT_shader_explicit_arithmetic_types_int16 1\n" diff --git a/glslang/MachineIndependent/Versions.h b/glslang/MachineIndependent/Versions.h index 29ebed248..564995b27 100755 --- a/glslang/MachineIndependent/Versions.h +++ b/glslang/MachineIndependent/Versions.h @@ -281,6 +281,8 @@ const char* const E_GL_NV_shader_sm_builtins = "GL_NV_shader_ const char* const E_GL_NV_integer_cooperative_matrix = "GL_NV_integer_cooperative_matrix"; const char* const E_GL_NV_shader_invocation_reorder = "GL_NV_shader_invocation_reorder"; +const char* const E_GL_QCOM_image_processing = "GL_QCOM_image_processing"; + // AEP const char* const E_GL_ANDROID_extension_pack_es31a = "GL_ANDROID_extension_pack_es31a"; const char* const E_GL_KHR_blend_equation_advanced = "GL_KHR_blend_equation_advanced"; diff --git a/gtests/Spv.FromFile.cpp b/gtests/Spv.FromFile.cpp index 537bc589e..4482161cd 100644 --- a/gtests/Spv.FromFile.cpp +++ b/gtests/Spv.FromFile.cpp @@ -76,6 +76,7 @@ using OpenGLSemantics = GlslangTest<::testing::TestWithParam>; using VulkanAstSemantics = GlslangTest<::testing::TestWithParam>; using HlslIoMap = GlslangTest<::testing::TestWithParam>; using GlslIoMap = GlslangTest<::testing::TestWithParam>; +using CompileVulkanToSpirvTestQCOM = GlslangTest<::testing::TestWithParam>; using CompileVulkanToSpirvTestAMD = GlslangTest<::testing::TestWithParam>; using CompileVulkanToSpirvTestNV = GlslangTest<::testing::TestWithParam>; using CompileVulkanToSpirv14TestNV = GlslangTest<::testing::TestWithParam>; @@ -196,6 +197,15 @@ TEST_P(GlslIoMap, FromFile) GetParam().flattenUniforms); } +// Compiling GLSL to SPIR-V under Vulkan semantics (QCOM extensions enabled). +// Expected to successfully generate SPIR-V. +TEST_P(CompileVulkanToSpirvTestQCOM, FromFile) +{ + loadFileCompileAndCheck(GlobalTestSettings.testRoot, GetParam(), + Source::GLSL, Semantics::Vulkan, glslang::EShTargetVulkan_1_0, glslang::EShTargetSpv_1_0, + Target::Spv); +} + // Compiling GLSL to SPIR-V under Vulkan semantics (AMD extensions enabled). // Expected to successfully generate SPIR-V. TEST_P(CompileVulkanToSpirvTestAMD, FromFile) @@ -783,6 +793,18 @@ INSTANTIATE_TEST_SUITE_P( FileNameAsCustomTestSuffix ); +INSTANTIATE_TEST_SUITE_P( + Glsl, CompileVulkanToSpirvTestQCOM, + ::testing::ValuesIn(std::vector({ + "spv.tpipSampleWeighted.frag", + "spv.tpipBoxFilter.frag", + "spv.tpipBlockMatchSSD.frag", + "spv.tpipBlockMatchSAD.frag", + "spv.tpipTextureArrays.frag", + })), + FileNameAsCustomTestSuffix +); + INSTANTIATE_TEST_SUITE_P( Glsl, CompileVulkanToSpirvTestAMD, ::testing::ValuesIn(std::vector({ diff --git a/known_good.json b/known_good.json index cb600dbae..95029bd9f 100644 --- a/known_good.json +++ b/known_good.json @@ -5,7 +5,7 @@ "site" : "github", "subrepo" : "KhronosGroup/SPIRV-Tools", "subdir" : "External/spirv-tools", - "commit" : "v2023.4.rc2" + "commit" : "89ca3aa571fe238944b31e88d5d8fe75fab0227a" }, { "name" : "spirv-tools/external/spirv-headers",