Initialize repository.
This commit is contained in:
commit
7785d22ef0
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
/target
|
1736
Cargo.lock
generated
Normal file
1736
Cargo.lock
generated
Normal file
File diff suppressed because it is too large
Load Diff
9
Cargo.toml
Normal file
9
Cargo.toml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
[package]
|
||||||
|
name = "donten"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
winit = "0.30.5"
|
||||||
|
rayon = "1.10.0"
|
||||||
|
crossbeam = "0.8.4"
|
13
src/bin/client.rs
Normal file
13
src/bin/client.rs
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
fn main()
|
||||||
|
{
|
||||||
|
// Initialize Donten engine
|
||||||
|
let cfg = donten::Config::new();
|
||||||
|
let _engine = if let Ok(engine) = donten::Donten::init(cfg) {
|
||||||
|
engine
|
||||||
|
} else {
|
||||||
|
println!("fatal: failed to initialize engine.");
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
|
||||||
|
std::thread::park();
|
||||||
|
}
|
13
src/bin/server.rs
Normal file
13
src/bin/server.rs
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
fn main()
|
||||||
|
{
|
||||||
|
// Initialize Donten engine
|
||||||
|
let cfg = donten::Config::new();
|
||||||
|
let _engine = if let Ok(engine) = donten::Donten::init(cfg) {
|
||||||
|
engine
|
||||||
|
} else {
|
||||||
|
println!("fatal: failed to initialize engine.");
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
}
|
10
src/config/mod.rs
Normal file
10
src/config/mod.rs
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
pub struct Config {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Config {
|
||||||
|
pub fn new() -> Self
|
||||||
|
{
|
||||||
|
Self { }
|
||||||
|
}
|
||||||
|
}
|
17
src/error.rs
Normal file
17
src/error.rs
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
pub struct Error {
|
||||||
|
|
||||||
|
}
|
||||||
|
impl Error {
|
||||||
|
pub fn new() -> Self
|
||||||
|
{
|
||||||
|
Self { }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*impl std::error::Error for Error {
|
||||||
|
|
||||||
|
}
|
||||||
|
impl std::fmt::Display for Error {
|
||||||
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
|
|
||||||
|
}
|
||||||
|
}*/
|
27
src/lib.rs
Normal file
27
src/lib.rs
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
#![allow(dead_code, unused_imports)]
|
||||||
|
use crossbeam::channel::Sender;
|
||||||
|
|
||||||
|
mod error; pub use error::Error;
|
||||||
|
mod config; pub use config::Config;
|
||||||
|
use system::{Subsystem, Query};
|
||||||
|
mod system;
|
||||||
|
mod platform;
|
||||||
|
|
||||||
|
pub struct Donten {
|
||||||
|
channel:Sender<Query>,
|
||||||
|
}
|
||||||
|
impl Donten {
|
||||||
|
pub fn init(_config:Config) -> Result<Self, Error>
|
||||||
|
{
|
||||||
|
// Initialize supervisor.
|
||||||
|
let channel = system::Supervisor::start()?;
|
||||||
|
|
||||||
|
// Parse config and push instructions to supervisor.
|
||||||
|
|
||||||
|
// ... //
|
||||||
|
|
||||||
|
Ok(Self {
|
||||||
|
channel,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
0
src/platform/mod.rs
Normal file
0
src/platform/mod.rs
Normal file
13
src/system/api/mod.rs
Normal file
13
src/system/api/mod.rs
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
use super::*;
|
||||||
|
|
||||||
|
pub struct APISystem {
|
||||||
|
channel:Sender<Query>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl APISystem {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Subsystem for APISystem {
|
||||||
|
|
||||||
|
}
|
13
src/system/audio/mod.rs
Normal file
13
src/system/audio/mod.rs
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
use super::*;
|
||||||
|
|
||||||
|
pub struct AudioSystem {
|
||||||
|
channel:Sender<Query>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl AudioSystem {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Subsystem for AudioSystem {
|
||||||
|
|
||||||
|
}
|
13
src/system/control/mod.rs
Normal file
13
src/system/control/mod.rs
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
use super::*;
|
||||||
|
|
||||||
|
pub struct ControlSystem {
|
||||||
|
channel:Sender<Query>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ControlSystem {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Subsystem for ControlSystem {
|
||||||
|
|
||||||
|
}
|
12
src/system/input/device.rs
Normal file
12
src/system/input/device.rs
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
use super::Usage;
|
||||||
|
|
||||||
|
pub struct Device {
|
||||||
|
pub name:String,
|
||||||
|
pub manufacturer:String,
|
||||||
|
pub serial:String,
|
||||||
|
|
||||||
|
usages:Vec<Usage>,
|
||||||
|
}
|
||||||
|
impl Device {
|
||||||
|
|
||||||
|
}
|
16
src/system/input/mod.rs
Normal file
16
src/system/input/mod.rs
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
use super::*;
|
||||||
|
|
||||||
|
mod usage; use usage::Usage;
|
||||||
|
mod device; use device::Device;
|
||||||
|
|
||||||
|
pub struct InputSystem {
|
||||||
|
channel:Sender<Query>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl InputSystem {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Subsystem for InputSystem {
|
||||||
|
|
||||||
|
}
|
9
src/system/input/usage.rs
Normal file
9
src/system/input/usage.rs
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
pub struct Usage {
|
||||||
|
usage:u32,
|
||||||
|
minimum:i32,
|
||||||
|
maximum:i32,
|
||||||
|
value:u32,
|
||||||
|
}
|
||||||
|
impl Usage {
|
||||||
|
|
||||||
|
}
|
35
src/system/mod.rs
Normal file
35
src/system/mod.rs
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
use crate::Error;
|
||||||
|
use crossbeam::channel::{self, Sender, Receiver};
|
||||||
|
|
||||||
|
pub(crate) mod query; pub(crate) use query::{Query, QueryData};
|
||||||
|
|
||||||
|
pub(crate) mod supervisor; pub(crate) use supervisor::*;
|
||||||
|
pub(crate) mod window; pub(crate) use window::*;
|
||||||
|
pub(crate) mod render; pub(crate) use render::*;
|
||||||
|
pub(crate) mod audio; pub(crate) use audio::*;
|
||||||
|
pub(crate) mod input; pub(crate) use input::*;
|
||||||
|
pub(crate) mod control; pub(crate) use control::*;
|
||||||
|
pub(crate) mod scene; pub(crate) use scene::*;
|
||||||
|
pub(crate) mod network; pub(crate) use network::*;
|
||||||
|
pub(crate) mod storage; pub(crate) use storage::*;
|
||||||
|
pub(crate) mod api; pub(crate) use api::*;
|
||||||
|
|
||||||
|
pub(crate) trait Subsystem {
|
||||||
|
fn start() -> Result<Sender<Query>, Error> { Err(Error::new()) }
|
||||||
|
fn shutdown() -> Result<(), Error> { Ok(()) }
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Copy)]
|
||||||
|
pub enum System {
|
||||||
|
Supervisor = 0,
|
||||||
|
Window,
|
||||||
|
Render,
|
||||||
|
Audio,
|
||||||
|
Input,
|
||||||
|
Control,
|
||||||
|
Scene,
|
||||||
|
Network,
|
||||||
|
Storage,
|
||||||
|
API,
|
||||||
|
_MAX,
|
||||||
|
}
|
13
src/system/network/mod.rs
Normal file
13
src/system/network/mod.rs
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
use super::*;
|
||||||
|
|
||||||
|
pub struct NetworkSystem {
|
||||||
|
channel:Sender<Query>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl NetworkSystem {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Subsystem for NetworkSystem {
|
||||||
|
|
||||||
|
}
|
20
src/system/query.rs
Normal file
20
src/system/query.rs
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
use super::*;
|
||||||
|
|
||||||
|
pub struct Query {
|
||||||
|
pub resp:Option<Sender<Query>>,
|
||||||
|
pub data:QueryData,
|
||||||
|
}
|
||||||
|
impl Query {
|
||||||
|
pub fn new(resp:Option<Sender<Query>>, data:QueryData) -> Self
|
||||||
|
{
|
||||||
|
Self {
|
||||||
|
resp,
|
||||||
|
data,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub enum QueryData {
|
||||||
|
Supervisor(SupervisorQuery),
|
||||||
|
Window(WindowQuery),
|
||||||
|
}
|
13
src/system/render/mod.rs
Normal file
13
src/system/render/mod.rs
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
use super::*;
|
||||||
|
|
||||||
|
pub struct RenderSystem {
|
||||||
|
channel:Sender<Query>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl RenderSystem {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Subsystem for RenderSystem {
|
||||||
|
|
||||||
|
}
|
11
src/system/render/vulkan/mod.rs
Normal file
11
src/system/render/vulkan/mod.rs
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
use super::Renderer;
|
||||||
|
|
||||||
|
pub struct Vulkan {
|
||||||
|
|
||||||
|
}
|
||||||
|
impl Vulkan {
|
||||||
|
|
||||||
|
}
|
||||||
|
impl Renderer for Vulkan {
|
||||||
|
|
||||||
|
}
|
13
src/system/scene/mod.rs
Normal file
13
src/system/scene/mod.rs
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
use super::*;
|
||||||
|
|
||||||
|
pub struct SceneSystem {
|
||||||
|
channel:Sender<Query>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl SceneSystem {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Subsystem for SceneSystem {
|
||||||
|
|
||||||
|
}
|
13
src/system/storage/mod.rs
Normal file
13
src/system/storage/mod.rs
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
use super::*;
|
||||||
|
|
||||||
|
pub struct StorageSystem {
|
||||||
|
channel:Sender<Query>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl StorageSystem {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Subsystem for StorageSystem {
|
||||||
|
|
||||||
|
}
|
72
src/system/supervisor/internal.rs
Normal file
72
src/system/supervisor/internal.rs
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
use crate::system::*;
|
||||||
|
|
||||||
|
pub struct Internal {
|
||||||
|
subsystems:[Option<Sender<Query>>; System::_MAX as usize],
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Internal {
|
||||||
|
pub fn thread(tx:Sender<Query>, rx:Receiver<Query>)
|
||||||
|
{
|
||||||
|
let mut sv = Internal {
|
||||||
|
subsystems:std::array::from_fn(|_| None),
|
||||||
|
};
|
||||||
|
sv.subsystems[System::Supervisor as usize] = Some(tx);
|
||||||
|
|
||||||
|
while let Ok(query) = rx.recv() {
|
||||||
|
match query.data {
|
||||||
|
QueryData::Supervisor(request) => match request {
|
||||||
|
SupervisorQuery::Start {
|
||||||
|
system,
|
||||||
|
} => if sv.subsystems[system as usize].is_none() {
|
||||||
|
if let Ok(channel) = match system {
|
||||||
|
|
||||||
|
System::Window => WindowSystem::start(),
|
||||||
|
|
||||||
|
_ => { Err(Error::new()) }
|
||||||
|
} {
|
||||||
|
for i in 0..sv.subsystems.len() {
|
||||||
|
|
||||||
|
// Notify active subsystems that subsystem has started.
|
||||||
|
if let Some(tx) = &sv.subsystems[i] {
|
||||||
|
tx.send(Query::new(None, QueryData::Supervisor(
|
||||||
|
SupervisorQuery::Status {
|
||||||
|
system,
|
||||||
|
channel: Some(channel.clone()),
|
||||||
|
}
|
||||||
|
))).ok();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SupervisorQuery::Stop {
|
||||||
|
system,
|
||||||
|
} => if let Some(tx) = &sv.subsystems[system as usize] {
|
||||||
|
|
||||||
|
// Send shutdown instruction to subsystem.
|
||||||
|
tx.send(Query::new(None, QueryData::Supervisor(
|
||||||
|
SupervisorQuery::Stop {
|
||||||
|
system,
|
||||||
|
}
|
||||||
|
))).ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
SupervisorQuery::Status {
|
||||||
|
system,
|
||||||
|
channel: _,
|
||||||
|
} => if let Some(from) = query.resp {
|
||||||
|
from.send(Query::new(None, QueryData::Supervisor(
|
||||||
|
SupervisorQuery::Status {
|
||||||
|
system,
|
||||||
|
channel:sv.subsystems[system as usize].clone(),
|
||||||
|
}
|
||||||
|
))).ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
_ => { }
|
||||||
|
}
|
||||||
|
_ => { }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
26
src/system/supervisor/mod.rs
Normal file
26
src/system/supervisor/mod.rs
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
use super::*;
|
||||||
|
|
||||||
|
mod query; pub use query::SupervisorQuery;
|
||||||
|
mod internal; use internal::Internal;
|
||||||
|
|
||||||
|
pub struct Supervisor {
|
||||||
|
channel:Sender<Query>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Supervisor {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Subsystem for Supervisor {
|
||||||
|
fn start() -> Result<Sender<Query>, crate::Error>
|
||||||
|
{
|
||||||
|
let (tx, rx) = channel::bounded::<Query>(24);
|
||||||
|
|
||||||
|
let sys_tx = tx.clone();
|
||||||
|
std::thread::spawn(move || {
|
||||||
|
Internal::thread(sys_tx, rx);
|
||||||
|
});
|
||||||
|
|
||||||
|
Ok(tx)
|
||||||
|
}
|
||||||
|
}
|
18
src/system/supervisor/query.rs
Normal file
18
src/system/supervisor/query.rs
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
use crate::system::*;
|
||||||
|
|
||||||
|
pub enum SupervisorQuery {
|
||||||
|
None,
|
||||||
|
|
||||||
|
Start {
|
||||||
|
system:System,
|
||||||
|
},
|
||||||
|
|
||||||
|
Stop {
|
||||||
|
system:System,
|
||||||
|
},
|
||||||
|
|
||||||
|
Status {
|
||||||
|
system:System,
|
||||||
|
channel:Option<Sender<Query>>,
|
||||||
|
}
|
||||||
|
}
|
31
src/system/window/internal.rs
Normal file
31
src/system/window/internal.rs
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
use crate::system::*;
|
||||||
|
|
||||||
|
pub struct Internal {
|
||||||
|
|
||||||
|
}
|
||||||
|
impl Internal {
|
||||||
|
pub fn thread(rx:Receiver<Query>)
|
||||||
|
{
|
||||||
|
let _sv = Internal {
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
while let Ok(msg) = rx.recv() {
|
||||||
|
match msg.data {
|
||||||
|
QueryData::Supervisor(request) => match request {
|
||||||
|
SupervisorQuery::Stop {
|
||||||
|
system: _,
|
||||||
|
} => {
|
||||||
|
|
||||||
|
// Perform shutdown operations and terminate thread.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_ => { }
|
||||||
|
}
|
||||||
|
|
||||||
|
_ => { }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
27
src/system/window/mod.rs
Normal file
27
src/system/window/mod.rs
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
use super::*;
|
||||||
|
|
||||||
|
mod query; pub use query::WindowQuery;
|
||||||
|
mod internal; use internal::Internal;
|
||||||
|
|
||||||
|
pub struct WindowSystem {
|
||||||
|
channel:Sender<Query>,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
impl WindowSystem {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Subsystem for WindowSystem {
|
||||||
|
|
||||||
|
fn start() -> Result<Sender<Query>, crate::Error>
|
||||||
|
{
|
||||||
|
let (tx, rx) = channel::bounded::<Query>(24);
|
||||||
|
|
||||||
|
std::thread::spawn(move || {
|
||||||
|
Internal::thread(rx);
|
||||||
|
});
|
||||||
|
|
||||||
|
Ok(tx)
|
||||||
|
}
|
||||||
|
}
|
3
src/system/window/query.rs
Normal file
3
src/system/window/query.rs
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
pub enum WindowQuery {
|
||||||
|
None,
|
||||||
|
}
|
Reference in New Issue
Block a user