TextureView
Quick answer
TextureView reinterprets a texture without copying memory: it selects mip levels, array layers or a compatible format for the same storage. Create it with texture.createView({dimension, baseMipLevel, levelCount, format}). Use views to render into one cube face or sample a single array slice.
texture. createView ( props ) → TextureView
Key points
- baseMipLevel and levelCount restrict the visible mip range.
- Array and cube textures expose individual layers through views.
- Format reinterpretation works only within compatible format families.
Example
const target = device.createTexture({
width: 256,
height: 256,
format: 'rgba8unorm',
usage: Texture.SAMPLE | Texture.RENDER | Texture.COPY_DST
});
const fbo = device.createFramebuffer({
width: 256,
height: 256,
colorAttachments: [target.createView({ mipLevelCount: 1, arrayLayerCount: 1 })]
});const atlas = device.createTexture({
width: 128,
height: 128,
depth: 8,
dimension: '2d-array',
format: 'rgba8unorm',
usage: Texture.SAMPLE | Texture.RENDER
});
const layer3 = atlas.createView({
dimension: '2d',
baseArrayLayer: 3,
arrayLayerCount: 1,
baseMipLevel: 0,
mipLevelCount: 1
});
Notes
- Reinterpreting across incompatible format families is rejected at creation.
- Destroying the parent texture invalidates every view derived from it.
English edition written for Atlaslog. Code is taken from the original Chinese page and runs unchanged.
Atlaslog (2026). TextureView. https://www.jingweizhi.com/en/lumagl/api/texture-view.html (accessed 2026-11-03).