GPUCommandEncoder
- class wgpu.GPUCommandEncoder
Bases:
GPUCommandsMixin
,GPUDebugCommandsMixin
,GPUObjectBase
Object to record a series of commands.
When done, call
finish()
to obtain aGPUCommandBuffer
object.Create a command encoder using GPUDevice.create_command_encoder().
- begin_compute_pass(**parameters)
Record the beginning of a compute pass. Returns a
GPUComputePassEncoder
object.- Parameters:
label (str) – A human-readable label. Optional.
timestamp_writes – unused
- begin_render_pass(**parameters)
Record the beginning of a render pass. Returns a
GPURenderPassEncoder
object.- Parameters:
label (str) – A human-readable label. Optional.
color_attachments (list) – List of
structs.RenderPassColorAttachment
dicts.depth_stencil_attachment (
structs.RenderPassDepthStencilAttachment
) – Describes the depth stencil attachment. Default None.occlusion_query_set (
GPUQuerySet
) – Default None.timestamp_writes – unused
- clear_buffer(buffer: GPUBuffer, offset: int = 0, size: int | None = None)
Set (part of) the given buffer to zeros.
- Parameters:
buffer (
GPUBuffer
) – The buffer to clear.offset (int) – The byte offset.
size (int, optional) – The size to clear in bytes. If None, the effective size is the full size minus the offset.
Alignment: both offset and size must be a multiple of 4.
- copy_buffer_to_buffer(source: GPUBuffer, source_offset: int, destination: GPUBuffer, destination_offset: int, size: int)
Copy the contents of a buffer to another buffer.
- Parameters:
Alignment: the size, source offset, and destination offset must all be a multiple of 4.
- copy_buffer_to_texture(source:, destination:, copy_size: ~typing.List[int] |)
Copy the contents of a buffer to a texture (view).
- Parameters:
source (
GPUBuffer
) – A dict with fields: buffer, offset, bytes_per_row, rows_per_image.destination (
GPUTexture
) – A dict with fields: texture, mip_level, origin.copy_size (int) – The number of bytes to copy.
Alignment: the
bytes_per_row
must be a multiple of 256.
- copy_texture_to_buffer(source:, destination:, copy_size: ~typing.List[int] |)
Copy the contents of a texture (view) to a buffer.
- Parameters:
source (
GPUTexture
) – A dict with fields: texture, mip_level, origin.destination (
GPUBuffer
) – A dict with fields: buffer, offset, bytes_per_row, rows_per_image.copy_size (int) – The number of bytes to copy.
Alignment: the
bytes_per_row
must be a multiple of 256.
- copy_texture_to_texture(source:, destination:, copy_size: ~typing.List[int] |)
Copy the contents of a texture (view) to another texture (view).
- Parameters:
source (
GPUTexture
) – A dict with fields: texture, mip_level, origin.destination (
GPUTexture
) – A dict with fields: texture, mip_level, origin.copy_size (int) – The number of bytes to copy.
- finish(**parameters)
Finish recording. Returns a
GPUCommandBuffer
to submit to aGPUQueue
.- Parameters:
label (str) – A human-readable label. Optional.
- resolve_query_set(query_set: GPUQuerySet, first_query: int, query_count: int, destination: GPUBuffer, destination_offset: int)
Resolves query results from a
GPUQuerySet
out into a range of aGPUBuffer
.- Parameters:
query_set (
GPUQuerySet
) – The source query set.first_query (int) – The first query to resolve.
query_count (int) – The amount of queries to resolve.
destination (
GPUBuffer
) – The buffer to write the results to.destination_offset (int) – The byte offset in the buffer.
Alignment: the destination offset must be a multiple of 256.