From fc092d5e5b920a387bf079cb3ad736677194a863 Mon Sep 17 00:00:00 2001 From: chyyran Date: Thu, 23 Feb 2023 01:34:04 -0500 Subject: [PATCH] quark: add quark preset project --- .gitmodules | 6 ++ Cargo.lock | 177 ++++++++++++++++++++++++++++++++++- Cargo.toml | 4 +- bml | 1 + librashader-quark/Cargo.toml | 9 ++ librashader-quark/src/lib.rs | 40 ++++++++ test/quark-shaders | 1 + 7 files changed, 235 insertions(+), 3 deletions(-) create mode 160000 bml create mode 100644 librashader-quark/Cargo.toml create mode 100644 librashader-quark/src/lib.rs create mode 160000 test/quark-shaders diff --git a/.gitmodules b/.gitmodules index 4e5bf8d..5505517 100644 --- a/.gitmodules +++ b/.gitmodules @@ -7,3 +7,9 @@ [submodule "test/shaders_slang"] path = test/shaders_slang url = https://github.com/libretro/slang-shaders +[submodule "test/quark-shaders"] + path = test/quark-shaders + url = https://github.com/hizzlekizzle/quark-shaders +[submodule "bml"] + path = bml + url = https://github.com/chyyran/bml diff --git a/Cargo.lock b/Cargo.lock index 4d1ead8..393273d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -197,6 +197,17 @@ dependencies = [ "generic-array", ] +[[package]] +name = "bml" +version = "0.3.0" +dependencies = [ + "ordered-multimap", + "pest", + "pest_derive", + "smartstring", + "thiserror", +] + [[package]] name = "bumpalo" version = "3.12.0" @@ -388,6 +399,28 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b" +[[package]] +name = "const-random" +version = "0.1.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "368a7a772ead6ce7e1de82bfb04c485f3db8ec744f72925af5735e29a22cc18e" +dependencies = [ + "const-random-macro", + "proc-macro-hack", +] + +[[package]] +name = "const-random-macro" +version = "0.1.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d7d6ab3c3a2282db210df5f02c4dab6e0a7057af0fb7ebd4070f30fe05c0ddb" +dependencies = [ + "getrandom", + "once_cell", + "proc-macro-hack", + "tiny-keccak", +] + [[package]] name = "constant_time_eq" version = "0.2.4" @@ -447,6 +480,15 @@ dependencies = [ "libc", ] +[[package]] +name = "cpufeatures" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28d997bd5e24a5928dd43e46dc529867e207907fe0b239c3477d924f7f2ca320" +dependencies = [ + "libc", +] + [[package]] name = "crc32fast" version = "1.3.2" @@ -522,6 +564,12 @@ dependencies = [ "winapi", ] +[[package]] +name = "crunchy" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" + [[package]] name = "crypto-common" version = "0.1.6" @@ -620,6 +668,15 @@ dependencies = [ "libloading", ] +[[package]] +name = "dlv-list" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d529fd73d344663edfd598ccb3f344e46034db51ebd103518eae34338248ad73" +dependencies = [ + "const-random", +] + [[package]] name = "downcast-rs" version = "1.2.0" @@ -936,13 +993,19 @@ dependencies = [ "ahash", ] +[[package]] +name = "hashbrown" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" + [[package]] name = "hashlink" version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "69fe1fcf8b4278d860ad0548329f892a3631fb63f82574df68275f34cdbe0ffa" dependencies = [ - "hashbrown", + "hashbrown 0.12.3", ] [[package]] @@ -1005,7 +1068,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1885e79c1fc4b10f0e172c475f458b7f7b93061064d98c3293e98c5ba0c8b399" dependencies = [ "autocfg", - "hashbrown", + "hashbrown 0.12.3", ] [[package]] @@ -1220,6 +1283,13 @@ dependencies = [ "thiserror", ] +[[package]] +name = "librashader-quark" +version = "0.1.0" +dependencies = [ + "bml", +] + [[package]] name = "librashader-reflect" version = "0.1.3" @@ -1719,6 +1789,16 @@ version = "1.17.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3" +[[package]] +name = "ordered-multimap" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ed8acf08e98e744e5384c8bc63ceb0364e68a6854187221c18df61c4797690e" +dependencies = [ + "dlv-list", + "hashbrown 0.13.2", +] + [[package]] name = "os_str_bytes" version = "6.4.1" @@ -1760,6 +1840,50 @@ version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e" +[[package]] +name = "pest" +version = "2.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "028accff104c4e513bad663bbcd2ad7cfd5304144404c31ed0a77ac103d00660" +dependencies = [ + "thiserror", + "ucd-trie", +] + +[[package]] +name = "pest_derive" +version = "2.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ac3922aac69a40733080f53c1ce7f91dcf57e1a5f6c52f421fadec7fbdc4b69" +dependencies = [ + "pest", + "pest_generator", +] + +[[package]] +name = "pest_generator" +version = "2.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d06646e185566b5961b4058dd107e0a7f56e77c3f484549fb119867773c0f202" +dependencies = [ + "pest", + "pest_meta", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "pest_meta" +version = "2.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6f60b2ba541577e2a0c307c8f39d1439108120eb7903adeb6497fa880c59616" +dependencies = [ + "once_cell", + "pest", + "sha2", +] + [[package]] name = "petgraph" version = "0.6.3" @@ -1840,6 +1964,12 @@ dependencies = [ "version_check", ] +[[package]] +name = "proc-macro-hack" +version = "0.5.20+deprecated" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc375e1527247fe1a97d8b7156678dfe7c1af2fc075c9a4db3690ecd2a148068" + [[package]] name = "proc-macro2" version = "1.0.51" @@ -2096,6 +2226,17 @@ dependencies = [ "pkg-config", ] +[[package]] +name = "sha2" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "82e6b795fe2e3b1e845bafcb27aa35405c4d47cdfc92af5fc8d3002f76cebdc0" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + [[package]] name = "shaderc" version = "0.8.2" @@ -2132,6 +2273,17 @@ version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" +[[package]] +name = "smartstring" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fb72c633efbaa2dd666986505016c32c3044395ceaf881518399d2f4127ee29" +dependencies = [ + "autocfg", + "static_assertions", + "version_check", +] + [[package]] name = "smithay-client-toolkit" version = "0.16.0" @@ -2182,6 +2334,12 @@ dependencies = [ "cmake", ] +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + [[package]] name = "strsim" version = "0.10.0" @@ -2271,6 +2429,15 @@ dependencies = [ "weezl", ] +[[package]] +name = "tiny-keccak" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c9d3793400a45f954c52e73d068316d76b6f4e36977e3fcebb13a2721e80237" +dependencies = [ + "crunchy", +] + [[package]] name = "tiny-skia" version = "0.7.0" @@ -2328,6 +2495,12 @@ version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" +[[package]] +name = "ucd-trie" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e79c4d996edb816c91e4308506774452e55e95c3c9de07b6729e17e15a5ef81" + [[package]] name = "unicode-ident" version = "1.0.6" diff --git a/Cargo.toml b/Cargo.toml index 66c4019..13d72c5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,7 +12,9 @@ members = [ "librashader-runtime-vk", "librashader-cache", "librashader-capi", - "librashader-build-script" + "librashader-quark", + "librashader-build-script", + "bml" ] [workspace.metadata.release] diff --git a/bml b/bml new file mode 160000 index 0000000..0c932a1 --- /dev/null +++ b/bml @@ -0,0 +1 @@ +Subproject commit 0c932a1fa661f542e2c6ef833c0ffefc95138fab diff --git a/librashader-quark/Cargo.toml b/librashader-quark/Cargo.toml new file mode 100644 index 0000000..9f1f976 --- /dev/null +++ b/librashader-quark/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "librashader-quark" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +bml = { path = "../bml"} \ No newline at end of file diff --git a/librashader-quark/src/lib.rs b/librashader-quark/src/lib.rs new file mode 100644 index 0000000..f457c4b --- /dev/null +++ b/librashader-quark/src/lib.rs @@ -0,0 +1,40 @@ +use std::error::Error; +use std::fs::File; +use std::io::Read; +use std::path::Path; +use bml::BmlNode; + +pub fn add(left: usize, right: usize) -> usize { + left + right +} + +pub fn parse_preset(path: impl AsRef) -> Result> { + let path = path.as_ref(); + let path = path + .canonicalize()?; + + let mut manifest_path = path.join("manifest.bml"); + let mut contents = String::new(); + File::open(&manifest_path) + .and_then(|mut f| f.read_to_string(&mut contents))?; + // BML expects a newline. + contents.push_str("\n"); + let contents = contents.to_string(); + Ok(bml::BmlNode::try_from(&*contents)?) +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn parse_shader() { + let preset = parse_preset("../test/quark-shaders/CRT-Royale.shader").unwrap(); + + for program in preset.named("program") { + eprintln!("{:?}", program); + + } + + } +} diff --git a/test/quark-shaders b/test/quark-shaders new file mode 160000 index 0000000..2fa0ba1 --- /dev/null +++ b/test/quark-shaders @@ -0,0 +1 @@ +Subproject commit 2fa0ba174042f2b5f0a9d3408adba75e0b03a8ff