[DX11] Compute Shader - shared memory problem

Started by
0 comments, last by MJP 12 years, 1 month ago
I have simple piece of code...

DecompressedShared is marked as groupshared, Decompressed is RWStructuredBuffer, lastDecompressedIndex is groupshared variable


uint index = 0;
for (uint j = lastDecompressedIndex; j < (lastDecompressedIndex + 2); j++)
{
Decompressed[j] = DecompressedShared[index];
index++;
}


Hovewer.. if I use code above, i got wrong result A | 0 | C | 0 ....
If I use this code instead:

Decompressed[lastDecompressedIndex + 0] = DecompressedShared[0];
Decompressed[lastDecompressedIndex + 1] = DecompressedShared[1];


I got correct result A | B | C | D ...

I dont understand it...huh.png
Advertisement
You should check the assembly. I would bet that the compiler is going to do wacky things with that loop since it will have to re-load the value of lastDecompressedIndex for every loop iteration. I would try storing the value in a local variable so that it gets stored in a register, and see how that changes the resulting assembly code.

This topic is closed to new replies.

Advertisement