Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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

share|improve this question

1 Answer 1

up vote 3 down vote accepted

Your dispatch call Dispatch( 100, 0, 0 ) is not actually creating any thread groups. You need (100, 1, 1). The total number of thread groups is the product of the three dimensions, so any zero dimension will nullify the whole thing.

Also, you're not re-copying the structured buffer to the staging buffer after running the compute shader.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.