mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-29 00:58:11 +08:00
Store the wgpu executor as an Arc and restore the upload texture node
This commit is contained in:
@@ -9,7 +9,7 @@ pub use graphene_application_io::ApplicationIo;
|
|||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct PlatformApplicationIo {
|
pub struct PlatformApplicationIo {
|
||||||
#[cfg(feature = "wgpu")]
|
#[cfg(feature = "wgpu")]
|
||||||
gpu_executor: Option<WgpuExecutor>,
|
gpu_executor: Option<std::sync::Arc<WgpuExecutor>>,
|
||||||
resources: Option<Box<dyn resource::LoadResource>>,
|
resources: Option<Box<dyn resource::LoadResource>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -26,7 +26,7 @@ impl PlatformApplicationIo {
|
|||||||
|
|
||||||
Self {
|
Self {
|
||||||
#[cfg(feature = "wgpu")]
|
#[cfg(feature = "wgpu")]
|
||||||
gpu_executor: executor,
|
gpu_executor: executor.map(std::sync::Arc::new),
|
||||||
resources: None,
|
resources: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -39,7 +39,7 @@ impl PlatformApplicationIo {
|
|||||||
set_wgpu_available(wgpu_available);
|
set_wgpu_available(wgpu_available);
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
gpu_executor: executor,
|
gpu_executor: executor.map(std::sync::Arc::new),
|
||||||
resources: None,
|
resources: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -57,7 +57,12 @@ impl ApplicationIo for PlatformApplicationIo {
|
|||||||
|
|
||||||
#[cfg(feature = "wgpu")]
|
#[cfg(feature = "wgpu")]
|
||||||
fn gpu_executor(&self) -> Option<&Self::Executor> {
|
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<std::sync::Arc<Self::Executor>> {
|
||||||
|
self.gpu_executor.clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn load_resource(&self, hash: resource::ResourceHash) -> resource::ResourceFuture<'_> {
|
fn load_resource(&self, hash: resource::ResourceHash) -> resource::ResourceFuture<'_> {
|
||||||
|
|||||||
@@ -21,6 +21,9 @@ pub trait ApplicationIo {
|
|||||||
fn gpu_executor(&self) -> Option<&Self::Executor> {
|
fn gpu_executor(&self) -> Option<&Self::Executor> {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
fn gpu_executor_arc(&self) -> Option<Arc<Self::Executor>> {
|
||||||
|
None
|
||||||
|
}
|
||||||
fn load_resource(&self, hash: resource::ResourceHash) -> resource::ResourceFuture<'_>;
|
fn load_resource(&self, hash: resource::ResourceHash) -> resource::ResourceFuture<'_>;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -31,6 +34,10 @@ impl<T: ApplicationIo> ApplicationIo for &T {
|
|||||||
(**self).gpu_executor()
|
(**self).gpu_executor()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn gpu_executor_arc(&self) -> Option<Arc<T::Executor>> {
|
||||||
|
(**self).gpu_executor_arc()
|
||||||
|
}
|
||||||
|
|
||||||
fn load_resource(&self, hash: resource::ResourceHash) -> resource::ResourceFuture<'_> {
|
fn load_resource(&self, hash: resource::ResourceHash) -> resource::ResourceFuture<'_> {
|
||||||
(**self).load_resource(hash)
|
(**self).load_resource(hash)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -84,3 +84,15 @@ impl<'i> Convert<List<Raster<CPU>>, &'i WgpuExecutor> for List<Raster<CPU>> {
|
|||||||
self
|
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<List<Raster<GPU>>, &'a WgpuExecutor>>(
|
||||||
|
_: impl Ctx,
|
||||||
|
#[implementations(List<Raster<CPU>>, List<Raster<GPU>>)] input: T,
|
||||||
|
executor: &'a WgpuExecutor,
|
||||||
|
) -> List<Raster<GPU>> {
|
||||||
|
input.convert(Footprint::DEFAULT, executor)
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user