-
Notifications
You must be signed in to change notification settings - Fork 1.3k
fix(windows): revert editor to RGBA output and fix DX12 adapter selec… #1614
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -49,14 +49,32 @@ pub struct SharedGpuContext { | |
| static GPU: OnceCell<Option<SharedGpuContext>> = OnceCell::const_new(); | ||
|
|
||
| async fn init_gpu_inner() -> Option<SharedGpuContext> { | ||
| #[cfg(target_os = "windows")] | ||
| let instance = wgpu::Instance::new(&wgpu::InstanceDescriptor { | ||
| backends: wgpu::Backends::DX12 | wgpu::Backends::VULKAN, | ||
| ..Default::default() | ||
| }); | ||
| #[cfg(not(target_os = "windows"))] | ||
| let instance = wgpu::Instance::new(&wgpu::InstanceDescriptor::default()); | ||
|
|
||
| #[cfg(target_os = "windows")] | ||
| let instance = { | ||
| let dx12_instance = wgpu::Instance::new(&wgpu::InstanceDescriptor { | ||
| backends: wgpu::Backends::DX12, | ||
| ..Default::default() | ||
| }); | ||
| let has_dx12 = dx12_instance | ||
| .request_adapter(&wgpu::RequestAdapterOptions { | ||
| power_preference: wgpu::PowerPreference::HighPerformance, | ||
| force_fallback_adapter: false, | ||
| compatible_surface: None, | ||
| }) | ||
| .await | ||
| .is_ok(); | ||
| if has_dx12 { | ||
| tracing::info!("Using DX12 backend for shared GPU context"); | ||
| dx12_instance | ||
| } else { | ||
| tracing::info!("DX12 not available for shared context, falling back to all backends"); | ||
| wgpu::Instance::new(&wgpu::InstanceDescriptor::default()) | ||
| } | ||
| }; | ||
|
Comment on lines
+55
to
+76
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Duplicated DX12 probe logic This block is identical to the one in Additionally, the probe adapter returned by Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time! Prompt To Fix With AIThis is a comment left during a code review.
Path: apps/desktop/src-tauri/src/gpu_context.rs
Line: 55:76
Comment:
**Duplicated DX12 probe logic**
This block is identical to the one in `crates/rendering/src/lib.rs:985-1006`. Both create a DX12-only instance, probe for a DX12 adapter, and fall back to default backends. Consider extracting this into a shared helper (e.g., in the rendering crate or a common utility) to keep the two initialization paths in sync and avoid divergence over time.
Additionally, the probe adapter returned by `request_adapter` on line 61-68 is immediately discarded (only `.is_ok()` is checked), and then `request_adapter` is called again on line 78-85 with the exact same options on the same `dx12_instance`. You could reuse the probe adapter directly instead of requesting it twice.
<sub>Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!</sub>
How can I resolve this? If you propose a fix, please make it concise. |
||
|
|
||
| let hardware_adapter = instance | ||
| .request_adapter(&wgpu::RequestAdapterOptions { | ||
| power_preference: wgpu::PowerPreference::HighPerformance, | ||
|
|
||
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.
Minor: logging the DX12 probe error can help distinguish “no adapter” vs driver/init failures (same pattern exists in
crates/rendering/src/lib.rs).