Skip to content

Commit 1ad5ed2

Browse files
committed
use direct copy for chrome and convert for firefox
1 parent fbbeadd commit 1ad5ed2

File tree

1 file changed

+24
-5
lines changed

1 file changed

+24
-5
lines changed

editor/src/node_graph_executor/runtime.rs

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -365,11 +365,30 @@ impl NodeRuntime {
365365
let surface_texture = surface_inner.get_current_texture().expect("Failed to get surface texture");
366366
self.current_viewport_texture = Some(image_texture.clone());
367367

368-
// Use the blitter to copy the texture to the surface, handling format conversion
369-
// (e.g., Rgba8Unorm source to Bgra8Unorm surface on Firefox)
370-
let source_view = image_texture.texture.create_view(&vello::wgpu::TextureViewDescriptor::default());
371-
let target_view = surface_texture.texture.create_view(&vello::wgpu::TextureViewDescriptor::default());
372-
surface.surface.blitter.copy(&executor.context.device, &mut encoder, &source_view, &target_view);
368+
// Only use the blitter if formats differ, otherwise use efficient direct copy
369+
if surface.surface.format == vello::wgpu::TextureFormat::Rgba8Unorm {
370+
// Same format as Vello's output - use direct texture copy
371+
encoder.copy_texture_to_texture(
372+
vello::wgpu::TexelCopyTextureInfoBase {
373+
texture: image_texture.texture.as_ref(),
374+
mip_level: 0,
375+
origin: Default::default(),
376+
aspect: Default::default(),
377+
},
378+
vello::wgpu::TexelCopyTextureInfoBase {
379+
texture: &surface_texture.texture,
380+
mip_level: 0,
381+
origin: Default::default(),
382+
aspect: Default::default(),
383+
},
384+
image_texture.texture.size(),
385+
);
386+
} else {
387+
// Different format (e.g., Firefox's Bgra8Unorm on Mac) - use blitter for conversion
388+
let source_view = image_texture.texture.create_view(&vello::wgpu::TextureViewDescriptor::default());
389+
let target_view = surface_texture.texture.create_view(&vello::wgpu::TextureViewDescriptor::default());
390+
surface.surface.blitter.copy(&executor.context.device, &mut encoder, &source_view, &target_view);
391+
}
373392

374393
executor.context.queue.submit([encoder.finish()]);
375394
surface_texture.present();

0 commit comments

Comments
 (0)