simvx.graphics.renderer.secondary_sru

Secondary-device SubViewport SRU recorder for multi-device offload.

The cross-device offload coordinator (:class:~..gpu.multi_device.SRUOffloadCoordinator) renders an offloaded SubViewport SRU on a secondary GPU and then transfers its colour image to the primary for compositing. The per-device GPU recording is delegated to this object so the shared :class:~.forward.Renderer is NOT made to grow a multi-device entry point (the single-device path must stay unchanged).

class:

SecondarySRURenderer wraps a Renderer already constructed + setup on a secondary device (via a :class:~..gpu.secondary_engine.SecondaryRenderContext facade). It exposes one method, :meth:render_sru_offscreen, mirroring the primary

meth:

~..scene_adapter.SceneAdapter.render_sru_from_plan slice model but recording into an OWN one-shot command buffer on the secondary device and submitting on the secondary graphics queue (a secondary never shares the primary’s frame command buffer; its render must complete + signal before the cross-device transfer reads the colour image).

Scope. This runs only on a system exposing two or more Vulkan devices, never on a single-device run (no facade / secondary device is constructed there, so the offload coordinator that would call this is never built), and it is not exercised by the test suite. The residency substitution it depends on (a secondary MeshHandle per primary mesh) is flagged where the primary CPU geometry must be supplied (see :meth:render_sru_offscreen).

Module Contents

Classes

SecondarySRURenderer

Records one offloaded SubViewport SRU on a secondary device.

Data

API

simvx.graphics.renderer.secondary_sru.log

‘getLogger(…)’

simvx.graphics.renderer.secondary_sru.__all__

[‘SecondarySRURenderer’]

class simvx.graphics.renderer.secondary_sru.SecondarySRURenderer(facade: Any, renderer: Any)

Records one offloaded SubViewport SRU on a secondary device.

Constructed by the secondary_renderer_factory with the secondary

Class:

~..gpu.secondary_engine.SecondaryRenderContext facade and a Renderer(facade) already set up on that device. The offload coordinator calls :meth:render_sru_offscreen once per offloaded SRU per frame.

Initialization

set_residency(residency: Any) None

Bind the :class:~..gpu.secondary_engine.SecondaryResidency for handle remap.

The coordinator owns residency (it mirrors meshes/textures before calling this); binding it here lets the recorder substitute each instance’s primary

Class:

~..types.MeshHandle for the secondary one. Optional: when unset the recorder assumes the SRU’s handles are already secondary-resident.

render_sru_offscreen(sru: Any, target: Any) None

Record + submit one SRU’s draws into target on the secondary device.

Mirrors the primary :meth:SceneAdapter.render_sru_from_plan slice model on the secondary renderer:

  1. begin_frame the secondary renderer (clears its per-frame lists + resets its indirect batches; this device records its OWN frame).

  2. Remap each instance’s primary :class:MeshHandle to the secondary one via the bound residency (geometry was mirrored by the coordinator). FLAGGED: requires the secondary mesh to be resident; an instance whose mesh is not resident is skipped with a warning (it would index the wrong device’s buffers otherwise).

  3. Install the SRU’s single camera viewport, reserve a transform-SSBO slice, upload the SRU transforms into it, and set materials/lights mirrored from the primary (set by the coordinator via :meth:set_materials).

  4. Allocate a one-shot command buffer on the secondary command pool, begin the offscreen pass on target, render_scene_content (hdr_output 0 so the offscreen image holds LDR), end the pass, overlay any Draw2D ops, then submit on the secondary graphics queue and wait. The RenderTarget leaves the colour image in SHADER_READ_ONLY_OPTIMAL, ready for the cross-device transfer’s TRANSFER_SRC barrier.

set_materials(materials: Any) None

Mirror the primary material SSBO contents onto the secondary renderer.

set_lights(lights: Any) None

Mirror the primary light SSBO contents onto the secondary renderer.