Skip to content

Commit

Permalink
s/OUTPUT_ATTACHMENT/RENDER_ATTACHMENT/g (gpuweb#1168)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kangz authored Oct 22, 2020
1 parent 5b02f86 commit e004dc3
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
10 changes: 5 additions & 5 deletions design/UsageValidationRules.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Buffers have the following usages (and commands inducing that usage):
- (Maybe `STORAGE_TEXEL` and `UNIFORM_TEXEL`?)

Textures have the following usages:
- `OUTPUT_ATTACHMENT` for the subresources referenced by `WebGPURenderPassDescriptor`
- `RENDER_ATTACHMENT` for the subresources referenced by `WebGPURenderPassDescriptor`
- `SAMPLED` and `STORAGE` for subresources corresponding to the image views referenced by bindgroups passed to `setBindGroup`, with the usage corresponding to the binding's type.
- `COPY_SRC` for textures used as the copy source of various commands.
- `COPY_DST` for textures used as the copy destination of various commands.
Expand All @@ -21,14 +21,14 @@ Read only usages are `VERTEX`, `INDEX`, `INDIRECT`, `UBO`, `COPY_SRC` and `SAMPL

## Render passes

In render passes the only writable resources are textures used as `OUTPUT_ATTACHMENT` and resources used as `STORAGE`.
In render passes the only writable resources are textures used as `RENDER_ATTACHMENT` and resources used as `STORAGE`.

To avoid data hazards the simplest validation rules would be to check for every subresource that it is used as either:
- `OUTPUT_ATTACHMENT`
- `RENDER_ATTACHMENT`
- A combination of read-only usages
- `STORAGE`

If there is no usage of `STORAGE` then there are no data-races as everything is read-only, except `OUTPUT_ATTACHMENT` which is well-ordered.
If there is no usage of `STORAGE` then there are no data-races as everything is read-only, except `RENDER_ATTACHMENT` which is well-ordered.
For `STORAGE` resources, the order of reads and writes to the same memory location is undefined and it is up to the application to ensure data-race freeness.

## Compute passes
Expand Down Expand Up @@ -70,7 +70,7 @@ For example D3D12 assumes UAV is always writeable and disallows transitioning to
### More constrained texture usage validation

Each layer and mip-level of textures can have an independent usage which means implementations might need to track usage per mip-level per layer of a resource.
If this is deemed too costly, we could only have two sub-resources tracked in textures: the part as `OUTPUT_ATTACHMENT` and the rest.
If this is deemed too costly, we could only have two sub-resources tracked in textures: the part as `RENDER_ATTACHMENT` and the rest.
This would mean for example that a texture couldn't be used as both `STORAGE` and a read-only usage inside a render pass.
The state tracking required in implementation would become significantly simpler at the cost of flexibility for the applications.
When using the more constrained version of usage validation for textures, the cost of validation is O(commands).
Expand Down
2 changes: 1 addition & 1 deletion samples/hello-cube.html
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@
sampleCount: 1,
dimension: "2d",
format: "depth32float-stencil8",
usage: GPUTextureUsage.OUTPUT_ATTACHMENT
usage: GPUTextureUsage.RENDER_ATTACHMENT
};

const depthTexture = device.createTexture(depthTextureDescriptor);
Expand Down
20 changes: 10 additions & 10 deletions spec/index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -709,10 +709,10 @@ A [=physical resource=] can be used on GPU in one of the following <dfn dfn>inte
Allowed by {{GPUTextureUsage/STORAGE}}.
: <dfn>attachment</dfn>
:: Texture used as an output attachment in a render pass.
Allowed by {{GPUTextureUsage/OUTPUT_ATTACHMENT}}.
Allowed by {{GPUTextureUsage/RENDER_ATTACHMENT}}.
: <dfn>attachment-read</dfn>
:: Texture used as a read-only attachment in a render pass. Preserves the contents.
Allowed by {{GPUTextureUsage/OUTPUT_ATTACHMENT}}.
Allowed by {{GPUTextureUsage/RENDER_ATTACHMENT}}.
</dl>

Textures may consist of separate [=mipmap levels=] and [=array layers=],
Expand Down Expand Up @@ -1937,7 +1937,7 @@ interface GPUTextureUsage {
const GPUFlagsConstant COPY_DST = 0x02;
const GPUFlagsConstant SAMPLED = 0x04;
const GPUFlagsConstant STORAGE = 0x08;
const GPUFlagsConstant OUTPUT_ATTACHMENT = 0x10;
const GPUFlagsConstant RENDER_ATTACHMENT = 0x10;
};
</script>

Expand Down Expand Up @@ -3877,7 +3877,7 @@ enum GPUBlendOperation {
Return `true`, if and only if, all of the following conditions are satisfied:

1. |descriptor|.{{GPUColorStateDescriptor/format}} is listed in {#plain-color-formats}
with {{GPUTextureUsage/OUTPUT_ATTACHMENT}} capability.
with {{GPUTextureUsage/RENDER_ATTACHMENT}} capability.
1. |descriptor|.{{GPUColorStateDescriptor/alphaBlend}} and |descriptor|.{{GPUColorStateDescriptor/colorBlend}}
are either both defaults, or |descriptor|.{{GPUColorStateDescriptor/format}} has
{{GPUTextureComponentType/"float"}} component type.
Expand Down Expand Up @@ -5610,14 +5610,14 @@ dictionary GPURenderPassColorAttachmentDescriptor {

1. |this|.{{GPURenderPassColorAttachmentDescriptor/attachment}} must have a renderable color format.
1. |this|.{{GPURenderPassColorAttachmentDescriptor/attachment}}.{{GPUTextureView/[[texture]]}}.{{GPUTexture/[[textureUsage]]}}
must contain {{GPUTextureUsage/OUTPUT_ATTACHMENT}}.
must contain {{GPUTextureUsage/RENDER_ATTACHMENT}}.
1. |this|.{{GPURenderPassColorAttachmentDescriptor/attachment}} must be a view of a single [=subresource=].
1. If |this|.{{GPURenderPassColorAttachmentDescriptor/resolveTarget}} is not `null`:

1. |this|.{{GPURenderPassColorAttachmentDescriptor/attachment}} must be multisampled.
1. |this|.{{GPURenderPassColorAttachmentDescriptor/resolveTarget}} must not be multisampled.
1. |this|.{{GPURenderPassColorAttachmentDescriptor/resolveTarget}}.{{GPUTextureView/[[texture]]}}.{{GPUTexture/[[textureUsage]]}}
must contain {{GPUTextureUsage/OUTPUT_ATTACHMENT}}.
must contain {{GPUTextureUsage/RENDER_ATTACHMENT}}.
1. |this|.{{GPURenderPassColorAttachmentDescriptor/resolveTarget}} must be a view of a single [=subresource=].

1. The dimensions of the [=subresource=]s seen by |this|.{{GPURenderPassColorAttachmentDescriptor/resolveTarget}}
Expand Down Expand Up @@ -5700,7 +5700,7 @@ dictionary GPURenderPassDepthStencilAttachmentDescriptor {
1. |this|.{{GPURenderPassDepthStencilAttachmentDescriptor/attachment}} must be a view of a
single [=texture subresource=].
1. |this|.{{GPURenderPassDepthStencilAttachmentDescriptor/attachment}}.{{GPUTexture/[[textureUsage]]}}
must contain {{GPUTextureUsage/OUTPUT_ATTACHMENT}}.
must contain {{GPUTextureUsage/RENDER_ATTACHMENT}}.
1. |this|.{{GPURenderPassDepthStencilAttachmentDescriptor/depthReadOnly}} is `true`,
|this|.{{GPURenderPassDepthStencilAttachmentDescriptor/depthLoadValue}} must be
{{GPULoadOp/"load"}} and |this|.{{GPURenderPassDepthStencilAttachmentDescriptor/depthStoreOp}}
Expand Down Expand Up @@ -6783,7 +6783,7 @@ interface GPUCanvasContext {
dictionary GPUSwapChainDescriptor : GPUObjectDescriptorBase {
required GPUDevice device;
required GPUTextureFormat format;
GPUTextureUsageFlags usage = 0x10; // GPUTextureUsage.OUTPUT_ATTACHMENT
GPUTextureUsageFlags usage = 0x10; // GPUTextureUsage.RENDER_ATTACHMENT
};
</script>

Expand Down Expand Up @@ -7140,7 +7140,7 @@ The "Filter" column specifies whether textures of this format can be sampled in
<tr>
<th>Format
<th>{{GPUTextureComponentType|Component Type}}
<th>{{GPUTextureUsage/OUTPUT_ATTACHMENT}}
<th>{{GPUTextureUsage/RENDER_ATTACHMENT}}
<th>{{GPUTextureUsage/STORAGE}}
<th>Filter
</thead>
Expand Down Expand Up @@ -7363,7 +7363,7 @@ The "Filter" column specifies whether textures of this format can be sampled in

### Depth/stencil formats ### {#depth-formats}

All depth formats support {{GPUTextureUsage/COPY_SRC}}, {{GPUTextureUsage/COPY_DST}}, {{GPUTextureUsage/SAMPLED}}, and {{GPUTextureUsage/OUTPUT_ATTACHMENT}} usage. However, the source/destination is restricted based on the format.
All depth formats support {{GPUTextureUsage/COPY_SRC}}, {{GPUTextureUsage/COPY_DST}}, {{GPUTextureUsage/SAMPLED}}, and {{GPUTextureUsage/RENDER_ATTACHMENT}} usage. However, the source/destination is restricted based on the format.

None of the depth formats can be filtered.

Expand Down

0 comments on commit e004dc3

Please sign in to comment.