Synchonizing dependent commands on the same queue with fences?
### Question description
I am learning how to implement a renderer for `egui`, which I sometimes need to update existing textures that will be rendered (for example, a new character is rasterized and needs to be cached in the atlas).
Initially I thought `AutoCommandBuffer` has ordering guarantee, so I called `copy_buffer_to_image` and `begin_rendering`/`draw` in the same builder. However I get `AlreadyInUse` errors on the texture when submitting the command.
Then I thought `GpuFuture.then_execute()` can guarantee order, so I split it into 2 command buffers, but I didn't help.
In the end I inserted a `then_signal_fence_and_flush()` between the `then_execute()` and this seems to fixed the issue.
However I don't understand what is happening. With `then_execute()` everything should be in order on the GPU. Do I need `then_signal_fence_and_flush()` because vulkano's resource checker runs on the CPU hence need to be synchronized to prove it is safe even though it is already safe enough on the GPU side? The [documentations](https://docs.rs/vulkano/0.35.2/vulkano/sync/future/index.html) only talked about using semaphores to sync between queues but very little about fences. Am I correct that fences are needed between dependent operations on the same queue?
关闭于 2025-12-29 1 条评论