From 538a4c75b819a48b0d4f631d68be7ce24c379e8c Mon Sep 17 00:00:00 2001 From: Brandon Jones Date: Thu, 13 Jun 2024 13:37:14 -0700 Subject: [PATCH] Algorithm steps for attachment load/store (#4706) * Algorithm steps for attachment load/store * Address Kai's feedback --- spec/index.bs | 144 ++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 140 insertions(+), 4 deletions(-) diff --git a/spec/index.bs b/spec/index.bs index 55a51da0c6..56e4d456f0 100644 --- a/spec/index.bs +++ b/spec/index.bs @@ -9598,6 +9598,7 @@ dictionary GPUCommandEncoderDescriptor 1. Set |pass|.{{GPURenderCommandsMixin/[[drawCount]]}} to 0. 1. Set |pass|.{{GPURenderPassEncoder/[[maxDrawCount]]}} to |descriptor|.{{GPURenderPassDescriptor/maxDrawCount}}. + 1. Set |pass|.{{GPURenderPassEncoder/[[maxDrawCount]]}} to |descriptor|.{{GPURenderPassDescriptor/maxDrawCount}}. 1. [$Enqueue a command$] on |this| which issues the subsequent steps on the [=Queue timeline=] when executed. @@ -9607,10 +9608,72 @@ dictionary GPUCommandEncoderDescriptor 1. Let the {{GPUCommandBuffer/[[renderState]]}} of the currently executing {{GPUCommandBuffer}} be a new [=RenderState=]. - 1. Issue: Perform attachment loads/clears. - - Issue: specify the behavior of read-only depth/stencil + 1. Set {{GPUCommandBuffer/[[renderState]]}}.{{RenderState/[[colorAttachments]]}} to + |descriptor|.{{GPURenderPassDescriptor/colorAttachments}}. + 1. Set {{GPUCommandBuffer/[[renderState]]}}.{{RenderState/[[depthStencilAttachment]]}} to + |descriptor|.{{GPURenderPassDescriptor/depthStencilAttachment}}. + + 1. For each non-`null` |colorAttachment| in |descriptor|.{{GPURenderPassDescriptor/colorAttachments}}: + 1. Let |colorView| be |colorAttachment|.{{GPURenderPassColorAttachment/view}}. + 1. If |colorView|.{{GPUTextureView/[[descriptor]]}}.{{GPUTextureViewDescriptor/dimension}} is: +
+ : {{GPUTextureViewDimension/"3d"}} + :: + Let |colorSubregion| be |colorAttachment|.{{GPURenderPassColorAttachment/depthSlice}} of + |colorView|. + + : Otherwise + :: + Let |colorSubregion| be |colorView|. +
+ + 1. If |colorAttachment|.{{GPURenderPassColorAttachment/loadOp}} is: +
+ : {{GPULoadOp/"load"}} + :: + Ensure the contents of |colorSubregion| are loaded into the [=framebuffer memory=] + associated with |colorSubregion|. + + : {{GPULoadOp/"clear"}} + :: + Set every [=texel block|texel=] of the [=framebuffer memory=] associated with + |colorSubregion| to |colorAttachment|.{{GPURenderPassColorAttachment/clearValue}}. +
+ + 1. If |depthStencilAttachment| is not `null`: + 1. If |depthStencilAttachment|.{{GPURenderPassDepthStencilAttachment/depthLoadOp}} is: +
+ : {{GPULoadOp/"load"}} + :: + Ensure the contents of the [=aspect/depth=] [=GPUTextureView/subresource=] of + |depthStencilView| are loaded into the [=framebuffer memory=] associated with + |depthStencilView|. + + : {{GPULoadOp/"clear"}} + :: + Set every [=texel block|texel=] of the [=framebuffer memory=] associated with the + [=aspect/depth=] [=GPUTextureView/subresource=] of |depthStencilView| to + |depthStencilAttachment|.{{GPURenderPassDepthStencilAttachment/depthClearValue}}. +
+ + 1. If |depthStencilAttachment|.{{GPURenderPassDepthStencilAttachment/stencilLoadOp}} is: +
+ : {{GPULoadOp/"load"}} + :: + Ensure the contents of the [=aspect/stencil=] [=GPUTextureView/subresource=] of + |depthStencilView| are loaded into the [=framebuffer memory=] associated with + |depthStencilView|. + + : {{GPULoadOp/"clear"}} + :: + Set every [=texel block|texel=] of the [=framebuffer memory=] associated with the + [=aspect/stencil=] [=GPUTextureView/subresource=] |depthStencilView| to + |depthStencilAttachment|.{{GPURenderPassDepthStencilAttachment/stencilClearValue}}. +
+ + Issue: specify the behavior of read-only depth/stencil + : beginComputePass(descriptor) @@ -10915,8 +10978,20 @@ When executing encoded render pass commands as part of a {{GPUCommandBuffer}}, a : \[[stencilReference]], of type {{GPUStencilValue}} :: Current stencil reference value, initially `0`. + + : \[[colorAttachments]], of type [=sequence=]<{{GPURenderPassColorAttachment}}?> + :: The color attachments and state for this render pass. + + : \[[depthStencilAttachment]], of type {{GPURenderPassDepthStencilAttachment}}? + :: The depth/stencil attachment and state for this render pass. +Render passes also have framebuffer memory, which contains the [=texel block|texel=] data associated with +each attachment that is written into by draw commands and read from for blending and depth/stencil testing. + +Note: Depending on the GPU hardware, [=framebuffer memory=] may be the memory allocated by the attachment textures or +may be a separate area of memory that the texture data is copied to and from, such as with tile-based architectures. + ### Render Pass Encoder Creation ### {#render-pass-encoder-creation}