llvm / llvm/llvm-project

[HLSL] Erroneous register validation warning on structs with resources in base class

Open
#176,062 2 comments 0 reactions 1 assignee Claimed by @gayanMatch View on GitHub
HLSL
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

Register type validation does not seem to be scanning base classes when looking for resources in a structure/class. The following code is valid and in Clang it produces two warnings.

```
struct A {
RWBuffer BufA;
StructuredBuffer BufB;
};

struct B : A {
};

B b : register(u10) : register(t20);

[numthreads(4,1,1)]
void main() {
}
```

Warnings reported:
```
:9:3: warning: binding type 'u' only applies to types containing UAV resources [-Wlegacy-constant-register-binding]
9 | B b : register(u10) : register(t20);
| ^
:9:3: warning: binding type 't' only applies to types containing SRV resources [-Wlegacy-constant-register-binding]
2 warnings generated.
```
https://godbolt.org/z/qvKKPPr8d

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.