Skip to main content

Abstract Class: Texture

Defined in: modules/core/src/api/adapter/resources/texture.ts:221

Abstract Texture interface Texture Object https://gpuweb.github.io/gpuweb/#gputexture

Extends​

Constructors​

Constructor​

new Texture(device, props, backendProps?): Texture

Defined in: modules/core/src/api/adapter/resources/texture.ts:278

Do not use directly. Create with device.createTexture()

Parameters​

device​

Device

props​

TextureProps

backendProps?​
byteAlignment?​

number

Returns​

Texture

Overrides​

DeviceResource.constructor

Properties​

baseDimension​

readonly baseDimension: "1d" | "2d" | "3d"

Defined in: modules/core/src/api/adapter/resources/texture.ts:241

base dimension of this texture


byteAlignment​

readonly byteAlignment: number

Defined in: modules/core/src/api/adapter/resources/texture.ts:255

Rows are multiples of this length, padded with extra bytes if needed


depth​

readonly depth: number

Defined in: modules/core/src/api/adapter/resources/texture.ts:249

depth of this texture


device​

abstract readonly device: Device

Defined in: modules/core/src/api/adapter/resources/device-resource.ts:127

The device that this resource is associated with

Inherited from​

DeviceResource.device


dimension​

readonly dimension: "1d" | "2d" | "2d-array" | "cube" | "cube-array" | "3d"

Defined in: modules/core/src/api/adapter/resources/texture.ts:239

dimension of this texture


format​

readonly format: TextureFormat

Defined in: modules/core/src/api/adapter/resources/texture.ts:243

format of this texture


handle​

abstract readonly handle: unknown

Defined in: modules/core/src/api/adapter/resources/device-resource.ts:129

The handle for the underlying resource, e.g. WebGL object or WebGPU handle

Inherited from​

DeviceResource.handle


height​

readonly height: number

Defined in: modules/core/src/api/adapter/resources/texture.ts:247

height in pixels of this texture


id​

id: string

Defined in: modules/core/src/api/adapter/resources/device-resource.ts:121

props.id, for debugging.

Inherited from​

DeviceResource.id


isReady​

readonly isReady: boolean = true

Defined in: modules/core/src/api/adapter/resources/texture.ts:264

isReady is always true. It is provided for type compatibility with DynamicTexture.


mipLevels​

readonly mipLevels: number

Defined in: modules/core/src/api/adapter/resources/texture.ts:251

mip levels in this texture


props​

readonly props: Required<Props>

Defined in: modules/core/src/api/adapter/resources/device-resource.ts:123

The props that this resource was created with

Inherited from​

DeviceResource.props


ready​

readonly ready: Promise<Texture>

Defined in: modules/core/src/api/adapter/resources/texture.ts:262

The ready promise is always resolved. It is provided for type compatibility with DynamicTexture.


sampler​

abstract sampler: Sampler

Defined in: modules/core/src/api/adapter/resources/texture.ts:257

Default sampler for this texture


samples​

readonly samples: number

Defined in: modules/core/src/api/adapter/resources/texture.ts:253

sample count


updateTimestamp​

updateTimestamp: number

Defined in: modules/core/src/api/adapter/resources/texture.ts:267

"Time" of last update. Monotonically increasing timestamp. TODO move to DynamicTexture?


userData​

readonly userData: Record<string, unknown> = {}

Defined in: modules/core/src/api/adapter/resources/device-resource.ts:125

User data object, reserved for the application

Inherited from​

DeviceResource.userData


view​

abstract view: TextureView

Defined in: modules/core/src/api/adapter/resources/texture.ts:259

Default view for this texture


width​

readonly width: number

Defined in: modules/core/src/api/adapter/resources/texture.ts:245

width in pixels of this texture


COPY_DST​

static COPY_DST: number = 0x02

Defined in: modules/core/src/api/adapter/resources/texture.ts:231

he texture can be used as the destination of a copy or write operation


COPY_SRC​

static COPY_SRC: number = 0x01

Defined in: modules/core/src/api/adapter/resources/texture.ts:229

The texture can be used as the source of a copy operation


defaultProps​

static defaultProps: Required<TextureProps>

Defined in: modules/core/src/api/adapter/resources/texture.ts:730

Default properties for resource

Overrides​

DeviceResource.defaultProps


RENDER​

static RENDER: number = 0x10

Defined in: modules/core/src/api/adapter/resources/texture.ts:227

The texture can be used as a color or depth/stencil attachment in a render pass


