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

41
SPIRV/GLSL.ext.QCOM.h Normal file
View file

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

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

View file

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

View file

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

View file

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

View file

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

View file

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