extension: GL_QCOM_image_processing support

This commit is contained in:
Wooyoung Kim 2023-08-21 17:14:52 -07:00 committed by GitHub
parent 4e7ccd4af5
commit db8719ae07
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
24 changed files with 939 additions and 5 deletions

View file

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