mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-17 23:38:06 +08:00
* Implement skeleton for graphene-cli * Configure gpu surface on non wasm32 targets * Create window with full hd size * Create window using the graphen-cli * Use window size for surface creation * Reuse surface configuration * Reduce window size for native applications to 800x600 * Add compute pipeline test * Poll wgpu execution externally * Remove cache node after texture upload * Add profiling instructions * Add more debug markers * Evaluate extract node before flattening the network * Reenable hue saturation node for compilation * Make hue saturation node work on the gpu + make f32 default for user inputs * Add version of test files without caching * Only dispatch each workgroup not pixel * ICE * Add quantization to gpu code * Fix quantization * Load images at graph runtime * Fix quantization calculation * Feature gate quantization * Use git version of autoquant * Add license to `graphene-cli` * Fix graphene-cli test case * Ignore tests on non unix platforms * Fix flattening test
171 lines
4.0 KiB
Rust
171 lines
4.0 KiB
Rust
#![cfg_attr(not(feature = "std"), no_std)]
|
|
|
|
#[cfg(feature = "alloc")]
|
|
extern crate alloc;
|
|
|
|
#[cfg_attr(feature = "log", macro_use)]
|
|
#[cfg(feature = "log")]
|
|
extern crate log;
|
|
|
|
pub mod consts;
|
|
pub mod generic;
|
|
pub mod ops;
|
|
pub mod structural;
|
|
#[cfg(feature = "std")]
|
|
pub mod text;
|
|
#[cfg(feature = "std")]
|
|
pub mod uuid;
|
|
pub mod value;
|
|
|
|
#[cfg(feature = "gpu")]
|
|
pub mod gpu;
|
|
|
|
#[cfg(feature = "alloc")]
|
|
pub mod memo;
|
|
pub mod storage;
|
|
|
|
pub mod raster;
|
|
#[cfg(feature = "alloc")]
|
|
pub mod transform;
|
|
|
|
#[cfg(feature = "alloc")]
|
|
mod graphic_element;
|
|
#[cfg(feature = "alloc")]
|
|
pub use graphic_element::*;
|
|
#[cfg(feature = "alloc")]
|
|
pub mod vector;
|
|
|
|
#[cfg(feature = "alloc")]
|
|
pub mod application_io;
|
|
|
|
pub mod quantization;
|
|
|
|
use core::any::TypeId;
|
|
pub use raster::Color;
|
|
|
|
// pub trait Node: for<'n> NodeIO<'n> {
|
|
pub trait Node<'i, Input: 'i>: 'i {
|
|
type Output: 'i;
|
|
fn eval(&'i self, input: Input) -> Self::Output;
|
|
fn reset(&self) {}
|
|
#[cfg(feature = "std")]
|
|
fn serialize(&self) -> Option<std::sync::Arc<dyn core::any::Any>> {
|
|
log::warn!("Node::serialize not implemented for {}", core::any::type_name::<Self>());
|
|
None
|
|
}
|
|
}
|
|
|
|
pub trait NodeMut<'i, Input: 'i>: 'i {
|
|
type MutOutput: 'i;
|
|
fn eval_mut(&'i mut self, input: Input) -> Self::MutOutput;
|
|
}
|
|
|
|
pub trait NodeOnce<'i, Input>
|
|
where
|
|
Input: 'i,
|
|
{
|
|
type OnceOutput: 'i;
|
|
fn eval_once(self, input: Input) -> Self::OnceOutput;
|
|
}
|
|
|
|
impl<'i, T: Node<'i, I>, I: 'i> NodeOnce<'i, I> for &'i T {
|
|
type OnceOutput = T::Output;
|
|
fn eval_once(self, input: I) -> Self::OnceOutput {
|
|
(self).eval(input)
|
|
}
|
|
}
|
|
impl<'i, T: Node<'i, I> + ?Sized, I: 'i> NodeMut<'i, I> for &'i T {
|
|
type MutOutput = T::Output;
|
|
fn eval_mut(&'i mut self, input: I) -> Self::MutOutput {
|
|
(*self).eval(input)
|
|
}
|
|
}
|
|
|
|
#[cfg(feature = "alloc")]
|
|
mod types;
|
|
#[cfg(feature = "alloc")]
|
|
pub use types::*;
|
|
|
|
pub trait NodeIO<'i, Input: 'i>: 'i + Node<'i, Input>
|
|
where
|
|
Self::Output: 'i + StaticTypeSized,
|
|
Input: 'i + StaticTypeSized,
|
|
{
|
|
fn node_name(&self) -> &'static str {
|
|
core::any::type_name::<Self>()
|
|
}
|
|
|
|
fn input_type(&self) -> TypeId {
|
|
TypeId::of::<Input::Static>()
|
|
}
|
|
fn input_type_name(&self) -> &'static str {
|
|
core::any::type_name::<Input>()
|
|
}
|
|
fn output_type(&self) -> core::any::TypeId {
|
|
TypeId::of::<<Self::Output as StaticTypeSized>::Static>()
|
|
}
|
|
fn output_type_name(&self) -> &'static str {
|
|
core::any::type_name::<Self::Output>()
|
|
}
|
|
#[cfg(feature = "alloc")]
|
|
fn to_node_io(&self, parameters: Vec<Type>) -> NodeIOTypes {
|
|
NodeIOTypes {
|
|
input: concrete!(<Input as StaticTypeSized>::Static),
|
|
output: concrete!(<Self::Output as StaticTypeSized>::Static),
|
|
parameters,
|
|
}
|
|
}
|
|
}
|
|
|
|
impl<'i, N: Node<'i, I>, I> NodeIO<'i, I> for N
|
|
where
|
|
N::Output: 'i + StaticTypeSized,
|
|
I: 'i + StaticTypeSized,
|
|
{
|
|
}
|
|
|
|
impl<'i, 's: 'i, I: 'i, N: Node<'i, I> + ?Sized> Node<'i, I> for &'i N {
|
|
type Output = N::Output;
|
|
fn eval(&'i self, input: I) -> N::Output {
|
|
(*self).eval(input)
|
|
}
|
|
}
|
|
#[cfg(feature = "alloc")]
|
|
impl<'i, 's: 'i, I: 'i, O: 'i, N: Node<'i, I, Output = O> + ?Sized> Node<'i, I> for Box<N> {
|
|
type Output = O;
|
|
fn eval(&'i self, input: I) -> O {
|
|
(**self).eval(input)
|
|
}
|
|
}
|
|
#[cfg(feature = "alloc")]
|
|
impl<'i, 's: 'i, I: 'i, O: 'i, N: Node<'i, I, Output = O> + ?Sized> Node<'i, I> for alloc::sync::Arc<N> {
|
|
type Output = O;
|
|
fn eval(&'i self, input: I) -> O {
|
|
(**self).eval(input)
|
|
}
|
|
}
|
|
|
|
use core::pin::Pin;
|
|
|
|
use dyn_any::StaticTypeSized;
|
|
#[cfg(feature = "alloc")]
|
|
impl<'i, I: 'i, O: 'i> Node<'i, I> for Pin<Box<dyn Node<'i, I, Output = O> + 'i>> {
|
|
type Output = O;
|
|
fn eval(&'i self, input: I) -> O {
|
|
(**self).eval(input)
|
|
}
|
|
}
|
|
impl<'i, I: 'i, O: 'i> Node<'i, I> for Pin<&'i (dyn NodeIO<'i, I, Output = O> + 'i)> {
|
|
type Output = O;
|
|
fn eval(&'i self, input: I) -> O {
|
|
(**self).eval(input)
|
|
}
|
|
}
|
|
|
|
#[cfg(feature = "alloc")]
|
|
pub use crate::application_io::{ExtractImageFrame, SurfaceFrame, SurfaceId};
|
|
#[cfg(feature = "wasm")]
|
|
pub type WasmSurfaceHandle = application_io::SurfaceHandle<web_sys::HtmlCanvasElement>;
|
|
#[cfg(feature = "wasm")]
|
|
pub type WasmSurfaceHandleFrame = application_io::SurfaceHandleFrame<web_sys::HtmlCanvasElement>;
|