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

Move Arc inside dispatch enum #6848

Closed
sagudev opened this issue Jan 3, 2025 · 1 comment · Fixed by #6850
Closed

Move Arc inside dispatch enum #6848

sagudev opened this issue Jan 3, 2025 · 1 comment · Fixed by #6850

Comments

@sagudev
Copy link
Contributor

sagudev commented Jan 3, 2025

With #6665 wgpu::Adapter become Arc<dispatch::DispatchAdapter>, but we could move Arc one level lower into Dispatch*, like so:

#[derive(Debug, Clone)]
pub struct Adapter {
    pub(crate) inner: DispatchAdapter,
}

pub enum DispatchAdapter {
    #[cfg(wgpu_core)]
    Core(Arc<CoreAdapter>),
    #[cfg(webgpu)]
    WebGPU(Arc<WebAdapter>),
}

This way PartialEq, Eq, PartialOrd, Ord, Hash can start depending on inner arcs, so there would be no need to bound them on InterfaceTypes. This will make #6658 simpler and more inline with this (and will also remove more Arc indirections).

This would allow us to eventually remove Arc wrapping Core as we already have Arcs inside Core types (essentially lowering Arc even further down).

cc @cwfitzgerald

@sagudev
Copy link
Contributor Author

sagudev commented Jan 3, 2025

As noted in #6665 (comment) the only problems are &mut types (that are not clonable now anyway) so we need special handling of those (to keep old behavior). Here is how changes would look like: https://github.com/sagudev/wgpu/tree/arc-in-dispatch

SIDE-NOTE: On custom context Arc::get_mut seems good for those as only one instance allowed externally anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

1 participant