-
Notifications
You must be signed in to change notification settings - Fork 14.9k
Fix for incomplete buffer types in HLSL #163823
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
base: main
Are you sure you want to change the base?
Conversation
Thank you for submitting a Pull Request (PR) to the LLVM Project! This PR will be automatically labeled and the relevant teams will be notified. If you wish to, you can add reviewers by using the "Reviewers" section on this page. If this is not working for you, it is probably because you do not have write permissions for the repository. In which case you can instead tag reviewers by name in a comment by using If you have received no comments on your PR for a week, you can request a review by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate is once a week. Please remember that you are asking for valuable time from other developers. If you have further questions, they may be answered by the LLVM GitHub User Guide. You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums. |
@llvm/pr-subscribers-clang Author: Sietze Riemersma (KungFuDonkey) ChangesI am actually looking into getting clangd to work with HLSL. There is currently no good tool available for HLSL and as HLSL seems to be supported (up to a certain point) inside clang, I want to see how far I can push the tool to support the different language features. The first feature that requires an update is the SEMA (semantics?) around the buffer types. HLSL has updated their usage of buffer types in recent versions, so these need to be updated here as well. The first issue I ran into is the following;
I will start with 1. in this PR. An explanation for 2. will be later in this post. Please note that I am not familiar with this code base, this is my first time :), so the solution I give here might not be good, but I am willing to learn and move code around if necessary. 1. Some buffers are registered as incomplete typesI have a local test case that is as follows. We have a file: // complete types
RasterizerOrderedStructuredBuffer<float3> buf0 : register(u0);
ConsumeStructuredBuffer<float3> buf1 : register(u0);
AppendStructuredBuffer<float3> buf2 : register(u0);
RWStructuredBuffer<float3> buf3 : register(u0);
StructuredBuffer<float3> buf4 : register(t0);
RasterizerOrderedBuffer<float3> buf5 : register(u0);
Buffer<float3> buf6 : register(t0);
RWBuffer<float3> buf7 : register(u0);
// incomplete types
ByteAddressBuffer buf8 : register(t0);
RWByteAddressBuffer buf9 : register(u0);
RasterizerOrderedByteAddressBuffer buf10 : register(u0);
// missing
ConstantBuffer<float4> buf11 : register(b0); and we call clangd on this file. I have a compile_commands.json that handles cli args (args in output). The output is:
Calling
Thus, a call to CompleteType is missing for these 3 buffers. I was not able to find where that is. 2.
|
@llvm/pr-subscribers-hlsl Author: Sietze Riemersma (KungFuDonkey) ChangesI am actually looking into getting clangd to work with HLSL. There is currently no good tool available for HLSL and as HLSL seems to be supported (up to a certain point) inside clang, I want to see how far I can push the tool to support the different language features. The first feature that requires an update is the SEMA (semantics?) around the buffer types. HLSL has updated their usage of buffer types in recent versions, so these need to be updated here as well. The first issue I ran into is the following;
I will start with 1. in this PR. An explanation for 2. will be later in this post. Please note that I am not familiar with this code base, this is my first time :), so the solution I give here might not be good, but I am willing to learn and move code around if necessary. 1. Some buffers are registered as incomplete typesI have a local test case that is as follows. We have a file: // complete types
RasterizerOrderedStructuredBuffer<float3> buf0 : register(u0);
ConsumeStructuredBuffer<float3> buf1 : register(u0);
AppendStructuredBuffer<float3> buf2 : register(u0);
RWStructuredBuffer<float3> buf3 : register(u0);
StructuredBuffer<float3> buf4 : register(t0);
RasterizerOrderedBuffer<float3> buf5 : register(u0);
Buffer<float3> buf6 : register(t0);
RWBuffer<float3> buf7 : register(u0);
// incomplete types
ByteAddressBuffer buf8 : register(t0);
RWByteAddressBuffer buf9 : register(u0);
RasterizerOrderedByteAddressBuffer buf10 : register(u0);
// missing
ConstantBuffer<float4> buf11 : register(b0); and we call clangd on this file. I have a compile_commands.json that handles cli args (args in output). The output is:
Calling
Thus, a call to CompleteType is missing for these 3 buffers. I was not able to find where that is. 2.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Calling complete type before the type is completed breaks a lot, we also deliberately don't populate or complete the decls until they are used in a context that requires them to be complete. Lazy initializing the decls is a huge performance win.
I am actually looking into getting clangd to work with HLSL. There is currently no good tool available for HLSL and as HLSL seems to be supported (up to a certain point) inside clang, I want to see how far I can push the tool to support the different language features.
The first feature that requires an update is the SEMA (semantics?) around the buffer types. HLSL has updated their usage of buffer types in recent versions, so these need to be updated here as well.
The first issue I ran into is the following;
ConstantBuffer<type>
is missingI will start with 1. in this PR. An explanation for 2. will be later in this post. Please note that I am not familiar with this code base, this is my first time :), so the solution I give here might not be good, but I am willing to learn and move code around if necessary.
1. Some buffers are registered as incomplete types
I have a local test case that is as follows. We have a file:
and we call clangd on this file. I have a compile_commands.json that handles cli args (args in output).
The output is:
Calling
CompleteType(Decl);
on the types makes the issues go away for the incomplete buffers:Thus, a call to CompleteType is missing for these 3 buffers. I was not able to find where that is.
2.
ConstantBuffer<type>
is missingThis type is in theory the same as saying
cbuffer type
.Adding the ConstantBuffer as a new Build in Type here fixes the issue: