Skip to content

Commit

Permalink
Update store field and refactor EmptyInvoker to LambdaInvoker
Browse files Browse the repository at this point in the history
The `store` field's type in `Operations` is revised from boolean to `StoreOp::Store` to convey the operation more explicitly. The `EmptyInvoker` class is renamed to `LambdaInvoker` to better indicate its usage. Cargo dependencies have also been updated for synchronization with current versions and pulling the correct branch for `egui_node_graph`.

Signed-off-by: xxorza <[email protected]>
  • Loading branch information
xorza committed Dec 15, 2023
1 parent 5791b35 commit 7733d70
Show file tree
Hide file tree
Showing 10 changed files with 35 additions and 24 deletions.
9 changes: 5 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,26 @@ graph_lib = { path = "./Graph", package = "graph", features = ["wgpu"] }
common = { path = "./Common", package = "common" }
uilib = { path = "./uilib", package = "uilib" }
imaginarium = { path = "./Imaginarium", package = "imaginarium", features = ["wgpu"] }
egui_node_graph = { path = "./egui_node_graph/egui_node_graph" }

egui_node_graph = { git = "ssh://[email protected]/xorza/egui_node_graph.git", branch = "main" }

serde = { version = "*", features = ["derive"] }
serde_yaml = "*"
serde_json = "*"
uuid = { version = "*", features = ["v4", "serde"] }
anyhow = "*"
wgpu = { version = "0.17.1" }
wgpu = { version = "0.18.0" }
bytemuck = { version = "*", features = ["derive"] }
pollster = "*"
tiff = "*"
png = "*"
image_lib = { version = "*", package = "image" }
num-traits = "*"
winit = "*"
winit = "0.28.7"
glam = "*"
glyph_brush = "*"
mlua = { version = "*", features = ["lua54", "vendored"] }
egui_file = { version = "0.11.0" }
egui_file = { version = "0.11.1" }
eframe = { version = "0.23.0", features = ["wgpu"] }
strum = "*"
strum_macros = "*"
Expand Down
6 changes: 3 additions & 3 deletions Graph/src/elements/basic_invoker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ use strum_macros::{Display, EnumIter};
use crate::data::{DataType, DynamicValue, StaticValue};
use crate::function::{Function, FunctionId, InputInfo, OutputInfo};
use crate::graph::FunctionBehavior;
use crate::invoke_context::{EmptyInvoker, InvokeArgs, InvokeCache, Invoker};
use crate::invoke_context::{InvokeArgs, InvokeCache, Invoker, LambdaInvoker};

pub type Logger = Arc<Mutex<Vec<String>>>;

pub struct BasicInvoker {
lambda_invoker: EmptyInvoker,
lambda_invoker: LambdaInvoker,
}

