diff --git a/SPIRV/GlslangToSpv.cpp b/SPIRV/GlslangToSpv.cpp index ef39aec3..1674c550 100755 --- a/SPIRV/GlslangToSpv.cpp +++ b/SPIRV/GlslangToSpv.cpp @@ -227,6 +227,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); + bool hasQCOMImageProceessingDecoration(spv::Id id, spv::Decoration decor); void addImageProcessingQCOMDecoration(spv::Id id, spv::Decoration decor); void addImageProcessing2QCOMDecoration(spv::Id id, bool isForGather); spv::Id createSpvConstant(const glslang::TIntermTyped&); @@ -283,6 +284,7 @@ protected: spv::Id taskPayloadID; // Used later for generating OpTraceKHR/OpExecuteCallableKHR/OpHitObjectRecordHit*/OpHitObjectGetShaderBindingTableData std::unordered_map locationToSymbol[4]; + std::unordered_map > idToQCOMDecorations; }; // @@ -3382,6 +3384,8 @@ bool TGlslangToSpvTraverser::visitAggregate(glslang::TVisit visit, glslang::TInt case glslang::EOpImageBlockMatchGatherSSDQCOM: case glslang::EOpImageBlockMatchGatherSADQCOM: + builder.addCapability(spv::CapabilityTextureBlockMatchQCOM); + builder.addExtension(spv::E_SPV_QCOM_image_processing); builder.addCapability(spv::CapabilityTextureBlockMatch2QCOM); builder.addExtension(spv::E_SPV_QCOM_image_processing2); break; @@ -9834,6 +9838,16 @@ void TGlslangToSpvTraverser::addMeshNVDecoration(spv::Id id, int member, const g } } +bool TGlslangToSpvTraverser::hasQCOMImageProceessingDecoration(spv::Id id, spv::Decoration decor) +{ + std::vector &decoVec = idToQCOMDecorations[id]; + for ( auto d : decoVec ) { + if ( d == decor ) + return true; + } + return false; +} + void TGlslangToSpvTraverser::addImageProcessingQCOMDecoration(spv::Id id, spv::Decoration decor) { spv::Op opc = builder.getOpCode(id); @@ -9844,7 +9858,10 @@ void TGlslangToSpvTraverser::addImageProcessingQCOMDecoration(spv::Id id, spv::D if (opc == spv::OpLoad) { spv::Id texid = builder.getIdOperand(id, 0); - builder.addDecoration(texid, decor); + if (!hasQCOMImageProceessingDecoration(texid, decor)) {// + builder.addDecoration(texid, decor); + idToQCOMDecorations[texid].push_back(decor); + } } } @@ -9862,7 +9879,10 @@ void TGlslangToSpvTraverser::addImageProcessing2QCOMDecoration(spv::Id id, bool if (this->glslangIntermediate->getSpv().spv >= glslang::EShTargetSpv_1_4) { assert(iOSet.count(tsid) > 0); } - this->builder.addDecoration(tsid, decor); + if (!hasQCOMImageProceessingDecoration(tsid, decor)) { + this->builder.addDecoration(tsid, decor); + idToQCOMDecorations[tsid].push_back(decor); + } } }; diff --git a/SPIRV/doc.cpp b/SPIRV/doc.cpp index 26e4b101..ea4915fe 100755 --- a/SPIRV/doc.cpp +++ b/SPIRV/doc.cpp @@ -1064,6 +1064,7 @@ const char* CapabilityString(int info) case CapabilityTextureSampleWeightedQCOM: return "TextureSampleWeightedQCOM"; case CapabilityTextureBoxFilterQCOM: return "TextureBoxFilterQCOM"; case CapabilityTextureBlockMatchQCOM: return "TextureBlockMatchQCOM"; + case CapabilityTextureBlockMatch2QCOM: return "TextureBlockMatch2QCOM"; default: return "Bad"; } diff --git a/Test/baseResults/spv.tpipBlockMatchGatherSAD.frag.out b/Test/baseResults/spv.tpipBlockMatchGatherSAD.frag.out index be4c1617..6a543b3c 100644 --- a/Test/baseResults/spv.tpipBlockMatchGatherSAD.frag.out +++ b/Test/baseResults/spv.tpipBlockMatchGatherSAD.frag.out @@ -1,17 +1,19 @@ spv.tpipBlockMatchGatherSAD.frag -Validation failed // Module Version 10000 // Generated by (magic number): 8000b // Id's are bound by 72 Capability Shader - Capability Bad + Capability TextureBlockMatchQCOM + Capability TextureBlockMatch2QCOM + Extension "SPV_QCOM_image_processing" Extension "SPV_QCOM_image_processing2" 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" SourceExtension "GL_QCOM_image_processing2" Name 4 "main" Name 9 "tgt_coords" diff --git a/Test/baseResults/spv.tpipBlockMatchGatherSSD.frag.out b/Test/baseResults/spv.tpipBlockMatchGatherSSD.frag.out index 5b63e49d..74479c1b 100644 --- a/Test/baseResults/spv.tpipBlockMatchGatherSSD.frag.out +++ b/Test/baseResults/spv.tpipBlockMatchGatherSSD.frag.out @@ -1,17 +1,19 @@ spv.tpipBlockMatchGatherSSD.frag -Validation failed // Module Version 10000 // Generated by (magic number): 8000b // Id's are bound by 72 Capability Shader - Capability Bad + Capability TextureBlockMatchQCOM + Capability TextureBlockMatch2QCOM + Extension "SPV_QCOM_image_processing" Extension "SPV_QCOM_image_processing2" 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" SourceExtension "GL_QCOM_image_processing2" Name 4 "main" Name 9 "tgt_coords" diff --git a/Test/baseResults/spv.tpipBlockMatchWindowSAD.frag.out b/Test/baseResults/spv.tpipBlockMatchWindowSAD.frag.out index afadf030..ff102565 100644 --- a/Test/baseResults/spv.tpipBlockMatchWindowSAD.frag.out +++ b/Test/baseResults/spv.tpipBlockMatchWindowSAD.frag.out @@ -6,7 +6,7 @@ Validation failed Capability Shader Capability TextureBlockMatchQCOM - Capability Bad + Capability TextureBlockMatch2QCOM Extension "SPV_QCOM_image_processing" Extension "SPV_QCOM_image_processing2" 1: ExtInstImport "GLSL.std.450" @@ -39,7 +39,6 @@ Validation failed Decorate 44(tex2D_src1) DecorationBlockMatchTextureQCOM Decorate 48(samp) DecorationBlockMatchSamplerQCOM Decorate 53(tex2D_src2) DecorationBlockMatchTextureQCOM - Decorate 48(samp) DecorationBlockMatchSamplerQCOM Decorate 61(target_samp) DescriptorSet 0 Decorate 61(target_samp) Binding 4 Decorate 64(ref_samp) DescriptorSet 0 diff --git a/Test/baseResults/spv.tpipBlockMatchWindowSSD.frag.out b/Test/baseResults/spv.tpipBlockMatchWindowSSD.frag.out index 864a8bca..1e2fa1fb 100644 --- a/Test/baseResults/spv.tpipBlockMatchWindowSSD.frag.out +++ b/Test/baseResults/spv.tpipBlockMatchWindowSSD.frag.out @@ -6,7 +6,7 @@ Validation failed Capability Shader Capability TextureBlockMatchQCOM - Capability Bad + Capability TextureBlockMatch2QCOM Extension "SPV_QCOM_image_processing" Extension "SPV_QCOM_image_processing2" 1: ExtInstImport "GLSL.std.450" @@ -39,7 +39,6 @@ Validation failed Decorate 44(tex2D_src1) DecorationBlockMatchTextureQCOM Decorate 48(samp) DecorationBlockMatchSamplerQCOM Decorate 53(tex2D_src2) DecorationBlockMatchTextureQCOM - Decorate 48(samp) DecorationBlockMatchSamplerQCOM Decorate 61(target_samp) DescriptorSet 0 Decorate 61(target_samp) Binding 4 Decorate 64(ref_samp) DescriptorSet 0 diff --git a/Test/spv.tpipBlockMatchGatherSAD.frag b/Test/spv.tpipBlockMatchGatherSAD.frag index d793a5e6..7ac8fd0d 100644 --- a/Test/spv.tpipBlockMatchGatherSAD.frag +++ b/Test/spv.tpipBlockMatchGatherSAD.frag @@ -1,4 +1,5 @@ #version 450 +#extension GL_QCOM_image_processing : require #extension GL_QCOM_image_processing2 : require precision highp float; diff --git a/Test/spv.tpipBlockMatchGatherSSD.frag b/Test/spv.tpipBlockMatchGatherSSD.frag index d3a0bcea..7890e35f 100644 --- a/Test/spv.tpipBlockMatchGatherSSD.frag +++ b/Test/spv.tpipBlockMatchGatherSSD.frag @@ -1,4 +1,5 @@ #version 450 +#extension GL_QCOM_image_processing : require #extension GL_QCOM_image_processing2 : require precision highp float;