GPUTexture

class wgpu.GPUTexture

Bases: GPUObjectBase

Represents a 1D, 2D or 3D color image object.

A texture also can have mipmaps (different levels of varying detail), and arrays. The texture represents the “raw” data. A GPUTextureView is used to define how the texture data should be interpreted.

Create a texture using GPUDevice.create_texture().

create_view(**parameters)

Create a GPUTextureView object.

If no arguments are given, a default view is given, with the same format and dimension as the texture.

Parameters:
  • label (str) – A human-readable label. Optional.

  • format (enums.TextureFormat) – What channels it stores and how.

  • dimension (enums.TextureViewDimension) – The dimensionality of the texture view.

  • usage (enums.TextureUsage) – The allowed usage(s) for the texture view. Must be a subset of the usage flags of the texture. If 0, defaults to the full set of usage flags of the texture.

  • aspect (enums.TextureAspect) – Whether this view is used for depth, stencil, or all. Default all.

  • base_mip_level (int) – The starting mip level. Default 0.

  • mip_level_count (int) – The number of mip levels. Default None.

  • base_array_layer (int) – The starting array layer. Default 0.

  • array_layer_count (int) – The number of array layers. Default None.

property depth_or_array_layers: int

The texture’s depth or number of layers. Also see .size.

destroy() None

Destroy the texture.

Explicitly destroys the texture, freeing its memory and putting the object in an unusable state. In general its easier (and safer) to just let the garbage collector do its thing.

property dimension: TextureDimension

The dimension of the texture.

property format: TextureFormat

The format of the texture.

property height: int

The texture’s height. Also see .size.

property mip_level_count: int

The total number of the mipmap levels of the texture.

property sample_count: int

The number of samples in each texel of the texture.

property size

The size of the texture in mipmap level 0, as a 3-tuple of ints.

property usage: int

The allowed usages for this texture.

property width: int

The texture’s width. Also see .size.