Files
reims-vgpu/docs
Anees Iqbal 0b12ba407e 🐛 Lay out VA encoder inputs in the driver's own Y tiles on iHD
On an Intel GPU under iHD, a guest's encode session got other bytes from a
frame the rt GPU wrote into the encoder's input than from the same frame
uploaded. The input was imported linear, and iHD codes a linear import
differently from a surface of its own:
- H.264's P pictures differed at 640x360 and smaller;
- every HEVC Main 10 picture differed, intra ones too, at about ten times
  the bits.
iHD's own inputs are Y-tiled (I915_FORMAT_MOD_Y_TILED). Their pitch is the
coded row's bytes rounded up to 128, and their chroma plane sits at the pitch
times the coded height rounded up to 32 rows. An import declared and written
in that layout coded as the upload did, byte for byte, in every profile at
five sizes up to 1080p. The one exception is where iHD differs from one
upload to the next anyway (HEVC Main at 640x360 and 1080p). Measured on an
Iris Xe, iHD 26.3.5.

What changed for the guest: on iHD, the GPU-filled path's samples are the
ones the upload path would give. Nothing changes on radeonsi: its own inputs
are in AMD's 64 KiB swizzle, so its inputs stay linear at rows of 256, which
it codes as the upload.

The changes:
- `VideoEncoder::input_layout` makes one surface as the encoder's pool does
  and exports it. Where that surface is in Y tiles in this layout, the input
  takes its pitch, chroma offset and size. Otherwise the input is linear, as
  before.
- `import_input` takes the tiling, and `Target::import_as` declares Y tiles
  in the DRM PRIME descriptor.
- The fill asks the layout once per shape, sizes the input from it, and
  passes the kernel its tiling word.
- `TargetTiling::byte_at` is the Y-tile address the tests write and check
  by.

Tests:
- The VA crate's import test now writes its input in the encoder's own
  layout, so on iHD it writes Y tiles.
- The rt kernel test fills every case into a linear input and a Y-tiled
  one, and compares the whole input byte for byte.
- New unit tests cover the Y-tiled layouts iHD gave, the misfits that are
  refused, the tile address, the linear layout and the fill's declines.
2026-11-20 22:48:58 -08:00
..