GPUQueue

class wgpu.GPUQueue

Bases: GPUObjectBase

Object to submit command buffers to.

You can obtain a queue object via the GPUDevice.queue property.

on_submitted_work_done()

TODO

read_buffer(buffer, buffer_offset=0, size=None)

Takes the data contents of the buffer and return them as a memoryview.

Parameters:
  • buffer – The GPUBuffer object to read from.

  • buffer_offset (int) – The offset in the buffer to start reading from.

  • size – The number of bytes to read. Default all minus offset.

This copies the data in the given buffer to a temporary buffer and then maps that buffer to read the data. The given buffer’s usage must include COPY_SRC.

Also see GPUBuffer.map().

read_texture(source, data_layout, size)

Reads the contents of the texture and return them as a memoryview.

Parameters:
  • source – A dict with fields: “texture” (a texture object), “origin” (a 3-tuple), “mip_level” (an int, default 0).

  • data_layout – A dict with fields: “offset” (an int, default 0), “bytes_per_row” (an int), “rows_per_image” (an int, default 0).

  • size – A 3-tuple of ints specifying the size to write.

Unlike GPUCommandEncoder.copyBufferToTexture(), there is no alignment requirement on bytes_per_row, although in the current implementation there will be a performance penalty if bytes_per_row is not a multiple of 256 (because we’ll be copying data row-by-row in Python).

submit(command_buffers)

Submit a GPUCommandBuffer to the queue.

Parameters:

command_buffers (list) – The GPUCommandBuffer objects to add.

write_buffer(buffer, buffer_offset, data, data_offset=0, size=None)

Takes the data contents and schedules a write operation of these contents to the buffer. A snapshot of the data is taken; any changes to the data after this function is called do not affect the buffer contents.

Parameters:
  • buffer – The GPUBuffer object to write to.

  • buffer_offset (int) – The offset in the buffer to start writing at.

  • data – The data to write. Must be contiguous.

  • data_offset – The byte offset in the data. Default 0.

  • size – The number of bytes to write. Default all minus offset.

This maps the data to a temporary buffer and then copies that buffer to the given buffer. The given buffer’s usage must include COPY_DST.

Also see GPUBuffer.map().

write_texture(destination, data, data_layout, size)

Takes the data contents and schedules a write operation of these contents to the destination texture in the queue. A snapshot of the data is taken; any changes to the data after this function is called do not affect the texture contents.

Parameters:
  • destination – A dict with fields: “texture” (a texture object), “origin” (a 3-tuple), “mip_level” (an int, default 0).

  • data – The data to write.

  • data_layout – A dict with fields: “offset” (an int, default 0), “bytes_per_row” (an int), “rows_per_image” (an int, default 0).

  • size – A 3-tuple of ints specifying the size to write.

Unlike GPUCommandEncoder.copyBufferToTexture(), there is no alignment requirement on bytes_per_row.