Abstract Class: Texture
Defined in: modules/core/src/adapter/resources/texture.ts:203
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/adapter/resources/texture.ts:260
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/adapter/resources/texture.ts:223
base dimension of this texture
byteAlignment
readonlybyteAlignment:number
Defined in: modules/core/src/adapter/resources/texture.ts:237
Rows are multiples of this length, padded with extra bytes if needed
depth
readonlydepth:number
Defined in: modules/core/src/adapter/resources/texture.ts:231
depth of this texture
destroyed
destroyed:
boolean=false
Defined in: modules/core/src/adapter/resources/resource.ts:131
Whether this resource has been destroyed
Inherited from
device
abstractreadonlydevice:Device
Defined in: modules/core/src/adapter/resources/resource.ts:124
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/adapter/resources/texture.ts:221
dimension of this texture
format
readonlyformat:TextureFormat
Defined in: modules/core/src/adapter/resources/texture.ts:225
format of this texture
handle
abstractreadonlyhandle:unknown
Defined in: modules/core/src/adapter/resources/resource.ts:126
The handle for the underlying resource, e.g. WebGL object or WebGPU handle
Inherited from
height
readonlyheight:number
Defined in: modules/core/src/adapter/resources/texture.ts:229
height in pixels of this texture
id
id:
string
Defined in: modules/core/src/adapter/resources/resource.ts:118
props.id, for debugging.
Inherited from
isReady
readonlyisReady:boolean=true
Defined in: modules/core/src/adapter/resources/texture.ts:246
isReady is always true. It is provided for type compatibility with DynamicTexture.
mipLevels
readonlymipLevels:number
Defined in: modules/core/src/adapter/resources/texture.ts:233
mip levels in this texture
props
readonlyprops:Required<Props>
Defined in: modules/core/src/adapter/resources/resource.ts:120
The props that this resource was created with
Inherited from
ready
readonlyready:Promise<Texture>
Defined in: modules/core/src/adapter/resources/texture.ts:244
The ready promise is always resolved. It is provided for type compatibility with DynamicTexture.
sampler
abstractsampler:Sampler
Defined in: modules/core/src/adapter/resources/texture.ts:239
Default sampler for this texture
samples
readonlysamples:number
Defined in: modules/core/src/adapter/resources/texture.ts:235
sample count
updateTimestamp
updateTimestamp:
number
Defined in: modules/core/src/adapter/resources/texture.ts:249
"Time" of last update. Monotonically increasing timestamp. TODO move to DynamicTexture?
userData
readonlyuserData:Record<string,unknown> ={}
Defined in: modules/core/src/adapter/resources/resource.ts:122
User data object, reserved for the application
Inherited from
view
abstractview:TextureView
Defined in: modules/core/src/adapter/resources/texture.ts:241
Default view for this texture
width
readonlywidth:number
Defined in: modules/core/src/adapter/resources/texture.ts:227
width in pixels of this texture
COPY_DST
staticCOPY_DST:number=0x02
Defined in: modules/core/src/adapter/resources/texture.ts:213
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/adapter/resources/texture.ts:211
The texture can be used as the source of a copy operation
defaultProps
staticdefaultProps:Required<TextureProps>
Defined in: modules/core/src/adapter/resources/texture.ts:699
Default properties for resource
Overrides
RENDER
staticRENDER:number=0x10
Defined in: modules/core/src/adapter/resources/texture.ts:209
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/adapter/resources/texture.ts:218
Deprecated
Use Texture.RENDER
SAMPLE
staticSAMPLE:number=0x04
Defined in: modules/core/src/adapter/resources/texture.ts:205
The texture can be bound for use as a sampled texture in a shader
STORAGE
staticSTORAGE:number=0x08
Defined in: modules/core/src/adapter/resources/texture.ts:207
The texture can be bound for use as a storage texture in a shader
TEXTURE
staticTEXTURE:number=0x04
Defined in: modules/core/src/adapter/resources/texture.ts:216
Deprecated
Use Texture.SAMPLE
Accessors
[toStringTag]
Get Signature
get [toStringTag]():
string
Defined in: modules/core/src/adapter/resources/texture.ts:251
Returns
string
Overrides
isHandleBorrowed
Get Signature
get isHandleBorrowed():
boolean
Defined in: modules/core/src/adapter/resources/resource.ts:147
Whether luma.gl may only reference the opaque externally owned resource handle.
Returns
boolean
Inherited from
ownsHandle
Get Signature
get ownsHandle():
boolean
Defined in: modules/core/src/adapter/resources/resource.ts:140
Whether luma.gl created and owns the underlying resource handle.
Returns
boolean
Inherited from
Methods
_initializeData()
_initializeData(
data):void
Defined in: modules/core/src/adapter/resources/texture.ts:452
Initialize texture with supplied props
Parameters
data
ExternalImage | TypedArray | null | undefined
Returns
void
_normalizeCopyElementImageOptions()
_normalizeCopyElementImageOptions(
options_):Required<CopyElementImageOptions>
Defined in: modules/core/src/adapter/resources/texture.ts:514
Parameters
options_
Returns
Required<CopyElementImageOptions>
_normalizeCopyExternalImageOptions()
_normalizeCopyExternalImageOptions(
options_):Required<CopyExternalImageOptions>
Defined in: modules/core/src/adapter/resources/texture.ts:494
Parameters
options_
Returns
Required<CopyExternalImageOptions>
_normalizeCopyImageDataOptions()
_normalizeCopyImageDataOptions(
options_):Required<CopyImageDataOptions>
Defined in: modules/core/src/adapter/resources/texture.ts:485
Parameters
options_
Returns
Required<CopyImageDataOptions>
_normalizeTextureReadOptions()
_normalizeTextureReadOptions(
options_):Required<TextureReadOptions>
Defined in: modules/core/src/adapter/resources/texture.ts:531
Parameters
options_
Returns
Required<TextureReadOptions>
_normalizeTextureWriteOptions()
_normalizeTextureWriteOptions(
options_):Required<TextureWriteOptions>
Defined in: modules/core/src/adapter/resources/texture.ts:615
Parameters
options_
Returns
Required<TextureWriteOptions>
attachResource()
attachResource(
resource):void
Defined in: modules/core/src/adapter/resources/resource.ts:200
Attaches a resource. Attached resources are auto destroyed when this resource is destroyed Called automatically when sub resources are auto created but can be called by application
Parameters
resource
Returns
void
Inherited from
clone()
clone(
size?):Texture
Defined in: modules/core/src/adapter/resources/texture.ts:306
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_?):TextureMemoryLayout
Defined in: modules/core/src/adapter/resources/texture.ts:345
Calculates the memory layout of the texture, required when reading and writing data.
Parameters
options_?
TextureReadOptions = {}
Returns
the backend-aligned linear layout, in particular bytesPerRow which includes any required padding for buffer copy/read paths
copyElementImage()
abstractcopyElementImage(options):object
Defined in: modules/core/src/adapter/resources/texture.ts:322
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/adapter/resources/texture.ts:319
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/adapter/resources/texture.ts:333
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/adapter/resources/texture.ts:316
Create a texture view for this texture
Parameters
props
Returns
delete()
delete():
this
Defined in: modules/core/src/adapter/resources/resource.ts:181
Returns
this
Deprecated
Use destroy()
Inherited from
destroy()
destroy():
void
Defined in: modules/core/src/adapter/resources/resource.ts:173
destroy can be called on any resource to release it before it is garbage collected.
Returns
void
Inherited from
destroyAttachedResource()
destroyAttachedResource(
resource):void
Defined in: modules/core/src/adapter/resources/resource.ts:214
Destroys a resource (only if owned), and removes from the owned (auto-destroy) list for this resource.
Parameters
resource
Returns
void
Inherited from
Resource.destroyAttachedResource
destroyAttachedResources()
destroyAttachedResources():
void
Defined in: modules/core/src/adapter/resources/resource.ts:221
Destroy all owned resources. Make sure the resources are no longer needed before calling.
Returns
void
Inherited from
Resource.destroyAttachedResources
detachResource()
detachResource(
resource):void
Defined in: modules/core/src/adapter/resources/resource.ts:207
Detach an attached resource. The resource will no longer be auto-destroyed when this resource is destroyed.
Parameters
resource
Returns
void
Inherited from
generateMipmapsWebGL()
generateMipmapsWebGL():
void
Defined in: modules/core/src/adapter/resources/texture.ts:429
Generate mipmaps (WebGL only)
Returns
void
getProps()
getProps():
object
Defined in: modules/core/src/adapter/resources/resource.ts:190
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/adapter/resources/texture.ts:372
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/adapter/resources/texture.ts:384
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/adapter/resources/texture.ts:424
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/adapter/resources/texture.ts:311
Set sampler props associated with this texture
Parameters
sampler
Returns
void
toJSON()
toJSON():
string
Defined in: modules/core/src/adapter/resources/resource.ts:113
Compact serialization for assertion diffs and structured debug logs.
Returns
string
Inherited from
toString()
toString():
string
Defined in: modules/core/src/adapter/resources/texture.ts:255
Returns
string
Overrides
writeBuffer()
writeBuffer(
buffer,options?):void
Defined in: modules/core/src/adapter/resources/texture.ts:398
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/adapter/resources/texture.ts:411
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.