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

Skip to content

Conversation

Jiawei-Shao
Copy link
Contributor

@Jiawei-Shao Jiawei-Shao commented Apr 22, 2020

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.

Preview | Diff

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.
@Jiawei-Shao
Copy link
Contributor Author

"The format of the source texture must be the same as the one of
the destination texture as is required on Metal" is based on the statement "the source and destination textures must have the same pixel format and sample count".

"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" is based on the statement "if you use CopyTextureRegion with a depth-stencil buffer or a multisampled resource, you must copy the whole subresource".

"The source and destination subresources must be different as is
required by D3D12" is based on the statement "as a consequence, the source and destination resources: must be different subresources (although they can be from the same resource)".

Copy link
Contributor

@kvark kvark left a comment

Choose a reason for hiding this comment

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

Looks good to me, thank you! Just a few notes.

spec/index.bs Outdated
{{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=].
Copy link
Contributor

Choose a reason for hiding this comment

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

can we have a short define for mip(n) of a texture to avoid repeating this 6 times?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've written this part in another way. PTAL, thanks!

@kvark
Copy link
Contributor

kvark commented Apr 22, 2020

The format of the source texture must be the same as the one of
the destination texture as is required on Metal

It's fine for now, but in the future we need to allow copies between different formats of the same size. In Metal, that would be done by creating a texture view with a different format, and copying into it.

@Jiawei-Shao
Copy link
Contributor Author

Thanks @kvark for your review.

Hi @kainino0x @JusSn, could you take a look when you have time?

Copy link
Contributor

@kainino0x kainino0x left a comment

Choose a reason for hiding this comment

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

Was just in the middle of it :) LGTM, just some nits.

- (|textureCopyView|.{{GPUTextureCopyView/origin}}.{{GPUOrigin3DDict/y}} + |copySize|.[=Extent3D/height=]) must be less than or equal to the [=Extent3D/height=] of the [=textureCopyView subresource size=] of |textureCopyView|.
- (|textureCopyView|.{{GPUTextureCopyView/arrayLayer}} + |copySize|.[=Extent3D/depth=]) must be less than or equal to the [=Extent3D/depth=] 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.

@kvark
Copy link
Contributor

kvark commented May 4, 2020

@JusSn please review this post-landing!

@kvark kvark merged commit be26167 into gpuweb:master May 4, 2020
@kvark
Copy link
Contributor

kvark commented May 4, 2020

We need to follow up with a clarification of what is considered to be "subresource", and that it's forbidden to have the 2 sets of subresources (source and destination) to intersect if the parent texture is the same.

@kainino0x
Copy link
Contributor

We need to follow up with a clarification of what is considered to be "subresource", and that it's forbidden to have the 2 sets of subresources (source and destination) to intersect if the parent texture is the same.

Ended up doing this in #730 because I needed to edit that text anyway.

JusSn pushed a commit to JusSn/gpuweb that referenced this pull request Jun 8, 2020
* 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.

* Address reviewer's comments

* Define "textureCopyView subresource size" in an algorithm

* Address more reviewer's comments
JusSn pushed a commit to JusSn/gpuweb that referenced this pull request Jun 8, 2020
* 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.

* Address reviewer's comments

* Define "textureCopyView subresource size" in an algorithm

* Address more reviewer's comments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants