Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[HLSL] Add an attribute to differentiate resource attributes for Buffer vs StructuredBuffer and RawBuffer #107907

Closed
Tracked by #101557
bogner opened this issue Sep 9, 2024 · 1 comment · Fixed by #107954
Assignees
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema" HLSL HLSL Language Support

Comments

@bogner
Copy link
Contributor

bogner commented Sep 9, 2024

The target extension types for buffers are split into dx.TypedBuffer and dx.RawBuffer in order to separate the types of operation that are possible on the two. Specifically, Typed buffers must be accessed one typed element at a time, whereas Raw and Structured buffers don't have this restriction.

We need to represent this difference in the HLSL AST in order to correctly generate the target types. To do so, we should introduce a type attribute [[raw_buffer]] that will be used on buffer types such as StructuredBuffer or ByteAddressBuffer that do not require typed element access.
 
Note: This is related to llvm/wg-hlsl#68 and llvm/wg-hlsl#42. We should add this attribute to the table in that document.

AC:

  • A new type attribute is introduced that conveys this information on an __hlsl_resource_t
@bogner bogner added HLSL HLSL Language Support and removed new issue labels Sep 9, 2024
hekota added a commit to hekota/llvm-project that referenced this issue Sep 10, 2024
This PR introduces new HLSL resource type attribute [[hlsl::row_access]].
Presence of this attribute means that the resource must be accessed in 16-byte
blocks at-a-time, or four 32-bit components, also knows as rows.
This information is necessary in order to properly distinguish between a typed
buffer like `RWBuffer<float4>` which is translated to `dx.TypedBuffer` vs.
`RWStructuredBuffer<float4>` which does not have this access constraint and
will be translated to `dx.RawBuffer`.

Fixes llvm#107907
hekota added a commit that referenced this issue Sep 17, 2024
This PR introduces new HLSL resource type attribute
`[[hlsl::raw_buffer]]`. Presence of this attribute on a resource handle
means that the resource does not require typed element access. The
attribute will be used on resource handles that represent buffers like
`StructuredBuffer` or `ByteAddressBuffer` and in DXIL it will be
translated to target extension type `dx.RawBuffer`.

Fixes #107907
@EugeneZelenko EugeneZelenko added the clang:frontend Language frontend issues, e.g. anything involving "Sema" label Sep 17, 2024
@llvmbot
Copy link
Member

llvmbot commented Sep 17, 2024

@llvm/issue-subscribers-clang-frontend

Author: Justin Bogner (bogner)

The target extension types for buffers are split into [dx.TypedBuffer and dx.RawBuffer]( https://llvm.org/docs/DirectX/DXILResources.html#buffers) in order to separate the types of operation that are possible on the two. Specifically, Typed buffers must be accessed one typed element at a time, whereas Raw and Structured buffers don't have this restriction.

We need to represent this difference in the HLSL AST in order to correctly generate the target types. To do so, we should introduce a type attribute [[raw_buffer]] that will be used on buffer types such as StructuredBuffer or ByteAddressBuffer that do not require typed element access.
 
Note: This is related to llvm/wg-hlsl#68 and llvm/wg-hlsl#42. We should add this attribute to the table in that document.

AC:

  • A new type attribute is introduced that conveys this information on an __hlsl_resource_t

tmsri pushed a commit to tmsri/llvm-project that referenced this issue Sep 19, 2024
This PR introduces new HLSL resource type attribute
`[[hlsl::raw_buffer]]`. Presence of this attribute on a resource handle
means that the resource does not require typed element access. The
attribute will be used on resource handles that represent buffers like
`StructuredBuffer` or `ByteAddressBuffer` and in DXIL it will be
translated to target extension type `dx.RawBuffer`.

Fixes llvm#107907
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema" HLSL HLSL Language Support
Projects
Status: No status
Development

Successfully merging a pull request may close this issue.

4 participants