mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-15 22:28:10 +08:00
Fix
This commit is contained in:
@@ -73,7 +73,7 @@ pub fn wrap_network_in_scope(network: NodeNetwork, editor_api: Arc<PlatformEdito
|
||||
DocumentNode {
|
||||
call_argument: concrete!(Context),
|
||||
inputs: vec![
|
||||
NodeInput::scope(graphene_std::render_background::background_compositor_pipeline::IDENTIFIER),
|
||||
NodeInput::scope(graphene_std::render_background::composit_background_pipeline::IDENTIFIER),
|
||||
NodeInput::node(NodeId(3), 0),
|
||||
],
|
||||
implementation: DocumentNodeImplementation::ProtoNode(graphene_std::render_background::render_background::IDENTIFIER),
|
||||
|
||||
@@ -267,7 +267,7 @@ pub async fn editor_api<'a: 'n>(_: impl Ctx, #[scope("editor-api")] editor_api:
|
||||
}
|
||||
|
||||
#[node_macro::node(category(""))]
|
||||
pub async fn resource<'a: 'n>(_: impl Ctx, hash: ResourceHash, #[editor_api::IDENTIFIER] editor_api: &'a PlatformEditorApi) -> Resource {
|
||||
pub async fn resource<'a: 'n>(_: impl Ctx, hash: ResourceHash, #[scope(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");
|
||||
@@ -275,11 +275,11 @@ pub async fn resource<'a: 'n>(_: impl Ctx, hash: ResourceHash, #[editor_api::IDE
|
||||
}
|
||||
|
||||
#[node_macro::node(category(""), inject_scope)]
|
||||
pub async fn wgpu_executor<'a: 'n>(_: impl Ctx, #[editor_api::IDENTIFIER] editor_api: &'a PlatformEditorApi) -> &'a ::wgpu_executor::WgpuExecutor {
|
||||
pub async fn wgpu_executor<'a: 'n>(_: impl Ctx, #[scope(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> {
|
||||
pub async fn try_wgpu_executor<'a: 'n>(_: impl Ctx, #[scope(editor_api::IDENTIFIER)] editor_api: &'a PlatformEditorApi) -> Option<&'a ::wgpu_executor::WgpuExecutor> {
|
||||
editor_api.application_io.as_ref().unwrap().gpu_executor()
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ use wgpu_executor::{AsyncWgpuPipeline, WgpuExecutor, WgpuPipelineCache};
|
||||
#[node_macro::node(category(""))]
|
||||
async fn render_background<'a: 'n>(
|
||||
ctx: impl Ctx + ExtractFootprint + ExtractVarArgs,
|
||||
#[scope(background_compositor_pipeline::IDENTIFIER)] pipeline: WgpuPipelineCache,
|
||||
#[scope(composit_background_pipeline::IDENTIFIER)] pipeline: WgpuPipelineCache,
|
||||
data: RenderOutput,
|
||||
) -> RenderOutput {
|
||||
let footprint = ctx.footprint();
|
||||
@@ -36,7 +36,7 @@ async fn render_background<'a: 'n>(
|
||||
RenderOutputType::Texture(foreground_texture) => {
|
||||
let doc_to_screen = (glam::DAffine2::from_scale(glam::DVec2::splat(render_params.scale)) * render_params.footprint.transform).as_affine2();
|
||||
let blended = pipeline
|
||||
.run::<BackgroundCompositor>(&BackgroundCompositorArgs {
|
||||
.run::<CompositBackground>(&CompositBackgroundArgs {
|
||||
foreground: foreground_texture.as_ref(),
|
||||
backgrounds: &metadata.backgrounds,
|
||||
document_to_screen: doc_to_screen,
|
||||
@@ -118,16 +118,18 @@ async fn render_background<'a: 'n>(
|
||||
}
|
||||
|
||||
#[node_macro::node(category(""), inject_scope)]
|
||||
async fn background_compositor_pipeline<'a: 'n>(
|
||||
async fn composit_background_pipeline<'a: 'n>(
|
||||
_ctx: impl Ctx,
|
||||
#[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] pipeline: WgpuPipelineCache,
|
||||
) -> WgpuPipelineCache {
|
||||
executor.pipeline_init::<BackgroundCompositor>(pipeline);
|
||||
if let Some(executor) = executor {
|
||||
executor.pipeline_init::<CompositBackground>(pipeline);
|
||||
}
|
||||
pipeline.clone()
|
||||
}
|
||||
|
||||
pub struct BackgroundCompositor {
|
||||
pub struct CompositBackground {
|
||||
checker_rect_pipeline: wgpu::RenderPipeline,
|
||||
checker_viewport_pipeline: wgpu::RenderPipeline,
|
||||
fullscreen_pipeline: wgpu::RenderPipeline,
|
||||
@@ -136,15 +138,15 @@ pub struct BackgroundCompositor {
|
||||
sampler: wgpu::Sampler,
|
||||
}
|
||||
|
||||
pub struct BackgroundCompositorArgs<'a> {
|
||||
pub struct CompositBackgroundArgs<'a> {
|
||||
foreground: &'a wgpu::Texture,
|
||||
backgrounds: &'a [rendering::Background],
|
||||
document_to_screen: Affine2,
|
||||
zoom: f32,
|
||||
}
|
||||
|
||||
impl AsyncWgpuPipeline for BackgroundCompositor {
|
||||
type Args<'a> = BackgroundCompositorArgs<'a>;
|
||||
impl AsyncWgpuPipeline for CompositBackground {
|
||||
type Args<'a> = CompositBackgroundArgs<'a>;
|
||||
type Out = Arc<wgpu::Texture>;
|
||||
|
||||
fn create(executor: &WgpuExecutor) -> Self {
|
||||
@@ -327,7 +329,7 @@ impl AsyncWgpuPipeline for BackgroundCompositor {
|
||||
}
|
||||
|
||||
async fn run<'a>(&'a self, executor: &'a WgpuExecutor, args: &'a Self::Args<'_>) -> Self::Out {
|
||||
let &BackgroundCompositorArgs {
|
||||
let &CompositBackgroundArgs {
|
||||
foreground,
|
||||
backgrounds,
|
||||
document_to_screen,
|
||||
@@ -437,7 +439,7 @@ impl AsyncWgpuPipeline for BackgroundCompositor {
|
||||
}
|
||||
}
|
||||
|
||||
impl BackgroundCompositor {
|
||||
impl CompositBackground {
|
||||
fn create_checker_bind_group(&self, device: &wgpu::Device, uniforms: CompositeUniforms) -> wgpu::BindGroup {
|
||||
let buffer = device.create_buffer_init(&wgpu::util::BufferInitDescriptor {
|
||||
label: Some("background_checker_uniforms"),
|
||||
|
||||
@@ -58,7 +58,7 @@ pub async fn render_pixel_preview<'a: 'n>(
|
||||
let transform = DAffine2::from_translation(-upstream_min) * footprint.transform.inverse() * DAffine2::from_scale(logical_resolution);
|
||||
|
||||
let resampled = pipeline
|
||||
.run::<PixelPreview>(&ResamplerArgs {
|
||||
.run::<PixelPreview>(&PixelPreviewArgs {
|
||||
source: source_texture.as_ref(),
|
||||
transform: &transform,
|
||||
size: physical_resolution,
|
||||
@@ -77,10 +77,12 @@ pub async fn render_pixel_preview<'a: 'n>(
|
||||
#[node_macro::node(category(""), inject_scope)]
|
||||
async fn pixel_preview_pipeline<'a: 'n>(
|
||||
_ctx: impl Ctx,
|
||||
#[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] pipeline: WgpuPipelineCache,
|
||||
) -> WgpuPipelineCache {
|
||||
executor.pipeline_init::<PixelPreview>(pipeline);
|
||||
if let Some(executor) = executor {
|
||||
executor.pipeline_init::<PixelPreview>(pipeline);
|
||||
}
|
||||
pipeline.clone()
|
||||
}
|
||||
|
||||
@@ -89,14 +91,14 @@ pub struct PixelPreview {
|
||||
bind_group_layout: wgpu::BindGroupLayout,
|
||||
}
|
||||
|
||||
pub struct ResamplerArgs<'a> {
|
||||
pub struct PixelPreviewArgs<'a> {
|
||||
source: &'a wgpu::Texture,
|
||||
transform: &'a DAffine2,
|
||||
size: UVec2,
|
||||
}
|
||||
|
||||
impl AsyncWgpuPipeline for PixelPreview {
|
||||
type Args<'a> = ResamplerArgs<'a>;
|
||||
type Args<'a> = PixelPreviewArgs<'a>;
|
||||
type Out = Arc<wgpu::Texture>;
|
||||
|
||||
fn create(executor: &WgpuExecutor) -> Self {
|
||||
@@ -169,7 +171,7 @@ impl AsyncWgpuPipeline for PixelPreview {
|
||||
|
||||
async fn run<'a>(&'a self, executor: &'a WgpuExecutor, args: &'a Self::Args<'_>) -> Self::Out {
|
||||
let context = &executor.context();
|
||||
let &ResamplerArgs { source, transform, size } = args;
|
||||
let &PixelPreviewArgs { source, transform, size } = args;
|
||||
|
||||
let output = executor.request_texture(size).await;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user