Hello there. First post :).
I'm trying to perform cellular automata in the GPU without double buffering, I came across a very weird problem though that I could simplify into few lines of code:
for (int x = 0; x < max; ++x)
{
for (int y = 1; y < max; ++y)
{
uint down = map[int2(x, y-1)];
if (!down)
{
map[int2(x, y-1)] = 64;
map[int2(x, y)] = 0;
}
}
}
map is `RWTexture2D<uint> map : register(u0);`. It's dispatched with (1,1,1) and numthreads (1,1,1) so it loops the whole area (in this case 256*256) in a single thread (I know this isn't good but it's the simplest way to repro the issue I could come up with). It works fine when `max` is passed in a constant buffer, however, as soon as I hardcode that value simply by adding `int max = 256;` (and removing from the cbuffer) the shader simply crashes. I think it could be some compiler optimization gone wrong but I'm compiling debug shaders.
Do you guys have any idea what could be causing that? The shader compiles fine and there's no error whatsoever, it simply hangs forever when I hardcode that value. I am making sure that the value is exactly the same as passed in the constant. I have no idea what kind of nonsense is going on there
Thanks in advance