diff options
author | Helena Kotas <hekotas@microsoft.com> | 2025-05-14 18:41:17 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-05-14 18:41:17 -0700 |
commit | 520773b47eba0df02730b929df073e1a38474bae (patch) | |
tree | 1fa2cd37e286512bb22814d354737faaba594196 /clang/lib/Sema/HLSLExternalSemaSource.cpp | |
parent | 34be80aa6edda60e240e4ea46f28b1b54ababf72 (diff) | |
download | llvm-520773b47eba0df02730b929df073e1a38474bae.zip llvm-520773b47eba0df02730b929df073e1a38474bae.tar.gz llvm-520773b47eba0df02730b929df073e1a38474bae.tar.bz2 |
[HLSL] Add resource constructor with implicit binding for global resources (#138976)
Adds constructor for resources with implicit binding and applies it to
all resources without binding at the global scope.
Adds Clang builtin function
`__builtin_hlsl_resource_handlefromimplicitbinding` that gets translated
to `llvm.dx|spv.resource.handlefromimplicitbinding` intrinsic calls.
Specific bindings are assigned in DXILResourceImplicitBinding pass.
Design proposals:
https://github.com/llvm/wg-hlsl/blob/main/proposals/0024-implicit-resource-binding.md
https://github.com/llvm/wg-hlsl/blob/main/proposals/0025-resource-constructors.md
One change from the proposals is that the `orderId` parameter is added
onto the constructor. Originally it was supposed to be generated in
codegen when the `llvm.dx|spv.resource.handlefromimplicitbinding` call
is emitted, but that is not possible because the call is inside a
constructor, and the constructor body is generated once per resource
type and not resource instance. So the only way to inject instance-based
data like `orderId` into the
`llvm.dx|spv.resource.handlefromimplicitbinding` call is that it must
come in via the constructor argument.
Closes #136784
Diffstat (limited to 'clang/lib/Sema/HLSLExternalSemaSource.cpp')
-rw-r--r-- | clang/lib/Sema/HLSLExternalSemaSource.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/clang/lib/Sema/HLSLExternalSemaSource.cpp b/clang/lib/Sema/HLSLExternalSemaSource.cpp index f09232a..38bde7c 100644 --- a/clang/lib/Sema/HLSLExternalSemaSource.cpp +++ b/clang/lib/Sema/HLSLExternalSemaSource.cpp @@ -132,7 +132,8 @@ static BuiltinTypeDeclBuilder setupBufferType(CXXRecordDecl *Decl, Sema &S, return BuiltinTypeDeclBuilder(S, Decl) .addHandleMember(RC, IsROV, RawBuffer) .addDefaultHandleConstructor() - .addHandleConstructorFromBinding(); + .addHandleConstructorFromBinding() + .addHandleConstructorFromImplicitBinding(); } // This function is responsible for constructing the constraint expression for |