RENDER_ATTACHMENT​

static RENDER_ATTACHMENT: number = 0x10

Defined in: modules/core/src/api/adapter/resources/texture.ts:236

Deprecated​

Use Texture.RENDER


SAMPLE​

static SAMPLE: number = 0x04

Defined in: modules/core/src/api/adapter/resources/texture.ts:223

The texture can be bound for use as a sampled texture in a shader


STORAGE​

static STORAGE: number = 0x08

Defined in: modules/core/src/api/adapter/resources/texture.ts:225

The texture can be bound for use as a storage texture in a shader


TEXTURE​

static TEXTURE: number = 0x04

Defined in: modules/core/src/api/adapter/resources/texture.ts:234

Deprecated​

Use Texture.SAMPLE

Accessors​

[toStringTag]​

Get Signature​

get [toStringTag](): string

Defined in: modules/core/src/api/adapter/resources/texture.ts:269

Returns​

string

Overrides​

DeviceResource.[toStringTag]


destroyed​

Get Signature​

get destroyed(): boolean

Defined in: modules/core/src/api/adapter/resources/resource.ts:27

Whether destruction has completed, including when cleanup reported an error.

Returns​

boolean

Inherited from​

DeviceResource.destroyed


isHandleBorrowed​

Get Signature​

get isHandleBorrowed(): boolean

Defined in: modules/core/src/api/adapter/resources/device-resource.ts:146

Whether luma.gl may only reference the opaque externally owned resource handle.

Returns​

boolean

Inherited from​

DeviceResource.isHandleBorrowed


ownedResources​

Get Signature​

get ownedResources(): readonly Resource[]

Defined in: modules/core/src/api/adapter/resources/resource.ts:22

A snapshot of this resource's children. Mutating the snapshot cannot change ownership.

Returns​

readonly Resource[]

Inherited from​

DeviceResource.ownedResources


owner​

Get Signature​

get owner(): Resource | null

Defined in: modules/core/src/api/adapter/resources/resource.ts:17

The resource responsible for destroying this resource, or null for caller-managed lifetime.

Returns​

Resource | null

Inherited from​

DeviceResource.owner


ownsHandle​

Get Signature​

get ownsHandle(): boolean

Defined in: modules/core/src/api/adapter/resources/device-resource.ts:139

Whether luma.gl created and owns the underlying resource handle.

Returns​

boolean

Inherited from​

DeviceResource.ownsHandle

Methods​

_initializeData()​

_initializeData(data): void

Defined in: modules/core/src/api/adapter/resources/texture.ts:477

Initialize texture with supplied props

Parameters​

data​

ExternalImage | TypedArray | null | undefined

Returns​

void


_normalizeCopyElementImageOptions()​

_normalizeCopyElementImageOptions(options_, result?): Required<CopyElementImageOptions>

Defined in: modules/core/src/api/adapter/resources/texture.ts:550

Parameters​

options_​

CopyElementImageOptions

result?​

Required<CopyElementImageOptions> = ...

Returns​

Required<CopyElementImageOptions>


_normalizeCopyExternalImageOptions()​

_normalizeCopyExternalImageOptions(options_, result?): Required<CopyExternalImageOptions>

Defined in: modules/core/src/api/adapter/resources/texture.ts:528

Parameters​

options_​

CopyExternalImageOptions

result?​

Required<CopyExternalImageOptions> = ...

Returns​

Required<CopyExternalImageOptions>


_normalizeCopyImageDataOptions()​

_normalizeCopyImageDataOptions(options_, result?): Required<CopyImageDataOptions>

Defined in: modules/core/src/api/adapter/resources/texture.ts:511

The optional result is caller-owned scratch storage; every result field is overwritten.

Parameters​

options_​

CopyImageDataOptions

result?​

Required<CopyImageDataOptions> = ...

Returns​

Required<CopyImageDataOptions>


_normalizeTextureReadOptions()​

_normalizeTextureReadOptions(options_, result?): Required<TextureReadOptions>

Defined in: modules/core/src/api/adapter/resources/texture.ts:570

Parameters​

options_​

TextureReadOptions

result?​

Required<TextureReadOptions> = ...

Returns​

Required<TextureReadOptions>


_normalizeTextureWriteOptions()​

_normalizeTextureWriteOptions(options_, result?): Required<TextureWriteOptions>

Defined in: modules/core/src/api/adapter/resources/texture.ts:652

Parameters​

options_​

