I’m quickly going crazy trying to find what’s causing this to not compile with D3DCompileFromFile
, but I’m getting nowhere. I’d greatly appreciate if someone would please look over this short shader code and tell me whether there’s an error I’m missing.
struct GPUTile
{
float4 pos[3];
};
AppendStructuredBuffer<GPUTile> renderTiles : register(u0);
StructuredBuffer<GPUTile> currentTiles : register(t0);
AppendStructuredBuffer<GPUTile> nextTiles : register(u1);
int IsVisible(GPUTile tile)
{
return true;
}
bool IsLarge(GPUTile tile)
{
return true;
}
[numthreads(4, 1, 1)]
void main(uint3 Gid : SV_GroupID, uint3 GTid : SV_GroupThreadID)
{
const int3 subdivisionMap[4] =
{
{ 0, 3, 5 },
{ 3, 1, 5 },
{ 4, 1, 5 },
{ 3, 4, 5 }
};
GPUTile currTile = currentTiles[Gid.x];
float4 q1 = 0.5f * (currTile.pos[1] + currTile.pos[0]);
float4 q2 = 0.5f * (currTile.pos[1] + currTile.pos[2]);
float4 q3 = 0.5f * (currTile.pos[2] + currTile.pos[0]);
float4 points[6] = { currTile.pos[0], currTile.pos[1], currTile.pos[2], q1, q2, q3 };
int3 mapped = subdivisionMap[GTid.x];
GPUTile newTile = (GPUTile) 0;
newTile.pos[0] = points[mapped[0]];
newTile.pos[1] = points[mapped[1]];
newTile.pos[2] = points[mapped[2]];
if (IsVisible(newTile))
{
if (IsLarge(newTile))
{
nextTiles.Append(newTile);
}
else
{
renderTiles.Append(newTile);
}
}
}
The code is intended to be a LOD algorithm for a triangular tile, though the issue is with compilation so I don’t think the algorithm needs explanation.
The error I get is D3D12 ERROR: ID3D12Device::CreateComputeShader: Compute Shader is corrupt or in an unrecognized format. [ STATE_CREATION ERROR #322: CREATECOMPUTESHADER_INVALIDSHADERBYTECODE]
which annoyingly I cannot find any information about.