-
Notifications
You must be signed in to change notification settings - Fork 963
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
WIP: Support extern context impl #6658
base: trunk
Are you sure you want to change the base?
Conversation
TBH, I have no idea what's wrong with WASM. |
wgpu/src/api/instance.rs
Outdated
#[doc(hidden)] | ||
/// Creates Instance from custom context implementation | ||
pub fn from_custom_instance(instance: std::sync::Arc<dyn InstanceInterface>) -> Self { | ||
Self { | ||
inner: dispatch::DispatchInstance::Custom(backend::custom::DynContext::new(instance)), | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is triggering visibility problems for WASM, but I do not know why.
9090201
to
088532e
Compare
Ping me if this needs looking at or you need help before it is out of draft, going to un-assign myself for bookeeeping |
Signed-off-by: sagudev <[email protected]>
Signed-off-by: sagudev <[email protected]>
In 79ecded I removed InterfaceTypes trait as it's not really needed anymore (this makes writing Custom/Dyn wrappers easier as they do not need to impl traits directly, avoiding a lot of boilerplate), all bounds are actually enforced in |
Hmm... I don't love it as it makes things less structured, but can't see a strong argument against removing the trait. Will fully consider it when I review this. You can leave it as part of this PR for now. |
I have alternative approach in sagudev@ce58280 which keeps the trait but instead of using interfaces in bounds it uses |
Connections
Based on #6619, fixes #6330
Description
This PR enables users of wgpu to provide custom Instance impl (and other wgpu types as all other types are derived from Instance->Adapter->Device), by adding
Custom
variant and custom backend that has dyn wrapper for all types:struct DynDevice(Arc<dyn DeviceInterface>)
. I'm intermixing Custom with Dyn because I cannot really decide on name (CustomDevice
is weird, but we already have Dyn* in wgpu-hal).There are few rough sports:
RenderBundleEncoderInterface::finish
(other backends hacks around by not using dyn dispatch, but we can't:wgpu/wgpu/src/api/render_bundle_encoder.rs
Lines 54 to 60 in b876b8c
InstanceInterface::new
cannot work because we cannot use dyn dispatch to create new instance (instance must be created by consumer)unimplemented!
future work:
Testing
For testing we simply pass wgpu-core/webgpu as dyn Instance (be5acfa), so this works, but I plan to do example of creating dummy interface (for testing purposes).
Checklist
cargo fmt
.taplo format
.cargo clippy
. If applicable, add:--target wasm32-unknown-unknown
--target wasm32-unknown-emscripten
cargo xtask test
to run tests.CHANGELOG.md
. See simple instructions inside file.