[clang] [llvm] [HLSL] Implement Texture2D type and Sample method in Clang (PR #177240)
Nathan Gauër via cfe-commits
cfe-commits at lists.llvm.org
Tue Jan 27 08:35:06 PST 2026
================
@@ -861,8 +861,23 @@ llvm::Type *CommonSPIRTargetCodeGenInfo::getSPIRVImageTypeFromHLSLResource(
Ty->isSignedIntegerType() ? "spirv.SignedImage" : "spirv.Image";
// Dim
- // For now we assume everything is a buffer.
- IntParams[0] = 5;
+ switch (attributes.ResourceDimension) {
+ case llvm::dxil::ResourceDimension::Dimension1D:
+ IntParams[0] = 0;
+ break;
+ case llvm::dxil::ResourceDimension::Dimension2D:
+ IntParams[0] = 1;
+ break;
+ case llvm::dxil::ResourceDimension::Dimension3D:
+ IntParams[0] = 2;
+ break;
+ case llvm::dxil::ResourceDimension::DimensionCube:
+ IntParams[0] = 3;
+ break;
+ case llvm::dxil::ResourceDimension::DimensionUnknown:
+ IntParams[0] = 5;
----------------
Keenuts wrote:
Why is unknown mapped to `spv::Dim::Buffer`?
Also should you use `SPIV::Dim::` enum? looking at the `.td` file, seems those are defined and can be used here
https://github.com/llvm/llvm-project/pull/177240
More information about the cfe-commits
mailing list