Fix circular dependencies in workspace

This commit is contained in:
Tony Klink 2024-04-02 19:12:59 -06:00
parent 960e2f8a37
commit 173cfe2acf
Signed by: klink
GPG key ID: 85175567C4D19231
11 changed files with 148 additions and 72 deletions

22
Cargo.lock generated
View file

@ -1280,6 +1280,27 @@ dependencies = [
name = "khors" name = "khors"
version = "0.1.0" version = "0.1.0"
[[package]]
name = "khors-app"
version = "0.1.0"
dependencies = [
"anyhow",
"downcast-rs",
"egui",
"flax",
"flume",
"glam",
"khors-core",
"khors-graphics",
"parking_lot",
"serde",
"serde-lexpr",
"vulkano",
"vulkano-shaders",
"vulkano-util",
"winit",
]
[[package]] [[package]]
name = "khors-config" name = "khors-config"
version = "0.1.0" version = "0.1.0"
@ -1349,6 +1370,7 @@ version = "0.1.0"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"egui-vulkano", "egui-vulkano",
"khors-app",
"khors-config", "khors-config",
"khors-core", "khors-core",
"khors-graphics", "khors-graphics",

View file

@ -9,6 +9,7 @@ edition = "2021"
members = [ members = [
"khors-core", "khors-core",
"vendor/egui-vulkano", "vendor/egui-vulkano",
"modules/khors-app",
"modules/khors-graphics", "modules/khors-graphics",
"modules/khors-window", "modules/khors-window",
"modules/khors-config", "modules/khors-config",
@ -18,6 +19,9 @@ members = [
default-members = [ "khors-test" ] default-members = [ "khors-test" ]
[workspace.dependencies]
flax = { version = "0.6.2", features = ["derive", "serde", "tokio", "tracing"] }
[[bin]] [[bin]]
name = "khors-test" name = "khors-test"
path = "./khors-test" path = "./khors-test"

View file

@ -1,5 +1,3 @@
pub mod app;
pub mod events; pub mod events;
pub mod module; pub mod module;
pub mod time; pub mod time;
pub mod debug_gui;

View file

@ -5,10 +5,13 @@ use flax::World;
use super::events::Events; use super::events::Events;
use super::debug_gui::DebugGuiStack;
pub trait Module { pub trait Module {
fn on_update(&mut self, world: &mut World, events: &mut Events, frame_time: Duration) -> Result<()>; fn on_update(
&mut self,
world: &mut World,
events: &mut Events,
frame_time: Duration,
) -> Result<()>;
} }
pub struct ModulesStack { pub struct ModulesStack {
@ -17,7 +20,9 @@ pub struct ModulesStack {
impl ModulesStack { impl ModulesStack {
pub fn new() -> Self { pub fn new() -> Self {
Self { modules: Vec::new() } Self {
modules: Vec::new(),
}
} }
pub fn iter(&self) -> std::slice::Iter<Box<dyn Module>> { pub fn iter(&self) -> std::slice::Iter<Box<dyn Module>> {
@ -64,63 +69,3 @@ impl<'a> IntoIterator for &'a mut ModulesStack {
self.iter_mut() self.iter_mut()
} }
} }
// THREAD LOCAL STUFF
pub trait RenderModule {
fn on_update(&mut self, gui_stack: &mut DebugGuiStack, vk_context: &mut vulkano_util::context::VulkanoContext, vk_windows: &mut vulkano_util::window::VulkanoWindows, world: &mut World, events: &mut Events, frame_time: Duration) -> Result<()>;
}
pub struct RenderModulesStack {
modules: Vec<Box<dyn RenderModule>>,
}
impl RenderModulesStack {
pub fn new() -> Self {
Self { modules: Vec::new() }
}
pub fn iter(&self) -> std::slice::Iter<Box<dyn RenderModule>> {
self.modules.iter()
}
pub fn iter_mut(&mut self) -> std::slice::IterMut<Box<dyn RenderModule>> {
self.modules.iter_mut()
}
pub fn push<T: 'static + RenderModule>(&mut self, layer: T) {
let layer = Box::new(layer);
self.modules.push(layer);
}
pub fn insert<T: 'static + RenderModule>(&mut self, index: usize, layer: T) {
let layer = Box::new(layer);
self.modules.insert(index, layer);
}
}
impl Default for RenderModulesStack {
fn default() -> Self {
Self::new()
}
}
impl<'a> IntoIterator for &'a RenderModulesStack {
type Item = &'a Box<dyn RenderModule>;
type IntoIter = std::slice::Iter<'a, Box<dyn RenderModule>>;
fn into_iter(self) -> Self::IntoIter {
self.iter()
}
}
impl<'a> IntoIterator for &'a mut RenderModulesStack {
type Item = &'a mut Box<dyn RenderModule>;
type IntoIter = std::slice::IterMut<'a, Box<dyn RenderModule>>;
fn into_iter(self) -> Self::IntoIter {
self.iter_mut()
}
}

View file

@ -7,6 +7,7 @@ edition = "2021"
[dependencies] [dependencies]
khors-core = { path = "../khors-core", version = "0.1.0" } khors-core = { path = "../khors-core", version = "0.1.0" }
khors-app = { path = "../modules/khors-app", version = "0.1.0" }
egui-vulkano = { path = "../vendor/egui-vulkano", version = "0.1.0" } egui-vulkano = { path = "../vendor/egui-vulkano", version = "0.1.0" }
khors-graphics = { path = "../modules/khors-graphics", version = "0.1.0" } khors-graphics = { path = "../modules/khors-graphics", version = "0.1.0" }
khors-window = { path = "../modules/khors-window", version = "0.1.0" } khors-window = { path = "../modules/khors-window", version = "0.1.0" }

View file

@ -1,7 +1,7 @@
use anyhow::Result; use anyhow::Result;
use khors_config::ConfigModule; use khors_config::ConfigModule;
use khors_core::app::App; use khors_app::App;
use khors_graphics::RenderModule; use khors_graphics::RenderModule;
use khors_window::WindowModule; use khors_window::WindowModule;
use tokio::runtime::Builder; use tokio::runtime::Builder;

View file

@ -0,0 +1,24 @@
[package]
name = "khors-app"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
khors-core = { path = "../../khors-core", version = "0.1.0" }
khors-graphics = { path = "../khors-graphics", version = "0.1.0" }
anyhow = "1.0.80"
egui = "0.27.1"
glam = "0.27.0"
winit = { version = "0.29.15",features = ["rwh_05"] }
vulkano = { git = "https://github.com/vulkano-rs/vulkano.git", branch = "master" }
vulkano-shaders = { git = "https://github.com/vulkano-rs/vulkano.git", branch = "master" }
vulkano-util = { git = "https://github.com/vulkano-rs/vulkano.git", branch = "master" }
flax = { version = "0.6.2", features = ["derive", "serde", "tokio", "tracing"] }
flume = "0.11.0"
parking_lot = "0.12.1"
downcast-rs = "1.2.0"
serde = { version = "1.0.197", features = ["derive"] }
serde-lexpr = "0.1.3"

View file

@ -1,10 +1,13 @@
#![warn(dead_code)] #![warn(dead_code)]
use khors_core::{
use crate::{
debug_gui::DebugGuiStack,
events::Events, events::Events,
module::{Module, ModulesStack, RenderModule as ThreadLocalModule, RenderModulesStack}, module::{Module, ModulesStack},
}; };
use khors_graphics::{
debug_gui::DebugGuiStack,
render_module::{RenderModule as ThreadLocalModule, RenderModulesStack},
};
use anyhow::Result; use anyhow::Result;
use flax::{component, Schedule, World}; use flax::{component, Schedule, World};
use vulkano::device::DeviceFeatures; use vulkano::device::DeviceFeatures;

View file

@ -1,3 +1,6 @@
pub mod debug_gui;
pub mod render_module;
use flax::{entity_ids, BoxedSystem, Query, QueryBorrow, Schedule, System, World}; use flax::{entity_ids, BoxedSystem, Query, QueryBorrow, Schedule, System, World};
use glam::{ use glam::{
f32::{Mat3, Vec3}, f32::{Mat3, Vec3},
@ -45,7 +48,8 @@ use vulkano_util::{
}; };
use egui_vulkano::Gui; use egui_vulkano::Gui;
use khors_core::{debug_gui::DebugGuiStack, module::RenderModule as ThreadLocalModule}; use crate::debug_gui::DebugGuiStack;
use crate::render_module::RenderModule as ThreadLocalModule;
use self::{ use self::{
model::{INDICES, NORMALS, POSITIONS}, model::{INDICES, NORMALS, POSITIONS},

View file

@ -0,0 +1,75 @@
use crate::debug_gui::DebugGuiStack;
use anyhow::Result;
use flax::World;
use khors_core::events::Events;
use std::time::Duration;
// THREAD LOCAL STUFF
pub trait RenderModule {
fn on_update(
&mut self,
gui_stack: &mut DebugGuiStack,
vk_context: &mut vulkano_util::context::VulkanoContext,
vk_windows: &mut vulkano_util::window::VulkanoWindows,
world: &mut World,
events: &mut Events,
frame_time: Duration,
) -> Result<()>;
}
pub struct RenderModulesStack {
modules: Vec<Box<dyn RenderModule>>,
}
impl RenderModulesStack {
pub fn new() -> Self {
Self {
modules: Vec::new(),
}
}
pub fn iter(&self) -> std::slice::Iter<Box<dyn RenderModule>> {
self.modules.iter()
}
pub fn iter_mut(&mut self) -> std::slice::IterMut<Box<dyn RenderModule>> {
self.modules.iter_mut()
}
pub fn push<T: 'static + RenderModule>(&mut self, layer: T) {
let layer = Box::new(layer);
self.modules.push(layer);
}
pub fn insert<T: 'static + RenderModule>(&mut self, index: usize, layer: T) {
let layer = Box::new(layer);
self.modules.insert(index, layer);
}
}
impl Default for RenderModulesStack {
fn default() -> Self {
Self::new()
}
}
impl<'a> IntoIterator for &'a RenderModulesStack {
type Item = &'a Box<dyn RenderModule>;
type IntoIter = std::slice::Iter<'a, Box<dyn RenderModule>>;
fn into_iter(self) -> Self::IntoIter {
self.iter()
}
}
impl<'a> IntoIterator for &'a mut RenderModulesStack {
type Item = &'a mut Box<dyn RenderModule>;
type IntoIter = std::slice::IterMut<'a, Box<dyn RenderModule>>;
fn into_iter(self) -> Self::IntoIter {
self.iter_mut()
}
}