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 option to initialize with existing wgpu instance/adapter/device/queue #5319

Merged
merged 7 commits into from
Oct 29, 2024

Conversation

ArthurBrussee
Copy link
Contributor

When mixing and matching eframe with other wgpu applications (https://github.com/tracel-ai/burn in my case), it can be helpful to use an existing wgpu setup to initialize eframe with. This PR changes the WpuConfiguration (in a non-backwards compat way :/), to either take some options how to create a wgpu setup, or an existing wgpu setup (consisting of an instance, adapter, device and queue).

  • I have followed the instructions in the PR template

Copy link

Preview available at https://egui-pr-preview.github.io/pr/5319-custom-device
Note that it might take a couple seconds for the update to show up after the preview_build workflow has completed.

Copy link
Collaborator

@Wumpf Wumpf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! I really like having this hook in there.
Comments are entirely about naming & docs, approach & structure looks good to me!

Comment on lines 291 to 292
/// * `WGPU_BACKEND`: `vulkan`, `dx11`, `dx12`, `metal`, `opengl`, `webgpu`
/// * `WGPU_POWER_PREF`: `low`, `high` or `none`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice, thanks for documenting that! But it should point out that these are only used for picking the default, nothing else

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've moved this closer to where they are actually used. Maybe they're a bit too hidden now, but idk!

crates/egui-wgpu/src/lib.rs Outdated Show resolved Hide resolved
crates/egui-wgpu/src/lib.rs Outdated Show resolved Hide resolved
crates/egui-wgpu/src/lib.rs Outdated Show resolved Hide resolved
crates/egui-wgpu/src/lib.rs Outdated Show resolved Hide resolved
@ArthurBrussee
Copy link
Contributor Author

Thanks for the speedy review :D Much better names now, definitely was a bit too quick as I adopted this from existing adapter selection code.

@Wumpf Wumpf self-requested a review October 29, 2024 16:10
Copy link
Collaborator

@Wumpf Wumpf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks again!

crates/egui-wgpu/src/lib.rs Outdated Show resolved Hide resolved
@Wumpf Wumpf merged commit 759a0b2 into emilk:master Oct 29, 2024
25 checks passed
@Wumpf Wumpf changed the title Add option to initialize on existing wgpu setup Add option to initialize with existing wgpu instance/adapter/device/queue Oct 29, 2024
hacknus pushed a commit to hacknus/egui that referenced this pull request Oct 30, 2024
When mixing and matching eframe with other wgpu applications
(https://github.com/tracel-ai/burn in my case), it can be helpful to use
an existing wgpu setup to initialize eframe with. This PR changes the
WpuConfiguration (in a non-backwards compat way :/), to either take some
options how to create a wgpu setup, or an existing wgpu setup
(consisting of an instance, adapter, device and queue).

* [x] I have followed the instructions in the PR template

---------

Co-authored-by: Andreas Reich <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants