diff --git a/spec/index.bs b/spec/index.bs index 42b5ce1fa2..6949923315 100644 --- a/spec/index.bs +++ b/spec/index.bs @@ -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}}: @@ -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()}}. + +
+ +textureCopyView subresource size + + **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}}. + +
+
Valid Buffer Copy Range @@ -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: @@ -2613,17 +2631,20 @@ Given a {{GPUBufferCopyView}} |bufferCopyView|, a {{GPUTextureFormat}} |format| Valid Texture Copy Range -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|.
@@ -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]]}} @@ -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=]. @@ -2733,6 +2756,79 @@ Given a {{GPUCommandEncoder}} |encoder| and the arguments {{GPUTextureCopyView}} +### copyTextureToTexture(source, destination, copySize) ### {#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=]. + +
+ +
+ +copyTextureToTexture Valid Usage + +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}}. + + + +
+ + ## Programmable Passes ## {#programmable-passes}