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
props
backendProps?
byteAlignment?
number
Returns
Texture
Overrides
Properties
baseDimension
readonlybaseDimension:"1d"|"2d"|"3d"
Defined in: modules/core/src/api/adapter/resources/texture.ts:241
base dimension of this texture
byteAlignment
readonlybyteAlignment: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
readonlydepth:number
Defined in: modules/core/src/api/adapter/resources/texture.ts:249
depth of this texture
device
abstractreadonlydevice:Device
Defined in: modules/core/src/api/adapter/resources/device-resource.ts:127
The device that this resource is associated with
Inherited from
dimension
readonlydimension:"1d"|"2d"|"2d-array"|"cube"|"cube-array"|"3d"
Defined in: modules/core/src/api/adapter/resources/texture.ts:239
dimension of this texture
format
readonlyformat:TextureFormat
Defined in: modules/core/src/api/adapter/resources/texture.ts:243
format of this texture
handle
abstractreadonlyhandle: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
height
readonlyheight: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
isReady
readonlyisReady: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
readonlymipLevels:number
Defined in: modules/core/src/api/adapter/resources/texture.ts:251
mip levels in this texture
props
readonlyprops:Required<Props>
Defined in: modules/core/src/api/adapter/resources/device-resource.ts:123
The props that this resource was created with
Inherited from
ready
readonlyready: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
abstractsampler:Sampler
Defined in: modules/core/src/api/adapter/resources/texture.ts:257
Default sampler for this texture
samples
readonlysamples: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
readonlyuserData:Record<string,unknown> ={}
Defined in: modules/core/src/api/adapter/resources/device-resource.ts:125
User data object, reserved for the application
Inherited from
view
abstractview:TextureView
Defined in: modules/core/src/api/adapter/resources/texture.ts:259
Default view for this texture
width
readonlywidth:number
Defined in: modules/core/src/api/adapter/resources/texture.ts:245
width in pixels of this texture
COPY_DST
staticCOPY_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
staticCOPY_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
staticdefaultProps:Required<TextureProps>
Defined in: modules/core/src/api/adapter/resources/texture.ts:730
Default properties for resource
Overrides
RENDER
staticRENDER: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
staticRENDER_ATTACHMENT:number=0x10
Defined in: modules/core/src/api/adapter/resources/texture.ts:236
Deprecated
Use Texture.RENDER
SAMPLE
staticSAMPLE: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
staticSTORAGE: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
staticTEXTURE: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
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
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
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
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
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_
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_
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_
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_
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_
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
attachResource()
attachResource(
resource):void
Defined in: modules/core/src/api/adapter/resources/resource.ts:96
Parameters
resource
Returns
void
Deprecated
Use resource.transferOwnershipTo(this).
Inherited from
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?
Returns
copyElementImage()
abstractcopyElementImage(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
Returns
object
height
height:
number
width
width:
number
copyExternalImage()
abstractcopyExternalImage(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
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
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()
abstractcreateView(props):TextureView
Defined in: modules/core/src/api/adapter/resources/texture.ts:334
Create a texture view for this texture
Parameters
props
Returns
delete()
delete():
this
Defined in: modules/core/src/api/adapter/resources/resource.ts:90
Returns
this
Deprecated
Use destroy().
Inherited from
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
destroyAttachedResource()
destroyAttachedResource(
resource):void
Defined in: modules/core/src/api/adapter/resources/resource.ts:108
Parameters
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
Returns
void
Deprecated
Use resource.transferOwnershipTo(null). Only detaches a child owned by this.
Inherited from
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
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?
buffer?
Returns
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?
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?
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
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
toString()
toString():
string
Defined in: modules/core/src/api/adapter/resources/texture.ts:273
Returns a string representation of an object.
Returns
string
Overrides
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
Source GPU buffer.
options?
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?
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.