Skip to content

[Impeller] Vulkan sync validation: render pass incoming dependency doesn't cover a color attachment's LOAD loadOp #195696

Closed

Description

@gaaclarke

Steps to reproduce

With #195596 applied, build impeller_unittests with SwiftShader and run it with synchronization validation enabled:

./bin/et build -c ci/host_debug_arm64_tests //flutter/impeller:impeller_unittests
cd ../out/ci/host_debug_arm64_tests
VK_ICD_FILENAMES=$PWD/vk_swiftshader_icd.json \
VK_LAYER_PATH=$PWD/vulkan-data \
VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation \
DYLD_LIBRARY_PATH=$PWD \
./impeller_unittests \
  --gtest_filter='Play/RendererTest.CachesRenderPassAndFramebufferMixed/Vulkan' \
  --enable_vulkan_sync_validation

Expected results

No synchronization hazards reported.

Actual results

ID Name: SYNC-HAZARD-READ-AFTER-WRITE
Trigger: vkCmdBeginRenderPass(): READ_AFTER_WRITE hazard detected: attachment loadOp access is not synchronized with the attachment layout transition. vkCmdBeginRenderPass reads the color aspect of attachment 0 (VkImageView 0x…) in subpass 0 of VkRenderPass 0x… (loadOp VK_ATTACHMENT_LOAD_OP_LOAD), which was previously written during an image layout transition initiated by the same command.
The current synchronization allows VK_ACCESS_2_COLOR_ATTACHMENT_WRITE_BIT accesses at VK_PIPELINE_STAGE_2_COLOR_ATTACHMENT_OUTPUT_BIT, but to prevent this hazard, it must allow VK_ACCESS_2_COLOR_ATTACHMENT_READ_BIT accesses at VK_PIPELINE_STAGE_2_COLOR_ATTACHMENT_OUTPUT_BIT.

Analysis

A color attachment with LoadAction::kLoad is read by its loadOp at COLOR_ATTACHMENT_OUTPUT with COLOR_ATTACHMENT_READ access. The incoming VK_SUBPASS_EXTERNAL dependency in RenderPassBuilderVK::Build only lists eColorAttachmentWrite in dstAccessMask. So the attachment's layout transition, and any earlier writes, aren't made visible to the load. It probably also needs eColorAttachmentRead. Adding it locally gets rid of the hazard.

This is the color counterpart of the depth/stencil dstAccessMask gap in #194987 and #195599, in the same dependency. One fix may cover both.

Play/RendererTest.CachesRenderPassAndFramebufferMixed/Vulkan isn't in the sync validation shard (#195502). It could be added once this is fixed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work liste: impellerImpeller rendering backend issues and features requestsengineflutter/engine related. See also e: labels.team-engineOwned by Engine teamtriaged-engineTriaged by Engine team

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions