GPURenderCommandsMixin

class wgpu.GPURenderCommandsMixin

Bases: object

Mixin for classes that provide rendering commands.

draw(vertex_count, instance_count=1, first_vertex=0, first_instance=0)

Run the render pipeline without an index buffer.

Parameters:
  • vertex_count (int) – The number of vertices to draw.

  • instance_count (int) – The number of instances to draw. Default 1.

  • first_vertex (int) – The vertex offset. Default 0.

  • first_instance (int) – The instance offset. Default 0.

draw_indexed(index_count, instance_count=1, first_index=0, base_vertex=0, first_instance=0)

Run the render pipeline using an index buffer.

Parameters:
  • index_count (int) – The number of indices to draw.

  • instance_count (int) – The number of instances to draw. Default 1.

  • first_index (int) – The index offset. Default 0.

  • base_vertex (int) – A number added to each index in the index buffer. Default 0.

  • first_instance (int) – The instance offset. Default 0.

draw_indexed_indirect(indirect_buffer, indirect_offset)

Like draw_indexed(), but the function arguments are in a buffer.

Parameters:
  • indirect_buffer (GPUBuffer) – The buffer that contains the arguments.

  • indirect_offset (int) – The byte offset at which the arguments are.

draw_indirect(indirect_buffer, indirect_offset)

Like draw(), but the function arguments are in a buffer.

Parameters:
  • indirect_buffer (GPUBuffer) – The buffer that contains the arguments.

  • indirect_offset (int) – The byte offset at which the arguments are.

set_index_buffer(buffer, index_format, offset=0, size=None)

Set the index buffer for this render pass.

Parameters:
  • buffer (GPUBuffer) – The buffer that contains the indices.

  • index_format (GPUIndexFormat) – The format of the index data contained in buffer. If strip_index_format is given in the call to GPUDevice.create_render_pipeline(), it must match.

  • offset (int) – The byte offset in the buffer. Default 0.

  • size (int) – The number of bytes to use. If zero, the remaining size (after offset) of the buffer is used. Default 0.

set_pipeline(pipeline)

Set the pipeline for this render pass.

Parameters:

pipeline (GPURenderPipeline) – The pipeline to use.

set_vertex_buffer(slot, buffer, offset=0, size=None)

Associate a vertex buffer with a bind slot.

Parameters:
  • slot (int) – The binding slot for the vertex buffer.

  • buffer (GPUBuffer) – The buffer that contains the vertex data.

  • offset (int) – The byte offset in the buffer. Default 0.

  • size (int) – The number of bytes to use. If zero, the remaining size (after offset) of the buffer is used. Default 0.