Skip to content

Commit 6a57a2f

Browse files
committed
Add per-pixel accounting of render target depths
Fixes #2965.
1 parent f03e681 commit 6a57a2f

File tree

1 file changed

+73
-1
lines changed

1 file changed

+73
-1
lines changed

spec/index.bs

Lines changed: 73 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1589,6 +1589,11 @@ applications should generally request the "worst" limits that work for their con
15891589
{{GPURenderPassDescriptor}}.{{GPURenderPassDescriptor/colorAttachments}},
15901590
and {{GPURenderPassLayout}}.{{GPURenderPassLayout/colorFormats}}.
15911591

1592+
<tr><td><dfn>maxTotalColorAttachmentDepth</dfn>
1593+
<td>{{GPUSize32}} <td>[=limit class/maximum=] <td>32
1594+
<tr class=row-continuation><td colspan=4>
1595+
The maximum number of bytes necessary to hold a pixel, across all color attachments.
1596+
15921597
<tr><td><dfn>maxComputeWorkgroupStorageSize</dfn>
15931598
<td>{{GPUSize32}} <td>[=limit class/maximum=] <td>16384 bytes
15941599
<tr class=row-continuation><td colspan=4>
@@ -1660,6 +1665,7 @@ interface GPUSupportedLimits {
16601665
readonly attribute unsigned long maxInterStageShaderComponents;
16611666
readonly attribute unsigned long maxInterStageShaderVariables;
16621667
readonly attribute unsigned long maxColorAttachments;
1668+
readonly attribute unsigned long maxTotalColorAttachmentDepth;
16631669
readonly attribute unsigned long maxComputeWorkgroupStorageSize;
16641670
readonly attribute unsigned long maxComputeInvocationsPerWorkgroup;
16651671
readonly attribute unsigned long maxComputeWorkgroupSizeX;
@@ -7345,6 +7351,17 @@ dictionary GPUFragmentState : GPUProgrammableStage {
73457351

73467352
Otherwise:
73477353
- |colorState|.{{GPUColorTargetState/writeMask}} must be 0.
7354+
- [$Validating GPUFragmentState's total color attachment depth$](|device|, |descriptor|.{{GPUFragmentState/targets}}) succeeds.
7355+
</div>
7356+
7357+
<div algorithm>
7358+
<dfn abstract-op>Validating GPUFragmentState's total color attachment depth</dfn>({{GPUDevice}} |device|, sequence<{{GPUColorTargetState}}?> |targets|)
7359+
7360+
1. Let |formats| be an empty sequence<{{GPUTextureFormat}}>
7361+
1. For each |target| in |targets|:
7362+
1. If |target| is {{undefined}}, continue.
7363+
1. Append |target|.{{GPUColorTargetState/format}} to |formats|.
7364+
1. [$Calculating total color attachment depth$](|formats|) must be &le; |device|.{{device/[[limits]]}}.{{supported limits/maxTotalColorAttachmentDepth}}.
73487365
</div>
73497366

73507367
Note:
@@ -10193,6 +10210,8 @@ dictionary GPURenderPassDescriptor : GPUObjectDescriptorBase {
1019310210

1019410211
1. |this|.{{GPURenderPassDescriptor/depthStencilAttachment}} must meet the [$GPURenderPassDepthStencilAttachment/GPURenderPassDepthStencilAttachment Valid Usage$] rules.
1019510212

10213+
1. [$Validating GPURenderPassDescriptor's total color attachment depth$](|device|, |this|.{{GPURenderPassDescriptor/colorAttachments}}) succeeds.
10214+
1019610215
1. All {{GPURenderPassColorAttachment/view}}s in non-`null` members of |this|.{{GPURenderPassDescriptor/colorAttachments}},
1019710216
and |this|.{{GPURenderPassDescriptor/depthStencilAttachment}}.{{GPURenderPassDepthStencilAttachment/view}}
1019810217
if present, must have equal {{GPUTexture/sampleCount}}s.
@@ -10233,6 +10252,16 @@ dictionary GPURenderPassDescriptor : GPUObjectDescriptorBase {
1023310252
of the attachments are the same, so we can take any of them, assuming the descriptor is valid.
1023410253
</div>
1023510254

10255+
<div algorithm>
10256+
<dfn abstract-op>Validating GPURenderPassDescriptor's total color attachment depth</dfn>({{GPUDevice}} |device|, sequence<{{GPURenderPassColorAttachment}}?> |colorAttachments|)
10257+
10258+
1. Let |formats| be an empty sequence<{{GPUTextureFormat}}>
10259+
1. For each |colorAttachment| in |colorAttachments|:
10260+
1. If |colorAttachment| is {{undefined}}, continue.
10261+
1. Append |colorAttachment|.{{GPURenderPassColorAttachment/view}}.{{GPUTextureView/[[descriptor]]}}.{{GPUTextureViewDescriptor/format}} to |formats|.
10262+
1. [$Calculating total color attachment depth$](|formats|) must be &le; |device|.{{device/[[limits]]}}.{{supported limits/maxTotalColorAttachmentDepth}}.
10263+
</div>
10264+
1023610265
#### Color Attachments #### {#color-attachments}
1023710266

1023810267
<script type=idl>
@@ -10359,6 +10388,36 @@ dictionary GPURenderPassColorAttachment {
1035910388
where |descriptor| is |view|.{{GPUTextureView/[[descriptor]]}}.
1036010389
</div>
1036110390

10391+
<div algorithm>
10392+
<dfn abstract-op>Calculating total color attachment depth</dfn>(|formats|)
10393+
10394+
**Arguments:**
10395+
10396+
- sequence<{{GPUTextureFormat}}> |formats|
10397+
10398+
**Returns:** {{GPUSize32}}
10399+
10400+
1. Let |total| be 0.
10401+
1. For each |format| in |formats|
10402+
1. [=Assert=]: |format| is a [=color renderable format=].
10403+
1. Let |texelBlockSize| be the [=Texel block size=] of |format|.
10404+
1. Let |componentSize| be the [=component width=] of |format|.
10405+
1. If |componentSize| is [=mixed component width=]:
10406+
1. Set |texelBlockSize| to 8.
10407+
1. Set |componentSize| to 4.
10408+
1. Otherwise, divide |componentSize| by 8 (to convert bits to bytes).
10409+
1. If |format| is any of the following formats, then set |texelBlockSize| to 8.
10410+
- {{GPUTextureFormat/"rgba8unorm-srgb"}}
10411+
- {{GPUTextureFormat/"rgba8unorm"}}
10412+
- {{GPUTextureFormat/"bgra8unorm-srgb"}}
10413+
- {{GPUTextureFormat/"bgra8unorm"}}
10414+
- {{GPUTextureFormat/"rgba8snorm"}}
10415+
1. Round |total| up to the smallest multiple of |componentSize| greater than or equal to |total|.
10416+
1. Add |texelBlockSize| to |total|.
10417+
1. Return |total|.
10418+
10419+
</div>
10420+
1036210421
#### Depth/Stencil Attachments #### {#depth-stencil-attachments}
1036310422

1036410423
<script type=idl>
@@ -11437,6 +11496,7 @@ GPURenderBundleEncoder includes GPURenderCommandsMixin;
1143711496
- |descriptor|.{{GPURenderPassLayout/depthStencilFormat}} must not be `null`.
1143811497
- For each |colorFormat| in |descriptor|.{{GPURenderPassLayout/colorFormats}}:
1143911498
- |colorFormat| is `null`, or it must be a [=color renderable format=].
11499+
- [$Validating GPURenderBundleEncoderDescriptor's total color attachment depth$](|this|, |descriptor|.{{GPURenderPassLayout/colorFormats}}) succeeds.
1144011500
- Let |depthStencilFormat| be |descriptor|.{{GPURenderPassLayout/depthStencilFormat}}.
1144111501
- If |depthStencilFormat| is not `null`:
1144211502
- |depthStencilFormat| must be a [=depth-or-stencil format=].
@@ -11455,6 +11515,16 @@ GPURenderBundleEncoder includes GPURenderCommandsMixin;
1145511515
</div>
1145611516
</dl>
1145711517

11518+
<div algorithm>
11519+
<dfn abstract-op>Validating GPURenderBundleEncoderDescriptor's total color attachment depth</dfn>({{GPUDevice}} |device|, sequence<{{GPUTextureFormat}}?> |colorFormats|)
11520+
11521+
1. Let |formats| be an empty sequence<{{GPUTextureFormat}}>
11522+
1. For each |colorFormat| in |colorFormats|:
11523+
1. If |colorFormat| is {{undefined}}, continue.
11524+
1. Append |colorFormat| to |formats|.
11525+
1. [$Calculating total color attachment depth$](|formats|) must be &le; |device|.{{device/[[limits]]}}.{{supported limits/maxTotalColorAttachmentDepth}}.
11526+
</div>
11527+
1145811528
### Encoding ### {#render-bundle-encoding}
1145911529

1146011530
<script type=idl>
@@ -13886,6 +13956,8 @@ The {{GPUTextureUsage/RENDER_ATTACHMENT}} and {{GPUTextureUsage/STORAGE_BINDING}
1388613956
specify support for {{GPUTextureUsage/RENDER_ATTACHMENT|GPUTextureUsage.RENDER_ATTACHMENT}}
1388713957
and {{GPUTextureUsage/STORAGE_BINDING|GPUTextureUsage.STORAGE_BINDING}} usage respectively.
1388813958

13959+
In the below table, the <dfn dfn>component width</dfn> of a format is equal to the value in the "X-bits per component" header of the section that format lies within.
13960+
1388913961
<table class=data>
1389013962
<thead class=stickyheader>
1389113963
<tr>
@@ -14164,7 +14236,7 @@ and {{GPUTextureUsage/STORAGE_BINDING|GPUTextureUsage.STORAGE_BINDING}} usage re
1416414236
<td>
1416514237
<td>&checkmark;
1416614238
<td>16
14167-
<tr><th class=stickyheader>mixed component width<th><th><th><th><th><th>
14239+
<tr><th class=stickyheader><dfn dfn>mixed component width</dfn><th><th><th><th><th><th>
1416814240
<tr>
1416914241
<td>{{GPUTextureFormat/rgb10a2unorm}}
1417014242
<td>{{GPUTextureSampleType/"float"}},<br/>{{GPUTextureSampleType/"unfilterable-float"}}

0 commit comments

Comments
 (0)