Skip to content

Conversation

@sagudev
Copy link
Collaborator

@sagudev sagudev commented Apr 15, 2025

Connections
Fixes #7533

Description
When implementing custom beckend, one was not be able to extract actual custom type from descriptors. This is now possible by introducing as_custom method on each wgpu API type (and Dispatch* type) that are analogues to as_hal. They try to return actual concrete custom type that is stored inside custom backend and return None if backend is not custom (or user wanted wrong T).

Testing
Example is modified to cover obtaining original custom type from dynamic custom backend type.

Squash or Rebase? Squash, but it's reviewable per commit.

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.
  • If this contains user-facing changes, add a CHANGELOG.md entry.

sagudev added 2 commits April 15, 2025 10:30
Signed-off-by: sagudev <[email protected]>
Signed-off-by: sagudev <[email protected]>
@sagudev sagudev marked this pull request as ready for review April 15, 2025 08:55
@sagudev sagudev requested a review from a team as a code owner April 15, 2025 08:55
@cwfitzgerald cwfitzgerald self-assigned this Apr 16, 2025
@raphaelhetzel
Copy link
Contributor

I already use the changes in this pr to run the compute hello_world example inside wasmtime (custom backend passing the calls to wgpu running on the host).
So i can confirm that this is needed and useful.
Thanks @sagudev.

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.

Small note but otherwise fine. Just wanted to clue you in I would like to have a unified interface for as_hal, as_custom, and a potential future as_webgpu. I'm not sure exactly what this would look like, but I think having a single entry point would probably good for api consistency. This is fine to have for the mean time however.

Signed-off-by: sagudev <[email protected]>
@cwfitzgerald cwfitzgerald merged commit 6666d52 into gfx-rs:trunk Apr 18, 2025
37 checks passed
sharmajai pushed a commit to sharmajai/wgpu that referenced this pull request Oct 12, 2025
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.

Custom Backend: No api to get custom buffer during create_bind_group.

3 participants