Skip to content

[DirectX] Error occurs when using global resource handles in function parameters or when compiling with -O0 #140819

@Icohedron

Description

@Icohedron

There are two known cases under which using resource handles results in errors of the form error: Load of {.*} is not a global resource handle

Case 1 - Resource Handle Function Parameter

This is a case preventing the compilation of a few DML shaders.

Using a resource handle function argument results in an error along the lines of error: Load of "agg.tmp.i1.sroa.0" is not a global resource handle.

// RUN: clang-dxc -E CSMain -T cs_6_2 -enable-16bit-types -O3 %s
inline void Foo(RWStructuredBuffer<uint> b) {
   b[0] = 0;
}
RWStructuredBuffer<uint> buf;
[numthreads(1, 1, 1)]
void CSMain() {
   Foo(buf);
}

Reproduction: https://godbolt.org/z/fcaE5dn11

Case 2 - -O0 optimization

With -O0, global resource handles can not be used due to an error of the form error: Load of "this1.i" is not a global resource handle.

// RUN: clang-dxc -E CSMain -T cs_6_7 -O0 %s
RWBuffer<uint> output : register(u0);
[numthreads(1,1,1)]
void CSMain() { 
    output[0] = 0;
}

Reproduction: https://godbolt.org/z/6vP5xxYsE

Note: godbolt/compiler explorer reports the name of the global resource handle as "" instead of giving them actual names.

Metadata

Metadata

Assignees

Type

Projects

Status

Closed

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions