simvx.graphics.renderer.gpu_batch¶
GPU-driven batch rendering with multi-draw indirect (MDI) and fallback.
Module Contents¶
Classes¶
Manages batched draw commands. |
Data¶
API¶
- simvx.graphics.renderer.gpu_batch.__all__¶
[‘GPUBatch’]
- class simvx.graphics.renderer.gpu_batch.GPUBatch(device: Any, physical_device: Any, max_draws: int = 1000, *, use_mdi: bool = True)[source]¶
Manages batched draw commands.
When
use_mdi=True(default), usesvkCmdDrawIndexedIndirectto issue all draw commands in a single GPU call. Whenuse_mdi=False, falls back to a loop ofvkCmdDrawIndexedcalls — functionally identical but slower on GPUs that support MDI.Usage::
batch = GPUBatch(device, physical_device, max_draws=100) batch.add_draw(index_count=36, first_instance=0) batch.upload() batch.draw(cmd)
Initialization
- add_draw(index_count: int, instance_count: int = 1, first_index: int = 0, vertex_offset: int = 0, first_instance: int = 0) int[source]¶
Add a draw command. Returns the draw index.
- add_draws(index_count: int, first_instances: numpy.ndarray | list[int]) int[source]¶
Bulk-add draw commands sharing the same mesh — avoids per-instance Python loop.
Args: index_count: Index count for the mesh (same for all draws). first_instances: (N,) array of SSBO instance indices.
Returns: Batch offset of the first added draw command.