simvx.graphics.renderer._base

RendererBackend protocol: defines the contract any rendering backend must satisfy.

The default Renderer (Vulkan, forward) is the reference implementation. Other backends (WebGPU, streaming) implement the same protocol so SceneAdapter, App, and testing infrastructure work identically across backends.

Module Contents

Classes

RendererBackend

Base class for rendering pipelines (forward, deferred, webgpu, etc.).

Data

API

simvx.graphics.renderer._base.log

‘getLogger(…)’

simvx.graphics.renderer._base.__all__

[‘RendererBackend’]

class simvx.graphics.renderer._base.RendererBackend

Bases: abc.ABC

Base class for rendering pipelines (forward, deferred, webgpu, etc.).

Backends implement these methods. SceneAdapter calls the submission methods each frame; Engine calls the lifecycle methods. The numpy boundary (VertexStreams, MATERIAL_DTYPE, LIGHT_DTYPE, TRANSFORM_DTYPE) is the contract.

abstractmethod begin_frame() None

Reset per-frame state, prepare for new submissions.

abstractmethod pre_render(cmd: Any) None

Offscreen passes (shadows, SSAO): after submissions, before main pass.

abstractmethod render(cmd: Any) None

Record draw commands into cmd during the main render pass.

abstractmethod resize(width: int, height: int) None

Handle framebuffer resize.

abstractmethod destroy() None

Release all GPU resources.

abstractmethod submit_instance(mesh_handle: simvx.graphics.types.MeshHandle, transform: numpy.ndarray, material_id: int, viewport_id: int = 0) None

Submit a single mesh instance for rendering.

abstractmethod submit_multimesh(mesh_handle: simvx.graphics.types.MeshHandle, transforms: numpy.ndarray, material_id: int = 0, material_ids: numpy.ndarray | None = None, viewport_id: int = 0, count: int = 0, cache_key: int = 0, version: int = 0) None

Submit multiple instances of the same mesh.

cache_key (a stable per-node id) + version (bumps when the block’s transforms/material change) let a backend skip re-uploading an unchanged (static) block. 0/0 opts out (always re-upload).

abstractmethod submit_skinned_instance(mesh_handle: simvx.graphics.types.MeshHandle, transform: numpy.ndarray, material_id: int, joint_matrices: numpy.ndarray) None

Submit a skinned mesh with joint matrices.

abstractmethod set_materials(materials: numpy.ndarray) None

Upload material array (MATERIAL_DTYPE) to GPU.

abstractmethod set_lights(lights: numpy.ndarray) None

Upload light array (LIGHT_DTYPE) to GPU.

abstractmethod submit_particles(particle_data: numpy.ndarray) None

Submit CPU particle data for rendering.

abstractmethod submit_light2d(**kwargs: Any) None

Submit a 2D light source.

abstractmethod register_mesh(streams: simvx.graphics.types.VertexStreams, indices: numpy.ndarray) simvx.graphics.types.MeshHandle

Register a mesh’s vertex streams on GPU, return a handle for submissions.

abstractmethod upload_texture_pixels(pixels: numpy.ndarray, width: int, height: int) int

Upload RGBA pixel data to GPU, return bindless texture index.

Matches the _TextureRegistrar protocol consumed by TextureManager.

abstractmethod capture_frame() numpy.ndarray

Capture the last rendered frame as (H, W, 4) uint8 RGBA numpy array.

__slots__

()