用途:配置 GPURenderPassDescriptor 的 attachments,即渲染通道写入的目标,包括画布颜色目标、MRT 额外颜色目标、深度模板缓冲和 MSAA。
主要能力:颜色附件字段(view、loadOp、storeOp、clearValue、resolveTarget、depthSlice);深度模板附件字段(view、depthLoadOp/depthStoreOp、depthClearValue、depthReadOnly、stencil 相关字段);深度格式 depth16unorm、depth24plus、depth24plus-stencil8、depth32float、depth32float-stencil8(后者需设备特性)。版本为 WebGPU 1.0-stable,Chrome 113+、Safari 26+、Firefox 141+。
必要用法:每帧在帧函数内调用 context.getCurrentTexture().createView(),不可跨帧缓存;clearValue 仅在 loadOp 为 "clear" 时生效;MRT 的 colorAttachments 数量与格式须与管线 fragment.targets 一致;深度纹理格式须与管线 depthStencil.format 一致且带 RENDER_ATTACHMENT 用途;MSAA 需在多重采样纹理、管线 multisample.count 与单采样 resolveTarget 三处统一 sampleCount(1 或 4 为通用支持值);纯深度通道(如阴影贴图)使用空 colorAttachments 加 depthStencilAttachment。
适用场景:单颜色目标渲染到画布、延迟着色 G-buffer 等 MRT、深度测试或模板缓冲、MSAA 抗锯齿、阴影贴图等深度专用通道。
限制:资料未提供收费、价格与平台信息;sampleCount 仅 1 和 4 通用支持;depth32float-stencil8 需设备特性;depthReadOnly 为 false 且存在深度面时必须提供 depthLoadOp/depthStoreOp,为 true 时不得提供。