This commit is contained in:
Timon
2026-06-16 20:30:11 +00:00
parent 78618d28a8
commit c5bd8acce9
5 changed files with 24 additions and 11 deletions

View File

@@ -261,8 +261,13 @@ where
)
}
#[node_macro::node(category(""), inject_scope)]
pub async fn editor_api<'a: 'n>(_: impl Ctx, #[scope("editor-api")] editor_api: &'a PlatformEditorApi) -> &'a PlatformEditorApi {
editor_api
}
#[node_macro::node(category(""))]
pub async fn resource<'a: 'n>(_: impl Ctx, hash: ResourceHash, #[scope("editor-api")] editor_api: &'a PlatformEditorApi) -> Resource {
pub async fn resource<'a: 'n>(_: impl Ctx, hash: ResourceHash, #[editor_api::IDENTIFIER] editor_api: &'a PlatformEditorApi) -> Resource {
let application_io = editor_api.application_io.as_ref().expect("ApplicationIo must be available when using resources");
application_io.load_resource(hash).await.unwrap_or_else(|| {
panic!("Resource {hash} not found");
@@ -270,6 +275,11 @@ pub async fn resource<'a: 'n>(_: impl Ctx, hash: ResourceHash, #[scope("editor-a
}
#[node_macro::node(category(""), inject_scope)]
pub async fn wgpu_executor<'a: 'n>(_: impl Ctx, #[scope("editor-api")] editor_api: &'a PlatformEditorApi) -> &'a ::wgpu_executor::WgpuExecutor {
pub async fn wgpu_executor<'a: 'n>(_: impl Ctx, #[editor_api::IDENTIFIER] editor_api: &'a PlatformEditorApi) -> &'a ::wgpu_executor::WgpuExecutor {
editor_api.application_io.as_ref().unwrap().gpu_executor().expect("GPU executor not available")
}
#[node_macro::node(category(""), inject_scope)]
pub async fn try_wgpu_executor<'a: 'n>(_: impl Ctx, #[editor_api::IDENTIFIER] editor_api: &'a PlatformEditorApi) -> Option<&'a ::wgpu_executor::WgpuExecutor> {
editor_api.application_io.as_ref().unwrap().gpu_executor()
}

View File

@@ -326,8 +326,8 @@ fn flood_fill(start: &TileCoord, tile_set: &HashSet<TileCoord>, visited: &mut Ha
#[node_macro::node(category(""))]
pub async fn render_output_cache<'a: 'n>(
ctx: impl Ctx + ExtractAll + CloneVarArgs + ExtractRealTime + ExtractAnimationTime + ExtractPointerPosition + Sync,
#[scope(crate::platform_application_io::wgpu_executor::IDENTIFIER)] executor: &'a WgpuExecutor,
#[scope("editor-api")] editor_api: &'a PlatformEditorApi,
#[scope(crate::platform_application_io::try_wgpu_executor::IDENTIFIER)] executor: Option<&'a WgpuExecutor>,
#[scope(crate::platform_application_io::editor_api::IDENTIFIER)] editor_api: &'a PlatformEditorApi,
data: impl Node<Context<'static>, Output = RenderOutput> + Send + Sync,
#[data] tile_cache: TileCache,
) -> RenderOutput {
@@ -404,8 +404,8 @@ pub async fn render_output_cache<'a: 'n>(
return data.eval(context.into_context()).await;
}
let executor = executor.expect("GPU executor not available");
let output_texture = executor.request_texture(physical_resolution).await;
let combined_metadata = composite_cached_regions(&all_regions, &output_texture, &device_origin_offset, &footprint.transform, &executor);
RenderOutput {

View File

@@ -75,7 +75,7 @@ async fn render_intermediate<'a: 'n, T: 'static + Render + WasmNotSend + Send +
#[node_macro::node(category(""))]
async fn render<'a: 'n>(
ctx: impl Ctx + ExtractFootprint + ExtractVarArgs,
#[scope(crate::platform_application_io::wgpu_executor::IDENTIFIER)] executor: &'a WgpuExecutor,
#[scope(crate::platform_application_io::try_wgpu_executor::IDENTIFIER)] executor: Option<&'a WgpuExecutor>,
data: RenderIntermediate,
) -> RenderOutput {
let footprint = ctx.footprint();
@@ -133,6 +133,7 @@ async fn render<'a: 'n>(
}
let texture = executor
.expect("GPU executor not available")
.render_vello_scene(&transformed_scene, physical_resolution, context, None)
.await
.expect("Failed to render Vello scene");