KhronosGroup / Vulkan-Samples

One stop solution for all Vulkan samples
Apache License 2.0
4.33k stars 647 forks source link

ComputeNbody sample - compute.uniform_buffer looks not properly synchronized, it's updated right after QueueSubmit. #1094

Open tonyx123 opened 4 months ago

tonyx123 commented 4 months ago

Please look at ComputeNBody::render and ComputeNBody::draw. We add an WaitForIdle in Api::VulkanSample::submit_frame(), so: For graphics sequence, it's QueueSubmit -> WaitForIdle -> graphics.uniform_buffer.update. Most samples implement similar to this. For compute sequence, it's QueueSubmit -> compute.uniform_buffer.update, there's no synchronization between the submission and buffer-update, which I think is wrong.

SaschaWillems commented 4 months ago

It's kinda hard to help with that little information, so can you elaborate?

graphics.uniform_buffer is only updated from the host and it's using host coherent memory.

Why do you think sync is missing, and what sync do you think is missing?

tonyx123 commented 3 months ago

Sorry for the typo. I mean "For compute sequence, it's QueueSubmit -> compute.uniform_buffer.update"

We submit compute cmdBuf first then update compute uniform. I don't see anything to guarantee that the compute cmdBuf execution happens before its uniform get updated. Isn't it an issue?