Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WebGPU] mip level validation is not handled correctly in copyBuffer/TextureToBuffer/Texture #11727

Conversation

mwyrzykowski
Copy link
Contributor

@mwyrzykowski mwyrzykowski commented Mar 20, 2023

77d269e

[WebGPU] mip level validation is not handled correctly in copyBuffer/TextureToBuffer/Texture
https://bugs.webkit.org/show_bug.cgi?id=254175
<radar://106958194>

Reviewed by NOBODY (OOPS!).

The correct sizes were already computed in logicalMiplevelSpecificTextureExtent
but they were not used for validation.

* Source/WebGPU/WebGPU/CommandEncoder.mm:
(WebGPU::CommandEncoder::copyBufferToTexture):
(WebGPU::CommandEncoder::copyTextureToBuffer):
* Source/WebGPU/WebGPU/Queue.mm:
(WebGPU::Queue::writeTexture):
3D textures with rowBytes > 2048 will assert in Metal in debug
and release.

* Source/WebGPU/WebGPU/Texture.mm:
(WebGPU::Texture::validateLinearTextureData):
Metal requires the copy size to be a multiple of the block size.

77d269e

Misc iOS, tvOS & watchOS macOS Linux Windows
βœ… πŸ§ͺ style βœ… πŸ›  ios βœ… πŸ›  mac βœ… πŸ›  wpe βœ… πŸ›  wincairo
βœ… πŸ›  ios-sim βœ… πŸ›  mac-AS-debug βœ… πŸ§ͺ wpe-wk2
βœ… πŸ§ͺ webkitperl βœ… πŸ§ͺ ios-wk2 βœ… πŸ§ͺ api-mac βœ… πŸ›  gtk
βœ… πŸ§ͺ ios-wk2-wpt βœ… πŸ§ͺ mac-wk1 βœ… πŸ§ͺ gtk-wk2
βœ… πŸ§ͺ api-ios βœ… πŸ§ͺ mac-wk2 βœ… πŸ§ͺ api-gtk
βœ… πŸ›  tv βœ… πŸ§ͺ mac-AS-debug-wk2
βœ… πŸ›  tv-sim βœ… πŸ§ͺ mac-wk2-stress
βœ… πŸ›  watch
βœ… πŸ›  watch-sim

@mwyrzykowski mwyrzykowski self-assigned this Mar 20, 2023
@mwyrzykowski mwyrzykowski added the WebGPU For bugs in WebGPU label Mar 20, 2023
|| destination.origin.x + widthForMetal > logicalSize.width
|| destination.origin.y + heightForMetal > logicalSize.height
|| destination.origin.z + depthForMetal > logicalSize.depthOrArrayLayers
|| sourceBytesPerRow > 2048) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

maybe 2048 should be from one of the device limits?

Copy link
Contributor

Choose a reason for hiding this comment

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

If you don't find a device limit, please document with a FIXME to come back and fix it up later.

Copy link
Contributor

@djg djg left a comment

Choose a reason for hiding this comment

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

:shipit:

if (!widthForMetal || !heightForMetal)
return;

if (widthForMetal * heightForMetal > destinationBuffer.length) {
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 think this is wrong, at least it causes a regression in compressed texture formats copyTextureToTexture cases

…TextureToBuffer/Texture

https://bugs.webkit.org/show_bug.cgi?id=254175
<radar://106958194>

Reviewed by NOBODY (OOPS!).

The correct sizes were already computed in logicalMiplevelSpecificTextureExtent
but they were not used for validation.

* Source/WebGPU/WebGPU/CommandEncoder.mm:
(WebGPU::CommandEncoder::copyBufferToTexture):
(WebGPU::CommandEncoder::copyTextureToBuffer):
* Source/WebGPU/WebGPU/Queue.mm:
(WebGPU::Queue::writeTexture):
3D textures with rowBytes > 2048 will assert in Metal in debug
and release.

* Source/WebGPU/WebGPU/Texture.mm:
(WebGPU::Texture::validateLinearTextureData):
Metal requires the copy size to be a multiple of the block size.
@mwyrzykowski mwyrzykowski force-pushed the eng/WebGPU-mip-level-validation-is-not-handled-correctly-in-copyBufferTextureToBufferTexture branch from 986ca43 to 77d269e Compare April 18, 2023 22:15
@webkit-early-warning-system
Copy link
Collaborator

Starting EWS tests for 77d269e. Live statuses available at the PR page, #11727

@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Apr 19, 2023
@mwyrzykowski
Copy link
Contributor Author

Closing since some of this validation is incorrect

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merging-blocked Applied to prevent a change from being merged WebGPU For bugs in WebGPU
Projects
None yet
4 participants