Writing to a structured buffer with a compute shader (D3D11)
- by Vertexwahn
I have some problems writing to a structured buffer. First I create a structured buffer that is filled with float values beginning from 0 to 99. Afterwards a copy the structured buffer to a CPU accessible buffer is made to print the content of the structured buffer to the console. The output is as expected (Numbers 0 to 99 appear on the console). Afterwards I use a compute shader that should change the contents of the structured buffer:
RWStructuredBuffer<float> Result : register( u0 );
[numthreads(1, 1, 1)]
void CS_main( uint3 GroupId : SV_GroupID )
{
Result[GroupId.x] = GroupId.x * 10;
}
But the compute shader does not change the contents of the structured buffer.
The source code can be found here (main.cpp):
https://bitbucket.org/Vertexwahn/cmakedemos/src/4abb067afd5781b87a553c4c720956668adca22a/D3D11ComputeShader/src/main.cpp?at=default
FillCS.hlsl:
https://bitbucket.org/Vertexwahn/cmakedemos/src/4abb067afd5781b87a553c4c720956668adca22a/D3D11ComputeShader/src/FillCS.hlsl?at=default