Metal / MSL external texture implementation #8117
Open
+1,358
−447
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.
Connections
Part of #4386
Description
Metal / MSL implementation of external textures. Similar to HLSL and DX12 implementation in #7826 and #8037
The first commit is a refactoring to split
Writer::write_wrapped_functions()
in to a separate function for each expression type. This has no functional change, just splits an already large function into smaller chunks in preparation for even more expression types being wrapped.The second commit makes the external texture snapshot test slightly more interesting.
The third commit contains the MSL changes. These are basically exactly the same as the HLSL equivalent, the main difference being that MSL actually allows us to wrap textures in structs, meaning we are able to declare a type
NagaExternalTextureWrapper
which contains fields for each texture plane and the params buffer. We construct an instance of this for each global external texture passed into the entry point, and are then able to pass it around as a single parameter rather than having to pass each plane and the params struct separately.The last commit contains the Metal HAL changes. We just need to create a resource binding for each plane and the params buffer. We also need to ensure that the parameters buffer's size matches the type of the MSL struct it is bound to, otherwise metal complains.
Testing
Covered by existing Naga snapshot and gpu tests
Squash or Rebase?
Rebase. I'll add fixup commits if required during review, then will manually squash these as appropriate prior to merging
Checklist
cargo fmt
.taplo format
.cargo clippy --tests
. If applicable, add:--target wasm32-unknown-unknown
cargo xtask test
to run tests.CHANGELOG.md
entry.