Fixes crash of import memory with vkMemoryDedicatedAllocateInfo that have mismatched import handles - #8
Merged
utkarshdalal merged 3 commits intoJul 25, 2026
Conversation
have mismatched import handles Currently, some drivers will hard-crash the AllocateMemory if trying to import an image crated with VK_EXTERNAL_MEMORY_HANDLE_TYPE_DMA_BUF_BIT_EXT into AHB
leegao
force-pushed
the
fix-AllocateMemory-import
branch
from
July 24, 2026 01:16
c4cbcf7 to
c4c42fa
Compare
leegao
marked this pull request as ready for review
July 24, 2026 01:17
Reverts part of GameNative@2af0e2e that broken blitting for some games See leegao/bionic-vulkan-wrapper#157 (comment) GAME - renders to the primary image [r, g, b, a] or [b, g, r, a], physically backed by device local memory (so under TILING_OPTIMAL, configured in either RGBA or BGRA mode) WSI - copies (byte-for-byte) the primary image to the secondary image, which is hardcoded as AHB_RGBA (since Mali doesn't support AHB_BGRA), but physically contains [b, g, r, a] memory for x11 X11 - imports the AHB_RGBA buffer containing assumed to be [b, g, r, a] data
handle check up to vkAllocateMemory
Contributor
Author
|
@utkarshdalal see 0bd55cb the handle_types check is lifted up now, and we do an explicit unlink of the MemoryDedicatedAllocateInfo without an external import handle type |
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.
Commit 1
Currently, some drivers will hard-crash the dispatch->AllocateMemory (on older Mali drivers) if trying to import an image created with VK_EXTERNAL_MEMORY_HANDLE_TYPE_DMA_BUF_BIT_EXT into a:
This PR introduces handle type tracking and validates the call to dispatch->AllocateMemory in the 3 handle import paths in wrapper_AllocateMemory to ensure that the wrong handle type won't crash the driver.
Commit 2
Fixes the blitting fallback path swapping blue/red on certain game engines (those preferring rgba8 swapchain)
Investigation: leegao/bionic-vulkan-wrapper#157 (comment)
The flow for a blit goes something like this:
this fails when the game picks [r, g, b, a] as the swapchain image, as the vkCopyImage will place [r, g, b, a] data instead of the expected [b, g, r, a] data into the AHB_RGBA secondary image (I know, this is confusing), hence swapping the b/r channels.
This commit reverts the part of 2af0e2e that introduced [r, g, b, a] as a valid swapchain format (originally meant as a fast path to avoid emulating bgra8)
Testing: see leegao/bionic-vulkan-wrapper#157 (comment) (still has to be done by thirdparty tester, many thanks to https://github.com/gtaforever00 and https://github.com/Artewar67)
For @utkarshdalal - would appreciate feeding this patch through code-review to double check everything as well