DirectXShaderCompiler icon indicating copy to clipboard operation
DirectXShaderCompiler copied to clipboard

Attempting to pass a texture in the AS->MS payload struct causes crash

Open jeffnn opened this issue 1 year ago • 1 comments

Description Attempts to compile the following code results in an internal crash in the compiler. (GetLoweredUDT() returns nullptr when passed the payload's type) (This happened while writing tests. Not a customer scenario AFAIK)

Steps to Reproduce

// -T as_6_6 
struct MyPayload
{
    Texture2D tex;
};

[numthreads(1, 1, 1)]
void main(uint gid : SV_GroupID)
{
  MyPayload payload;
  DispatchMesh(1, 1, 1, payload);
}

Actual Behavior Asserts, then crash

Environment

  • DXC version: dxcompiler.dll: 1.8 - 1.8.0.4583 (compiled from github top-of-tree, circa 5/10/2024)
  • Host Operating System Win11, insider flight

jeffnn avatar May 14 '24 17:05 jeffnn

Jeff's repro on godbolt: https://godbolt.org/z/MdoaKz686

While it's not explicitly stated, the payload is essentially in groupshared memory. The closest the spec comes is to point out that "The size of the payload structure counts against groupshared memory limits". If I remember correctly, shaders with payloads not in groupshared won't run. Consequently, it makes sense that resources can't be in payloads since they can't be in groupshared. Crashing isn't okay of course.

Out of curiosity, I tried putting resources in groupshared and had similar, but not identical failures: https://godbolt.org/z/8cfoesvos

pow2clk avatar May 15 '24 01:05 pow2clk