GPUCommandEncoder
- class wgpu.GPUCommandEncoder
Bases:
GPUCommandsMixin,GPUDebugCommandsMixin,GPUObjectBaseObject to record a series of commands.
When done, call
finish()to obtain aGPUCommandBufferobject.Create a command encoder using GPUDevice.create_command_encoder().
- begin_compute_pass(**parameters)
Record the beginning of a compute pass. Returns a
GPUComputePassEncoderobject.- Parameters:
label (str) – A human-readable label. Optional.
timestamp_writes – unused
- begin_render_pass(**parameters)
Record the beginning of a render pass. Returns a
GPURenderPassEncoderobject.- Parameters:
label (str) – A human-readable label. Optional.
color_attachments (list) – List of
structs.RenderPassColorAttachmentdicts.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 | None = None, offset: int = 0, size: int | None = 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 | None = None, source_offset: int | None = None, destination: GPUBuffer | None = None, destination_offset: int | None = None, size: int | None = None) None
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: TexelCopyBufferInfo | dict | None = None, destination: TexelCopyTextureInfo | dict | None = None, copy_size: tuple[int, int, int] | Extent3D | dict | None = None) None
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_rowmust be a multiple of 256.
- copy_texture_to_buffer(source: TexelCopyTextureInfo | dict | None = None, destination: TexelCopyBufferInfo | dict | None = None, copy_size: tuple[int, int, int] | Extent3D | dict | None = None) None
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_rowmust be a multiple of 256.
- copy_texture_to_texture(source: TexelCopyTextureInfo | dict | None = None, destination: TexelCopyTextureInfo | dict | None = None, copy_size: tuple[int, int, int] | Extent3D | dict | None = None) None
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
GPUCommandBufferto submit to aGPUQueue.- Parameters:
label (str) – A human-readable label. Optional.
- resolve_query_set(query_set: GPUQuerySet | None = None, first_query: int | None = None, query_count: int | None = None, destination: GPUBuffer | None = None, destination_offset: int | None = None) None
Resolves query results from a
GPUQuerySetout 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.