[llvm-branch-commits] [clang] [llvm] [HLSL] Add GetDimensions to Texture2D. (PR #189991)
Helena Kotas via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Thu Apr 2 10:02:51 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);
----------------
hekota wrote:
Looking at the tests, I see that the codegen is correct, though I would expect here something like this:
```suggestion
llvm::Type *RetType = CGF.IntTy;
if (NumRetComps > 1)
RetType = llvm::VectorType::get(RetType, ElementCount::getFixed(NumRetComps));
Value *DimValue =
CGF.Builder.CreateIntrinsic(RetTy, IntrinsicID, Args);
```
https://github.com/llvm/llvm-project/pull/189991
More information about the llvm-branch-commits
mailing list