diff --git a/node-graph/graph-craft/src/application_io.rs b/node-graph/graph-craft/src/application_io.rs index cd2304da31..4e4ebc5b95 100644 --- a/node-graph/graph-craft/src/application_io.rs +++ b/node-graph/graph-craft/src/application_io.rs @@ -9,7 +9,7 @@ pub use graphene_application_io::ApplicationIo; #[derive(Default)] pub struct PlatformApplicationIo { #[cfg(feature = "wgpu")] - gpu_executor: Option, + gpu_executor: Option>, resources: Option>, } @@ -26,7 +26,7 @@ impl PlatformApplicationIo { Self { #[cfg(feature = "wgpu")] - gpu_executor: executor, + gpu_executor: executor.map(std::sync::Arc::new), resources: None, } } @@ -39,7 +39,7 @@ impl PlatformApplicationIo { set_wgpu_available(wgpu_available); Self { - gpu_executor: executor, + gpu_executor: executor.map(std::sync::Arc::new), resources: None, } } @@ -57,7 +57,12 @@ impl ApplicationIo for PlatformApplicationIo { #[cfg(feature = "wgpu")] fn gpu_executor(&self) -> Option<&Self::Executor> { - self.gpu_executor.as_ref() + self.gpu_executor.as_deref() + } + + #[cfg(feature = "wgpu")] + fn gpu_executor_arc(&self) -> Option> { + self.gpu_executor.clone() } fn load_resource(&self, hash: resource::ResourceHash) -> resource::ResourceFuture<'_> { diff --git a/node-graph/libraries/application-io/src/lib.rs b/node-graph/libraries/application-io/src/lib.rs index 1b5fbe3115..5534cdacb1 100644 --- a/node-graph/libraries/application-io/src/lib.rs +++ b/node-graph/libraries/application-io/src/lib.rs @@ -21,6 +21,9 @@ pub trait ApplicationIo { fn gpu_executor(&self) -> Option<&Self::Executor> { None } + fn gpu_executor_arc(&self) -> Option> { + None + } fn load_resource(&self, hash: resource::ResourceHash) -> resource::ResourceFuture<'_>; } @@ -31,6 +34,10 @@ impl ApplicationIo for &T { (**self).gpu_executor() } + fn gpu_executor_arc(&self) -> Option> { + (**self).gpu_executor_arc() + } + fn load_resource(&self, hash: resource::ResourceHash) -> resource::ResourceFuture<'_> { (**self).load_resource(hash) } diff --git a/node-graph/libraries/wgpu-executor/src/texture_conversion.rs b/node-graph/libraries/wgpu-executor/src/texture_conversion.rs index 872b55678c..385e432a18 100644 --- a/node-graph/libraries/wgpu-executor/src/texture_conversion.rs +++ b/node-graph/libraries/wgpu-executor/src/texture_conversion.rs @@ -84,3 +84,15 @@ impl<'i> Convert>, &'i WgpuExecutor> for List> { self } } + +/// Uploads an raster texture from the CPU to the GPU. This is now deprecated and the Convert node should be used in the future. +/// +/// Accepts either individual raster data or a `List` of raster elements and converts it to the GPU format using the WgpuExecutor's device and queue. +#[node_macro::node(category(""))] +pub fn upload_texture<'a, T: Convert>, &'a WgpuExecutor>>( + _: impl Ctx, + #[implementations(List>, List>)] input: T, + executor: &'a WgpuExecutor, +) -> List> { + input.convert(Footprint::DEFAULT, executor) +}