#[repr(u32)]
Expand Down Expand Up @@ -72,7 +72,7 @@ impl From<i64> for Math2ArgOp {

impl BasicInvoker {
pub fn new(logger: Logger) -> Self {
let mut invoker = EmptyInvoker::default();
let mut invoker = LambdaInvoker::default();

//print
invoker.add_lambda(
Expand Down
6 changes: 3 additions & 3 deletions Graph/src/elements/timers_invoker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ use std::time::Instant;
use crate::data::{DataType, DynamicValue, StaticValue};
use crate::function::{Function, FunctionId, InputInfo, OutputInfo};
use crate::graph::FunctionBehavior;
use crate::invoke_context::{EmptyInvoker, InvokeArgs, InvokeCache, Invoker};
use crate::invoke_context::{InvokeArgs, InvokeCache, Invoker, LambdaInvoker};

pub struct TimersInvoker {
lambda_invoker: EmptyInvoker,
lambda_invoker: LambdaInvoker,
}

struct FrameEventContext {
Expand All @@ -17,7 +17,7 @@ struct FrameEventContext {

impl Default for TimersInvoker {
fn default() -> TimersInvoker {
let mut invoker = EmptyInvoker::default();
let mut invoker = LambdaInvoker::default();

invoker.add_lambda(
Function {
Expand Down
6 changes: 3 additions & 3 deletions Graph/src/invoke_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pub struct UberInvoker {
}

#[derive(Default)]
pub struct EmptyInvoker {
pub struct LambdaInvoker {
all_functions: Vec<Function>,
lambdas: HashMap<FunctionId, Box<Lambda>>,
}
Expand Down Expand Up @@ -98,7 +98,7 @@ impl InvokeCache {
}
}

impl EmptyInvoker {
impl LambdaInvoker {
pub fn add_lambda<F>(&mut self, function: Function, lambda: F)
where F: Fn(&mut InvokeCache, &mut InvokeArgs, &mut InvokeArgs) + 'static
{
Expand Down Expand Up @@ -158,7 +158,7 @@ impl Invoker for UberInvoker {
}
}

impl Invoker for EmptyInvoker {
impl Invoker for LambdaInvoker {
fn all_functions(&self) -> Vec<Function> {
self.all_functions.clone()
}
Expand Down
4 changes: 2 additions & 2 deletions Graph/src/tests/compute_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::compute::Compute;
use crate::data::{DataType, DynamicValue, StaticValue};
use crate::function::{Function, FunctionId, InputInfo, OutputInfo};
use crate::graph::{Binding, FunctionBehavior, Graph};
use crate::invoke_context::{EmptyInvoker, InvokeCache};
use crate::invoke_context::{InvokeCache, LambdaInvoker};
use crate::runtime_graph::RuntimeGraph;

struct TestValues {
Expand All @@ -24,7 +24,7 @@ where
GetA: Fn() -> i64 + 'static,
GetB: Fn() -> i64 + 'static,
{
let mut invoker = EmptyInvoker::default();
let mut invoker = LambdaInvoker::default();

// print
invoker.add_lambda(
Expand Down
10 changes: 5 additions & 5 deletions Imaginarium/src/wgpu/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ impl From<wgpu::TextureFormat> for ColorFormat {

impl From<&ColorFormat> for wgpu::TextureFormat {
fn from(value: &ColorFormat) -> Self {
match value {
&ColorFormat::GRAY_U8 => wgpu::TextureFormat::R8Unorm,
&ColorFormat::GRAY_I8 => wgpu::TextureFormat::R8Snorm,
match *value {
ColorFormat::GRAY_U8 => wgpu::TextureFormat::R8Unorm,
ColorFormat::GRAY_I8 => wgpu::TextureFormat::R8Snorm,

&ColorFormat::RGBA_U8 => wgpu::TextureFormat::Rgba8Unorm,
&ColorFormat::RGBA_I8 => wgpu::TextureFormat::Rgba8Snorm,
ColorFormat::RGBA_U8 => wgpu::TextureFormat::Rgba8Unorm,
ColorFormat::RGBA_I8 => wgpu::TextureFormat::Rgba8Snorm,

_ => panic!("Not implemented color format: {:?}", value.to_string()),
}
Expand Down
6 changes: 5 additions & 1 deletion Imaginarium/src/wgpu/wgpu_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ impl WgpuContext {
pub fn new() -> anyhow::Result<WgpuContext> {
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
backends: wgpu::Backends::PRIMARY,
flags: Default::default(),
dx12_shader_compiler: wgpu::Dx12Compiler::Dxc { dxil_path: None, dxc_path: None },
gles_minor_version: Default::default(),
});
let adapter = instance
.request_adapter(&wgpu::RequestAdapterOptions {
Expand Down Expand Up @@ -344,12 +346,14 @@ impl WgpuContext {
resolve_target: None,
ops: wgpu::Operations {
load: wgpu::LoadOp::Clear(wgpu::Color::GREEN),
store: true,
store: wgpu::StoreOp::Store,
},
}),
],
depth_stencil_attachment: None,
timestamp_writes: None,
label: None,
occlusion_query_set: None,
});

render_pass.push_debug_group("Prepare data for draw.");
Expand Down
2 changes: 2 additions & 0 deletions uilib/src/app_base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ fn setup(title: &str) -> Setup {

let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
backends: wgpu::Backends::PRIMARY,
flags: Default::default(),
dx12_shader_compiler: wgpu::Dx12Compiler::Dxc { dxil_path: None, dxc_path: None },
gles_minor_version: Default::default(),
});
let size = window.inner_size();
let surface = unsafe {
Expand Down
6 changes: 4 additions & 2 deletions uilib/src/renderer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -342,19 +342,21 @@ impl WgpuRenderer {
resolve_target: None,
ops: Operations {
load: LoadOp::Clear(Color::RED),
store: true,
store: StoreOp::Store,
},
}),
Some(RenderPassColorAttachment {
view: &self.id_tex_view,
resolve_target: None,
ops: Operations {
load: LoadOp::Clear(Color::BLACK),
store: true,
store: StoreOp::Store,
},
}),
],
depth_stencil_attachment: None,
timestamp_writes: None,
occlusion_query_set: None,
});
render_pass.push_debug_group("Prepare data for draw.");
render_pass.set_pipeline(&self.pipeline);
Expand Down
4 changes: 3 additions & 1 deletion uilib/src/sample_app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -301,10 +301,12 @@ impl App for SampleApp {
resolve_target: None,
ops: wgpu::Operations {
load: wgpu::LoadOp::Clear(wgpu::Color::BLACK),
store: true,
store: wgpu::StoreOp::Store,
},
})],
depth_stencil_attachment: None,
timestamp_writes: None,
occlusion_query_set: None,
});
render_pass.push_debug_group("Prepare data for draw.");
render_pass.set_pipeline(&self.pipeline);
Expand Down

0 comments on commit 7733d70

Please sign in to comment.