#define size 17
RWStructuredBuffer<float> OutputBuffer : register(u0);
groupshared float SharedPositions[size * size];
[numthreads(size, size, 1)]
void CS( uint3 GroupID : SV_GroupID, uint3 DispatchThreadID : SV_DispatchThreadID, uint3 GroupThreadID : SV_GroupThreadID, uint GroupIndex : SV_GroupIndex )
{
// Write Vertex Position to shared memory
SharedPositions[GroupIndex] = 1.0f;
// Wait for Shared Memory to be ready
GroupMemoryBarrierWithGroupSync();
OutputBuffer[GroupIndex] = SharedPositions[GroupIndex];
}
When compiling with D3D10_SHADER_OPTIMIZATION_LEVEL higher than 1, I get the following error:
error X3695: race condition writing to shared memory detected, consider making this write conditional.[/quote]
But since I write to "GroupIndex", no more than one thread will ever write to the same location.
What condition does the compiler require for this to compile properly?