RedMagic 11 Pro display fixes: IMapper5 gralloc backend and UBWC swapchain buffers - #4
Open
Leb-Sun wants to merge 6 commits into
Open
RedMagic 11 Pro display fixes: IMapper5 gralloc backend and UBWC swapchain buffers#4Leb-Sun wants to merge 6 commits into
Leb-Sun wants to merge 6 commits into
Conversation
…swapchain buffers
… are compression-compatible
… dead fallback patch
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.
Makes vendor display features that consume the app's swapchain — RedMagic GameSpace upscaling and frame generation — work under Turnip. Both device-confirmed on Adreno 840 / Android 16. Supersedes #2 and #3.
Also drops the
-e(eco) variant: its only behavioural change was measured worse and already removed, leaving tunables for a closed question. Variants are nowbandp.Root cause — three chained gaps
1. Turnip never requested UBWC. Android's loader asks the driver, via
vkGetPhysicalDeviceImageFormatProperties2+VkAndroidHardwareBufferUsageANDROID, what usage to allocate swapchain buffers with (frameworks/native/vulkan/libvulkan/swapchain.cpp:1450+— it returns before the legacyGetSwapchainGrallocUsageXchain, which modern Android never calls). Measured with an app-side probe:androidHardwareBufferUsage0x2000x100002000x100002000x10000000is the QTI vendor bit requesting UBWC. Mesa'svk_image_usage_to_ahb_usage()has no vendor-usage concept — there is an in-treeXXXacknowledging this.2. QTI's mapper misdescribes the resulting buffer. For 1216x2688 RGBA8888 UBWC it reports
fourcc=0,modifier=0(LINEAR — wrong) and two planes with the metadata plane first:plane[0] offset=86016 stride=4864(data, 12164) andplane[1] offset=0 stride=128(metadata, 128672=86016).3. Mesa rejects that.
vk_gralloc_to_drm_explicit_layout()treats any plane n>0 at offset 0 as disjoint and returnsVK_ERROR_INVALID_EXTERNAL_HANDLE, sovkCreateSwapchainKHRfails and the screen goes black.Changes
add_aimapper_gralloc.py— IMapper5 gralloc backend reached throughandroid_load_sphal_library()+AIMapper_loadIMapper(). A driver loaded into an app process cannot linklibui, so Mesa's existing IMapper backends are gated out andu_grallocfalls back tou_gralloc_fallback.c(no YCbCr, UBWC guessed from a private handle offset). Needs onlydlopen/dlsym.add_ubwc_swapchain_usage.py— sets the QTI UBWC usage bit, scoped to the allocation query only. It must not go invk_image_usage_to_ahb_usage(): that function also answers import validation, and demanding UBWC there rejects every linear buffer (observed: 448nativeImportAhbToVulkan failed).StandardMetadataType::COMPRESSION— device-measured, QTI returnsname="QTI" value=10for UBWC andname="android.hardware.graphics.common.Compression" value=0for linear. Plane-layout signature retained as a fallback for vendors that do not populate it.Verification
aimapper: UBWC via COMPRESSION metadata→WN-ANB-LAYOUT: result=0 modifier=0x500000000000001 planes=1, picture renders, upscaling and frame generation both working.Symptom ladder along the way: green (no RGBA source at all) → black (source exists, swapchain fails) → working.
Not included
add_anb_gralloc_usage34.py(ANB usage3/4 + spec 10) stays onubwc-swapchain-usage. It closes a real Mesa gap — Mesa dispatches only v1/v2 while its own header is spec 11 — but the modern loader never calls that chain, so it is unproven here and does not belong on a branch named "fixes".Note
This exact tree has not been built or run; it is assembled from device-confirmed pieces with diagnostics stripped. This PR is the first build of it.