From 2b9c78b99f067ef37a417824860f887973ed61e2 Mon Sep 17 00:00:00 2001 From: Jiawei Shao Date: Wed, 22 Apr 2020 13:26:06 +0800 Subject: [PATCH 1/4] Add validation rules on copyTextureToTexture This patch adds the validation rules on copyTextureToTexture: - Updated "GPUTextureCopyView Valid Usage" and "Valid Texture Copy Range" to reuse them in the validations of copyTextureToTexture. - The format of the source texture must be the same as the one of the destination texture as is required on Metal. - We can only copy the whole subresource when the textures are in depth-stencil formats or the textures are multisampled as is required by D3D12. - The source and destination subresources must be different as is required by D3D12. --- spec/index.bs | 95 ++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 90 insertions(+), 5 deletions(-) diff --git a/spec/index.bs b/spec/index.bs index 42b5ce1fa2..d9d4b8dce1 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}}: @@ -2562,6 +2561,8 @@ WebGPU provides {{GPUCommandEncoder/copyBufferToTexture()}} for buffer-to-textur The following validation rules apply to both {{GPUCommandEncoder/copyBufferToTexture()}} and {{GPUCommandEncoder/copyTextureToBuffer()}}. +[=Valid Texture Copy Range=] also applies to {{GPUCommandEncoder/copyTextureToTexture()}}. +
Valid Buffer Copy Range @@ -2598,8 +2599,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,8 +2612,11 @@ 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}}: @@ -2624,6 +2626,8 @@ validation rules apply: - (|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}}. + - |copySize|.[=Extent3D/width=] must be a multiple of |blockWidth|. + - |copySize|.[=Extent3D/height=] must be a multiple of |blockHeight|.
@@ -2676,6 +2680,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 +2726,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 +2739,85 @@ 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 continuous {{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 + + - |copy on the whole subresource| be the copy whose parameters |source|, |destination| and |copySize| meets the following conditions: + - The width of the [=physical size=] of |source|.{{GPUTextureCopyView/texture}} [=subresource=] at [=mipmap level=] {{GPUTextureCopyView/mipLevel}} must be equal to |copySize|.[=Extent3D/width=]. + - The height of the [=physical size=] of |source|.{{GPUTextureCopyView/texture}} [=subresource=] at [=mipmap level=] {{GPUTextureCopyView/mipLevel}} must be equal to |copySize|.[=Extent3D/height=]. + - The depth of the [=physical size=] of |source|.{{GPUTextureCopyView/texture}} [=subresource=] at [=mipmap level=] {{GPUTextureCopyView/mipLevel}} must be equal to |copySize|.[=Extent3D/depth=]. + - The width of the [=physical size=] of |destination|.{{GPUTextureCopyView/texture}} [=subresource=] at [=mipmap level=] {{GPUTextureCopyView/mipLevel}} must be equal to |copySize|.[=Extent3D/width=]. + - The height of the [=physical size=] of |destination|.{{GPUTextureCopyView/texture}} [=subresource=] at [=mipmap level=] {{GPUTextureCopyView/mipLevel}} must be equal to |copySize|.[=Extent3D/height=]. + - The depth of the [=physical size=] of |destination|.{{GPUTextureCopyView/texture}} [=subresource=] at [=mipmap level=] {{GPUTextureCopyView/mipLevel}} must be equal to |copySize|.[=Extent3D/depth=]. + +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 on 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 on 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|. + - The texture [=subresource=] represented by |source|.{{GPUTextureCopyView/texture}}, + |source|.{{GPUTextureCopyView/mipLevel}} and |source|.{{GPUTextureCopyView/arrayLayer}} must be different + from the texture [=subresource=] represented by |destination|.{{GPUTextureCopyView/texture}}, + |destination|.{{GPUTextureCopyView/mipLevel}} and |destination|.{{GPUTextureCopyView/arrayLayer}}. + + + +
+ + ## Programmable Passes ## {#programmable-passes}