Skip to content

Commit a1d7a87

Browse files
committed
fix TextureBlitter texture format mismatch
1 parent 5069ece commit a1d7a87

File tree

1 file changed

+5
-10
lines changed
  • node-graph/wgpu-executor/src

1 file changed

+5
-10
lines changed

node-graph/wgpu-executor/src/lib.rs

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ use graphene_application_io::{ApplicationIo, EditorApi, SurfaceHandle, SurfaceId
88
use graphene_core::{Color, Ctx};
99
pub use graphene_svg_renderer::RenderContext;
1010
use std::sync::{Arc, Mutex};
11-
use vello::Error;
1211
use vello::{AaConfig, AaSupport, RenderParams, Renderer, RendererOptions, Scene};
1312
use wgpu::util::TextureBlitter;
1413
use wgpu::{Origin3d, SurfaceConfiguration, TextureAspect};
@@ -54,6 +53,8 @@ unsafe impl StaticType for Surface {
5453
type Static = Surface;
5554
}
5655

56+
const VELLO_SURFACE_FORMAT: wgpu::TextureFormat = wgpu::TextureFormat::Rgba8Unorm;
57+
5758
impl WgpuExecutor {
5859
pub async fn render_vello_scene(&self, scene: &Scene, surface: &WgpuSurface, size: UVec2, context: &RenderContext, background: Color) -> Result<()> {
5960
let mut guard = surface.surface.target_texture.lock().unwrap();
@@ -73,7 +74,7 @@ impl WgpuExecutor {
7374
sample_count: 1,
7475
dimension: wgpu::TextureDimension::D2,
7576
usage: wgpu::TextureUsages::STORAGE_BINDING | wgpu::TextureUsages::TEXTURE_BINDING,
76-
format: wgpu::TextureFormat::Rgba8Unorm,
77+
format: VELLO_SURFACE_FORMAT,
7778
view_formats: &[],
7879
});
7980
let view = texture.create_view(&wgpu::TextureViewDescriptor::default());
@@ -87,7 +88,7 @@ impl WgpuExecutor {
8788
&self.context.device,
8889
&SurfaceConfiguration {
8990
usage: wgpu::TextureUsages::RENDER_ATTACHMENT | wgpu::TextureUsages::STORAGE_BINDING,
90-
format: wgpu::TextureFormat::Rgba8Unorm,
91+
format: VELLO_SURFACE_FORMAT,
9192
width: size.x,
9293
height: size.y,
9394
present_mode: surface_caps.present_modes[0],
@@ -151,13 +152,7 @@ impl WgpuExecutor {
151152
}
152153

153154
pub fn create_surface_inner(&self, surface: wgpu::Surface<'static>, window_id: SurfaceId) -> Result<SurfaceHandle<Surface>> {
154-
let capabilities = surface.get_capabilities(&self.context.adapter);
155-
let format = capabilities
156-
.formats
157-
.into_iter()
158-
.find(|it| matches!(it, wgpu::TextureFormat::Rgba8Unorm | wgpu::TextureFormat::Bgra8Unorm))
159-
.ok_or(Error::UnsupportedSurfaceFormat)?;
160-
let blitter = TextureBlitter::new(&self.context.device, format);
155+
let blitter = TextureBlitter::new(&self.context.device, VELLO_SURFACE_FORMAT);
161156
Ok(SurfaceHandle {
162157
window_id,
163158
surface: Surface {

0 commit comments

Comments
 (0)