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

ResourceDescriptorHeap doesn't work properly with templates (hlsl-2021) #3731

Closed
Jasper-Bekkers opened this issue Apr 30, 2021 · 1 comment · Fixed by #4114
Closed

ResourceDescriptorHeap doesn't work properly with templates (hlsl-2021) #3731

Jasper-Bekkers opened this issue Apr 30, 2021 · 1 comment · Fixed by #4114
Labels
hlsl2021 Pertaining to HLSL2021 features

Comments

@Jasper-Bekkers
Copy link

#ifdef FAILURE_CASE
struct SimpleBuffer {
    uint handle;

    template<typename T>
    T Load() {
        ByteAddressBuffer buf = ResourceDescriptorHeap[this.handle];
        return buf.Load<T>(0);
    }
};
#endif

[numthreads(1,1,1)]
void main() {
#ifdef FAILURE_CASE
    SimpleBuffer b = (SimpleBuffer)0;
    b.Load<uint>();
#endif

    ByteAddressBuffer buf = ResourceDescriptorHeap[0];
    buf.Load<uint>(0);
}

Works:
dxc -Tcs_6_6 -Emain -enable-templates test_bindless.hlsl

Doesn't work:
dxc -Tcs_6_6 -Emain -enable-templates -DFAILURE_CASE test_bindless.hlsl

Errors generated:

test_bindless.hlsl:8:20: error: no member named 'Load' in 'ByteAddressBuffer'
        return buf.Load<T>(0);
               ~~~ ^
test_bindless.hlsl:8:25: error: 'T' does not refer to a value
        return buf.Load<T>(0);
                        ^
test_bindless.hlsl:5:23: note: declared here
    template<typename T>
                      ^
test_bindless.hlsl:21:5: warning: ignoring return value of function that only reads data [-Wunused-value]
    buf.Load<uint>(0);
    ^~~~~~~~~~~~~~ ~

Notice, this doesn't just affect ByteAddressBuffer but all resource types it seems (StructuredBuffer, Texture etc).

@Jasper-Bekkers
Copy link
Author

@tcorringham You may be interested in this

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.

3 participants