Add COPY_SRC to Metal's surface usage bits.#4852
Merged
Wumpf merged 1 commit intogfx-rs:trunkfrom Dec 10, 2023
Toqozz:Toqozz-copysrc
Merged
Add COPY_SRC to Metal's surface usage bits.#4852Wumpf merged 1 commit intogfx-rs:trunkfrom Toqozz:Toqozz-copysrc
Wumpf merged 1 commit intogfx-rs:trunkfrom
Toqozz:Toqozz-copysrc
Conversation
Wumpf
approved these changes
Dec 9, 2023
Member
Wumpf
left a comment
There was a problem hiding this comment.
Thanks for the fix!
Digged around a tiny bit as well and also couldn't find any reason why the texture shouldn't be copyable.
Could you please add a brief changelog line about this bugfix?
Contributor
Author
|
Sure thing. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
On machines running Metal, we could not configure surfaces with the
COPY_SRCusage flag. This flag is used a pretty often on platforms that do support it, and often you'll have macOS users submitting a bug to the root project, which requires them to implement a backbuffer or some other workaround.See "Discussion".
Testing
The simplest way to test is to add a wgpu::TextureUsages::COPY_SRC usage flag to hello_triangle example's surface configuration. Prior to this change (and given you're on macOS), you'll get a panic Error in Surface::configure: requested usage is not supported. This change fixes the panic.
Discussion
I can't find anything that says why this shouldn't be/isn't possible. I've tested the change on an M1 Pro Macbook which works without any issues, and I've even run it with Metal API validation enabled -- no errors. I found this pull request from Feb 2022, which added the
COPY_DSTflag with similar concerns, but no real answers.From reading the Metal documentation (I'm a novice, to be clear), it seems that the flag that really matters is
isFrameBufferOnly, which we already set appropriately depending on whether the texture usage is onlyRENDER_ATTACHMENT.So everything seems fine. We could probably allow more flags, but this at least brings things in line with DX12.