Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

fix(windows): revert editor to RGBA output and fix DX12 adapter selection

Cursor Agentd045c4f81719
diff --git a/apps/desktop/src-tauri/src/gpu_context.rs b/apps/desktop/src-tauri/src/gpu_context.rs
index d9f8ac622..4fb5fe6da 100644
--- a/apps/desktop/src-tauri/src/gpu_context.rs
+++ b/apps/desktop/src-tauri/src/gpu_context.rs
@@ -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())
+ }
+ };
+
let hardware_adapter = instance
.request_adapter(&wgpu::RequestAdapterOptions {
power_preference: wgpu::PowerPreference::HighPerformance,
diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs
index d7ce869c9..f378538a0 100644
--- a/crates/editor/src/editor.rs
+++ b/crates/editor/src/editor.rs
@@ -147,48 +147,20 @@ impl Renderer {
break;
}
}
- let nv12_result = frame_renderer
- .render_nv12(
- current.segment_frames.clone(),
- current.uniforms.clone(),
+ match frame_renderer
+ .render_immediate(
+ current.segment_frames,
+ current.uniforms,
&current.cursor,
&mut layers,
)
- .await;
-
- match nv12_result {
- Ok(pipeline_frame) => {
- if let Some(prev) = pipeline_frame {
- (self.frame_cb)(EditorFrameOutput::Nv12(prev));
- }
- match frame_renderer.flush_pipeline_nv12().await {
- Some(Ok(current_frame)) => {
- (self.frame_cb)(EditorFrameOutput::Nv12(current_frame));
- }
- Some(Err(e)) => {
- tracing::warn!(error = %e, "Failed to flush NV12 pipeline frame");
- }
- None => {}
- }
+ .await
+ {
+ Ok(frame) => {
+ (self.frame_cb)(EditorFrameOutput::Rgba(frame));
}
Err(e) => {
- tracing::warn!(error = %e, "NV12 render failed, falling back to RGBA");
- match frame_renderer
- .render_immediate(
- current.segment_frames,
- current.uniforms,
- &current.cursor,
- &mut layers,
- )
- .await
- {
- Ok(frame) => {
- (self.frame_cb)(EditorFrameOutput::Rgba(frame));
- }
- Err(e) => {
- tracing::error!(error = %e, "Failed to render frame in editor");
- }
- }
+ tracing::error!(error = %e, "Failed to render frame in editor");
}
}
diff --git a/crates/rendering/src/lib.rs b/crates/rendering/src/lib.rs
index 5690609fe..14ce7b3d5 100644
--- a/crates/rendering/src/lib.rs
+++ b/crates/rendering/src/lib.rs
@@ -979,14 +979,32 @@ impl RenderVideoConstants {
.map(|c| XY::new(c.width, c.height)),
};
- #[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 optimal D3D11 interop");
+ dx12_instance
+ } else {
+ tracing::info!("DX12 not available, falling back to all backends");
+ wgpu::Instance::new(&wgpu::InstanceDescriptor::default())
+ }
+ };
+
let hardware_adapter = instance
.request_adapter(&wgpu::RequestAdapterOptions {
power_preference: wgpu::PowerPreference::HighPerformance,