Skip to content

feat(player): draw hardware frames through the GPU view on Windows and Linux - #43

Draft
oneo-me wants to merge 2 commits into
mainfrom
agiox/hw-decode-gpu-direct
Draft

oneo-me wants to merge 2 commits into
mainfrom
agiox/hw-decode-gpu-direct

Conversation

@oneo-me

@oneo-me oneo-me commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

Closes #39.

On Windows (D3D11VA) and Linux (VAAPI), player.View draws hardware-decoded pictures through NSGo's gpu view, imported with Device.ImportTexture (nsgo-dev/nsgo#2296), instead of copying them to memory, converting them to RGBA and uploading them through core.Image's pixel buffers.

  • Windows: each pool frame owns an NV12/P010 texture shared through an NT handle with a keyed mutex; the decoder's slice of D3D11VA's texture array is copied into it on the GPU (the views cannot import one slice of an array).
  • Linux: the VAAPI surface is exported as one DMA-BUF a plane with libva's vaExportSurfaceHandle, as FFmpeg does when built with libdrm, which ours is not.
  • The view converts luma and chroma to RGB in a WGSL shader by the frame's matrix (BT.601/709/2020) and range, 8- and 10-bit, turned as the stream is, and holds each frame until the fence of the last display frame that sampled it.
  • The gpu view sits under the image view, so pictures in memory (software decoding, stepping backward) still show, and the app's views stay above both. macOS and iOS keep the pixel-buffer path.
  • Snapshots copy a hardware frame to memory when taken; hardware decoders keep 7 more surfaces for the frames held on the GPU.
  • NSGo goes to the commit with ImportTexture, in the core and the app.

Measured on the devices (docs/performance.md): a 4K60 clip uses 9–16% of a core instead of 97–115% on the Windows PC, and 5–6% instead of 87–134% on Omarchy, with 130–155 MiB less private memory on Windows and 0.25–2.4 GiB less resident memory on Linux. Overlays (a child of the view and a view after it), 10-bit HEVC, snapshots, steps both ways and software decoding were checked on both. player and pipeline tests pass on both machines.

TestHLSLiveWindow fails on macOS on main as well; it is not touched here.

🤖 Generated with Claude Code

@oneo-me oneo-me self-assigned this Nov 24, 2026
…d Linux

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@oneo-me
oneo-me force-pushed the agiox/hw-decode-gpu-direct branch from 4a70661 to ee47c7c Compare November 24, 2026 18:30
…and Linux

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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.

Rendering: zero-copy on Windows and Linux

1 participant