Skip to content

GPUTexture

A texture is made up of 1d, 2d, or 3d arrays of data which can contain multiple values per-element to represent things like colors. Textures can be read and written in many ways, depending on the GPUTextureUsage they are created with. For example, textures can be sampled, read, and written from render and compute pipeline shaders, and they can be written by render pass outputs. Internally, textures are often stored in GPU memory with a layout optimized for multidimensional access rather than linear access. ## Lifetime A GPUTexture created by a device is owned by the caller: `close()` destroys it, and a native backend must also release its owned reference. A texture obtained from a canvas context is borrowed: closing its wrapper does not destroy the texture owned by the canvas. Closing an already closed texture does not release the same reference a second time.

Properties

depthOrArrayLayers

The depth or layer count of this GPUTexture. See [GPUTexture.depthOrArrayLayers in the WebGPU specification](https://www.w3.org/TR/webgpu/#dom-gputexture-depthorarraylayers).

dimension

The dimension of the set of texel for each of this GPUTexture’s subresources.

format

abstract val format: GPUTextureFormat
The format of this GPUTexture. See [GPUTexture.format in the WebGPU specification](https://www.w3.org/TR/webgpu/#dom-gputexture-format).

height

The height of this GPUTexture. See [GPUTexture.height in the WebGPU specification](https://www.w3.org/TR/webgpu/#dom-gputexture-height).

label

abstract var label: String
A developer-provided label which is used in an implementation-defined way. It can be used by the browser, OS, or other tools to help identify the underlying internal object to the developer. Examples include displaying the label in GPUError messages, console warnings, browser developer tools, and platform debugging utilities.

mipLevelCount

The number of mip levels of this GPUTexture. See [GPUTexture.mipLevelCount in the WebGPU specification](https://www.w3.org/TR/webgpu/#dom-gputexture-miplevelcount).

sampleCount

abstract val sampleCount: GPUSize32Out
The number of sample count of this GPUTexture. See [GPUTexture.sampleCount in the WebGPU specification](https://www.w3.org/TR/webgpu/#dom-gputexture-samplecount).

usage

abstract val usage: GPUTextureUsage
The allowed usages for this GPUTexture. See [GPUTexture.usage in the WebGPU specification](https://www.w3.org/TR/webgpu/#dom-gputexture-usage).

width

The width of this GPUTexture. See [GPUTexture.width in the WebGPU specification](https://www.w3.org/TR/webgpu/#dom-gputexture-width).

Functions

close

expect abstract fun close()

createView

abstract fun createView(descriptor: GPUTextureViewDescriptor? = null): GPUTextureView
Creates a GPUTextureView. **Parameters** - descriptor: Description of the GPUTextureView to create.