Falcor
Falcor copied to clipboard
Slang Crash on Compilation of Compute Shader
Crash with access violation in Program.cpp in Program::preprocessAndCreateProgramVersion when calling spCompile. I don't think my Falcor is completely up to date but it is using slang 0.12.5, which seems to be what the main repo is using right now.
Relevant Falcor code:
mMosiacResources.mpState = ComputeState::create();
mMosiacResources.mpComputeShader = ComputeProgram::createFromFile("Mosaic.cs.hlsl", "main");
mMosiacResources.mpState->setProgram(mMosiacResources.mpComputeShader);
mMosiacResources.mpVars = ComputeVars::create(mMosiacResources.mpComputeShader->getReflector());
My compute shader is pretty dumb, was going to improve it once I got the dumb version of it working. It's definitely possible that I've made some error here but I'm not sure what it is because slang is crashing rather than reporting it.
Compute Shader:
SamplerState gSampler;
Texture2D gColorTex;
Texture2D gCellTex;
RWTexture2D<float4> outColors;
const uint numCells = 25;
cbuffer PerFrame
{
int2 textureDimensions;
};
// 99% sure this could be better and actually use multiple threads
[numthreads(1, 1, 1)]
void main() //Dont need indexing when doing 1,1,1
{
float3 cellColorSums[numCells];
uint cellTexelCounts[numCells];
for (uint i = 0; i < numCells; ++i)
{
cellColorSums[i] = 0;
cellTexelCounts[i] = 0;
}
for (int i = 0; i < textureDimensions.x; ++i)
{
for (int j = 0; j < textureDimensions.y; ++j)
{
int2 index(i, j);
uint cellIndex = gCellTex.Load(index);
float4 texelColor = gColorTex.Load(index);
cellColorSums[cellIndex] += texelColor;
cellTexelCounts[cellIndex] += 1;
}
}
for (uint i = 0; i < numCells; ++i)
{
float3 outColor = (float3)cellColorSums[i] / cellPixelCounts[i];
outColors[i] = float4(outColor, 1.0f);
}
}
The relevant portion of the stack that's visible to me is...
GrfxSandbox::OnLoad()
Falcor::Program::getReflector()
Falcor::Program::getActiveVersion()
Falcor::Program::link()
Falcor::Program::preprocessAndCreateProgramVersion()
@tfoleyNV