wgpu icon indicating copy to clipboard operation
wgpu copied to clipboard

Fix synchronization validation error in `water` example on Vulkan

Open ErichDonGubler opened this issue 1 year ago • 3 comments

GPU-based validation was implemented for the Vulkan backend in #5046 (🎉). With it, we began to run into a validation error for the water example:

[2024-02-02T20:25:58Z ERROR wgpu_test::expectations] Validation Error: Validation Error: [ SYNC-HAZARD-WRITE-AFTER-READ ] Object 0: handle = 0xa808d50000000033, type = VK_OBJECT_TYPE_RENDER_PASS; | MessageID = 0x376bc9df | vkCmdEndRenderPass: Hazard WRITE_AFTER_READ in subpass 0 for attachment 1 depth aspect during store with storeOp VK_ATTACHMENT_STORE_OP_STORE. Access info (usage: SYNC_LATE_FRAGMENT_TESTS_DEPTH_STENCIL_ATTACHMENT_WRITE, prior_usage: SYNC_FRAGMENT_SHADER_SHADER_SAMPLED_READ, read_barriers: VkPipelineStageFlags2(0), command: vkCmdDraw, seq_no: 2, reset_no: 1)

Because of the value of validation, that PR was merged without a complete fix to water, changing the outcome we expect of CI testing to failure. We should fix it, and adjust the expected test outcome of that example back to fully passing.

Additional historical context: https://github.com/gfx-rs/wgpu/pull/5046#issuecomment-1927380045

ErichDonGubler avatar Feb 09 '24 18:02 ErichDonGubler

In Fedora's vulkan-validation-layers-1.3.275.0-1.fc39.x86_64, this also produces a message (line-wrapped):

[2024-04-09T21:02:01Z ERROR wgpu_test::expectations] Validation Error:
Validation Error: [ SYNC-HAZARD-WRITE-AFTER-WRITE ] Object 0: handle =
0x7f2fb53d44e0, type = VK_OBJECT_TYPE_QUEUE; | MessageID = 0x5c0ec5d6
| vkQueueSubmit(): Hazard WRITE_AFTER_WRITE for entry 7,
VkCommandBuffer 0x7f2fb6fd5b40[], Submitted access info
(submitted_usage:
SYNC_LATE_FRAGMENT_TESTS_DEPTH_STENCIL_ATTACHMENT_WRITE, command:
vkCmdEndRenderPass, seq_no: 3, renderpass: VkRenderPass
0x2d000000002d[], reset_no: 1). Access info (prior_usage:
SYNC_IMAGE_LAYOUT_TRANSITION, write_barriers:
SYNC_VERTEX_SHADER_SHADER_SAMPLED_READ|SYNC_VERTEX_SHADER_SHADER_STORAGE_READ|SYNC_VERTEX_SHADER_UNIFORM_READ|SYNC_FRAGMENT_SHADER_DEPTH_STENCIL_ATTACHMENT_READ|SYNC_FRAGMENT_SHADER_SHADER_SAMPLED_READ|SYNC_FRAGMENT_SHADER_SHADER_STORAGE_READ|SYNC_FRAGMENT_SHADER_UNIFORM_READ|SYNC_EARLY_FRAGMENT_TESTS_DEPTH_STENCIL_ATTACHMENT_READ|SYNC_LATE_FRAGMENT_TESTS_DEPTH_STENCIL_ATTACHMENT_READ|SYNC_COMPUTE_SHADER_SHADER_SAMPLED_READ|SYNC_COMPUTE_SHADER_SHADER_STORAGE_READ|SYNC_COMPUTE_SHADER_UNIFORM_READ,
queue: VkQueue 0x7f2fb53d44e0[], submit: 0, batch: 0, batch_tag: 28,
command: vkCmdPipelineBarrier, command_buffer: VkCommandBuffer
0x7f2fb6fd43c0[Main Command Encoder], seq_no: 1, VkImage
0x1c000000001c[Reflection Render Texture], VkImage
0x1f000000001f[Depth Buffer], reset_no: 1).

jimblandy avatar Apr 09 '24 21:04 jimblandy

as i known , command_encoder_run_render_pass_impl looks like has auto insert barrier in command buffer, in water example, create the depth texture view has add all possible TextureUsages, https://github.com/gfx-rs/wgpu/blob/cc0ee7bcbdcf6c50a07ef11a0be92fcb44dd537e/examples/src/water/mod.rs#L207-L209 so why validation layer still report WAR ?

zhanghe9702 avatar Apr 19 '24 10:04 zhanghe9702