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

Allow CAMetalLayer images to be used as storage textures #6603

Merged
merged 1 commit into from
Dec 1, 2024

Conversation

jim-ec
Copy link
Contributor

@jim-ec jim-ec commented Nov 24, 2024

Connections
Link to the issues addressed by this PR, or dependent PRs in other repositories

Description
Problem: I want to use swap chain images in compute shaders, but I cannot do this since the Metal backend does not report the storage usage flags to be supported. When adding the necessary flags, I am able to write to the swap chain images from a compute shader.

The Metal backend already sets framebufferOnly only if the usage is equivalent to COLOR_TARGET, see here, so no further changes seem to be necessary.

Testing
Explain how this change is tested.

Checklist

  • Run cargo fmt.
  • Run taplo format.
  • Run cargo clippy. If applicable, add:
    • --target wasm32-unknown-unknown
    • --target wasm32-unknown-emscripten
  • Run cargo xtask test to run tests.
  • Add change to CHANGELOG.md. See simple instructions inside file.

@jim-ec jim-ec requested a review from a team as a code owner November 24, 2024 16:46
@teoxoy
Copy link
Member

teoxoy commented Nov 25, 2024

Do all of the formats support this?

@jim-ec
Copy link
Contributor Author

jim-ec commented Nov 26, 2024

I tested all formats supported by my system and all of them worked:

  • Bgra8Unorm
  • Rgba16Float
  • Rgb10a2Unorm

And all worked when adjusting the storage format of the storage texture binding in the compute shader.

@teoxoy
Copy link
Member

teoxoy commented Nov 27, 2024

Looking at https://developer.apple.com/metal/Metal-Feature-Set-Tables.pdf I think this should work but I'm not too versed in the surface code.

@cwfitzgerald do you see any issue with adding these usage flags?

Copy link
Member

@cwfitzgerald cwfitzgerald left a comment

Choose a reason for hiding this comment

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

Yeah this is probably okay.

@cwfitzgerald cwfitzgerald merged commit 61dc75e into gfx-rs:trunk Dec 1, 2024
27 checks passed
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