Skip to content

Commit 9163ebb

Browse files
committed
Add GLSL_QCOM_image_processing3 support
1 parent a899a43 commit 9163ebb

21 files changed

Lines changed: 4097 additions & 37 deletions

SPIRV/GLSL.ext.QCOM.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ static const int GLSLextQCOMRevision = 1;
3939
const char* const E_SPV_QCOM_image_processing = "SPV_QCOM_image_processing";
4040
//SPV_QCOM_image_processing2
4141
const char* const E_SPV_QCOM_image_processing2 = "SPV_QCOM_image_processing2";
42+
//SPV_QCOM_image_processing3
43+
const char* const E_SPV_QCOM_image_processing3 = "SPV_QCOM_image_processing3";
4244
//SPV_QCOM_cooperative_matrix_conversion
4345
const char* const E_SPV_QCOM_cooperative_matrix_conversion = "SPV_QCOM_cooperative_matrix_conversion";
4446

SPIRV/GlslangToSpv.cpp

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8371,6 +8371,40 @@ spv::Id TGlslangToSpvTraverser::createImageTextureFunctionCall(glslang::TIntermO
83718371
}
83728372
}
83738373

8374+
if (cracked.gather) {
8375+
spv::GatherModes mode = spv::GatherModes::Max;
8376+
switch (node->getOp()) {
8377+
case glslang::EOpTextureGather4x1QCOM:
8378+
case glslang::EOpTextureGather4x1OffsetQCOM:
8379+
mode = spv::GatherModes::Gather4x1QCOM;
8380+
break;
8381+
case glslang::EOpTextureGatherDQCOM:
8382+
case glslang::EOpTextureGatherDOffsetQCOM:
8383+
mode = spv::GatherModes::GatherDQCOM;
8384+
break;
8385+
case glslang::EOpTextureGatherH2QCOM:
8386+
case glslang::EOpTextureGatherH2OffsetQCOM:
8387+
mode = spv::GatherModes::GatherH2QCOM;
8388+
break;
8389+
case glslang::EOpTextureGatherV2QCOM:
8390+
case glslang::EOpTextureGatherV2OffsetQCOM:
8391+
mode = spv::GatherModes::GatherV2QCOM;
8392+
break;
8393+
default:
8394+
break;
8395+
}
8396+
8397+
if (mode != spv::GatherModes::Max) {
8398+
if (mode == spv::GatherModes::Gather4x1QCOM) {
8399+
builder.addCapability(spv::Capability::ImageGatherLinearQCOM);
8400+
} else {
8401+
builder.addCapability(spv::Capability::ImageGatherExtendedModesQCOM);
8402+
}
8403+
builder.addExtension(spv::E_SPV_QCOM_image_processing3);
8404+
params.gatherMode = builder.makeIntConstant(unsigned(mode));
8405+
}
8406+
}
8407+
83748408
// nonprivate
83758409
if (imageType.getQualifier().nonprivate) {
83768410
params.nonprivate = true;

SPIRV/SpvBuilder.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3885,6 +3885,8 @@ Id Builder::createTextureCall(Decoration precision, Id resultType, bool sparse,
38853885
texArgs.push_back(parameters.Dref);
38863886
if (parameters.component != NoResult)
38873887
texArgs.push_back(parameters.component);
3888+
if (gather && parameters.gatherMode != NoResult)
3889+
texArgs.push_back(parameters.gatherMode);
38883890

38893891
if (parameters.granularity != NoResult)
38903892
texArgs.push_back(parameters.granularity);
@@ -3959,6 +3961,8 @@ Id Builder::createTextureCall(Decoration precision, Id resultType, bool sparse,
39593961
if (mask != ImageOperandsMask::MaskNone)
39603962
texArgs.insert(texArgs.begin() + optArgNum, (Id)mask);
39613963

3964+
bool isTextureGatherExtended = (gather && parameters.gatherMode != NoResult);
3965+
39623966
//
39633967
// Set up the instruction
39643968
//
@@ -3979,6 +3983,8 @@ Id Builder::createTextureCall(Decoration precision, Id resultType, bool sparse,
39793983
else
39803984
if (sparse)
39813985
opCode = Op::OpImageSparseGather;
3986+
else if (isTextureGatherExtended)
3987+
opCode = Op::OpImageGatherQCOM;
39823988
else
39833989
opCode = Op::OpImageGather;
39843990
} else if (explicitLod) {

SPIRV/SpvBuilder.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -680,6 +680,7 @@ class Builder {
680680
Id lodClamp;
681681
Id granularity;
682682
Id coarse;
683+
Id gatherMode;
683684
bool nonprivate;
684685
bool volatil;
685686
bool nontemporal;

SPIRV/doc.cpp

Lines changed: 47 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1143,6 +1143,8 @@ const char* CapabilityString(int info)
11431143
case (int)Capability::TextureBlockMatch2QCOM: return "TextureBlockMatch2QCOM";
11441144

11451145
case (int)Capability::CooperativeMatrixConversionQCOM: return "CooperativeMatrixConversionQCOM";
1146+
case (int)Capability::ImageGatherLinearQCOM: return "ImageGatherLinearQCOM";
1147+
case (int)Capability::ImageGatherExtendedModesQCOM: return "ImageGatherExtendedModesQCOM";
11461148

11471149
case (int)Capability::ReplicatedCompositesEXT: return "ReplicatedCompositesEXT";
11481150

@@ -1752,6 +1754,7 @@ const char* OpcodeString(int op)
17521754
case (int)Op::OpImageBlockMatchWindowSADQCOM: return "OpImageBlockMatchWindowSADQCOM";
17531755
case (int)Op::OpImageBlockMatchGatherSSDQCOM: return "OpImageBlockMatchGatherSSDQCOM";
17541756
case (int)Op::OpImageBlockMatchGatherSADQCOM: return "OpImageBlockMatchGatherSADQCOM";
1757+
case (int)Op::OpImageGatherQCOM: return "OpImageGatherQCOM";
17551758

17561759
case (int)Op::OpBitCastArrayQCOM: return "OpBitCastArrayQCOM";
17571760
case (int)Op::OpCompositeConstructCoopMatQCOM: return "OpCompositeConstructCoopMatQCOM";
@@ -3794,66 +3797,74 @@ void Parameterize()
37943797
InstructionDesc[enumCast(Op::OpStencilAttachmentReadEXT)].operands.push(OperandId, "'Sample'", true);
37953798
InstructionDesc[enumCast(Op::OpDepthAttachmentReadEXT)].operands.push(OperandId, "'Sample'", true);
37963799

3797-
InstructionDesc[enumCast(Op::OpImageSampleWeightedQCOM)].operands.push(OperandId, "'source texture'");
3798-
InstructionDesc[enumCast(Op::OpImageSampleWeightedQCOM)].operands.push(OperandId, "'texture coordinates'");
3799-
InstructionDesc[enumCast(Op::OpImageSampleWeightedQCOM)].operands.push(OperandId, "'weights texture'");
3800+
InstructionDesc[enumCast(Op::OpImageSampleWeightedQCOM)].operands.push(OperandId, "'Source Texture'");
3801+
InstructionDesc[enumCast(Op::OpImageSampleWeightedQCOM)].operands.push(OperandId, "'Texture Coordinates'");
3802+
InstructionDesc[enumCast(Op::OpImageSampleWeightedQCOM)].operands.push(OperandId, "'Weights Texture'");
38003803
InstructionDesc[enumCast(Op::OpImageSampleWeightedQCOM)].operands.push(OperandImageOperands, "", true);
38013804
InstructionDesc[enumCast(Op::OpImageSampleWeightedQCOM)].setResultAndType(true, true);
38023805

3803-
InstructionDesc[enumCast(Op::OpImageBoxFilterQCOM)].operands.push(OperandId, "'source texture'");
3804-
InstructionDesc[enumCast(Op::OpImageBoxFilterQCOM)].operands.push(OperandId, "'texture coordinates'");
3805-
InstructionDesc[enumCast(Op::OpImageBoxFilterQCOM)].operands.push(OperandId, "'box size'");
3806+
InstructionDesc[enumCast(Op::OpImageBoxFilterQCOM)].operands.push(OperandId, "'Source Texture'");
3807+
InstructionDesc[enumCast(Op::OpImageBoxFilterQCOM)].operands.push(OperandId, "'Texture Coordinates'");
3808+
InstructionDesc[enumCast(Op::OpImageBoxFilterQCOM)].operands.push(OperandId, "'Box Size'");
38063809
InstructionDesc[enumCast(Op::OpImageBoxFilterQCOM)].operands.push(OperandImageOperands, "", true);
38073810
InstructionDesc[enumCast(Op::OpImageBoxFilterQCOM)].setResultAndType(true, true);
38083811

3809-
InstructionDesc[enumCast(Op::OpImageBlockMatchSADQCOM)].operands.push(OperandId, "'target texture'");
3810-
InstructionDesc[enumCast(Op::OpImageBlockMatchSADQCOM)].operands.push(OperandId, "'target coordinates'");
3811-
InstructionDesc[enumCast(Op::OpImageBlockMatchSADQCOM)].operands.push(OperandId, "'reference texture'");
3812-
InstructionDesc[enumCast(Op::OpImageBlockMatchSADQCOM)].operands.push(OperandId, "'reference coordinates'");
3813-
InstructionDesc[enumCast(Op::OpImageBlockMatchSADQCOM)].operands.push(OperandId, "'block size'");
3812+
InstructionDesc[enumCast(Op::OpImageBlockMatchSADQCOM)].operands.push(OperandId, "'Target Texture'");
3813+
InstructionDesc[enumCast(Op::OpImageBlockMatchSADQCOM)].operands.push(OperandId, "'Target Coordinates'");
3814+
InstructionDesc[enumCast(Op::OpImageBlockMatchSADQCOM)].operands.push(OperandId, "'Reference Texture'");
3815+
InstructionDesc[enumCast(Op::OpImageBlockMatchSADQCOM)].operands.push(OperandId, "'Reference Coordinates'");
3816+
InstructionDesc[enumCast(Op::OpImageBlockMatchSADQCOM)].operands.push(OperandId, "'Block Size'");
38143817
InstructionDesc[enumCast(Op::OpImageBlockMatchSADQCOM)].operands.push(OperandImageOperands, "", true);
38153818
InstructionDesc[enumCast(Op::OpImageBlockMatchSADQCOM)].setResultAndType(true, true);
38163819

3817-
InstructionDesc[enumCast(Op::OpImageBlockMatchSSDQCOM)].operands.push(OperandId, "'target texture'");
3818-
InstructionDesc[enumCast(Op::OpImageBlockMatchSSDQCOM)].operands.push(OperandId, "'target coordinates'");
3819-
InstructionDesc[enumCast(Op::OpImageBlockMatchSSDQCOM)].operands.push(OperandId, "'reference texture'");
3820-
InstructionDesc[enumCast(Op::OpImageBlockMatchSSDQCOM)].operands.push(OperandId, "'reference coordinates'");
3821-
InstructionDesc[enumCast(Op::OpImageBlockMatchSSDQCOM)].operands.push(OperandId, "'block size'");
3820+
InstructionDesc[enumCast(Op::OpImageBlockMatchSSDQCOM)].operands.push(OperandId, "'Target Texture'");
3821+
InstructionDesc[enumCast(Op::OpImageBlockMatchSSDQCOM)].operands.push(OperandId, "'Target Coordinates'");
3822+
InstructionDesc[enumCast(Op::OpImageBlockMatchSSDQCOM)].operands.push(OperandId, "'Reference Texture'");
3823+
InstructionDesc[enumCast(Op::OpImageBlockMatchSSDQCOM)].operands.push(OperandId, "'Reference Coordinates'");
3824+
InstructionDesc[enumCast(Op::OpImageBlockMatchSSDQCOM)].operands.push(OperandId, "'Block Size'");
38223825
InstructionDesc[enumCast(Op::OpImageBlockMatchSSDQCOM)].operands.push(OperandImageOperands, "", true);
38233826
InstructionDesc[enumCast(Op::OpImageBlockMatchSSDQCOM)].setResultAndType(true, true);
38243827

3825-
InstructionDesc[enumCast(Op::OpImageBlockMatchWindowSSDQCOM)].operands.push(OperandId, "'target texture'");
3826-
InstructionDesc[enumCast(Op::OpImageBlockMatchWindowSSDQCOM)].operands.push(OperandId, "'target coordinates'");
3827-
InstructionDesc[enumCast(Op::OpImageBlockMatchWindowSSDQCOM)].operands.push(OperandId, "'reference texture'");
3828-
InstructionDesc[enumCast(Op::OpImageBlockMatchWindowSSDQCOM)].operands.push(OperandId, "'reference coordinates'");
3829-
InstructionDesc[enumCast(Op::OpImageBlockMatchWindowSSDQCOM)].operands.push(OperandId, "'block size'");
3828+
InstructionDesc[enumCast(Op::OpImageBlockMatchWindowSSDQCOM)].operands.push(OperandId, "'Target Texture'");
3829+
InstructionDesc[enumCast(Op::OpImageBlockMatchWindowSSDQCOM)].operands.push(OperandId, "'Target Coordinates'");
3830+
InstructionDesc[enumCast(Op::OpImageBlockMatchWindowSSDQCOM)].operands.push(OperandId, "'Reference Texture'");
3831+
InstructionDesc[enumCast(Op::OpImageBlockMatchWindowSSDQCOM)].operands.push(OperandId, "'Reference Coordinates'");
3832+
InstructionDesc[enumCast(Op::OpImageBlockMatchWindowSSDQCOM)].operands.push(OperandId, "'Block Size'");
38303833
InstructionDesc[enumCast(Op::OpImageBlockMatchWindowSSDQCOM)].operands.push(OperandImageOperands, "", true);
38313834
InstructionDesc[enumCast(Op::OpImageBlockMatchWindowSSDQCOM)].setResultAndType(true, true);
38323835

3833-
InstructionDesc[enumCast(Op::OpImageBlockMatchWindowSADQCOM)].operands.push(OperandId, "'target texture'");
3834-
InstructionDesc[enumCast(Op::OpImageBlockMatchWindowSADQCOM)].operands.push(OperandId, "'target coordinates'");
3835-
InstructionDesc[enumCast(Op::OpImageBlockMatchWindowSADQCOM)].operands.push(OperandId, "'reference texture'");
3836-
InstructionDesc[enumCast(Op::OpImageBlockMatchWindowSADQCOM)].operands.push(OperandId, "'reference coordinates'");
3837-
InstructionDesc[enumCast(Op::OpImageBlockMatchWindowSADQCOM)].operands.push(OperandId, "'block size'");
3836+
InstructionDesc[enumCast(Op::OpImageBlockMatchWindowSADQCOM)].operands.push(OperandId, "'Target Texture'");
3837+
InstructionDesc[enumCast(Op::OpImageBlockMatchWindowSADQCOM)].operands.push(OperandId, "'Target Coordinates'");
3838+
InstructionDesc[enumCast(Op::OpImageBlockMatchWindowSADQCOM)].operands.push(OperandId, "'Reference Texture'");
3839+
InstructionDesc[enumCast(Op::OpImageBlockMatchWindowSADQCOM)].operands.push(OperandId, "'Reference Coordinates'");
3840+
InstructionDesc[enumCast(Op::OpImageBlockMatchWindowSADQCOM)].operands.push(OperandId, "'Block Size'");
38383841
InstructionDesc[enumCast(Op::OpImageBlockMatchWindowSADQCOM)].operands.push(OperandImageOperands, "", true);
38393842
InstructionDesc[enumCast(Op::OpImageBlockMatchWindowSADQCOM)].setResultAndType(true, true);
38403843

3841-
InstructionDesc[enumCast(Op::OpImageBlockMatchGatherSSDQCOM)].operands.push(OperandId, "'target texture'");
3842-
InstructionDesc[enumCast(Op::OpImageBlockMatchGatherSSDQCOM)].operands.push(OperandId, "'target coordinates'");
3843-
InstructionDesc[enumCast(Op::OpImageBlockMatchGatherSSDQCOM)].operands.push(OperandId, "'reference texture'");
3844-
InstructionDesc[enumCast(Op::OpImageBlockMatchGatherSSDQCOM)].operands.push(OperandId, "'reference coordinates'");
3845-
InstructionDesc[enumCast(Op::OpImageBlockMatchGatherSSDQCOM)].operands.push(OperandId, "'block size'");
3844+
InstructionDesc[enumCast(Op::OpImageBlockMatchGatherSSDQCOM)].operands.push(OperandId, "'Target Texture'");
3845+
InstructionDesc[enumCast(Op::OpImageBlockMatchGatherSSDQCOM)].operands.push(OperandId, "'Target Coordinates'");
3846+
InstructionDesc[enumCast(Op::OpImageBlockMatchGatherSSDQCOM)].operands.push(OperandId, "'Reference Texture'");
3847+
InstructionDesc[enumCast(Op::OpImageBlockMatchGatherSSDQCOM)].operands.push(OperandId, "'Reference Coordinates'");
3848+
InstructionDesc[enumCast(Op::OpImageBlockMatchGatherSSDQCOM)].operands.push(OperandId, "'Block Size'");
38463849
InstructionDesc[enumCast(Op::OpImageBlockMatchGatherSSDQCOM)].operands.push(OperandImageOperands, "", true);
38473850
InstructionDesc[enumCast(Op::OpImageBlockMatchGatherSSDQCOM)].setResultAndType(true, true);
38483851

3849-
InstructionDesc[enumCast(Op::OpImageBlockMatchGatherSADQCOM)].operands.push(OperandId, "'target texture'");
3850-
InstructionDesc[enumCast(Op::OpImageBlockMatchGatherSADQCOM)].operands.push(OperandId, "'target coordinates'");
3851-
InstructionDesc[enumCast(Op::OpImageBlockMatchGatherSADQCOM)].operands.push(OperandId, "'reference texture'");
3852-
InstructionDesc[enumCast(Op::OpImageBlockMatchGatherSADQCOM)].operands.push(OperandId, "'reference coordinates'");
3853-
InstructionDesc[enumCast(Op::OpImageBlockMatchGatherSADQCOM)].operands.push(OperandId, "'block size'");
3852+
InstructionDesc[enumCast(Op::OpImageBlockMatchGatherSADQCOM)].operands.push(OperandId, "'Target Texture'");
3853+
InstructionDesc[enumCast(Op::OpImageBlockMatchGatherSADQCOM)].operands.push(OperandId, "'Target Coordinates'");
3854+
InstructionDesc[enumCast(Op::OpImageBlockMatchGatherSADQCOM)].operands.push(OperandId, "'Reference Texture'");
3855+
InstructionDesc[enumCast(Op::OpImageBlockMatchGatherSADQCOM)].operands.push(OperandId, "'Reference Coordinates'");
3856+
InstructionDesc[enumCast(Op::OpImageBlockMatchGatherSADQCOM)].operands.push(OperandId, "'Block Size'");
38543857
InstructionDesc[enumCast(Op::OpImageBlockMatchGatherSADQCOM)].operands.push(OperandImageOperands, "", true);
38553858
InstructionDesc[enumCast(Op::OpImageBlockMatchGatherSADQCOM)].setResultAndType(true, true);
38563859

3860+
InstructionDesc[enumCast(Op::OpImageGatherQCOM)].operands.push(OperandId, "'Sampled Image'");
3861+
InstructionDesc[enumCast(Op::OpImageGatherQCOM)].operands.push(OperandId, "'Coordinate'");
3862+
InstructionDesc[enumCast(Op::OpImageGatherQCOM)].operands.push(OperandId, "'Component'");
3863+
InstructionDesc[enumCast(Op::OpImageGatherQCOM)].operands.push(OperandId, "'Mode'");
3864+
InstructionDesc[enumCast(Op::OpImageGatherQCOM)].operands.push(OperandImageOperands, "", true);
3865+
InstructionDesc[enumCast(Op::OpImageGatherQCOM)].operands.push(OperandVariableIds, "", true);
3866+
InstructionDesc[enumCast(Op::OpImageGatherQCOM)].setResultAndType(true, true);
3867+
38573868
InstructionDesc[enumCast(Op::OpBitCastArrayQCOM)].operands.push(OperandId, "'source array'");
38583869
InstructionDesc[enumCast(Op::OpBitCastArrayQCOM)].setResultAndType(true, true);
38593870

0 commit comments

Comments
 (0)