Repository navigation
Conversation
…foEXT Only rowPitch was taken from pPlaneLayouts; the offset was ignored, so every plane was bound at the memory binding offset (packed sequentially for multi-plane images). Importing a dma-buf plane that does not start at offset 0, e.g. the CbCr plane of a single-buffer NV12 frame imported by libplacebo as its own image, therefore sampled the luma plane. Store the explicit per-plane offset and use it when binding memory, computing memory requirements and reporting the subresource layout. Per the spec it is relative to the image's memory binding, or to the plane's binding for disjoint images. Seen with mpv --hwdec=v4l2request --vo=gpu (Vulkan) decoding H.264 with the Apple AVD V4L2 stateless decoder: chroma showed luma data (green/magenta picture). The OpenGL/EGL dma-buf import path was fine. Assisted-by: Claude:claude-opus-5-5 Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
DjDeveloperr
added a commit
that referenced
this pull request
Oct 23, 2026
…ffsets hk: honor plane offsets from VkImageDrmFormatModifierExplicitCreateInfoEXT (port of #10)
|
Thanks! This is now in aurora-wip via #34 (merged), with your authorship and message kept. aurora-wip had already picked up the explicit offset for placement, requirements, binding and subresource layouts, so the port carries the remaining part: disjoint planes in separate bindings may share offsets. It also adds a bounds fix and a host test. Verified on an M2 Pro (AGX2) and on Neo (A18 Pro, G17P): |
|
Closing as merged manually |
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.
Honeykrisp takes only
rowPitchfromVkImageDrmFormatModifierExplicitCreateInfoEXT::pPlaneLayouts[]and ignoresoffset. It binds every plane at the memory binding offset (memoryOffset, then packed sequentially for multi-plane images). So an imported dma-buf plane that doesn't start at offset 0 is read from the wrong place.Where it shows up: libplacebo imports each plane of a single-buffer NV12 dma-buf as its own
VkImage(R8 for Y, RG8 for CbCr). It passes the CbCr offset (pitch × height) inpPlaneLayouts[0].offsetand binds the memory at offset 0, as the spec intends (src/vulkan/gpu_tex.c). Honeykrisp then samples the CbCr image from the start of the luma plane. In mpv with--hwdec=v4l2request(Apple AVD V4L2 stateless decoder, FFmpeg V4L2 request hwaccel) and Vulkan rendering, the picture is green and magenta, with edges doubled.The fix: store the explicit per-plane offset and use it in three places:
hk_image_plane_bind)hk_image_plane_add_req)vkGetImageSubresourceLayoutPer the spec, the offset is relative to the image's memory binding, or to the plane's binding for disjoint images. Images without an explicit layout behave as before.
Testing: Mac mini M1 (t8103), Debian Mesa 26.2.4 with this patch, mpv 0.41, libplacebo 7.360.1, a 4K59.94 H.264 file decoded by the AVD. Each mpv screenshot of a decoded frame was compared against the same frame decoded via copy-back (equal to software decode). The numbers are mean absolute RGB difference:
vo=gpu, Vulkanvo=gpu-next, Vulkanvo=gpu, OpenGL (EGL import, unaffected)vo=gpuVulkanReconstructing the frame with the CbCr plane read from offset 0 reproduces the broken screenshot (difference 3.5), which confirms the cause. With the patch, 4K60 playback through Vulkan had no dropped frames attributable to rendering.
I haven't run CTS. The relevant groups would be
dEQP-VK.drm_format_modifiers.*and the explicit/disjointycbcrtests. The bug is also still in upstream Mesamain(as of 2026-10-11); the patch applies there as well.