microsoft / microsoft/DirectXShaderCompiler
Error assigning struct into amplification payload
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 3.7k
- Forks
- 900
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 44
Description
Description
I was creating an amplification shader with a struct in the payload and I got a confusing internal error when compiling the shader whenever that struct is assigned to.
Steps to Reproduce
Here's my shader:
struct s {
float4x4 mat;
int array[3];
float2 vec;
};
struct payloadType { s data; };
groupshared payloadType payload;
[numthreads(1, 1, 1)]
void main()
{
s blah = (s)0;
payload.data = blah;
DispatchMesh(1, 1, 1, payload);
}
Compiling it gives me an error message. If I comment out the payload.data = blah; line then it's fine.
Actual Behavior
When I compile that shader with dxc amplification.hlsl -T as_6_7 I get the output:
error: llvm::cast<X>() argument of incompatible type!
This may be a duplicate of #5338 as it seems to be failing with the same assert if I run in a debug build of dxc, but in that case there's an explicit cast happening and here I'm not doing any cast (the initialisation of blah is just for convenience, the bug happens even if it's initialised without a cast from 0). If it is a duplicate feel free to close this but I didn't want to assume just because the same error is printed since the repro case seems like it might be different.
If I 'unwrap' the struct so all the members are loose in payloadType then there's no error, it seems to only happen when assigning a whole struct.
Environment
- DXC version: dxcompiler.dll: 1.7 - 1.7.2308.7 (69e54e290); dxil.dll: 1.7(101.7.2308.12)
- Host Operating System: Windows 10 19045.3570
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by saving the reported shader as amplification.hlsl and running dxc amplification.hlsl -T as_6_7, then compare it with the version where payload.data = blah is removed or the struct is unwrapped. Trace the compiler path for whole-struct assignment into the groupshared amplification payload and compare the related failure in issue #5338. Done means the repro no longer emits the incompatible llvm::cast error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100