Configure gpu surface on non wasm32 targets

This commit is contained in:
Dennis Kobert
2023-06-16 19:56:52 +02:00
committed by Keavon Chambers
parent 989c8ad5f8
commit 8cd161f087
8 changed files with 82 additions and 19 deletions

View File

@@ -5,8 +5,13 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
[features]
gpu = ["interpreted-executor/gpu", "graphene-std/gpu", "graphene-core/gpu", "wgpu-executor", "gpu-executor"]
default = ["wgpu"]
wgpu = ["wgpu-executor", "gpu"]
[dependencies]
log = "0.4"
bitflags = "1.2.1"
serde = { version = "1.0", features = ["derive"] }
@@ -30,6 +35,8 @@ future-executor = { path = "../future-executor", optional = true }
wasm-bindgen = { version = "0.2.86", optional = true }
futures = "0.3.28"
fern = { version = "0.6.2", features = ["colored"] }
chrono = "0.4.26"
[dependencies.document-legacy]
path = "../../document-legacy"

View File

@@ -1,3 +1,4 @@
use fern::colors::{Color, ColoredLevelConfig};
use std::{collections::HashMap, error::Error};
use document_legacy::{
@@ -25,6 +26,28 @@ impl NodeGraphUpdateSender for UpdateLogger {
}
fn main() -> Result<(), Box<dyn Error>> {
let colors = ColoredLevelConfig::new()
.debug(Color::Magenta)
.info(Color::Green)
.error(Color::Red);
fern::Dispatch::new()
.chain(std::io::stdout())
.level_for("foodcalc", log::LevelFilter::Trace)
.level_for("sqlx", log::LevelFilter::Trace)
.level_for("iced", log::LevelFilter::Trace)
.level(log::LevelFilter::Trace)
.format(move |out, message, record| {
out.finish(format_args!(
"[{}]{} {}",
// This will color the log level only, not the whole line. Just a touch.
colors.color(record.level()),
chrono::Utc::now().format("[%Y-%m-%d %H:%M:%S]"),
message
))
})
.apply()
.unwrap();
let document_path = std::env::args().nth(1).expect("No document path provided");
let document_string = std::fs::read_to_string(&document_path).expect("Failed to read document");
@@ -45,7 +68,7 @@ fn main() -> Result<(), Box<dyn Error>> {
let editor_api = WasmEditorApi {
image_frame: None,
font_cache: &FontCache::default(),
application_io: &WasmApplicationIo::default(),
application_io: &block_on(WasmApplicationIo::new()),
node_graph_message_sender: &UpdateLogger {},
imaginate_preferences: &ImaginatePreferences::default(),
};
@@ -92,7 +115,16 @@ pub fn wrap_network_in_scope(mut network: NodeNetwork) -> NodeNetwork {
};
// wrap the inner network in a scope
let nodes = vec![begin_scope(), inner_network, end_scope()];
let nodes = vec![
begin_scope(),
inner_network,
DocumentNode {
name: "End Scope".to_string(),
implementation: DocumentNodeImplementation::proto("graphene_core::memo::EndLetNode<_>"),
inputs: vec![NodeInput::node(0, 0), NodeInput::node(1, 0)],
..Default::default()
},
];
NodeNetwork {
inputs: vec![0],
outputs: vec![NodeOutput::new(2, 0)],
@@ -138,11 +170,3 @@ fn begin_scope() -> DocumentNode {
..Default::default()
}
}
fn end_scope() -> DocumentNode {
DocumentNode {
name: "End Scope".to_string(),
implementation: DocumentNodeImplementation::proto("graphene_core::memo::EndLetNode<_>"),
inputs: vec![NodeInput::value(TaggedValue::None, true), NodeInput::value(TaggedValue::ImageFrame(ImageFrame::empty()), true)],
..Default::default()
}
}

File diff suppressed because one or more lines are too long