GPUCommandEncoder

class wgpu.GPUCommandEncoder

Bases: GPUCommandsMixin, GPUDebugCommandsMixin, GPUObjectBase

Object to record a series of commands.

When done, call finish() to obtain a GPUCommandBuffer 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:
clear_buffer(buffer, offset=0, size=None)

Set (part of) the given buffer to zeros. Both offset and size must be a multiple of 4. If size is None, the whole buffer after offset is cleared.

copy_buffer_to_buffer(source, source_offset, destination, destination_offset, size)

Copy the contents of a buffer to another buffer.

Parameters:
  • source (GPUBuffer) – The source buffer.

  • source_offset (int) – The byte offset (a multiple of 4).

  • destination (GPUBuffer) – The target buffer.

  • destination_offset (int) – The byte offset in the destination buffer (a multiple of 4).

  • size (int) – The number of bytes to copy (a multiple of 4).

copy_buffer_to_texture(source, destination, copy_size)

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.

Note that the bytes_per_row must be a multiple of 256.

copy_texture_to_buffer(source, destination, copy_size)

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.

Note that the bytes_per_row must be a multiple of 256.

copy_texture_to_texture(source, destination, copy_size)

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 a GPUQueue.

Parameters:

label (str) – A human readable label. Optional.

resolve_query_set(query_set, first_query, query_count, destination, destination_offset)

TODO