Skip to content

Conversation

madsmtm
Copy link
Contributor

@madsmtm madsmtm commented Apr 25, 2025

Description
There are a few things that make the diff in #5641 larger than it needs to be. This PR intends to reduce that by making a few syntactic changes to the codebase.

In short, the changes are to import metal types instead of prefixing with metal::, and to avoid enum variant imports, see each commit for details.

This should both make the above PR easier to review, and make it less effort for me to keep up to date.

Testing
Run cargo run --bin wgpu-examples -- cube on macOS.

Squash or Rebase?
Can be rebased, but either is fine.

Checklist

  • Run cargo fmt.
  • Run taplo format.
  • Run cargo clippy --tests. If applicable, add:
    • --target wasm32-unknown-unknown
  • Run cargo xtask test to run tests.
    • Some naga tests fail locally, but pretty sure that's not my fault.
  • If this contains user-facing changes, add a CHANGELOG.md entry.

madsmtm added 2 commits April 25, 2025 09:54
A lot of Metal types are prefixed with MTL, which makes it quite clear
where they're coming from. This means that we don't loose any clarity if
we import them instead of having them prefixed with `metal::`.

This will make it easier to migrate to `objc2-metal` since that crate is
named differently from the `metal` crate.
The `metal` crate is currently unsound regarding unknown/future enum
variants, see gfx-rs/metal-rs#209 and
rust-lang/rfcs#3803.

`objc2-metal` fixes this by emitting C enums as a newtype + constants
for each variant, but that prevents us from importing the
variants/constants. So this commit converts to a pattern that works with
that in preparation for the migration.
@madsmtm madsmtm requested a review from a team as a code owner April 25, 2025 08:17
@madsmtm madsmtm changed the title chore: Prepare for migrating to objc2-metal [metal] chore: Prepare for migrating to objc2-metal Apr 25, 2025
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.

I think the enum change is better code anyway

@cwfitzgerald cwfitzgerald merged commit 949c5af into gfx-rs:trunk Apr 25, 2025
37 checks passed
@madsmtm madsmtm deleted the prepare-objc2-metal branch April 25, 2025 19:43
@madsmtm madsmtm mentioned this pull request Apr 25, 2025
4 tasks
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.

2 participants