TextureWriteOptions

result?​

Required<TextureWriteOptions> = ...

Returns​

Required<TextureWriteOptions>


[dispose]()​

[dispose](): void

Defined in: modules/core/src/api/adapter/resources/resource.ts:50

Destroy the resource when leaving a using scope.

Returns​

void

Inherited from​

DeviceResource.[dispose]


attachResource()​

attachResource(resource): void

Defined in: modules/core/src/api/adapter/resources/resource.ts:96

Parameters​

resource​

Resource

Returns​

void

Deprecated​

Use resource.transferOwnershipTo(this).

Inherited from​

DeviceResource.attachResource


clone()​

clone(size?): Texture

Defined in: modules/core/src/api/adapter/resources/texture.ts:324

Create a new texture with the same parameters and optionally a different size

Parameters​

size?​
height​

number

width​

number

Returns​

Texture

Note​

Textures are immutable and cannot be resized after creation, but we can create a similar texture with the same parameters but a new size.

Note​

Does not copy contents of the texture


computeMemoryLayout()​

computeMemoryLayout(options_?, result?): TextureMemoryLayout

Defined in: modules/core/src/api/adapter/resources/texture.ts:364

The optional result is caller-owned; internal scratch never escapes this call.

Parameters​

options_?​

TextureReadOptions = emptyTextureReadOptions

result?​

TextureMemoryLayout

Returns​

TextureMemoryLayout


copyElementImage()​

abstract copyElementImage(options): object

Defined in: modules/core/src/api/adapter/resources/texture.ts:340

Copy live DOM element pixels into the texture when supported by the current browser backend.

Parameters​

options​

CopyElementImageOptions

Returns​

object

height​

height: number

width​

width: number


copyExternalImage()​

abstract copyExternalImage(options): object

Defined in: modules/core/src/api/adapter/resources/texture.ts:337

Copy an image (e.g an ImageBitmap) into the texture

Parameters​

options​

CopyExternalImageOptions

Returns​

object

height​

height: number

width​

width: number


copyImageData()​

copyImageData(options): void

Defined in: modules/core/src/api/adapter/resources/texture.ts:351

Copy raw image data (bytes) into the texture.

Parameters​

options​

CopyImageDataOptions

Returns​

void

Note​

Deprecated compatibility wrapper over writeData.

Note​

Uses the same layout defaults and alignment rules as writeData.

Note​

Tightly packed CPU uploads can omit bytesPerRow and rowsPerImage.

Note​

If the CPU source rows are padded, pass explicit bytesPerRow and rowsPerImage.

Deprecated​

Use writeData()


createView()​

abstract createView(props): TextureView

Defined in: modules/core/src/api/adapter/resources/texture.ts:334

Create a texture view for this texture

Parameters​

props​

TextureViewProps

Returns​

TextureView


delete()​

delete(): this

Defined in: modules/core/src/api/adapter/resources/resource.ts:90

Returns​

this

Deprecated​

Use destroy().

Inherited from​

DeviceResource.delete


destroy()​

destroy(): void

Defined in: modules/core/src/api/adapter/resources/resource.ts:55

Destroy children before this resource. Subclasses implement hooks instead of overriding.

Returns​

void

Inherited from​

DeviceResource.destroy


destroyAttachedResource()​

destroyAttachedResource(resource): void

Defined in: modules/core/src/api/adapter/resources/resource.ts:108

Parameters​

resource​

Resource

Returns​

void

Deprecated​

Check resource.owner and call resource.destroy().

Inherited from​

DeviceResource.destroyAttachedResource


destroyAttachedResources()​

destroyAttachedResources(): void

Defined in: modules/core/src/api/adapter/resources/resource.ts:115

Returns​

void

Deprecated​

Destroy individually owned resources, or destroy the owner.

Inherited from​

DeviceResource.destroyAttachedResources


detachResource()​

detachResource(resource): void

Defined in: modules/core/src/api/adapter/resources/resource.ts:101

Parameters​

resource​

Resource

Returns​

void

Deprecated​

Use resource.transferOwnershipTo(null). Only detaches a child owned by this.

Inherited from​

DeviceResource.detachResource


generateMipmapsWebGL()​

generateMipmapsWebGL(): void

Defined in: modules/core/src/api/adapter/resources/texture.ts:454

Generate mipmaps (WebGL only)

Returns​

void


getProps()​

getProps(): object

Defined in: modules/core/src/api/adapter/resources/device-resource.ts:174

