Skip to content

hk: honor plane offsets from VkImageDrmFormatModifierExplicitCreateInfoEXT (port of #10) - #34

Merged
DjDeveloperr merged 3 commits into
aurora-wipfrom
aurora/hk-explicit-plane-offsets
Oct 23, 2026
Merged

DjDeveloperr merged 3 commits into
aurora-wipfrom
aurora/hk-explicit-plane-offsets

Conversation

@DjDeveloperr

Copy link
Copy Markdown

This ports @sithglan's #10 (Thomas Glanzmann) to aurora-wip, keeping his authorship, message and trailers.

aurora-wip already takes pPlaneLayouts[].offset as the plane offset (a2c4676). What was still missing from #10 is that disjoint images were refused when planes in separate bindings share an offset, for example two dma-bufs whose planes both start at 0. The commit is reduced to that change, with a port note.

Two follow-ups:

  • hk: keep bound image planes inside their memory object. Binds are now checked against the memory object's size instead of its page-rounded BO.
  • hk/tests: explicit DRM plane layout test (G13 and G17P no-op shims). It covers single-binding and disjoint NV12, misalignment and overlap refusal, and short-memory binds, plus the GPU-tiled and compressed modifiers on the stacked series. Without these fixes it fails.

Hardware, M2 Pro (AGX2):

  • drm_format_modifiers.*, ycbcr.*disjoint* (format, plane_view, query, 8-bit 4:2:0 copy) and api.external.memory.dma_buf.*: 5,878 cases, identical to base (3,142 pass, 2,736 not supported, 0 fail).
  • The explicit-layout test fails on base and passes with this branch (31 checks).
  • The G17P (A18 Pro) run is pending; I'll post the result here.

Note: aurora-wip requires explicit plane offsets to be 128-byte aligned; #10 as written accepted any offset. 1080p and 720p NV12 chroma offsets satisfy it.

Supersedes #10 for aurora-wip.

@DjDeveloperr
DjDeveloperr force-pushed the aurora/hk-explicit-plane-offsets branch from 2732e91 to 0f875a9 Compare October 22, 2026 23:07
@DjDeveloperr

Copy link
Copy Markdown
Author

Rebased onto aurora-wip c363804; no conflicts. Neo (A18 Pro, G17P) results: the explicit-layout test passes 25/25 with this branch and fails on the base. drm_format_modifiers.*, ycbcr.*disjoint* and api.external.memory.dma_buf.* (5,878 cases) are identical to base: 3,622 pass, 2,256 not supported, 0 fail. Together with the M2 Pro (AGX2) run above, both GPU families are covered.

sithglan and others added 3 commits October 22, 2026 20:04
…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: adapted to aurora-wip, whose precomputed plane offsets already
 take the explicit offset for placement, memory requirements, binding and
 subresource layouts; what remains lets disjoint planes share offsets]
(cherry picked from commit ba289e6)
vkBindImageMemory2 checked each plane, at the binding offset plus its
(possibly explicit) plane offset, against the size of the BO behind the
memory object. That BO is page-rounded and may come from the BO cache
larger still, so a plane could be bound past the end of the memory
object. Check against the memory object's allocation size where it has
one.
hk-vulkan-explicit-plane-layout creates LINEAR-modifier images through
VkImageDrmFormatModifierExplicitCreateInfoEXT whose planes do not start
at offset 0: an RGBA8 plane at 0x1000, NV12 with its CbCr plane at 0x1000
in one binding, and disjoint NV12 whose planes both start at 0 (or 0x80)
of their own bindings. It checks that the memory requirements cover each
plane's offset and size, that vkGetImageSubresourceLayout reports the
explicit offset, that binding succeeds at a nonzero memory offset and
fails on memory ending before a plane, and that misaligned offsets and
overlapping planes of one binding are refused. For the GPU-tiled
modifiers, compressed ones included, an explicit offset must grow the
requirements by exactly that offset, the subresource layout must report
it, and a compressed memory plane must be larger than a plain one by its
metadata.

It runs under the no-op DRM shim for G13 and G17P as
hk-g13g-explicit-plane-layout and hk-g17p-explicit-plane-layout.
@DjDeveloperr
DjDeveloperr force-pushed the aurora/hk-explicit-plane-offsets branch from 0f875a9 to 85d846e Compare October 23, 2026 00:05
@DjDeveloperr
DjDeveloperr merged commit 6ace067 into aurora-wip Oct 23, 2026
2 of 4 checks passed
@RyanTheTide
RyanTheTide deleted the aurora/hk-explicit-plane-offsets branch October 25, 2026 05:48
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