[clang] [llvm] [HLSL] Add GetDimensions to Texture2D. (PR #189991)
Steven Perron via cfe-commits
cfe-commits at lists.llvm.org
Tue Apr 7 06:58:12 PDT 2026
================
@@ -475,6 +475,37 @@ static Value *emitHlslClamp(CodeGenFunction &CGF, const CallExpr *E,
return Clamp;
}
+static Value *emitGetDimensions(CodeGenFunction &CGF, const CallExpr *E,
+ unsigned IntrinsicID, unsigned NumRetComps,
+ bool HasLod) {
+ Value *Handle = CGF.EmitScalarExpr(E->getArg(0));
+
+ SmallVector<Value *> Args{Handle};
+ if (HasLod)
+ Args.push_back(CGF.EmitScalarExpr(E->getArg(1)));
+
+ Value *DimValue =
+ CGF.Builder.CreateIntrinsic(IntrinsicID, {Handle->getType()}, Args);
----------------
s-perron wrote:
The arguments passed in are the arguments to be used for the function overloading. The `lod` is a fixed type, so it does not contribute to the name mangling. If we add the type of the second arguement to the list, we get the following error:
```
# | Intrinsic name not mangled correctly for type arguments! Should be: llvm.dx.resource.getdimensions.levels.xy.tdx.Texture_v4f32_0_0_0_2t
# | ptr @llvm.dx.resource.getdimensions.levels.xy.tdx.Texture_v4f32_0_0_0_2t.i32
# | Intrinsic name not mangled correctly for type arguments! Should be: llvm.dx.resource.getdimensions.levels.xy.tdx.Texture_v4f32_0_0_0_2t
# | ptr @llvm.dx.resource.getdimensions.levels.xy.tdx.Texture_v4f32_0_0_0_2t.i32
# | fatal error: error in backend: Broken module found, compilation aborted!
```
https://github.com/llvm/llvm-project/pull/189991
More information about the cfe-commits
mailing list