inexorgame / vulkan-renderer

A new 3D game engine for Linux and Windows using C++20 and Vulkan API 1.3, in very early but ongoing development
https://inexor.org
MIT License
746 stars 33 forks source link

Validation error: Hazard WRITE_AFTER_WRITE vs. layout transition #546

Open IAmNotHanni opened 1 year ago

IAmNotHanni commented 1 year ago

Describe The Bug

When enabling Vulkan synchronization validation layers, I get at least 2 validation errors.

Steps To Reproduce

  1. Open vkcube and select synchronization validation layers: grafik
  2. Download, builld and run Inexor's current main branch

Expected Behavior

In a correct implementation, no synchronization errors occur in the most ideal case.

Affected Code

The rendergraph(?)

Operating System

All

Application Version

4f7b8377e5ed91e85db9f040527f33127d247c31

Additional Context

None

Relevant Log Output

SYNC-HAZARD-WRITE-AFTER-WRITE(ERROR / SPEC): msgNum: 1544472022 - Validation Error: [ SYNC-HAZARD-WRITE-AFTER-WRITE ] Object 0: handle = 0x3fbcd60000000028, type = VK_OBJECT_TYPE_RENDER_PASS; | MessageID = 0x5c0ec5d6 | vkCmdBeginRenderPass: Hazard WRITE_AFTER_WRITE vs. layout transition in subpass 0 for attachment 1 aspect depth during load with loadOp VK_ATTACHMENT_LOAD_OP_CLEAR. Objects: 1 [0] 0x3fbcd60000000028, type: 18, name: NULL 2023-06-19 04:38:22.731829 critical 25072 [vulkan-renderer] Validation Error: [ SYNC-HAZARD-WRITE-AFTER-WRITE ] Object 0: handle = 0x3fbcd60000000028, type = VK_OBJECT_TYPE_RENDER_PASS; | MessageID = 0x5c0ec5d6 | vkCmdBeginRenderPass: Hazard WRITE_AFTER_WRITE vs. layout transition in subpass 0 for attachment 1 aspect depth during load with loadOp VK_ATTACHMENT_LOAD_OP_CLEAR.

IAmNotHanni commented 1 year ago

https://github.com/KhronosGroup/Vulkan-ValidationLayers/blob/main/docs/synchronization.md

IAmNotHanni commented 1 year ago

https://github.com/KhronosGroup/Vulkan-Docs/wiki/Synchronization-Examples-(Legacy-synchronization-APIs)#graphics-to-graphics-dependencies

IAmNotHanni commented 1 year ago

I think the issue is in RenderGraph::build_render_pass...

IAmNotHanni commented 1 year ago

I believe this will go a way once use dynamic rendering in rendergraph2, so I am not sure if it's worth looking into this any further.