diff --git a/node-graph/gstd/src/wasm_application_io.rs b/node-graph/gstd/src/wasm_application_io.rs index 834ec28c..54a8d34e 100644 --- a/node-graph/gstd/src/wasm_application_io.rs +++ b/node-graph/gstd/src/wasm_application_io.rs @@ -110,6 +110,8 @@ fn render_svg(data: impl GraphicElementRendered, mut render: SvgRender, render_p #[cfg(feature = "vello")] #[cfg_attr(not(target_arch = "wasm32"), allow(dead_code))] async fn render_canvas(render_config: RenderConfig, data: impl GraphicElementRendered, editor: &WasmEditorApi, surface_handle: wgpu_executor::WgpuSurface) -> RenderOutput { + use graphene_core::SurfaceFrame; + if let Some(exec) = editor.application_io.as_ref().unwrap().gpu_executor() { use vello::*; @@ -129,11 +131,12 @@ async fn render_canvas(render_config: RenderConfig, data: impl GraphicElementRen } else { unreachable!("Attempted to render with Vello when no GPU executor is available"); } - let frame = graphene_core::application_io::SurfaceHandleFrame { - surface_handle, + let frame = SurfaceFrame { + surface_id: surface_handle.window_id, + resolution: render_config.viewport.resolution, transform: glam::DAffine2::IDENTITY, }; - RenderOutput::CanvasFrame(frame.into()) + RenderOutput::CanvasFrame(frame) } #[cfg(target_arch = "wasm32")] diff --git a/node-graph/wgpu-executor/src/lib.rs b/node-graph/wgpu-executor/src/lib.rs index 3ee4faa6..404e8be0 100644 --- a/node-graph/wgpu-executor/src/lib.rs +++ b/node-graph/wgpu-executor/src/lib.rs @@ -505,24 +505,28 @@ impl WgpuExecutor { } #[cfg(target_arch = "wasm32")] - pub fn create_surface(&self, canvas: graphene_core::WasmSurfaceHandle, resolution: Option) -> Result> { + pub fn create_surface(&self, canvas: graphene_core::WasmSurfaceHandle) -> Result> { let surface = self.context.instance.create_surface(wgpu::SurfaceTarget::Canvas(canvas.surface))?; - let resolution = resolution.unwrap_or(UVec2::new(1920, 1080)); Ok(SurfaceHandle { window_id: canvas.window_id, - surface: Surface { inner: surface, resolution }, + surface: Surface { + inner: surface, + resolution: UVec2::ZERO, + }, }) } #[cfg(not(target_arch = "wasm32"))] - pub fn create_surface(&self, window: SurfaceHandle, resolution: Option) -> Result> { + pub fn create_surface(&self, window: SurfaceHandle) -> Result> { let size = window.surface.inner_size(); - let resolution = resolution.unwrap_or(UVec2 { x: size.width, y: size.height }); let surface = self.context.instance.create_surface(wgpu::SurfaceTarget::Window(Box::new(window.surface)))?; Ok(SurfaceHandle { window_id: window.window_id, - surface: Surface { inner: surface, resolution }, + surface: Surface { + inner: surface, + resolution: UVec2::ZERO, + }, }) } } @@ -907,17 +911,7 @@ pub struct CreateGpuSurfaceNode; async fn create_gpu_surface<'a: 'input, Io: ApplicationIo + 'a + Send + Sync>(editor_api: &'a EditorApi) -> Option { let canvas = editor_api.application_io.as_ref()?.window()?; let executor = editor_api.application_io.as_ref()?.gpu_executor()?; - Some(Arc::new(executor.create_surface(canvas, None).ok()?)) -} -pub struct ConfigureGpuSurfaceNode { - editor_api: EditorApi, -} - -#[node_macro::node_fn(ConfigureGpuSurfaceNode)] -async fn create_gpu_surface<'a: 'input, Io: ApplicationIo + 'a + Send + Sync>(resolution: UVec2, editor_api: &'a EditorApi) -> Option { - let canvas = editor_api.application_io.as_ref()?.create_window(); - let executor = editor_api.application_io.as_ref()?.gpu_executor()?; - Some(Arc::new(executor.create_surface(canvas, Some(resolution)).ok()?)) + Some(Arc::new(executor.create_surface(canvas).ok()?)) } pub struct RenderTextureNode {