Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
114 changes: 105 additions & 9 deletions spec/index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -2489,7 +2489,6 @@ offset {{GPUOrigin3D}} in texels, used when copying data from or to a {{GPUTextu

The following validation rules apply:
- |textureCopyView|.{{GPUTextureCopyView/texture}} must be a [=valid=] {{GPUTexture}}.
- The {{GPUTexture/[[sampleCount]]}} of |textureCopyView|.{{GPUTextureCopyView/texture}} must be 1.
- |textureCopyView|.{{GPUTextureCopyView/mipLevel}} must be less than the {{GPUTexture/[[mipLevelCount]]}} of
|textureCopyView|.{{GPUTextureCopyView/texture}}.
- If the |textureCopyView|.{{GPUTextureCopyView/texture}} is {{GPUTextureDimension/1d}} or {{GPUTextureDimension/3d}}:
Expand Down Expand Up @@ -2559,9 +2558,30 @@ dictionary GPUImageBitmapCopyView {
WebGPU provides {{GPUCommandEncoder/copyBufferToTexture()}} for buffer-to-texture copies and
{{GPUCommandEncoder/copyTextureToBuffer()}} for texture-to-buffer copies.

The following validation rules apply to both {{GPUCommandEncoder/copyBufferToTexture()}}
The following definitions and validation rules apply to both {{GPUCommandEncoder/copyBufferToTexture()}}
and {{GPUCommandEncoder/copyTextureToBuffer()}}.

[=textureCopyView subresource size=] and [=Valid Texture Copy Range=] also applies to
{{GPUCommandEncoder/copyTextureToTexture()}}.

<div algorithm="textureCopyView subresource size">

<dfn dfn>textureCopyView subresource size</dfn>

**Arguments:**
- {{GPUTextureCopyView}} |textureCopyView|

**Returns:**
- {{GPUExtent3D}}

The [=textureCopyView subresource size=] of |textureCopyView| is calculated as follows:

Its [=Extent3D/width=], [=Extent3D/height=] and [=Extent3D/depth=] are the width, height, and depth, respectively,
of the [=physical size=] of |textureCopyView|.{{GPUTextureCopyView/texture}} [=subresource=] at [=mipmap level=]
|textureCopyView|.{{GPUTextureCopyView/mipLevel}}.

</div>

<div algorithm class=validusage>

<dfn dfn>Valid Buffer Copy Range</dfn>
Expand Down Expand Up @@ -2598,8 +2618,6 @@ Given a {{GPUBufferCopyView}} |bufferCopyView|, a {{GPUTextureFormat}} |format|
For the texel block alignments:
- |bufferCopyView|.{{GPUBufferCopyView/rowsPerImage}} must be a multiple of |blockHeight|.
- |bufferCopyView|.{{GPUBufferCopyView/offset}} must be a multiple of |blockSize|.
- |copySize|.[=Extent3D/width=] must be a multiple of |blockWidth|.
- |copySize|.[=Extent3D/height=] must be a multiple of |blockHeight|.

For other members in |bufferCopyView|:
- If |copySize|.[=Extent3D/height=] is greater than 1:
Expand All @@ -2613,17 +2631,20 @@ Given a {{GPUBufferCopyView}} |bufferCopyView|, a {{GPUTextureFormat}} |format|

<dfn dfn>Valid Texture Copy Range</dfn>

Given a {{GPUTextureCopyView}} |textureCopyView| and a {{GPUExtent3D}} |copySize|, the following
validation rules apply:
Given a {{GPUTextureCopyView}} |textureCopyView| and a {{GPUExtent3D}} |copySize|, let
- |blockWidth| be the [=texel block width=] of |textureCopyView|.{{GPUTextureCopyView/texture}}.{{GPUTexture/[[format]]}}.
- |blockHeight| be the [=texel block height=] of |textureCopyView|.{{GPUTextureCopyView/texture}}.{{GPUTexture/[[format]]}}.

The following validation rules apply:

- If the {{GPUTexture/[[dimension]]}} of |textureCopyView|.{{GPUTextureCopyView/texture}} is
{{GPUTextureDimension/1d}}:
- Both |copySize|.[=Extent3D/height=] and [=Extent3D/depth=] must be 1.
- If the {{GPUTexture/[[dimension]]}} of |textureCopyView|.{{GPUTextureCopyView/texture}} is
{{GPUTextureDimension/2d}}:
- (|textureCopyView|.{{GPUTextureCopyView/origin}}.{{GPUOrigin3DDict/x}} + |copySize|.[=Extent3D/width=]) must be less than or equal to the width of the [=physical size=] of |textureCopyView|.{{GPUTextureCopyView/texture}} [=subresource=] at [=mipmap level=] {{GPUTextureCopyView/mipLevel}}.
- (|textureCopyView|.{{GPUTextureCopyView/origin}}.{{GPUOrigin3DDict/y}} + |copySize|.[=Extent3D/height=]) must be less than or equal to the height of the [=physical size=] of |textureCopyView|.{{GPUTextureCopyView/texture}} [=subresource=] at [=mipmap level=] {{GPUTextureCopyView/mipLevel}}
- (|textureCopyView|.{{GPUTextureCopyView/arrayLayer}} + |copySize|.[=Extent3D/depth=]) must be less than or equal to the depth of the [=Extent3D/depth=] of the |textureCopyView|.{{GPUTextureCopyView/texture}}.
- (|textureCopyView|.{{GPUTextureCopyView/origin}}.{{GPUOrigin3DDict/x}} + |copySize|.[=Extent3D/width=]), (|textureCopyView|.{{GPUTextureCopyView/origin}}.{{GPUOrigin3DDict/y}} + |copySize|.[=Extent3D/height=]) and (|textureCopyView|.{{GPUTextureCopyView/arrayLayer}} + |copySize|.[=Extent3D/depth=]) must be less than or equal to the [=Extent3D/width=], [=Extent3D/height=], and [=Extent3D/depth=], respectively, of the [=textureCopyView subresource size=] of |textureCopyView|.
- |copySize|.[=Extent3D/width=] must be a multiple of |blockWidth|.
- |copySize|.[=Extent3D/height=] must be a multiple of |blockHeight|.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have these rules for origin.x and origin.y somewhere? Seems they should be here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


</div>

Expand Down Expand Up @@ -2676,6 +2697,7 @@ Given a {{GPUCommandEncoder}} |encoder| and the arguments {{GPUBufferCopyView}}
- |destination| must be [=valid=].
- |destination|.{{GPUTextureCopyView/texture}}.{{GPUTexture/[[textureUsage]]}} must contain
{{GPUTextureUsage/COPY_DST}}.
- |destination|.{{GPUTextureCopyView/texture}}.{{GPUTexture/[[sampleCount]]}} must be 1.

For the copy ranges:
- [=Valid Buffer Copy Range=] applies to |source|, |destination|.{{GPUTextureCopyView/texture}}.{{GPUTexture/[[format]]}}
Expand Down Expand Up @@ -2721,6 +2743,7 @@ Given a {{GPUCommandEncoder}} |encoder| and the arguments {{GPUTextureCopyView}}
- |source| must be [=valid=].
- |source|.{{GPUTextureCopyView/texture}}.{{GPUTexture/[[textureUsage]]}} must contain
{{GPUTextureUsage/COPY_SRC}}.
- |source|.{{GPUTextureCopyView/texture}}.{{GPUTexture/[[sampleCount]]}} must be 1.

For |destination|:
- |destination| must be [=valid=].
Expand All @@ -2733,6 +2756,79 @@ Given a {{GPUCommandEncoder}} |encoder| and the arguments {{GPUTextureCopyView}}

</div>

### <dfn method for=GPUCommandEncoder>copyTextureToTexture(source, destination, copySize)</dfn> ### {#GPUCommandEncoder-copyTextureToTexture}

<div algorithm="GPUCommandEncoder.copyTextureToTexture">

**Arguments:**
- {{GPUTextureCopyView}} |source|
- {{GPUTextureCopyView}} |destination|
- {{GPUExtent3D}} |copySize|

**Returns:** void

Encode a command into the {{GPUCommandEncoder}} that copies data from a sub-region of one
or multiple contiguous {{GPUTexture}} [=subresources=] to another sub-region of one or
multiple continuous {{GPUTexture}} [=subresources=].

|source| and |copySize| define the region of the source texture [=subresources=].

|destination| and |copySize| define the region of the destination texture [=subresources=].

</div>

<div algorithm class=validusage>

<dfn abstract-op>copyTextureToTexture Valid Usage</dfn>

Given a {{GPUCommandEncoder}} |encoder| and the arguments {{GPUTextureCopyView}} |source|,
{{GPUTextureCopyView}} |destination|, {{GPUExtent3D}} |copySize|, let

- A |copy of the whole subresource| be the command |encoder|.{{GPUCommandEncoder/copyTextureToTexture()}} whose parameters |source|, |destination| and |copySize| meet the following conditions:
- The [=textureCopyView subresource size=] of |source| must be equal to |copySize|.
- The [=textureCopyView subresource size=] of |destination| must be equal to |copySize|.

The following validation rules apply:

For |encoder|:
- |encoder|.{{GPUCommandEncoder/copyTextureToTexture()}} must not be called when a {{GPURenderPassEncoder}}
is active on |encoder|.
- |encoder|.{{GPUCommandEncoder/copyTextureToTexture()}} must not be called when a {{GPUComputePassEncoder}}
is active on |encoder|.

For |source|:
- |source| must be [=valid=].
- |source|.{{GPUTextureCopyView/texture}}.{{GPUTexture/[[textureUsage]]}} must contain
{{GPUTextureUsage/COPY_SRC}}.

For |destination|:
- |destination| must be [=valid=].
- |destination|.{{GPUTextureCopyView/texture}}.{{GPUTexture/[[textureUsage]]}} must contain
{{GPUTextureUsage/COPY_DST}}.

For the texture {{GPUTexture/[[sampleCount]]}}:
- |source|.{{GPUTextureCopyView/texture}}.{{GPUTexture/[[sampleCount]]}} must be equal to |destination|.
{{GPUTextureCopyView/texture}}.{{GPUTexture/[[sampleCount]]}}.
- If |source|.{{GPUTextureCopyView/texture}}.{{GPUTexture/[[sampleCount]]}} is greater than 1:
- The copy with |source|, |destination| and |copySize| must be a |copy of the whole subresource|.

For the texture {{GPUTexture/[[format]]}}:
- |source|.{{GPUTextureCopyView/texture}}.{{GPUTexture/[[format]]}} must be equal to |destination|.
{{GPUTextureCopyView/texture}}.{{GPUTexture/[[format]]}}.
- If |source|.{{GPUTextureCopyView/texture}}.{{GPUTexture/[[format]]}} is a depth-stencil format:
- The copy with |source|, |destination| and |copySize| must be a |copy of the whole subresource|.

For the copy ranges:
- [=Valid Texture Copy Range=] applies to |source| and |copySize|.
- [=Valid Texture Copy Range=] applies to |destination| and |copySize|.
- If |source|.{{GPUTextureCopyView/texture}} is the same as |destination|.{{GPUTextureCopyView/texture}}:
- The [=subresource=] at [=mipmap level=] |source|.{{GPUTextureCopyView/mipLevel}} and [=array layer=] |source|.{{GPUTextureCopyView/arrayLayer}} must be different from the [=subresource=] at [=mipmap level=] |destination|.{{GPUTextureCopyView/mipLevel}} and [=array layer=] |destination|.{{GPUTextureCopyView/arrayLayer}}.

</dfn>

</div>


## Programmable Passes ## {#programmable-passes}

<script type=idl>
Expand Down