simvx.graphics.renderer.gpu_batch¶
GPU-driven batch rendering with multi-draw indirect.
Module Contents¶
Classes¶
Manages multi-draw indirect rendering for a batch of objects. |
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)¶
Manages multi-draw indirect rendering for a batch of objects.
Usage::
batch = GPUBatch(device, physical_device, max_draws=100) batch.add_draw(index_count=36, first_instance=0) batch.add_draw(index_count=36, first_instance=1) batch.upload() # In render loop: 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¶
Add a draw command. Returns the draw index.
- upload() None¶
Upload draw commands to GPU indirect buffer.
- draw(cmd: Any) None¶
Record vkCmdDrawIndexedIndirect for all commands in the batch.
- draw_range(cmd: Any, offset: int, count: int) None¶
Draw a sub-range of commands from the indirect buffer.
Args: cmd: Vulkan command buffer offset: First draw command index (not byte offset) count: Number of draw commands to execute
- reset() None¶
Clear batch for next frame.
- destroy() None¶
Free GPU resources.