Skip to content

hk: honor plane offsets from VkImageDrmFormatModifierExplicitCreateInfoEXT - #10

Closed
sithglan wants to merge 1 commit into
aurora-silicon:mainfrom
sithglan:hk-explicit-plane-offsets
Closed

sithglan wants to merge 1 commit into
aurora-silicon:mainfrom
sithglan:hk-explicit-plane-offsets

Conversation

@sithglan

@sithglan sithglan commented Oct 12, 2026 •

Copy link
Copy Markdown

Honeykrisp takes only rowPitch from VkImageDrmFormatModifierExplicitCreateInfoEXT::pPlaneLayouts[] and ignores offset. 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) in pPlaneLayouts[0].offset and 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:

  • binding memory (hk_image_plane_bind)
  • memory requirements (hk_image_plane_add_req)
  • vkGetImageSubresourceLayout

Per 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:

mpv video output without patch with patch
vo=gpu, Vulkan 49.53 0.00
vo=gpu-next, Vulkan 49.62 0.21
vo=gpu, OpenGL (EGL import, unaffected) 0.06 0.06
software decode, vo=gpu Vulkan — 0.02

Reconstructing 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/disjoint ycbcr tests. The bug is also still in upstream Mesa main (as of 2026-10-11); the patch applies there as well.

…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)
@DjDeveloperr

Copy link
Copy Markdown

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): drm_format_modifiers, ycbcr disjoint and dma_buf CTS are identical to base, and the new explicit-layout test passes.

@DjDeveloperr

Copy link
Copy Markdown

Closing as merged manually

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants