Vulkan
Vulkan copied to clipboard
Compute cull and lod: `idx == 0` may not ensures that uboOut.drawCount will be cleared as the first invocation?
In the example of compute cull and lod
, the uboOut.drawCount
is initialized to 0 by the shader of idx == 0
as the code shows:
https://github.com/SaschaWillems/Vulkan/blob/9c029b36fa9e2504af9e978c888193e6e59c82f0/data/shaders/glsl/computecullandlod/cull.comp#L81-L91
But I think there are maybe other invocations of the shader running in parallel and are scheduled a little bit faster so that atomicAdd(uboOut.drawCount, 1)
is executed before atomicExchange(uboOut.drawCount, 0)
. So as to ensure uboOut.drawCount
is initialized to 0 before increment, we may need to call vkCmdFillBuffer
in the commandbuffer.
That may be right. I'll check and add a vkCmdFillBuffer
.
I have removed the shader code and the buffer is now cleared using vkCmdFillBuffer
.