Repository navigation
Description
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/TypographerTest.GlyphAtlasTextureWillGrowTilMaxTextureSize/Vulkan' \
--enable_vulkan_sync_validationExpected results
No synchronization hazards reported.
Actual results
ID Name: SYNC-HAZARD-WRITE-AFTER-WRITE
Trigger: vkCmdPipelineBarrier(): WRITE_AFTER_WRITE hazard detected. vkCmdPipelineBarrier performs image layout transition on the VkImage 0x…[GlyphAtlas], which was previously written by vkCmdCopyImage.
No sufficient synchronization is present to ensure that a layout transition does not conflict with a prior write (VK_ACCESS_2_TRANSFER_WRITE_BIT) at VK_PIPELINE_STAGE_2_COPY_BIT.
Hint: Ensure that srcStageMask includes VK_PIPELINE_STAGE_2_COPY_BIT and srcAccessMask includes VK_ACCESS_2_TRANSFER_WRITE_BIT. The source side of the barrier protects layout transition writes from previous accesses, and the destination side cannot introduce this specific hazard.Analysis
After vkCmdCopyImage, BlitPassVK::OnCopyTextureToTextureCommand transitions the destination back to eShaderReadOnlyOptimal with src_stage = eTopOfPipe and src_access = {}. That empty source scope means neither the layout transition nor the following fragment shader reads are ordered after the copy's transfer writes. A texture that was just copied into, like a glyph atlas that grew, could be sampled while the copy is still writing it.
The source scope probably needs eTransfer / eTransferWrite. Making that change locally gets rid of the hazard.
This is the same pattern as BlitPassVK::ResizeTexture in #195598. One fix may cover both. The barriers before writes into the destination in the same file (OnCopyTextureToTextureCommand, OnCopyBufferToTextureCommand, ResizeTexture) also use eTopOfPipe / {} as their source scope. Sync validation doesn't flag them in the current tests, but they would be hazards if the destination had been sampled or rendered to earlier.
Play/TypographerTest.GlyphAtlasTextureWillGrowTilMaxTextureSize/Vulkan isn't in the sync validation shard (#195502). It could be added once this is fixed.
Activity
[Impeller] Order the Vulkan copy-texture-to-texture layout transition…
[Impeller] Order the Vulkan copy-texture-to-texture layout transition…