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

Using templates in combination with globallycoherent fails to compile #4583

Closed
DBouma opened this issue Aug 9, 2022 · 1 comment · Fixed by #4718
Closed

Using templates in combination with globallycoherent fails to compile #4583

DBouma opened this issue Aug 9, 2022 · 1 comment · Fixed by #4718
Assignees
Labels
hlsl2021 Pertaining to HLSL2021 features

Comments

@DBouma
Copy link

DBouma commented Aug 9, 2022

The use of templates, in particular when used to specify a texture value type, fails to compile.
I'm expecting this to be completely valid as this works without the globallycoherent specifier.
But instead this error is thrown:

error: 'globallycoherent' is not a valid modifier for a non-UAV type
   globallycoherent RWTexture2D<T> output = ResourceDescriptorHeap[0];
   ^

Example shader, compiled with -HV 2021:

template<typename T> void doSomething(uint2 pos) {
   globallycoherent RWTexture2D<T> output = ResourceDescriptorHeap[0];
   output[pos] = 0;
}

[numthreads(8,8,1)]
void main(uint2 threadId: SV_DispatchThreadID) {
   doSomething<float>(threadId);
}
@pow2clk pow2clk added the hlsl2021 Pertaining to HLSL2021 features label Aug 15, 2022
@llvm-beanz llvm-beanz self-assigned this Oct 4, 2022
@llvm-beanz
Copy link
Collaborator

The general issue here is that DXC verifies declaration attributes during first-pass parsing. This just flat out doesn't work with templates. With templates the attribute validation needs to be performed when the declaration is instantiated. There is no good easy fix for this. We really need to refactor and restructure how HLSL attributes are validated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hlsl2021 Pertaining to HLSL2021 features
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants
@llvm-beanz @pow2clk @DBouma and others