A couple of fixes to the GL_QCOM_image_processing2 support (#3578)

1) handle the extension requirements of GL_QCOM_image_processing2
   correctly
2) add QCOM image processing decorations to ids only once.
This commit is contained in:
Wooyoung Kim 2024-04-23 15:34:51 -07:00 committed by GitHub
parent b9b8fd917b
commit a4f870053f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 35 additions and 10 deletions

View File

@ -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<unsigned int, glslang::TIntermSymbol *> locationToSymbol[4];
std::unordered_map<spv::Id, std::vector<spv::Decoration> > 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<spv::Decoration> &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);
}
}
};

View File

@ -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";
}

View File

@ -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"

View File

@ -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"

View File

@ -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

View File

@ -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

View File

@ -1,4 +1,5 @@
#version 450
#extension GL_QCOM_image_processing : require
#extension GL_QCOM_image_processing2 : require
precision highp float;

View File

@ -1,4 +1,5 @@
#version 450
#extension GL_QCOM_image_processing : require
#extension GL_QCOM_image_processing2 : require
precision highp float;