summaryrefslogtreecommitdiff
path: root/source/slang/slang-emit-spirv.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2023-11-16 14:32:33 -0800
committerGitHub <noreply@github.com>2023-11-16 14:32:33 -0800
commit4c78efd0c34442866f20e9d00bbb6908115c9a01 (patch)
tree03ca8584847f0937a926f6b27386dcd982ed7780 /source/slang/slang-emit-spirv.cpp
parent12f7237e4060388494c549623f4a640327b7ca08 (diff)
Unify stdlib `Texture` types into one generic type. (#3327)
* Unify Texture types in stdlib into 1 generic type. * Fixes. * Fix. * Fixes. * Fix reflection. * Fix binding reflection. * Add gather intrinsics. * Fix gather intrinsics. * Fix texture type toText. * Fix intrinsic. * fix cuda intrinsic. * Fix project files. * cleanup. * Fix. * Fix. * Fix sampler feedback test. * Fix getDimension intrinsics. * Fix spirv sample image intrinsics. * Fix test. * Fix GLSL intrinsic. * Cleanup. --------- Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'source/slang/slang-emit-spirv.cpp')
-rw-r--r--source/slang/slang-emit-spirv.cpp57
1 files changed, 43 insertions, 14 deletions
diff --git a/source/slang/slang-emit-spirv.cpp b/source/slang/slang-emit-spirv.cpp
index 19c46f373..4c802641d 100644
--- a/source/slang/slang-emit-spirv.cpp
+++ b/source/slang/slang-emit-spirv.cpp
@@ -1361,12 +1361,8 @@ struct SPIRVEmitContext
case kIROp_TextureType:
return ensureTextureType(inst, cast<IRTextureType>(inst));
case kIROp_SamplerStateType:
+ case kIROp_SamplerComparisonStateType:
return emitOpTypeSampler(inst);
- case kIROp_TextureSamplerType:
- return emitOpTypeSampledImage(
- inst,
- ensureTextureType(nullptr, cast<IRTextureTypeBase>(inst))
- );
case kIROp_RaytracingAccelerationStructureType:
requireSPIRVCapability(SpvCapabilityRayTracingKHR);
@@ -1627,22 +1623,19 @@ struct SPIRVEmitContext
SpvDim dim = SpvDim1D; // Silence uninitialized warnings from msvc...
switch(inst->GetBaseShape())
{
- case TextureFlavor::Shape1D:
- case TextureFlavor::Shape1DArray:
+ case SLANG_TEXTURE_1D:
dim = SpvDim1D;
break;
- case TextureFlavor::Shape2D:
- case TextureFlavor::Shape2DArray:
+ case SLANG_TEXTURE_2D:
dim = SpvDim2D;
break;
- case TextureFlavor::Shape3D:
+ case SLANG_TEXTURE_3D:
dim = SpvDim3D;
break;
- case TextureFlavor::ShapeCube:
- case TextureFlavor::ShapeCubeArray:
+ case SLANG_TEXTURE_CUBE:
dim = SpvDimCube;
break;
- case TextureFlavor::ShapeBuffer:
+ case SLANG_TEXTURE_BUFFER:
dim = SpvDimBuffer;
break;
}
@@ -1717,6 +1710,24 @@ struct SPIRVEmitContext
//
// The op itself
//
+
+ if (inst->isCombined())
+ {
+ auto imageType = emitOpTypeImage(
+ nullptr,
+ dropVector(sampledType),
+ dim,
+ SpvLiteralInteger::from32(depth),
+ SpvLiteralInteger::from32(arrayed),
+ SpvLiteralInteger::from32(ms),
+ SpvLiteralInteger::from32(sampled),
+ format
+ );
+ return emitOpTypeSampledImage(
+ assignee,
+ imageType);
+ }
+
return emitOpTypeImage(
assignee,
dropVector(sampledType),
@@ -4578,6 +4589,24 @@ struct SPIRVEmitContext
emitOperand(ensureInst(sampledType));
break;
}
+ case kIROp_SPIRVAsmOperandImageType:
+ case kIROp_SPIRVAsmOperandSampledImageType:
+ {
+ IRBuilder builder(m_irModule);
+ auto textureInst = as<IRTextureTypeBase>(operand->getValue()->getDataType());
+ auto imageType = builder.getTextureType(
+ textureInst->getElementType(),
+ textureInst->getShapeInst(),
+ textureInst->getIsArrayInst(),
+ textureInst->getIsMultisampleInst(),
+ textureInst->getSampleCountInst(),
+ textureInst->getAccessInst(),
+ textureInst->getIsShadowInst(),
+ builder.getIntValue(builder.getIntType(), (operand->getOp() == kIROp_SPIRVAsmOperandSampledImageType ? 1 : 0)),
+ textureInst->getFormatInst());
+ emitOperand(ensureInst(imageType));
+ break;
+ }
case kIROp_SPIRVAsmOperandBuiltinVar:
{
emitOperand(ensureInst(operand));
@@ -4774,7 +4803,7 @@ struct SPIRVEmitContext
}
else
{
- emitInstCustomOperandFunc(
+ last = emitInstCustomOperandFunc(
opParent,
assignedInst,
opcode,