Combines a map of user props and default props, only including props from defaultProps

Returns​

object

returns a map of overridden default props

Inherited from​

DeviceResource.getProps


readBuffer()​

readBuffer(options?, buffer?): Buffer

Defined in: modules/core/src/api/adapter/resources/texture.ts:397

Read the contents of a texture into a GPU Buffer.

Parameters​

options?​

TextureReadOptions

buffer?​

Buffer

Returns​

Buffer

A Buffer containing the texture data.

Note​

The memory layout of the texture data is determined by the texture format and dimensions.

Note​

The application can call Texture.computeMemoryLayout() to compute the backend-aligned layout.

Note​

The application can call Buffer.readAsync() to read the returned buffer on the CPU.

Note​

The destination buffer must be supplied by the caller and must be large enough for the requested region.

Note​

On WebGPU this corresponds to a texture-to-buffer copy and uses buffer-copy alignment rules.

Note​

On WebGL, luma.gl emulates the same logical readback behavior.


readDataAsync()​

readDataAsync(options?): Promise<ArrayBuffer>

Defined in: modules/core/src/api/adapter/resources/texture.ts:409

Reads data from a texture into an ArrayBuffer.

Parameters​

options?​

TextureReadOptions

Returns​

Promise<ArrayBuffer>

An ArrayBuffer containing the texture data.

Note​

The memory layout of the texture data is determined by the texture format and dimensions.

Note​

The application can call Texture.computeMemoryLayout() to compute the layout.

Deprecated​

Use Texture.readBuffer() with an explicit destination buffer, or DynamicTexture.readAsync() for convenience readback.


readDataSyncWebGL()​

readDataSyncWebGL(options?): ArrayBuffer | ArrayBufferView<ArrayBufferLike>

Defined in: modules/core/src/api/adapter/resources/texture.ts:449

WebGL can read data synchronously.

Parameters​

options?​

TextureReadOptions

Returns​

ArrayBuffer | ArrayBufferView<ArrayBufferLike>

Note​

While it is convenient, the performance penalty is very significant


setSampler()​

setSampler(sampler): void

Defined in: modules/core/src/api/adapter/resources/texture.ts:329

Set sampler props associated with this texture

Parameters​

sampler​

SamplerProps | Sampler

Returns​

void


toJSON()​

toJSON(): string

Defined in: modules/core/src/api/adapter/resources/device-resource.ts:116

Compact serialization for assertion diffs and structured debug logs.

Returns​

string

Inherited from​

DeviceResource.toJSON


toString()​

toString(): string

Defined in: modules/core/src/api/adapter/resources/texture.ts:273

Returns a string representation of an object.

Returns​

string

Overrides​

DeviceResource.toString


transferOwnershipTo()​

transferOwnershipTo(owner): this

Defined in: modules/core/src/api/adapter/resources/resource.ts:32

Transfer exclusive ownership, or return lifetime responsibility to the caller with null.

Parameters​

owner​

Resource | null

Returns​

this

Inherited from​

DeviceResource.transferOwnershipTo


writeBuffer()​

writeBuffer(buffer, options?): void

Defined in: modules/core/src/api/adapter/resources/texture.ts:423

Writes a GPU Buffer into a texture.

Parameters​

buffer​

Buffer

Source GPU buffer.

options?​

TextureWriteOptions

Destination subresource, extent, and source layout options.

Returns​

void

Note​

The memory layout of the texture data is determined by the texture format and dimensions.

Note​

The application can call Texture.computeMemoryLayout() to compute the backend-aligned layout.

Note​

On WebGPU this corresponds to a buffer-to-texture copy and uses buffer-copy alignment rules.

Note​

On WebGL, luma.gl emulates the same destination and layout semantics.


writeData()​

writeData(data, options?): void

Defined in: modules/core/src/api/adapter/resources/texture.ts:436

Writes an array buffer into a texture.

Parameters​

data​

ArrayBuffer | SharedArrayBuffer | ArrayBufferView<ArrayBufferLike>

Source texel data.

options?​

TextureWriteOptions

Destination subresource, extent, and source layout options.

Returns​

void

Note​

If bytesPerRow and rowsPerImage are omitted, luma.gl computes a tightly packed CPU-memory layout for the requested region.

Note​

On WebGPU this corresponds to GPUQueue.writeTexture() and does not implicitly pad rows to 256 bytes.

Note​

On WebGL, padded CPU data is supported via the same bytesPerRow and rowsPerImage options.