GPUTextureView
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
Secure context: This feature is available only insecure contexts (HTTPS), in some or allsupporting browsers.
Note: This feature is available inWeb Workers.
TheGPUTextureView interface of theWebGPU API represents a view into a subset of the texture resources defined by a particularGPUTexture.
AGPUTextureView object instance is created using theGPUTexture.createView() method.
In this article
Instance properties
Examples
In the WebGPU SamplesCubemap demo, you will see multiple examples of howGPUTextureViews (created byGPUTexture.createView() calls) are used, both as aresource in aGPUDevice.createBindGroup() call, and as a providedview in thedepthStencilAttachment object of aGPUCommandEncoder.beginRenderPass() descriptor.
const uniformBindGroup = device.createBindGroup({ layout: pipeline.getBindGroupLayout(0), entries: [ { binding: 0, resource: { buffer: uniformBuffer, offset: 0, size: uniformBufferSize, }, }, { binding: 1, resource: sampler, }, { binding: 2, resource: cubemapTexture.createView({ dimension: "cube", }), }, ],});const renderPassDescriptor: GPURenderPassDescriptor = { colorAttachments: [ { view: undefined, // Assigned later loadOp: "clear", storeOp: "store", }, ], depthStencilAttachment: { view: depthTexture.createView(), depthClearValue: 1.0, depthLoadOp: "clear", depthStoreOp: "store", },};// …const commandEncoder = device.createCommandEncoder();const passEncoder = commandEncoder.beginRenderPass(renderPassDescriptor);// …Specifications
| Specification |
|---|
| WebGPU> # gputextureview> |
Browser compatibility
See also
- TheWebGPU API