-
Notifications
You must be signed in to change notification settings - Fork 949
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
Draft
sagudev
wants to merge
10
commits into
gfx-rs:trunk
Choose a base branch
from
sagudev:custom-ctx
base: trunk
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
+1,163
−7
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sagudev
changed the title
WIP: SUpport extern context impl
WIP: Support extern context impl
Dec 4, 2024
TBH, I have no idea what's wrong with WASM. |
6 tasks
sagudev
commented
Dec 6, 2024
wgpu/src/api/instance.rs
Outdated
Comment on lines
207
to
212
#[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.
Signed-off-by: sagudev <[email protected]>
Signed-off-by: sagudev <[email protected]>
Signed-off-by: sagudev <[email protected]>
Signed-off-by: sagudev <[email protected]>
Signed-off-by: sagudev <[email protected]>
Signed-off-by: sagudev <[email protected]>
Signed-off-by: sagudev <[email protected]>
Signed-off-by: sagudev <[email protected]>
this matches wgpu-core backend Signed-off-by: sagudev <[email protected]>
Signed-off-by: sagudev <[email protected]>
Ping me if this needs looking at or you need help before it is out of draft, going to un-assign myself for bookeeeping |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.