-
Notifications
You must be signed in to change notification settings - Fork 14.8k
Open
Open
Copy link
Labels
HLSLHLSL Language SupportHLSL Language Support
Description
There is no matching constructor when initializing a local variable struct with a struct read from a constant buffer.
https://godbolt.org/z/e1n1xnj6r
// compile args: -T cs_6_7 -E CSMain -enable-16bit-types
RWStructuredBuffer<uint> output : register(u0);
struct MyStruct {
int i;
};
cbuffer MyBuffer : register(b0) {
MyStruct myS;
};
[numthreads(1, 1, 1)]
void CSMain() {
MyStruct s = myS;
output[0] = s.i;
}
<source>:10:12: error: no matching constructor for initialization of 'MyStruct'
10 | MyStruct s = myS;
| ^ ~~~
<source>:2:8: note: candidate constructor (the implicit copy constructor) not viable: cannot bind reference in address space 'hlsl_constant' to object in generic address space in 1st argument
2 | struct MyStruct {
| ^~~~~~~~
<source>:2:8: note: candidate constructor (the implicit move constructor) not viable: cannot bind reference in address space 'hlsl_constant' to object in generic address space in 1st argument
2 | struct MyStruct {
| ^~~~~~~~
<source>:2:8: note: candidate constructor (the implicit default constructor) not viable: requires 0 arguments, but 1 was provided
1 error generated.
Compiler returned: 1
Metadata
Metadata
Assignees
Labels
HLSLHLSL Language SupportHLSL Language Support
Type
Projects
Status
Ready