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

Add raw_handle method for metal texture #6894

Merged
merged 3 commits into from
Jan 11, 2025

Conversation

ericszentivanyi
Copy link
Contributor

@ericszentivanyi ericszentivanyi commented Jan 11, 2025

Connections

Description
The problem was that a raw Metal texture was inaccessiable whereas a Vulkan texture could be with the raw_handle method. To fix this, I've implemented the raw_handle method which returns a reference to a metal::Texture.

Once a &metal::Texture is received through the method, it can be used through .clone to prevent a lifetime error and because metal::Texture does not implement the Copy trait as opposed to vk::Image.

Testing

Example:

let raw_texture = unsafe {
  texture.as_hal::<wgpu_hal::api::Metal, _, _>(|texture| {
    texture.unwrap().raw_handle().clone()
  })
};

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.

@cwfitzgerald
Copy link
Member

Thanks!

@cwfitzgerald cwfitzgerald added this pull request to the merge queue Jan 11, 2025
Merged via the queue into gfx-rs:trunk with commit 4efc992 Jan 11, 2025
29 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.

raw_handle method for Metal texture in wgpu-hal
2 participants