I'm using DirectX 12, trying to render using UAVs. Here is my pixel shader code:
struct PSInput
{
float4 position : SV_POSITION;
float4 color : COLOR;
};
struct FragmentDataStruct
{
float4 color;
float depth;
};
struct FragmentAndLinkStruct
{
FragmentDataStruct fragmentData;
uint nextFragment;
};
RWStructuredBuffer <FragmentAndLinkStruct> FLBuffer : register(u0);
RWByteAddressBuffer StartOffsetBuffer : register(u1);
float4 PSMain(PSInput input) : SV_TARGET
{
input.color.x = float(FLBuffer[0].nextFragment);
return input.color;
}
It fails compilation when using the D3DCompileFromFile
function.
When I replace this line:
input.color.x = float(FLBuffer[0].nextFragment);
with something like this:
FragmentAndLinkStruct otherThing;
otherThing.nextFragment = 1;
input.color.x = float(otherThing.nextFragment);
that has no mention of the RWStructuredBuffer
, then it compiles just fine and renders properly.
I don't think I have any issues with bound data (VS Graphics Debugger shows the two UAVs bound properly). I don't think that would affect the compiling of the shader, though.
Any time I reference FLBuffer
or StartOffsetBuffer
, it won't compile.
What would cause this problem?