gfxstream: Fix crash and synchronization in GPU scaled readback - #181
Closed
GOOG-sergiu wants to merge 1 commit into
Closed
gfxstream: Fix crash and synchronization in GPU scaled readback#181GOOG-sergiu wants to merge 1 commit into
GOOG-sergiu wants to merge 1 commit into
Conversation
When Android Studio or a client requests a scaled display frame (via gRPC streamScreenshot), readColorBufferPixelsScaled delegates to readColorBufferPixelsScaledGpu. This previously caused an immediate crash (SIGSEGV / exit code 139) on the host due to several Vulkan synchronization and memory violations: - Missing layout transition and memory barrier: sourceCbInfo->image was sampled in CompositorVk::drawImage() as VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL without transitioning from its current layout (e.g. COLOR_ATTACHMENT_OPTIMAL or GENERAL). On host drivers, sampling an attachment layout without a barrier triggers GPU MMU faults. Added a pre-draw pipeline barrier transitioning to SHADER_READ_ONLY_OPTIMAL and a post-draw barrier restoring the original layout. - Missing outbound subpass dependency: tempRenderPass only specified an inbound dependency (EXTERNAL -> 0), causing vkCmdCopyImageToBuffer to execute concurrently with active color attachment writes. Added an outbound dependency (0 -> EXTERNAL) to flush color attachment writes before the transfer read. - Missing staging buffer size check: validated requiredStagingSize against mStaging.mAllocationSize. - Hard aborts on transient errors: replaced VK_CHECK with graceful error logging, resource cleanup, and queue idling on fence failure. - Added graceful fallback to readColorBufferPixelsScaledCpu if readColorBufferPixelsScaledGpu fails. Bug: 553490628 Test: bazel test //host/vulkan:vk_common_operations_tests //host/vulkan:gfxstream_compositorvk_tests Change-Id: Icb7889bb7bbdc8dbe3d3ffdae0ba2899dfd85a2f
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When Android Studio or a client requests a scaled display frame (via gRPC streamScreenshot), readColorBufferPixelsScaled delegates to readColorBufferPixelsScaledGpu. This previously caused an immediate crash (SIGSEGV / exit code 139) on the host due to several Vulkan synchronization and memory violations:
Bug: 553490628
Test: bazel test //host/vulkan:vk_common_operations_tests //host/vulkan:gfxstream_compositorvk_tests
Change-Id: Icb7889bb7bbdc8dbe3d3ffdae0ba2899dfd85a2f