mirror of
https://github.com/nestriness/nestri.git
synced 2026-11-23 07:29:51 +02:00
At this point, why not.. Calling it `nespyro` since it's slightly modified, uses slang shader language instead, along other things.. --------- Co-authored-by: DatCaptainHorse <DatCaptainHorse@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
6.7 KiB
6.7 KiB
PyroWave decode in nesrecon / nesvideo
Status: built, 2026-10-01 (nescore e20a4d2, 0e729ef). Part 4 of 4; parts 1-3 are
2026-09-27-nespyro-codec-crate-design.md,
2026-10-01-pyrowave-transport-design.md,
2026-10-01-pyrowave-nescapture-design.md. Code lives in nescore
(crates/nesrecon, apps/nesvideo); nespyro is a git dep on nestri at the
same rev nesprotocol is pinned to.
Decisions
- nespyro decodes on nesrecon's device, from the decode thread, as one more backend beside Vulkan Video / VA-API / CPU. Its planes stay on the GPU and are converted by the render thread like a Vulkan Video picture.
- The device is no longer gated on H.264 Vulkan Video decode.
shared_decode_deviceexists when either pixelforge or nespyro fits. - Planes are always
Depth::Sixteen. PyroWave decodes in float and the stream carries no depth; R16 costs little and never bands an HDR stream. - Converter: a second entry point, three planes, chroma shift in the uniform's spare word. The two-plane path is untouched, so its output and tests do not move.
- Fix while open: the Vulkan-path RGBA target is
R8G8B8A8_UNORMwhile the shader writesrgba16fand the probe readsPASS_FORMAT; it becomesPASS_FORMAT. That changes the Vulkan Video path's output (it was undefined behaviour), so the PSNR baseline is re-taken for that path. - Deblock is off for PyroWave: it has no block grid.
block_grid_forreturns none, as for anything without one. - Busy is not an error. nespyro has three output slots and the renderer can hold all three (hand-off slot, current picture, retire queue); a frame that finds none free is dropped and counted, and the next decodes.
Device (vulkan/mod.rs)
nespyro::DeviceRequirements::query(.., Roles::DECODE)beside pixelforge's, independently. Device preference also accepts a nespyro-capable device.- Features: the 1.0 ones in
PhysicalDeviceFeatures, 16-bit storage in the existingVulkan11Features, subgroup size control and full subgroups in the existingVulkan13Features, and a newVulkan12Featuresfor 8-bit storage, int8, float16 (when available), buffer device address and timeline semaphores — replacing the standalone timeline struct, which may not be chained beside it. - Queue: nespyro gets the compute-only family's queue 0, which nesrecon
never submits to; pixelforge may use it too, but only from the same decode
thread, so the two are serialised by that thread. Without a compute-only
family, a second graphics queue if there is one. Without either -- every
Intel GPU under ANV, whose one family has one queue -- the render queue
itself, under a
QueueLockthe render thread holds around every submit, present andvkDeviceWaitIdle(VkCtx::queue_lock,VkCtx::wait_idle). The first build refused PyroWave in that case, which on this machine meant the client never advertised it and the hub refused every request. SharedVulkanDevicecarriespyro: Option<(family, index)>.nesrecon::decodes(PyroWave, _)answers from a flag set when the device was created with nespyro's additions; nesvideo advertises PyroWave only then.
Still open, out of scope: pixelforge's transfer queue can alias the graphics queue on a device without a transfer or compute family, and pixelforge has no lock to share. Unchanged by this part.
Decode thread (decode/)
- The channel carries
enum VideoUnit { Coded(Vec<u8>, VideoCodec), PyroWave(PyroUnit) },PyroUnit { packets: Vec<Bytes>, critical_complete, ts_ms }.VideoCodecgainsPyroWave; every closed match says what it means there. PyroDecoder(new backend): built lazily for the stream's size and chroma, rebuilt onPush::Reconfigure. Per unit: push every packet; decode whenreadiness().is_complete_enough_with(critical_complete); otherwise drop and count. OutputDecodedFrame::PyroWave(PyroPicture)into the same sink.decode_nsis CPU time as for the others; nespyro's GPU time goes to the log at trace once a second.
Render (vulkan/renderer.rs, yuv_convert.*)
import_frametakesPyroPictureinto the same slot the Vulkan picture uses; retired the same way, after the frame that sampled it.- The render submit waits on the picture's
readypoint when it has one. yuv_convert_planarentry: threeTexture2Dloads, chroma at(x >> shift, y >> shift), same matrix/range/peak code. R16 full range.- Matrix and range from the picture's
ColourDescription, per frame.
nesvideo
PyroCollectorframes go to the decode channel asVideoUnit::PyroWave. A full channel drops and counts; no IDR, nothing to resync.- The sequence header (first packet) gives size and colour:
stream_dims, andbitstream_colouras aStreamColour, so the existing colour logic picks the swapchain (HDR10 for PQ) exactly as for the other codecs. client_capabilitiesasksnesrecon::decodesfor PyroWave like the rest.- The overlay's "not decoded yet" note goes; the PyroWave rate line stays.
Tests (last step)
- Unit: channel/unit plumbing, colour mapping,
block_grid_for, the planar shader's text checks beside the existing ones. - Existing nesrecon/nesvideo tests stay green.
- Full stack by eye: PyroWave on screen, switching to and from a hardware codec, 4:2:0 and 4:4:4, SDR and HDR.
Found while building
- The channel type stayed. A PyroWave unit is serialised into the existing
Vec<u8>([flags][count]then length-prefixed packets,nesrecon::encode_pyro_unit), so PyroWave is one moreVideoDecodervariant and nothing else on the channel changed. One copy a frame, about 37 MB/s at 300 Mbit/s. - A picture keeps its decoder alive. Dropping a
nespyro::Decoderdestroys its output images even while aDecodedFrameof them is held, and a codec switch or resize drops one while the renderer still shows its last picture.PyroPictureholds anArcof the decoder, released after the slot. Worth fixing in nespyro itself when it is next opened: the output images should outlive the decoder or the frame should own them. - Capabilities are sent twice. The first message goes out at connect,
before the renderer has created the device that decides whether PyroWave
decodes. A second follows once it has; the host renegotiates to the codec
it was already on. A
--codec pyrowaverequest waits for the second, or the hub would refuse it. - Deblock is suppressed, not switched off.
PostProcessChaingained a per-type suppression, so a person's own pass toggles are untouched and the pass comes back on a switch to a block codec. - A device shared for PyroWave alone is not offered to the Vulkan Video
decoder (
SharedVulkanDevice::video_decode), which would otherwise fail and log an error on every switch to H.264.