Skip to main content

Module gpu_video

Module gpu_video 

Expand description

Painting decoded video on the GPU: uploading a hardware decoder’s planar output and converting YUV to RGB in a shader. Plain wgpu, so every target (WebGPU included) has it; gpu-video adds the zero-copy dmabuf import, which media::availability(Feature::ZeroCopyVideo) reports. Painting a decoded video frame on the GPU.

A hardware decoder produces YUV, not RGB — NV12 almost always, P010 for 10-bit. Two paths bring that to the screen without the CPU touching a pixel:

  • Zero-copy. The picture never left the GPU: crate::dmabuf_import aliases its dmabuf as textures. Reachable only for a linear buffer (see that module for why).
  • Plane upload. The decoder produced planes in system memory — what NVDEC yields, since nvcodec exports CUDA memory rather than a dmabuf. upload_planar pushes the two planes to the GPU as they are: 1.5 bytes per pixel with no conversion, against 4 bytes per pixel after a full-frame CPU colour conversion, which is what asking the pipeline for RGBA costs.

Either way the result is a set of YUV planes, and YuvConverter turns them into one sampleable RGBA texture with a fullscreen pass. That is the same arithmetic [media::frame::planar_to_rgba] does per pixel on the CPU, moved to the GPU.

Structs§

VideoPlanes
YUV planes living on the GPU, ready for conversion.
YuvConverter
Turns YUV planes into one RGBA texture with a fullscreen pass.

Functions§

upload_planar
Upload a planar system-memory picture to the GPU as-is.