[clang] [llvm] [HLSL] Implement Texture2D type and Sample method in Clang (PR #177240)
Steven Perron via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 27 08:47:05 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;
----------------
s-perron wrote:
I'm not sure which td file you're referring to. However, if you are looking at the SPIRV TD file in the backend that is unavailable in clang. You can still build clang without the spirv backend
https://github.com/llvm/llvm-project/pull/177240
More information about the llvm-commits
mailing list