Skip to content

feat(hip): import GL textures through EGL dma-buf export so the pinned ROCm 10.1 reads them (ADR-2132) - #2360

Merged
lusoris merged 1 commit into
masterfrom
rc4/api-wp3-hip-gl-dmabuf
Oct 9, 2026
Merged

lusoris merged 1 commit into
masterfrom
rc4/api-wp3-hip-gl-dmabuf

Conversation

@lusoris

@lusoris lusoris commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Summary

BLUF: HIP now imports OpenGL textures on the pinned ROCm 10.1 by exporting each texture as a dma-buf through EGL (EGL_MESA_image_dma_buf_export) and importing it as a DMABUF frame, with the GL sync object as the acquire fence. The runtime's GL interop is no longer called. Closes T-HIP-ROCM10-GL-TEXTURE-READ-2026-10-06 for vmafx (OBS on AMD Linux, #2238). Stacked on #2341 (rc4/api-wp3-hip).

radeonsi exports the texture in its own tiling (modifier DRM_FORMAT_MOD_INVALID; read as linear rows 223464 of 230400 samples differ), so a tiled export is copied on the GPU into a linear GBM dma-buf (one blit per plane inside the producer's context, GL state restored) and needs VMAFX_IMPORT_ALLOW_COPY. The context's GPU is checked against the device's. ADR-2132, research digest 2161.

Landing (Q-083)

Lands bottom-up after #2341 (WP3 HIP), one API PR at a time. The PR's diff (old base 20a3f4d4d, the #2341 head it was written on, to 657e74a53) was squashed into one commit, put on the restacked #2341 on 2026-10-07 and is now rebased onto master d70f0be5d (#2341 landed as e0f59be2a). ADR-2132 is Accepted.

ABI check against master: python3 scripts/codegen/vmafx-api.py --abi-check --against-ref origin/master -> definition is an append-only successor of origin/master (0 additions). This PR changes the documentation of VMAFX_MEMORY_GL_TEXTURE only, so abi_version stays 0.1.8.

Conflicts, resolved per hunk when the PR was first put on #2341:

  • core/api/vmafx.toml: this PR's doc text with the parent's ABI number.
  • docs/state.md: the resolver (T-HIP-ROCM10-GL-TEXTURE-READ-2026-10-06 moves to Recently closed and leaves the deferred label row).

The rebases since (onto #2290, onto #2341's landing head and onto master after #2341 landed) applied the feature and docs commits unchanged; each time the cpu clang-tidy baseline took master's side and core/src/vmafx/egl_export.c was measured again. Changed while landing:

  • The research digest is docs/research/2161-hip-gl-egl-dmabuf-tiling.md, not 2160: the SYCL lane (feat(api): import SYCL device frames with event fences, dma-bufs and GL textures (RC4 WP3, ADR-2091) #2342), which lands after this PR, holds Research-2160 (2160-vmafx-sycl-device-frames.md). The digest's heading, the link in ADR-2132's References and the closed state row follow.
  • The rebase note is the fragment docs/rebase-notes.d/hip-gl-egl-dmabuf.md (ADR-2197); the rendered files are master's.
  • ci(tidy): the cpu lane's baseline records core/src/vmafx/egl_export.c.

No integration-branch commit is carried.

Local gate (on 9f8979385, master d70f0be5d)

  • CPU (-Db_lto=false, -j4, warnings as errors): build 0 warnings; --suite=fast 433 OK, 0 failed (test_gpu_picture_pool_uaf on its own with MALLOC_PERTURB_=0: OK); codegen tests 207 passed; make test-netflix-golden GOLDEN_NINJA_JOBS=4 280 passed, 3 skipped; preflight.sh --stage msvcism pass; affected suites: tooling 2668 passed, 0 failed, 6 skipped. vmafx-api.py --check: 80 generated files match; --abi-check --against-ref origin/master: 0 additions.
  • HIP on the pinned toolchain plus EGL: image vmafx-hip-lane:rocm10.1.0-egl (the pinned rocm/dev-ubuntu-26.04:10.1.0-full@sha256:4f5ed1bf…, HIP 7.16.26385, with the EGL / GLES / X11 development libraries the GL test needs; ROCm unchanged), Mesa on the host display, gfx1036, every device run flock hip-gfx1036.lock timeout 290. Build (-Denable_hip=true -Denable_hipcc=true -Dhip_gfx_targets=gfx1036, -Dwerror=true, fatal link warnings): 0 warnings. test_vmafx_import_hip_gl 5/5: NV12 and P010 GL frames 42 values each, 0 differing from host upload; a tiled export refused without VMAFX_IMPORT_ALLOW_COPY; the producer's GL state restored; no current EGL context refused. test_vmafx_import_hip 16/16; test_vmafx_import_hip_fence 8/8; test_vmafx_fence_kinds 5/5; test_hip_shared_frame 9/9. test_vmafx_import_hip_bitexact, one run per clip (0 to 3 and the 4K pair): 354 cells, 16098 values, 0 cells differing, 0 attempts repeated, 9042 imports, 6028 conversions, 0 host copies.
  • Tidy (dev container, clang-tidy 22.1.8, scripts/dev/tidy-lane.sh --write --only ...), re-measured on this tree: cpu core/src/vmafx/egl_export.c 0 findings (again on master d70f0be5d); hip core/src/hip/import_frame.c, core/src/hip/import_gl.c, core/src/vmafx/egl_export.c, core/test/test_vmafx_import_hip_gl.c 0 findings.
  • Train gates (deliverables, docs/state.md touch and rows, silent revert against master, praetorctl audit): pass.

The earlier evidence on this PR (2026-10-07: the 50 fast+gpu HIP tests and the dropped-dispatch sightings in the bitexact runs) stays recorded under T-HIP-GFX1036-DROPPED-DISPATCHES-2026-10-01.

Type

  • feat — new feature

Checklist

  • Commits follow Conventional Commits.
  • make lint equivalent: pre-commit hooks green; tidy: cpu core/src/vmafx/egl_export.c 0 findings; hip core/src/hip/import_frame.c, import_gl.c, core/test/test_vmafx_import_hip_gl.c 0 findings (container lanes, ADR-1471).
  • Tests run (below). scripts/dev/preflight.sh --stage msvcism passes.
  • SIMD/GPU numeric twins untouched: no /cross-backend-diff needed (import path only).
  • New files carry the licence header.
  • ADR row in docs/adr/_index_fragments/2132-hip-gl-textures-through-egl-dmabuf.md, slug in _order.txt.

Bug-status hygiene

  • docs/state.md: T-HIP-ROCM10-GL-TEXTURE-READ-2026-10-06 moved to Recently closed.

Netflix golden-data gate

  • No golden assertion touched; the PR changes no extractor and no core/src extractor code.

Reproducer

Pinned image vmafx-hip-lane:rocm10.1.0 (rocm/dev-ubuntu-26.04:10.1.0-full plus libegl1 libegl-mesa0 libegl-dev libgles-dev libx11-dev; ROCm toolchain unchanged), gfx1036 (host ryzen-4090-arc), device lock held:

meson setup build-rocm10 core -Denable_hip=true -Denable_hipcc=true -Dhip_gfx_targets=gfx1036 -Denable_cuda=false -Denable_sycl=false -Db_lto=false -Denable_dnn=disabled
ninja -C build-rocm10 test/test_vmafx_import_hip_gl test/test_vmafx_import_hip test/test_vmafx_import_hip_fence test/test_vmafx_import_hip_bitexact
build-rocm10/test/test_vmafx_import_hip_gl

Evidence (ROCm 10.1.0, HIP 7.16.26385, gfx1036, Mesa 26.0.8, Linux 7.2.9)

Check Result
test_vmafx_import_hip_gl 5 of 5: NV12 (R8 + RG8) and P010 (R16 + RG16) GL frames with a GL sync, 42 values each, 0 differing from host upload; tiled export refused without ALLOW_COPY naming the flag and imported with it; producer GL state (framebuffer binding, scissor) restored; no EGL context current refused naming desc.memory
Host copies test counter 0; rocprofv3 --memory-copy-trace of the GL session: only host-to-device copies of the test's and the twins' tables (46), no device-to-host copy
test_vmafx_import_hip_bitexact 354 cells, 16098 values, 0 cells differing in every attempt, 9042 imports, 0 host copies (3 attempts rerun in a later run: the gfx1036 dropped-dispatch defect, printed)
test_vmafx_import_hip, _fence 16 of 16, 8 of 8 (acquire wait 0 bad of 16, planted skip 16 of 16; release canary 0 bad, planted early 16 of 16)
Planted defect the export read as it is (no linear copy): the import is refused with the dma-buf modifier check (desc.plane[0].modifier), test_gl_textures_nv12 fails
test_vmafx_import_hip_contract.py 15 tests including planted cases: GL export before its sync check, runtime GL interop call, export before the GPU check, unchecked GPU, copy without ALLOW_COPY, unwaited writers

ABI: --abi-check --against-ref origin/rc4/api-generation-prototype: append-only successor (141 additions; this PR adds no symbol, only the doc of VMAFX_MEMORY_GL_TEXTURE).

Deep-dive deliverables (ADR-0108)

  • Research digest — docs/research/2161-hip-gl-egl-dmabuf-tiling.md.
  • Decision matrix — ADR-2132 ## Alternatives considered.
  • AGENTS.md invariant note — core/src/hip/AGENTS.d/vmafx-device-frames.md (GL item), docs/development/rebase-sensitive-invariants.md.
  • Reproducer / smoke-test command — above.
  • CHANGELOG fragment — changelog.d/changed/hip-gl-textures-through-egl-dmabuf.md.
  • Rebase notes — fragment docs/rebase-notes.d/hip-gl-egl-dmabuf.md (ADR-2197), "HIP GL textures through EGL dma-bufs".

Known follow-ups

  • The SYCL lane keeps its own EGL export in core/src/sycl/import_gl.c; fold it onto core/src/vmafx/egl_export.c when the lanes merge (HISS-19).
  • Which Mesa versions and drivers export linear is not measured; the code reads a linear export in place and copies only a non-linear one.
  • A display whose EGL device has no DRM render node (some Wayland / X11 setups) is refused naming the missing check, not skipped.

@lusoris lusoris added the rc4 RC4: the vmaf_v1.0.16_3d0h path in Rust; lands after the v1.0.0-rc.3 tag label Oct 6, 2026
@github-actions github-actions Bot added the type:feature New feature or request label Oct 6, 2026
lusoris added a commit that referenced this pull request Oct 6, 2026
…to the integration branch

Conflicts resolved per hunk: core/api/vmafx.toml takes the lane's GL texture
text with integration's ABI number (0.1.7); docs/state.md through the
resolver; generated files (frame.h, the ADR and research indexes, the API
pages, the citation registry) took integration's side and were regenerated.
The shared EGL export (core/src/vmafx/egl_export.c, ADR-2132) joins
libvmafx_sources. CPU build clean.
@lusoris
lusoris force-pushed the rc4/api-wp3-hip branch 2 times, most recently from 142a898 to e0f59be Compare October 9, 2026 10:42
Base automatically changed from rc4/api-wp3-hip to master October 9, 2026 10:45
@lusoris
lusoris force-pushed the rc4/api-wp3-hip-gl-dmabuf branch from 657e74a to 9f89793 Compare October 9, 2026 14:28
@lusoris
lusoris marked this pull request as ready for review October 9, 2026 14:29
…d ROCm 10.1 reads them (ADR-2132) (#2360)

* feat(hip): import GL textures through EGL dma-buf export so the pinned ROCm 10.1 reads them (ADR-2132)

The runtime's GL interop maps a texture but cannot read it on ROCm 10.1, so
every GL import on HIP was refused. A GL texture is now exported as a dma-buf
through EGL and imported as a DMABUF frame. radeonsi exports its own tiling
(measured: 97 percent of samples differ when read as linear rows), so a tiled
export is copied on the GPU into a linear GBM dma-buf with
VMAFX_IMPORT_ALLOW_COPY, the producer's GL state restored. The context's GPU
is checked against the device's. Closes T-HIP-ROCM10-GL-TEXTURE-READ.

* docs(hip): move the rebase note to a fragment and leave the rendered files to the landing render (ADR-2197)

Under render at landing (ADR-2197) a pull request carries no rendered file:
the rebase note of the EGL dma-buf GL import moves to
docs/rebase-notes.d/hip-gl-egl-dmabuf.md; the landing render writes
CHANGELOG.md, the ADR index and docs/rebase-notes.md.

* ci(tidy): measure the translation units of the HIP GL import through EGL dma-bufs in the cpu lane

The clang-tidy coverage rule on master requires every tracked translation
unit to be read by a lane. The new and touched units of this pull request
were measured in the dev container (scripts/dev/tidy-lane.sh --write
--only ... cpu, clang-tidy 22.1.8): 0 findings, 0 uncited NOLINT; they join
the cpu lane's measured sources.

Signed-off-by: Lusoris <lusoris@proton.me>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

rc4 RC4: the vmaf_v1.0.16_3d0h path in Rust; lands after the v1.0.0-rc.3 tag type:feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant