fmt: clean up unused items
This commit is contained in:
parent
80fa30e54e
commit
1579516d25
31 changed files with 291 additions and 662 deletions
422
Cargo.lock
generated
422
Cargo.lock
generated
|
@ -8,56 +8,12 @@ version = "1.0.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe"
|
checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "aho-corasick"
|
|
||||||
version = "0.7.19"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "b4f55bd91a0978cbfd91c457a164bab8b4001c833b7f323132c0a4e1922dd44e"
|
|
||||||
dependencies = [
|
|
||||||
"memchr",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "arbitrary"
|
|
||||||
version = "1.2.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "29d47fbf90d5149a107494b15a7dc8d69b351be2db3bb9691740e88ec17fd880"
|
|
||||||
dependencies = [
|
|
||||||
"derive_arbitrary",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "atty"
|
|
||||||
version = "0.2.14"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"
|
|
||||||
dependencies = [
|
|
||||||
"hermit-abi",
|
|
||||||
"libc",
|
|
||||||
"winapi",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "autocfg"
|
name = "autocfg"
|
||||||
version = "1.1.0"
|
version = "1.1.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
|
checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "base64"
|
|
||||||
version = "0.13.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "bincode"
|
|
||||||
version = "1.3.3"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad"
|
|
||||||
dependencies = [
|
|
||||||
"serde",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bit-set"
|
name = "bit-set"
|
||||||
version = "0.5.3"
|
version = "0.5.3"
|
||||||
|
@ -85,18 +41,6 @@ version = "1.3.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
|
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "bstr"
|
|
||||||
version = "0.2.17"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "ba3569f383e8f1598449f1a423e72e99569137b47740b1da11ef19af3d5c3223"
|
|
||||||
dependencies = [
|
|
||||||
"lazy_static",
|
|
||||||
"memchr",
|
|
||||||
"regex-automata",
|
|
||||||
"serde",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bumpalo"
|
name = "bumpalo"
|
||||||
version = "3.11.1"
|
version = "3.11.1"
|
||||||
|
@ -121,12 +65,6 @@ version = "1.4.3"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610"
|
checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "cast"
|
|
||||||
version = "0.3.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cc"
|
name = "cc"
|
||||||
version = "1.0.73"
|
version = "1.0.73"
|
||||||
|
@ -142,17 +80,6 @@ version = "1.0.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "clap"
|
|
||||||
version = "2.34.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c"
|
|
||||||
dependencies = [
|
|
||||||
"bitflags",
|
|
||||||
"textwrap",
|
|
||||||
"unicode-width",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cmake"
|
name = "cmake"
|
||||||
version = "0.1.48"
|
version = "0.1.48"
|
||||||
|
@ -162,16 +89,6 @@ dependencies = [
|
||||||
"cc",
|
"cc",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "codespan-reporting"
|
|
||||||
version = "0.11.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "3538270d33cc669650c4b093848450d380def10c331d38c768e34cac80576e6e"
|
|
||||||
dependencies = [
|
|
||||||
"termcolor",
|
|
||||||
"unicode-width",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "color_quant"
|
name = "color_quant"
|
||||||
version = "1.1.0"
|
version = "1.1.0"
|
||||||
|
@ -187,42 +104,6 @@ dependencies = [
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "criterion"
|
|
||||||
version = "0.3.6"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "b01d6de93b2b6c65e17c634a26653a29d107b3c98c607c765bf38d041531cd8f"
|
|
||||||
dependencies = [
|
|
||||||
"atty",
|
|
||||||
"cast",
|
|
||||||
"clap",
|
|
||||||
"criterion-plot",
|
|
||||||
"csv",
|
|
||||||
"itertools",
|
|
||||||
"lazy_static",
|
|
||||||
"num-traits",
|
|
||||||
"oorandom",
|
|
||||||
"plotters",
|
|
||||||
"rayon",
|
|
||||||
"regex",
|
|
||||||
"serde",
|
|
||||||
"serde_cbor",
|
|
||||||
"serde_derive",
|
|
||||||
"serde_json",
|
|
||||||
"tinytemplate",
|
|
||||||
"walkdir",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "criterion-plot"
|
|
||||||
version = "0.4.5"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "2673cc8207403546f45f5fd319a974b1e6983ad1a3ee7e6041650013be041876"
|
|
||||||
dependencies = [
|
|
||||||
"cast",
|
|
||||||
"itertools",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "crossbeam-channel"
|
name = "crossbeam-channel"
|
||||||
version = "0.5.6"
|
version = "0.5.6"
|
||||||
|
@ -272,70 +153,18 @@ version = "0.2.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7"
|
checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "csv"
|
|
||||||
version = "1.1.6"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "22813a6dc45b335f9bade10bf7271dc477e81113e89eb251a0bc2a8a81c536e1"
|
|
||||||
dependencies = [
|
|
||||||
"bstr",
|
|
||||||
"csv-core",
|
|
||||||
"itoa 0.4.8",
|
|
||||||
"ryu",
|
|
||||||
"serde",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "csv-core"
|
|
||||||
version = "0.1.10"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "2b2466559f260f48ad25fe6317b3c8dac77b5bdb5763ac7d9d6103530663bc90"
|
|
||||||
dependencies = [
|
|
||||||
"memchr",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cty"
|
name = "cty"
|
||||||
version = "0.2.2"
|
version = "0.2.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b365fabc795046672053e29c954733ec3b05e4be654ab130fe8f1f94d7051f35"
|
checksum = "b365fabc795046672053e29c954733ec3b05e4be654ab130fe8f1f94d7051f35"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "derive_arbitrary"
|
|
||||||
version = "1.2.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "4903dff04948f22033ca30232ab8eca2c3fc4c913a8b6a34ee5199699814817f"
|
|
||||||
dependencies = [
|
|
||||||
"proc-macro2",
|
|
||||||
"quote",
|
|
||||||
"syn",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "diff"
|
|
||||||
version = "0.1.13"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "56254986775e3233ffa9c4d7d3faaf6d36a2c09d30b20687e9f88bc8bafc16c8"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "either"
|
name = "either"
|
||||||
version = "1.8.0"
|
version = "1.8.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "90e5c1c8368803113bf0c9584fc495a58b86dc8a29edbf8fe877d21d9507e797"
|
checksum = "90e5c1c8368803113bf0c9584fc495a58b86dc8a29edbf8fe877d21d9507e797"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "env_logger"
|
|
||||||
version = "0.9.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "c90bf5f19754d10198ccb95b70664fc925bd1fc090a0fd9a6ebc54acc8cd6272"
|
|
||||||
dependencies = [
|
|
||||||
"atty",
|
|
||||||
"humantime",
|
|
||||||
"log",
|
|
||||||
"regex",
|
|
||||||
"termcolor",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "exr"
|
name = "exr"
|
||||||
version = "1.5.2"
|
version = "1.5.2"
|
||||||
|
@ -344,7 +173,7 @@ checksum = "8eb5f255b5980bb0c8cf676b675d1a99be40f316881444f44e0462eaf5df5ded"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bit_field",
|
"bit_field",
|
||||||
"flume",
|
"flume",
|
||||||
"half 2.1.0",
|
"half",
|
||||||
"lebe",
|
"lebe",
|
||||||
"miniz_oxide 0.6.2",
|
"miniz_oxide 0.6.2",
|
||||||
"smallvec",
|
"smallvec",
|
||||||
|
@ -466,12 +295,6 @@ dependencies = [
|
||||||
"cmake",
|
"cmake",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "half"
|
|
||||||
version = "1.8.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "eabb4a44450da02c90444cf74558da904edde8fb4e9035a9a6a4e15445af0bd7"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "half"
|
name = "half"
|
||||||
version = "2.1.0"
|
version = "2.1.0"
|
||||||
|
@ -496,18 +319,6 @@ dependencies = [
|
||||||
"libc",
|
"libc",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "hexf-parse"
|
|
||||||
version = "0.2.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "dfa686283ad6dd069f105e5ab091b04c62850d3e4cf5d67debad1933f55023df"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "humantime"
|
|
||||||
version = "2.1.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "image"
|
name = "image"
|
||||||
version = "0.24.5"
|
version = "0.24.5"
|
||||||
|
@ -535,30 +346,8 @@ checksum = "10a35a97730320ffe8e2d410b5d3b69279b98d2c14bdb8b70ea89ecf7888d41e"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"autocfg",
|
"autocfg",
|
||||||
"hashbrown",
|
"hashbrown",
|
||||||
"serde",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "itertools"
|
|
||||||
version = "0.10.5"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473"
|
|
||||||
dependencies = [
|
|
||||||
"either",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "itoa"
|
|
||||||
version = "0.4.8"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "b71991ff56294aa922b450139ee08b3bfc70982c6b2c7562771375cf73542dd4"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "itoa"
|
|
||||||
version = "1.0.4"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "4217ad341ebadf8d8e724e264f13e593e0648f5b3e94b3896a5df283be015ecc"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "jobserver"
|
name = "jobserver"
|
||||||
version = "0.1.25"
|
version = "0.1.25"
|
||||||
|
@ -592,12 +381,6 @@ version = "3.1.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "e2db585e1d738fc771bf08a151420d3ed193d9d895a36df7f6f8a9456b911ddc"
|
checksum = "e2db585e1d738fc771bf08a151420d3ed193d9d895a36df7f6f8a9456b911ddc"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "lazy_static"
|
|
||||||
version = "1.4.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "lebe"
|
name = "lebe"
|
||||||
version = "0.5.2"
|
version = "0.5.2"
|
||||||
|
@ -751,29 +534,19 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "naga"
|
name = "naga"
|
||||||
version = "0.10.0"
|
version = "0.10.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "262d2840e72dbe250e8cf2f522d080988dfca624c4112c096238a4845f591707"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"arbitrary",
|
|
||||||
"bincode",
|
|
||||||
"bit-set",
|
"bit-set",
|
||||||
"bitflags",
|
"bitflags",
|
||||||
"codespan-reporting",
|
|
||||||
"criterion",
|
|
||||||
"diff",
|
|
||||||
"env_logger",
|
|
||||||
"hexf-parse",
|
|
||||||
"indexmap",
|
"indexmap",
|
||||||
"log",
|
"log",
|
||||||
"num-traits",
|
"num-traits",
|
||||||
"petgraph",
|
"petgraph",
|
||||||
"pp-rs",
|
"pp-rs",
|
||||||
"ron",
|
|
||||||
"rspirv",
|
|
||||||
"rustc-hash",
|
"rustc-hash",
|
||||||
"serde",
|
|
||||||
"spirv",
|
"spirv",
|
||||||
"termcolor",
|
|
||||||
"thiserror",
|
"thiserror",
|
||||||
"unicode-xid",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -861,12 +634,6 @@ version = "1.15.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "e82dad04139b71a90c080c8463fe0dc7902db5192d939bd0950f074d014339e1"
|
checksum = "e82dad04139b71a90c080c8463fe0dc7902db5192d939bd0950f074d014339e1"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "oorandom"
|
|
||||||
version = "11.1.3"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "0ab1bc2a289d34bd04a330323ac98a1b4bc82c9d9fcb1e66b63caa84da26b575"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "petgraph"
|
name = "petgraph"
|
||||||
version = "0.6.2"
|
version = "0.6.2"
|
||||||
|
@ -897,34 +664,6 @@ dependencies = [
|
||||||
"syn",
|
"syn",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "plotters"
|
|
||||||
version = "0.3.4"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "2538b639e642295546c50fcd545198c9d64ee2a38620a628724a3b266d5fbf97"
|
|
||||||
dependencies = [
|
|
||||||
"num-traits",
|
|
||||||
"plotters-backend",
|
|
||||||
"plotters-svg",
|
|
||||||
"wasm-bindgen",
|
|
||||||
"web-sys",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "plotters-backend"
|
|
||||||
version = "0.3.4"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "193228616381fecdc1224c62e96946dfbc73ff4384fba576e052ff8c1bea8142"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "plotters-svg"
|
|
||||||
version = "0.3.3"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "f9a81d2759aae1dae668f783c308bc5c8ebd191ff4184aaa1b37f65a6ae5a56f"
|
|
||||||
dependencies = [
|
|
||||||
"plotters-backend",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "png"
|
name = "png"
|
||||||
version = "0.17.7"
|
version = "0.17.7"
|
||||||
|
@ -997,40 +736,6 @@ dependencies = [
|
||||||
"num_cpus",
|
"num_cpus",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "regex"
|
|
||||||
version = "1.6.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "4c4eb3267174b8c6c2f654116623910a0fef09c4753f8dd83db29c48a0df988b"
|
|
||||||
dependencies = [
|
|
||||||
"aho-corasick",
|
|
||||||
"memchr",
|
|
||||||
"regex-syntax",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "regex-automata"
|
|
||||||
version = "0.1.10"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "regex-syntax"
|
|
||||||
version = "0.6.27"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "a3f87b73ce11b1619a3c6332f45341e0047173771e8b8b73f87bfeefb7b56244"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "ron"
|
|
||||||
version = "0.7.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "88073939a61e5b7680558e6be56b419e208420c2adb92be54921fa6b72283f1a"
|
|
||||||
dependencies = [
|
|
||||||
"base64",
|
|
||||||
"bitflags",
|
|
||||||
"serde",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "roxmltree"
|
name = "roxmltree"
|
||||||
version = "0.14.1"
|
version = "0.14.1"
|
||||||
|
@ -1066,21 +771,6 @@ version = "1.1.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
|
checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "ryu"
|
|
||||||
version = "1.0.11"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "4501abdff3ae82a1c1b477a17252eb69cee9e66eb915c1abaa4f44d873df9f09"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "same-file"
|
|
||||||
version = "1.0.6"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502"
|
|
||||||
dependencies = [
|
|
||||||
"winapi-util",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "scoped_threadpool"
|
name = "scoped_threadpool"
|
||||||
version = "0.1.9"
|
version = "0.1.9"
|
||||||
|
@ -1093,47 +783,6 @@ version = "1.1.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd"
|
checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "serde"
|
|
||||||
version = "1.0.147"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "d193d69bae983fc11a79df82342761dfbf28a99fc8d203dca4c3c1b590948965"
|
|
||||||
dependencies = [
|
|
||||||
"serde_derive",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "serde_cbor"
|
|
||||||
version = "0.11.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "2bef2ebfde456fb76bbcf9f59315333decc4fda0b2b44b420243c11e0f5ec1f5"
|
|
||||||
dependencies = [
|
|
||||||
"half 1.8.2",
|
|
||||||
"serde",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "serde_derive"
|
|
||||||
version = "1.0.147"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "4f1d362ca8fc9c3e3a7484440752472d68a6caa98f1ab81d99b5dfe517cec852"
|
|
||||||
dependencies = [
|
|
||||||
"proc-macro2",
|
|
||||||
"quote",
|
|
||||||
"syn",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "serde_json"
|
|
||||||
version = "1.0.87"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "6ce777b7b150d76b9cf60d28b55f5847135a003f7d7350c6be7a773508ce7d45"
|
|
||||||
dependencies = [
|
|
||||||
"itoa 1.0.4",
|
|
||||||
"ryu",
|
|
||||||
"serde",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "shaderc"
|
name = "shaderc"
|
||||||
version = "0.8.0"
|
version = "0.8.0"
|
||||||
|
@ -1178,7 +827,6 @@ checksum = "246bfa38fe3db3f1dfc8ca5a2cdeb7348c78be2112740cc0ec8ef18b6d94f830"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags",
|
"bitflags",
|
||||||
"num-traits",
|
"num-traits",
|
||||||
"serde",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -1203,24 +851,6 @@ dependencies = [
|
||||||
"unicode-ident",
|
"unicode-ident",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "termcolor"
|
|
||||||
version = "1.1.3"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "bab24d30b911b2376f3a13cc2cd443142f0c81dda04c118693e35b3835757755"
|
|
||||||
dependencies = [
|
|
||||||
"winapi-util",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "textwrap"
|
|
||||||
version = "0.11.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060"
|
|
||||||
dependencies = [
|
|
||||||
"unicode-width",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "thiserror"
|
name = "thiserror"
|
||||||
version = "1.0.37"
|
version = "1.0.37"
|
||||||
|
@ -1261,45 +891,18 @@ dependencies = [
|
||||||
"weezl",
|
"weezl",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "tinytemplate"
|
|
||||||
version = "1.2.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "be4d6b5f19ff7664e8c98d03e2139cb510db9b0a60b55f8e8709b689d939b6bc"
|
|
||||||
dependencies = [
|
|
||||||
"serde",
|
|
||||||
"serde_json",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "unicode-ident"
|
name = "unicode-ident"
|
||||||
version = "1.0.5"
|
version = "1.0.5"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "6ceab39d59e4c9499d4e5a8ee0e2735b891bb7308ac83dfb4e80cad195c9f6f3"
|
checksum = "6ceab39d59e4c9499d4e5a8ee0e2735b891bb7308ac83dfb4e80cad195c9f6f3"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "unicode-width"
|
|
||||||
version = "0.1.10"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "unicode-xid"
|
name = "unicode-xid"
|
||||||
version = "0.2.4"
|
version = "0.2.4"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c"
|
checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "walkdir"
|
|
||||||
version = "2.3.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "808cf2735cd4b6866113f648b791c6adc5714537bc222d9347bb203386ffda56"
|
|
||||||
dependencies = [
|
|
||||||
"same-file",
|
|
||||||
"winapi",
|
|
||||||
"winapi-util",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wasi"
|
name = "wasi"
|
||||||
version = "0.11.0+wasi-snapshot-preview1"
|
version = "0.11.0+wasi-snapshot-preview1"
|
||||||
|
@ -1360,16 +963,6 @@ version = "0.2.83"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "1c38c045535d93ec4f0b4defec448e4291638ee608530863b1e2ba115d4fff7f"
|
checksum = "1c38c045535d93ec4f0b4defec448e4291638ee608530863b1e2ba115d4fff7f"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "web-sys"
|
|
||||||
version = "0.3.60"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "bcda906d8be16e728fd5adc5b729afad4e444e106ab28cd1c7256e54fa61510f"
|
|
||||||
dependencies = [
|
|
||||||
"js-sys",
|
|
||||||
"wasm-bindgen",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "weezl"
|
name = "weezl"
|
||||||
version = "0.1.7"
|
version = "0.1.7"
|
||||||
|
@ -1392,15 +985,6 @@ version = "0.4.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
|
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "winapi-util"
|
|
||||||
version = "0.1.5"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178"
|
|
||||||
dependencies = [
|
|
||||||
"winapi",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "winapi-x86_64-pc-windows-gnu"
|
name = "winapi-x86_64-pc-windows-gnu"
|
||||||
version = "0.4.0"
|
version = "0.4.0"
|
||||||
|
|
|
@ -6,5 +6,4 @@ members = [
|
||||||
"librashader-reflect",
|
"librashader-reflect",
|
||||||
"librashader-runtime-dx11",
|
"librashader-runtime-dx11",
|
||||||
"librashader-runtime-gl",
|
"librashader-runtime-gl",
|
||||||
"naga"
|
|
||||||
]
|
]
|
|
@ -33,7 +33,7 @@ impl From<ShaderFormat> for gl::types::GLenum {
|
||||||
ShaderFormat::R32G32Sfloat => gl::RG32F,
|
ShaderFormat::R32G32Sfloat => gl::RG32F,
|
||||||
ShaderFormat::R32G32B32A32Uint => gl::RGBA32UI,
|
ShaderFormat::R32G32B32A32Uint => gl::RGBA32UI,
|
||||||
ShaderFormat::R32G32B32A32Sint => gl::RGBA32I,
|
ShaderFormat::R32G32B32A32Sint => gl::RGBA32I,
|
||||||
ShaderFormat::R32G32B32A32Sfloat => gl::RGBA32F
|
ShaderFormat::R32G32B32A32Sfloat => gl::RGBA32F,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,7 @@ impl From<WrapMode> for gl::types::GLenum {
|
||||||
WrapMode::ClampToBorder => gl::CLAMP_TO_BORDER,
|
WrapMode::ClampToBorder => gl::CLAMP_TO_BORDER,
|
||||||
WrapMode::ClampToEdge => gl::CLAMP_TO_EDGE,
|
WrapMode::ClampToEdge => gl::CLAMP_TO_EDGE,
|
||||||
WrapMode::Repeat => gl::REPEAT,
|
WrapMode::Repeat => gl::REPEAT,
|
||||||
WrapMode::MirroredRepeat => gl::MIRRORED_REPEAT
|
WrapMode::MirroredRepeat => gl::MIRRORED_REPEAT,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -53,7 +53,7 @@ impl From<FilterMode> for gl::types::GLenum {
|
||||||
fn from(value: FilterMode) -> Self {
|
fn from(value: FilterMode) -> Self {
|
||||||
match value {
|
match value {
|
||||||
FilterMode::Linear => gl::LINEAR,
|
FilterMode::Linear => gl::LINEAR,
|
||||||
_ => gl::NEAREST
|
_ => gl::NEAREST,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -64,7 +64,7 @@ impl FilterMode {
|
||||||
(FilterMode::Linear, FilterMode::Linear) => gl::LINEAR_MIPMAP_LINEAR,
|
(FilterMode::Linear, FilterMode::Linear) => gl::LINEAR_MIPMAP_LINEAR,
|
||||||
(FilterMode::Linear, FilterMode::Nearest) => gl::LINEAR_MIPMAP_NEAREST,
|
(FilterMode::Linear, FilterMode::Nearest) => gl::LINEAR_MIPMAP_NEAREST,
|
||||||
(FilterMode::Nearest, FilterMode::Linear) => gl::NEAREST_MIPMAP_LINEAR,
|
(FilterMode::Nearest, FilterMode::Linear) => gl::NEAREST_MIPMAP_LINEAR,
|
||||||
_ => gl::NEAREST_MIPMAP_NEAREST
|
_ => gl::NEAREST_MIPMAP_NEAREST,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,16 +7,16 @@ pub struct Image {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Image {
|
impl Image {
|
||||||
pub fn load(path: impl AsRef<Path>) -> Result<Self, image::ImageError>{
|
pub fn load(path: impl AsRef<Path>) -> Result<Self, image::ImageError> {
|
||||||
let image = image::open(path.as_ref())?.flipv().to_rgba8();
|
let image = image::open(path.as_ref())?.flipv().to_rgba8();
|
||||||
|
|
||||||
let height = image.height();
|
let height = image.height();
|
||||||
let width = image.width();
|
let width = image.width();
|
||||||
|
|
||||||
Ok(Image {
|
Ok(Image {
|
||||||
bytes: image.to_vec(),
|
bytes: image.to_vec(),
|
||||||
height,
|
height,
|
||||||
width
|
width,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,7 +73,6 @@ impl FromStr for WrapMode {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[repr(i32)]
|
#[repr(i32)]
|
||||||
#[derive(Copy, Clone, Default, Debug, Eq, PartialEq)]
|
#[derive(Copy, Clone, Default, Debug, Eq, PartialEq)]
|
||||||
pub enum WrapMode {
|
pub enum WrapMode {
|
||||||
|
@ -135,11 +134,8 @@ pub struct Size<T> {
|
||||||
pub height: T,
|
pub height: T,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl <T> Size<T> {
|
impl<T> Size<T> {
|
||||||
pub fn new(width: T, height: T) -> Self {
|
pub fn new(width: T, height: T) -> Self {
|
||||||
Size {
|
Size { width, height }
|
||||||
width,
|
|
||||||
height
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
use crate::ShaderParameter;
|
|
||||||
use std::convert::Infallible;
|
use std::convert::Infallible;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
|
|
|
@ -5,7 +5,7 @@ use std::path::Path;
|
||||||
use std::str::Lines;
|
use std::str::Lines;
|
||||||
|
|
||||||
#[cfg(feature = "line_directives")]
|
#[cfg(feature = "line_directives")]
|
||||||
const GL_GOOGLE_CPP_STYLE_LINE_DIRECTIVE: &'static str =
|
const GL_GOOGLE_CPP_STYLE_LINE_DIRECTIVE: &str =
|
||||||
"#extension GL_GOOGLE_cpp_style_line_directive : require";
|
"#extension GL_GOOGLE_cpp_style_line_directive : require";
|
||||||
|
|
||||||
fn read_file(path: impl AsRef<Path>) -> Result<String, PreprocessError> {
|
fn read_file(path: impl AsRef<Path>) -> Result<String, PreprocessError> {
|
||||||
|
|
|
@ -95,4 +95,3 @@ mod test {
|
||||||
eprintln!("{params:?}")
|
eprintln!("{params:?}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
use crate::{PreprocessError, ShaderParameter};
|
use crate::{PreprocessError, ShaderParameter};
|
||||||
use librashader_common::ShaderFormat;
|
use librashader_common::ShaderFormat;
|
||||||
use nom::bytes::complete::{is_not, tag, take_until, take_while};
|
use nom::bytes::complete::{is_not, tag, take_while};
|
||||||
use nom::combinator::map_res;
|
|
||||||
|
use nom::character::complete::multispace1;
|
||||||
use nom::number::complete::float;
|
use nom::number::complete::float;
|
||||||
use nom::sequence::delimited;
|
use nom::sequence::delimited;
|
||||||
use nom::IResult;
|
use nom::IResult;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
use nom::character::complete::multispace1;
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub(crate) struct ShaderMeta {
|
pub(crate) struct ShaderMeta {
|
||||||
|
@ -22,13 +22,14 @@ fn parse_parameter_string(input: &str) -> Result<ShaderParameter, PreprocessErro
|
||||||
let (input, _) = multispace1(input)?;
|
let (input, _) = multispace1(input)?;
|
||||||
let (input, description) = delimited(tag("\""), is_not("\""), tag("\""))(input)?;
|
let (input, description) = delimited(tag("\""), is_not("\""), tag("\""))(input)?;
|
||||||
let (input, _) = multispace1(input)?;
|
let (input, _) = multispace1(input)?;
|
||||||
Ok((
|
Ok((input, (name, description)))
|
||||||
input,
|
|
||||||
(name, description)
|
|
||||||
))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_parameter_string_inner<'a, 'b>(name: &'a str, description: &'a str, input: &'b str) -> IResult<&'b str, ShaderParameter> {
|
fn parse_parameter_string_inner<'a, 'b>(
|
||||||
|
name: &'a str,
|
||||||
|
description: &'a str,
|
||||||
|
input: &'b str,
|
||||||
|
) -> IResult<&'b str, ShaderParameter> {
|
||||||
let (input, initial) = float(input)?;
|
let (input, initial) = float(input)?;
|
||||||
let (input, _) = multispace1(input)?;
|
let (input, _) = multispace1(input)?;
|
||||||
let (input, minimum) = float(input)?;
|
let (input, minimum) = float(input)?;
|
||||||
|
@ -49,7 +50,6 @@ fn parse_parameter_string(input: &str) -> Result<ShaderParameter, PreprocessErro
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
let Ok((params, (name, description))) = parse_parameter_string_name(input) else {
|
let Ok((params, (name, description))) = parse_parameter_string_name(input) else {
|
||||||
return Err(PreprocessError::PragmaParseError(input.to_string()));
|
return Err(PreprocessError::PragmaParseError(input.to_string()));
|
||||||
};
|
};
|
||||||
|
@ -68,7 +68,6 @@ fn parse_parameter_string(input: &str) -> Result<ShaderParameter, PreprocessErro
|
||||||
step: 0f32,
|
step: 0f32,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn parse_pragma_meta(source: impl AsRef<str>) -> Result<ShaderMeta, PreprocessError> {
|
pub(crate) fn parse_pragma_meta(source: impl AsRef<str>) -> Result<ShaderMeta, PreprocessError> {
|
||||||
|
@ -94,7 +93,7 @@ pub(crate) fn parse_pragma_meta(source: impl AsRef<str>) -> Result<ShaderMeta, P
|
||||||
}
|
}
|
||||||
|
|
||||||
let format_string = line["#pragma format ".len()..].trim();
|
let format_string = line["#pragma format ".len()..].trim();
|
||||||
format = ShaderFormat::from_str(&format_string)?;
|
format = ShaderFormat::from_str(format_string)?;
|
||||||
|
|
||||||
if format == ShaderFormat::Unknown {
|
if format == ShaderFormat::Unknown {
|
||||||
return Err(PreprocessError::UnknownShaderFormat);
|
return Err(PreprocessError::UnknownShaderFormat);
|
||||||
|
|
|
@ -92,10 +92,10 @@ fn parse_reference(input: Span) -> IResult<Span, Token> {
|
||||||
fn parse_key_value(input: Span) -> IResult<Span, Token> {
|
fn parse_key_value(input: Span) -> IResult<Span, Token> {
|
||||||
let (input, (key, _)) = take_up_to(parse_assignment)(input)?;
|
let (input, (key, _)) = take_up_to(parse_assignment)(input)?;
|
||||||
let (input, (_, value)) = map_res(not_line_ending, optional_quotes)(input)?;
|
let (input, (_, value)) = map_res(not_line_ending, optional_quotes)(input)?;
|
||||||
let (_, value) = take_until::<_, _, nom::error::Error<Span>>("//")(value)
|
let (_, value) =
|
||||||
.unwrap_or((input, value));
|
take_until::<_, _, nom::error::Error<Span>>("//")(value).unwrap_or((input, value));
|
||||||
let (_, value) = take_until::<_, _, nom::error::Error<Span>>("#")(value)
|
let (_, value) =
|
||||||
.unwrap_or((input, value));
|
take_until::<_, _, nom::error::Error<Span>>("#")(value).unwrap_or((input, value));
|
||||||
let (_, (_, value)) = map_res(not_line_ending, optional_quotes)(value)?;
|
let (_, (_, value)) = map_res(not_line_ending, optional_quotes)(value)?;
|
||||||
|
|
||||||
Ok((input, Token { key, value }))
|
Ok((input, Token { key, value }))
|
||||||
|
@ -167,12 +167,12 @@ mod test {
|
||||||
}
|
}
|
||||||
|
|
||||||
// todo: fix
|
// todo: fix
|
||||||
const TEST2: &'static str = r#"
|
const TEST2: &str = r#"
|
||||||
// Color Correction with Dogway's awesome Grade shader
|
// Color Correction with Dogway's awesome Grade shader
|
||||||
// Grade is after Afterglow so that brightening the black level does not break the afterglow
|
// Grade is after Afterglow so that brightening the black level does not break the afterglow
|
||||||
shader9 = ../../shaders/dogway/hsm-grade.slang
|
shader9 = ../../shaders/dogway/hsm-grade.slang
|
||||||
"#;
|
"#;
|
||||||
const TEST: &'static str = r#"
|
const TEST: &str = r#"
|
||||||
#reference "../../alt"
|
#reference "../../alt"
|
||||||
shaders = 54
|
shaders = 54
|
||||||
|
|
||||||
|
|
|
@ -8,13 +8,12 @@ use nom::combinator::{eof, map_res};
|
||||||
use nom::IResult;
|
use nom::IResult;
|
||||||
use num_traits::cast::ToPrimitive;
|
use num_traits::cast::ToPrimitive;
|
||||||
|
|
||||||
|
|
||||||
use crate::parse::token::do_lex;
|
use crate::parse::token::do_lex;
|
||||||
|
use librashader_common::{FilterMode, WrapMode};
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io::Read;
|
use std::io::Read;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
use librashader_common::{FilterMode, WrapMode};
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum Value {
|
pub enum Value {
|
||||||
|
@ -67,29 +66,28 @@ impl Value {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn from_int(input: Span) -> Result<i32, ParsePresetError> {
|
fn from_int(input: Span) -> Result<i32, ParsePresetError> {
|
||||||
i32::from_str(input.trim()).map_err(|_| {
|
i32::from_str(input.trim())
|
||||||
ParsePresetError::ParserError {
|
.map_err(|_| ParsePresetError::ParserError {
|
||||||
offset: input.location_offset(),
|
offset: input.location_offset(),
|
||||||
row: input.location_line(),
|
row: input.location_line(),
|
||||||
col: input.get_column(),
|
col: input.get_column(),
|
||||||
kind: ParseErrorKind::Int,
|
kind: ParseErrorKind::Int,
|
||||||
}
|
})
|
||||||
}).or_else(|e| {
|
.or_else(|e| {
|
||||||
let result = f32::from_str(input.trim())
|
let result = f32::from_str(input.trim()).map_err(|_| e)?;
|
||||||
.map_err(|_| e)?;
|
let result = result
|
||||||
let result = result.trunc().to_i32()
|
.trunc()
|
||||||
.ok_or(ParsePresetError::ParserError {
|
.to_i32()
|
||||||
offset: input.location_offset(),
|
.ok_or(ParsePresetError::ParserError {
|
||||||
row: input.location_line(),
|
offset: input.location_offset(),
|
||||||
col: input.get_column(),
|
row: input.location_line(),
|
||||||
kind: ParseErrorKind::Int,
|
col: input.get_column(),
|
||||||
})?;
|
kind: ParseErrorKind::Int,
|
||||||
|
})?;
|
||||||
eprintln!("falling back to float trunc {result}");
|
|
||||||
Ok(result)
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
|
eprintln!("falling back to float trunc {result}");
|
||||||
|
Ok(result)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn from_ul(input: Span) -> Result<u32, ParsePresetError> {
|
fn from_ul(input: Span) -> Result<u32, ParsePresetError> {
|
||||||
|
@ -494,7 +492,7 @@ mod test {
|
||||||
pub fn parse_basic() {
|
pub fn parse_basic() {
|
||||||
let root =
|
let root =
|
||||||
PathBuf::from("../test/slang-shaders/bezel/Mega_Bezel/Presets/Base_CRT_Presets/MBZ__3__STD__MEGATRON-NTSC.slangp");
|
PathBuf::from("../test/slang-shaders/bezel/Mega_Bezel/Presets/Base_CRT_Presets/MBZ__3__STD__MEGATRON-NTSC.slangp");
|
||||||
let basic = parse_preset(&root);
|
let basic = parse_preset(root);
|
||||||
eprintln!("{:?}", basic);
|
eprintln!("{:?}", basic);
|
||||||
assert!(basic.is_ok());
|
assert!(basic.is_ok());
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
use crate::error::ParsePresetError;
|
use crate::error::ParsePresetError;
|
||||||
|
use librashader_common::{FilterMode, WrapMode};
|
||||||
use std::ops::Mul;
|
use std::ops::Mul;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
use librashader_common::{FilterMode, WrapMode};
|
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct ShaderPassConfig {
|
pub struct ShaderPassConfig {
|
||||||
|
@ -54,7 +54,7 @@ impl Mul<ScaleFactor> for f32 {
|
||||||
fn mul(self, rhs: ScaleFactor) -> Self::Output {
|
fn mul(self, rhs: ScaleFactor) -> Self::Output {
|
||||||
match rhs {
|
match rhs {
|
||||||
ScaleFactor::Float(f) => f * self,
|
ScaleFactor::Float(f) => f * self,
|
||||||
ScaleFactor::Absolute(f) => f as f32 * self
|
ScaleFactor::Absolute(f) => f as f32 * self,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -65,7 +65,7 @@ impl Mul<ScaleFactor> for u32 {
|
||||||
fn mul(self, rhs: ScaleFactor) -> Self::Output {
|
fn mul(self, rhs: ScaleFactor) -> Self::Output {
|
||||||
match rhs {
|
match rhs {
|
||||||
ScaleFactor::Float(f) => f * self as f32,
|
ScaleFactor::Float(f) => f * self as f32,
|
||||||
ScaleFactor::Absolute(f) => (f as u32 * self) as f32
|
ScaleFactor::Absolute(f) => (f as u32 * self) as f32,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,6 @@ edition = "2021"
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
naga = { version = "0.10.0", path = "../naga", features = ["glsl-in", "spv-in", "spv-out", "glsl-out", "wgsl-out"] }
|
|
||||||
shaderc = { version = "0.8.0" }
|
shaderc = { version = "0.8.0" }
|
||||||
spirv_cross = { version = "0.23.1", features = [ "glsl", "hlsl" ] }
|
spirv_cross = { version = "0.23.1", features = [ "glsl", "hlsl" ] }
|
||||||
|
|
||||||
|
@ -14,11 +13,16 @@ spirv_cross = { version = "0.23.1", features = [ "glsl", "hlsl" ] }
|
||||||
thiserror = "1.0.37"
|
thiserror = "1.0.37"
|
||||||
bitflags = "1.3.2"
|
bitflags = "1.3.2"
|
||||||
rustc-hash = "1.1.0"
|
rustc-hash = "1.1.0"
|
||||||
rspirv = "0.11.0+1.5.4"
|
|
||||||
|
|
||||||
rspirv-reflect = { git = "https://github.com/Traverse-Research/rspirv-reflect" }
|
|
||||||
|
|
||||||
librashader-common = { path = "../librashader-common" }
|
librashader-common = { path = "../librashader-common" }
|
||||||
librashader-preprocess = { path = "../librashader-preprocess" }
|
librashader-preprocess = { path = "../librashader-preprocess" }
|
||||||
|
|
||||||
|
naga = { version = "0.10.0", features = ["glsl-in", "spv-in", "spv-out", "glsl-out", "wgsl-out"], optional = true }
|
||||||
|
rspirv = { version = "0.11.0+1.5.4", optional = true }
|
||||||
|
rspirv-reflect = { git = "https://github.com/Traverse-Research/rspirv-reflect", optional = true }
|
||||||
|
|
||||||
|
[features]
|
||||||
|
default = []
|
||||||
|
unstable-rust-pipeline = [ "naga", "rspirv", "rspirv-reflect" ]
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
|
|
|
@ -2,13 +2,13 @@ use crate::back::targets::{CompilerBackend, FromCompilation, GLSL, HLSL};
|
||||||
use crate::back::CompileShader;
|
use crate::back::CompileShader;
|
||||||
use crate::error::ShaderReflectError;
|
use crate::error::ShaderReflectError;
|
||||||
use crate::front::shaderc::GlslangCompilation;
|
use crate::front::shaderc::GlslangCompilation;
|
||||||
use crate::reflect::cross::{CompiledAst, CrossReflect, GlslReflect, HlslReflect};
|
use crate::reflect::cross::{CompiledAst, GlslReflect, HlslReflect};
|
||||||
use crate::reflect::ReflectShader;
|
use crate::reflect::ReflectShader;
|
||||||
|
|
||||||
pub type GlVersion = spirv_cross::glsl::Version;
|
pub type GlVersion = spirv_cross::glsl::Version;
|
||||||
pub struct GlslangGlslContext {
|
pub struct GlslangGlslContext {
|
||||||
pub sampler_bindings: Vec<u32>,
|
pub sampler_bindings: Vec<u32>,
|
||||||
pub compiler: CompiledAst<spirv_cross::glsl::Target>
|
pub compiler: CompiledAst<spirv_cross::glsl::Target>,
|
||||||
}
|
}
|
||||||
impl FromCompilation<GlslangCompilation> for GLSL {
|
impl FromCompilation<GlslangCompilation> for GLSL {
|
||||||
type Target = GLSL;
|
type Target = GLSL;
|
||||||
|
@ -18,7 +18,10 @@ impl FromCompilation<GlslangCompilation> for GLSL {
|
||||||
fn from_compilation(
|
fn from_compilation(
|
||||||
compile: GlslangCompilation,
|
compile: GlslangCompilation,
|
||||||
) -> Result<
|
) -> Result<
|
||||||
CompilerBackend<impl CompileShader<Self::Target, Options = Self::Options, Context = Self::Context> + ReflectShader>,
|
CompilerBackend<
|
||||||
|
impl CompileShader<Self::Target, Options = Self::Options, Context = Self::Context>
|
||||||
|
+ ReflectShader,
|
||||||
|
>,
|
||||||
ShaderReflectError,
|
ShaderReflectError,
|
||||||
> {
|
> {
|
||||||
Ok(CompilerBackend {
|
Ok(CompilerBackend {
|
||||||
|
@ -35,7 +38,10 @@ impl FromCompilation<GlslangCompilation> for HLSL {
|
||||||
fn from_compilation(
|
fn from_compilation(
|
||||||
compile: GlslangCompilation,
|
compile: GlslangCompilation,
|
||||||
) -> Result<
|
) -> Result<
|
||||||
CompilerBackend<impl CompileShader<Self::Target, Options = Self::Options, Context = Self::Context> + ReflectShader>,
|
CompilerBackend<
|
||||||
|
impl CompileShader<Self::Target, Options = Self::Options, Context = Self::Context>
|
||||||
|
+ ReflectShader,
|
||||||
|
>,
|
||||||
ShaderReflectError,
|
ShaderReflectError,
|
||||||
> {
|
> {
|
||||||
Ok(CompilerBackend {
|
Ok(CompilerBackend {
|
||||||
|
|
|
@ -32,7 +32,10 @@ pub trait FromCompilation<T> {
|
||||||
|
|
||||||
fn from_compilation(
|
fn from_compilation(
|
||||||
compile: T,
|
compile: T,
|
||||||
) -> Result<CompilerBackend<impl CompileShader<Self::Target, Context=Self::Context> + ReflectShader>, ShaderReflectError>;
|
) -> Result<
|
||||||
|
CompilerBackend<impl CompileShader<Self::Target, Context = Self::Context> + ReflectShader>,
|
||||||
|
ShaderReflectError,
|
||||||
|
>;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait CompileShader<T: OutputTarget> {
|
pub trait CompileShader<T: OutputTarget> {
|
||||||
|
|
|
@ -3,6 +3,7 @@ use thiserror::Error;
|
||||||
|
|
||||||
#[derive(Error, Debug)]
|
#[derive(Error, Debug)]
|
||||||
pub enum ShaderCompileError {
|
pub enum ShaderCompileError {
|
||||||
|
#[cfg(feature = "unstable-rust-pipeline")]
|
||||||
#[error("shader")]
|
#[error("shader")]
|
||||||
NagaCompileError(Vec<naga::front::glsl::Error>),
|
NagaCompileError(Vec<naga::front::glsl::Error>),
|
||||||
|
|
||||||
|
@ -33,12 +34,14 @@ pub enum SemanticsErrorKind {
|
||||||
|
|
||||||
#[derive(Error, Debug)]
|
#[derive(Error, Debug)]
|
||||||
pub enum ShaderReflectError {
|
pub enum ShaderReflectError {
|
||||||
|
#[cfg(feature = "unstable-rust-pipeline")]
|
||||||
#[error("shader")]
|
#[error("shader")]
|
||||||
NagaCompileError(#[from] naga::front::spv::Error),
|
NagaCompileError(#[from] naga::front::spv::Error),
|
||||||
#[error("spirv")]
|
#[cfg(feature = "unstable-rust-pipeline")]
|
||||||
SpirvCrossError(#[from] spirv_cross::ErrorCode),
|
|
||||||
#[error("rspirv")]
|
#[error("rspirv")]
|
||||||
RspirvParseError(#[from] rspirv::binary::ParseState),
|
RspirvParseError(#[from] rspirv::binary::ParseState),
|
||||||
|
#[error("spirv")]
|
||||||
|
SpirvCrossError(#[from] spirv_cross::ErrorCode),
|
||||||
#[error("error when verifying vertex semantics")]
|
#[error("error when verifying vertex semantics")]
|
||||||
VertexSemanticError(SemanticsErrorKind),
|
VertexSemanticError(SemanticsErrorKind),
|
||||||
#[error("error when verifying texture semantics")]
|
#[error("error when verifying texture semantics")]
|
||||||
|
@ -63,6 +66,7 @@ pub enum ShaderReflectError {
|
||||||
BindingInUse(u32),
|
BindingInUse(u32),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "unstable-rust-pipeline")]
|
||||||
impl From<Vec<naga::front::glsl::Error>> for ShaderCompileError {
|
impl From<Vec<naga::front::glsl::Error>> for ShaderCompileError {
|
||||||
fn from(err: Vec<naga::front::glsl::Error>) -> Self {
|
fn from(err: Vec<naga::front::glsl::Error>) -> Self {
|
||||||
ShaderCompileError::NagaCompileError(err)
|
ShaderCompileError::NagaCompileError(err)
|
||||||
|
|
|
@ -1,2 +1,4 @@
|
||||||
|
#[cfg(feature = "unstable-rust-pipeline")]
|
||||||
pub mod naga;
|
pub mod naga;
|
||||||
|
|
||||||
pub mod shaderc;
|
pub mod shaderc;
|
||||||
|
|
|
@ -124,9 +124,10 @@ pub fn compile_spirv(source: &ShaderSource) -> Result<GlslangCompilation, Shader
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
use crate::front::shaderc::compile_spirv;
|
use crate::front::shaderc::compile_spirv;
|
||||||
|
use librashader_preprocess::ShaderSource;
|
||||||
#[test]
|
#[test]
|
||||||
pub fn compile_shader() {
|
pub fn compile_shader() {
|
||||||
let result = librashader_preprocess::load_shader_source("../test/basic.slang").unwrap();
|
let result = ShaderSource::load("../test/basic.slang").unwrap();
|
||||||
let _spirv = compile_spirv(&result).unwrap();
|
let _spirv = compile_spirv(&result).unwrap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
#![feature(let_else)]
|
|
||||||
#![feature(associated_type_defaults)]
|
|
||||||
#![feature(return_position_impl_trait_in_trait)]
|
#![feature(return_position_impl_trait_in_trait)]
|
||||||
|
|
||||||
pub mod back;
|
pub mod back;
|
||||||
|
|
|
@ -13,9 +13,9 @@ use spirv_cross::hlsl::ShaderModel;
|
||||||
use spirv_cross::spirv::{Ast, Decoration, Module, Resource, ShaderResources, Type};
|
use spirv_cross::spirv::{Ast, Decoration, Module, Resource, ShaderResources, Type};
|
||||||
use spirv_cross::{glsl, hlsl, ErrorCode};
|
use spirv_cross::{glsl, hlsl, ErrorCode};
|
||||||
|
|
||||||
|
use crate::back::cross::GlslangGlslContext;
|
||||||
use crate::back::targets::{GLSL, HLSL};
|
use crate::back::targets::{GLSL, HLSL};
|
||||||
use crate::back::{CompileShader, ShaderCompilerOutput};
|
use crate::back::{CompileShader, ShaderCompilerOutput};
|
||||||
use crate::back::cross::GlslangGlslContext;
|
|
||||||
|
|
||||||
pub struct CrossReflect<T>
|
pub struct CrossReflect<T>
|
||||||
where
|
where
|
||||||
|
@ -27,12 +27,12 @@ where
|
||||||
|
|
||||||
pub struct CompiledAst<T>
|
pub struct CompiledAst<T>
|
||||||
where
|
where
|
||||||
T: spirv_cross::spirv::Target {
|
T: spirv_cross::spirv::Target,
|
||||||
|
{
|
||||||
pub vertex: Ast<T>,
|
pub vertex: Ast<T>,
|
||||||
pub fragment: Ast<T>,
|
pub fragment: Ast<T>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
pub(crate) type HlslReflect = CrossReflect<hlsl::Target>;
|
pub(crate) type HlslReflect = CrossReflect<hlsl::Target>;
|
||||||
pub(crate) type GlslReflect = CrossReflect<glsl::Target>;
|
pub(crate) type GlslReflect = CrossReflect<glsl::Target>;
|
||||||
|
|
||||||
|
@ -408,7 +408,7 @@ where
|
||||||
SemanticErrorBlame::Vertex => BindingStage::VERTEX,
|
SemanticErrorBlame::Vertex => BindingStage::VERTEX,
|
||||||
SemanticErrorBlame::Fragment => BindingStage::FRAGMENT,
|
SemanticErrorBlame::Fragment => BindingStage::FRAGMENT,
|
||||||
},
|
},
|
||||||
id: name
|
id: name,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -739,7 +739,7 @@ impl CompileShader<GLSL> for CrossReflect<glsl::Target> {
|
||||||
}
|
}
|
||||||
|
|
||||||
// todo: options
|
// todo: options
|
||||||
let flatten = false;
|
let _flatten = false;
|
||||||
|
|
||||||
if vertex_resources.uniform_buffers.len() > 1 {
|
if vertex_resources.uniform_buffers.len() > 1 {
|
||||||
return Err(ShaderCompileError::SpirvCrossCompileError(
|
return Err(ShaderCompileError::SpirvCrossCompileError(
|
||||||
|
@ -814,8 +814,8 @@ impl CompileShader<GLSL> for CrossReflect<glsl::Target> {
|
||||||
sampler_bindings: texture_fixups,
|
sampler_bindings: texture_fixups,
|
||||||
compiler: CompiledAst {
|
compiler: CompiledAst {
|
||||||
vertex: self.vertex,
|
vertex: self.vertex,
|
||||||
fragment: self.fragment
|
fragment: self.fragment,
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -851,15 +851,16 @@ mod test {
|
||||||
|
|
||||||
use crate::back::CompileShader;
|
use crate::back::CompileShader;
|
||||||
use crate::reflect::semantics::{SemanticMap, VariableSemantics};
|
use crate::reflect::semantics::{SemanticMap, VariableSemantics};
|
||||||
|
use librashader_preprocess::ShaderSource;
|
||||||
|
use spirv_cross::glsl;
|
||||||
use spirv_cross::glsl::{CompilerOptions, Version};
|
use spirv_cross::glsl::{CompilerOptions, Version};
|
||||||
use spirv_cross::{glsl, hlsl};
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
pub fn test_into() {
|
pub fn test_into() {
|
||||||
let result = librashader_preprocess::load_shader_source("../test/basic.slang").unwrap();
|
let result = ShaderSource::load("../test/basic.slang").unwrap();
|
||||||
let mut uniform_semantics: FxHashMap<String, UniformSemantic> = Default::default();
|
let mut uniform_semantics: FxHashMap<String, UniformSemantic> = Default::default();
|
||||||
|
|
||||||
for (index, param) in result.parameters.iter().enumerate() {
|
for (_index, param) in result.parameters.iter().enumerate() {
|
||||||
uniform_semantics.insert(
|
uniform_semantics.insert(
|
||||||
param.id.clone(),
|
param.id.clone(),
|
||||||
UniformSemantic::Variable(SemanticMap {
|
UniformSemantic::Variable(SemanticMap {
|
||||||
|
@ -870,7 +871,7 @@ mod test {
|
||||||
}
|
}
|
||||||
let spirv = crate::front::shaderc::compile_spirv(&result).unwrap();
|
let spirv = crate::front::shaderc::compile_spirv(&result).unwrap();
|
||||||
let mut reflect = CrossReflect::<glsl::Target>::try_from(spirv).unwrap();
|
let mut reflect = CrossReflect::<glsl::Target>::try_from(spirv).unwrap();
|
||||||
let shader_reflection = reflect
|
let _shader_reflection = reflect
|
||||||
.reflect(
|
.reflect(
|
||||||
0,
|
0,
|
||||||
&ReflectSemantics {
|
&ReflectSemantics {
|
||||||
|
@ -882,7 +883,7 @@ mod test {
|
||||||
let mut opts = CompilerOptions::default();
|
let mut opts = CompilerOptions::default();
|
||||||
opts.version = Version::V4_60;
|
opts.version = Version::V4_60;
|
||||||
opts.enable_420_pack_extension = false;
|
opts.enable_420_pack_extension = false;
|
||||||
let compiled = reflect.compile(&opts, &shader_reflection).unwrap();
|
let compiled = reflect.compile(Version::V3_30).unwrap();
|
||||||
// eprintln!("{shader_reflection:#?}");
|
// eprintln!("{shader_reflection:#?}");
|
||||||
eprintln!("{:#}", compiled.fragment)
|
eprintln!("{:#}", compiled.fragment)
|
||||||
// let mut loader = rspirv::dr::Loader::new();
|
// let mut loader = rspirv::dr::Loader::new();
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
use std::ops::Index;
|
|
||||||
use crate::error::ShaderReflectError;
|
use crate::error::ShaderReflectError;
|
||||||
use crate::reflect::semantics::{
|
use crate::reflect::semantics::{
|
||||||
SemanticMap, TextureImage, TextureSemantics, TextureSizeMeta, VariableMeta, VariableSemantics,
|
SemanticMap, TextureImage, TextureSemantics, TextureSizeMeta, VariableMeta, VariableSemantics,
|
||||||
|
@ -7,10 +6,14 @@ use rustc_hash::FxHashMap;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
|
||||||
pub mod cross;
|
pub mod cross;
|
||||||
mod naga;
|
|
||||||
mod rspirv;
|
|
||||||
pub mod semantics;
|
pub mod semantics;
|
||||||
|
|
||||||
|
#[cfg(feature = "unstable-rust-pipeline")]
|
||||||
|
mod naga;
|
||||||
|
#[cfg(feature = "unstable-rust-pipeline")]
|
||||||
|
mod rspirv;
|
||||||
|
|
||||||
pub trait ReflectShader {
|
pub trait ReflectShader {
|
||||||
fn reflect(
|
fn reflect(
|
||||||
&mut self,
|
&mut self,
|
||||||
|
@ -98,9 +101,7 @@ impl TextureSemanticMap<UniformSemantic> for FxHashMap<String, SemanticMap<Textu
|
||||||
None => {
|
None => {
|
||||||
if let Some(semantics) = TextureSemantics::TEXTURE_SEMANTICS
|
if let Some(semantics) = TextureSemantics::TEXTURE_SEMANTICS
|
||||||
.iter()
|
.iter()
|
||||||
.find(|f| {
|
.find(|f| name.starts_with(f.texture_name()))
|
||||||
name.starts_with(f.texture_name())
|
|
||||||
})
|
|
||||||
{
|
{
|
||||||
if semantics.is_array() {
|
if semantics.is_array() {
|
||||||
let index = &name[semantics.texture_name().len()..];
|
let index = &name[semantics.texture_name().len()..];
|
||||||
|
|
|
@ -11,7 +11,7 @@ pub enum UniformType {
|
||||||
Size,
|
Size,
|
||||||
Unsigned,
|
Unsigned,
|
||||||
Signed,
|
Signed,
|
||||||
Float
|
Float,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Ord, PartialOrd, Eq, PartialEq, Copy, Clone, Hash)]
|
#[derive(Debug, Ord, PartialOrd, Eq, PartialEq, Copy, Clone, Hash)]
|
||||||
|
@ -35,7 +35,7 @@ impl VariableSemantics {
|
||||||
pub const fn semantics(self) -> SemanticMap<VariableSemantics, ()> {
|
pub const fn semantics(self) -> SemanticMap<VariableSemantics, ()> {
|
||||||
SemanticMap {
|
SemanticMap {
|
||||||
semantics: self,
|
semantics: self,
|
||||||
index: ()
|
index: (),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ impl VariableSemantics {
|
||||||
VariableSemantics::FinalViewport => UniformType::Size,
|
VariableSemantics::FinalViewport => UniformType::Size,
|
||||||
VariableSemantics::FrameCount => UniformType::Unsigned,
|
VariableSemantics::FrameCount => UniformType::Unsigned,
|
||||||
VariableSemantics::FrameDirection => UniformType::Signed,
|
VariableSemantics::FrameDirection => UniformType::Signed,
|
||||||
VariableSemantics::FloatParameter => UniformType::Float
|
VariableSemantics::FloatParameter => UniformType::Float,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -104,7 +104,7 @@ impl TextureSemantics {
|
||||||
pub const fn semantics(self, index: usize) -> SemanticMap<TextureSemantics> {
|
pub const fn semantics(self, index: usize) -> SemanticMap<TextureSemantics> {
|
||||||
SemanticMap {
|
SemanticMap {
|
||||||
semantics: self,
|
semantics: self,
|
||||||
index
|
index,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -118,7 +118,7 @@ pub trait ValidateTypeSemantics<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
|
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
|
||||||
pub struct SemanticMap<T, I=usize> {
|
pub struct SemanticMap<T, I = usize> {
|
||||||
pub semantics: T,
|
pub semantics: T,
|
||||||
pub index: I,
|
pub index: I,
|
||||||
}
|
}
|
||||||
|
@ -207,4 +207,4 @@ impl UniformMeta for TextureSizeMeta {
|
||||||
fn id(&self) -> &str {
|
fn id(&self) -> &str {
|
||||||
&self.id
|
&self.id
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,19 +1,19 @@
|
||||||
use std::collections::HashMap;
|
|
||||||
use std::error::Error;
|
|
||||||
use std::path::Path;
|
|
||||||
use rustc_hash::FxHashMap;
|
|
||||||
use librashader_preprocess::ShaderSource;
|
use librashader_preprocess::ShaderSource;
|
||||||
use librashader_presets::ShaderPassConfig;
|
use librashader_presets::ShaderPassConfig;
|
||||||
use librashader_reflect::back::{CompileShader};
|
|
||||||
use librashader_reflect::back::targets::{FromCompilation, HLSL};
|
use librashader_reflect::back::targets::{FromCompilation, HLSL};
|
||||||
use librashader_reflect::front::shaderc::GlslangCompilation;
|
use librashader_reflect::back::CompileShader;
|
||||||
use librashader_reflect::reflect::cross::{CrossReflect};
|
use rustc_hash::FxHashMap;
|
||||||
use librashader_reflect::reflect::{ReflectSemantics, ReflectShader, UniformSemantic};
|
use std::error::Error;
|
||||||
|
use std::path::Path;
|
||||||
|
|
||||||
use librashader_reflect::reflect::semantics::{SemanticMap, TextureSemantics, VariableSemantics};
|
use librashader_reflect::reflect::semantics::{SemanticMap, TextureSemantics, VariableSemantics};
|
||||||
|
use librashader_reflect::reflect::{ReflectSemantics, ReflectShader, UniformSemantic};
|
||||||
|
|
||||||
|
pub fn load_pass_semantics(
|
||||||
pub fn load_pass_semantics(uniform_semantics: &mut FxHashMap<String, UniformSemantic>, texture_semantics: &mut FxHashMap<String, SemanticMap<TextureSemantics>>,
|
uniform_semantics: &mut FxHashMap<String, UniformSemantic>,
|
||||||
config: &ShaderPassConfig) {
|
texture_semantics: &mut FxHashMap<String, SemanticMap<TextureSemantics>>,
|
||||||
|
config: &ShaderPassConfig,
|
||||||
|
) {
|
||||||
let Some(alias) = &config.alias else {
|
let Some(alias) = &config.alias else {
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
@ -26,77 +26,94 @@ pub fn load_pass_semantics(uniform_semantics: &mut FxHashMap<String, UniformSema
|
||||||
let index = config.id as usize;
|
let index = config.id as usize;
|
||||||
|
|
||||||
// PassOutput
|
// PassOutput
|
||||||
texture_semantics.insert(alias.clone(), SemanticMap {
|
texture_semantics.insert(
|
||||||
semantics: TextureSemantics::PassOutput,
|
alias.clone(),
|
||||||
index
|
SemanticMap {
|
||||||
});
|
semantics: TextureSemantics::PassOutput,
|
||||||
uniform_semantics.insert(format!("{alias}Size"), UniformSemantic::Texture(SemanticMap {
|
index,
|
||||||
semantics: TextureSemantics::PassOutput,
|
},
|
||||||
index
|
);
|
||||||
}));
|
uniform_semantics.insert(
|
||||||
|
format!("{alias}Size"),
|
||||||
|
UniformSemantic::Texture(SemanticMap {
|
||||||
|
semantics: TextureSemantics::PassOutput,
|
||||||
|
index,
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
// PassFeedback
|
// PassFeedback
|
||||||
texture_semantics.insert(format!("{alias}Feedback"), SemanticMap {
|
texture_semantics.insert(
|
||||||
semantics: TextureSemantics::PassFeedback,
|
format!("{alias}Feedback"),
|
||||||
index
|
SemanticMap {
|
||||||
});
|
semantics: TextureSemantics::PassFeedback,
|
||||||
uniform_semantics.insert(format!("{alias}FeedbackSize"), UniformSemantic::Texture(SemanticMap {
|
index,
|
||||||
semantics: TextureSemantics::PassFeedback,
|
},
|
||||||
index
|
);
|
||||||
}));
|
uniform_semantics.insert(
|
||||||
|
format!("{alias}FeedbackSize"),
|
||||||
|
UniformSemantic::Texture(SemanticMap {
|
||||||
|
semantics: TextureSemantics::PassFeedback,
|
||||||
|
index,
|
||||||
|
}),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn load(path: impl AsRef<Path>) -> Result<(), Box<dyn Error>>{
|
pub fn load(path: impl AsRef<Path>) -> Result<(), Box<dyn Error>> {
|
||||||
let preset = librashader_presets::ShaderPreset::try_parse(path)?;
|
let preset = librashader_presets::ShaderPreset::try_parse(path)?;
|
||||||
let mut passes: Vec<(&ShaderPassConfig, ShaderSource, _)> = preset.shaders.iter()
|
let passes: Vec<(&ShaderPassConfig, ShaderSource, _)> = preset
|
||||||
|
.shaders
|
||||||
|
.iter()
|
||||||
.map(|shader| {
|
.map(|shader| {
|
||||||
let source = librashader_preprocess::load_shader_source(&shader.name)
|
let source = ShaderSource::load(&shader.name).unwrap();
|
||||||
.unwrap();
|
let spirv = librashader_reflect::front::shaderc::compile_spirv(&source).unwrap();
|
||||||
let spirv = librashader_reflect::front::shaderc::compile_spirv(&source)
|
let reflect = HLSL::from_compilation(spirv).unwrap();
|
||||||
.unwrap();
|
|
||||||
let mut reflect = HLSL::from_compilation(spirv).unwrap();
|
|
||||||
(shader, source, reflect)
|
(shader, source, reflect)
|
||||||
}).collect();
|
})
|
||||||
|
.collect();
|
||||||
|
|
||||||
// todo: this can probably be extracted out.
|
// todo: this can probably be extracted out.
|
||||||
let mut uniform_semantics: FxHashMap<String, UniformSemantic> = Default::default();
|
let mut uniform_semantics: FxHashMap<String, UniformSemantic> = Default::default();
|
||||||
let mut texture_semantics: FxHashMap<String, SemanticMap<TextureSemantics>> = Default::default();
|
let mut texture_semantics: FxHashMap<String, SemanticMap<TextureSemantics>> =
|
||||||
|
Default::default();
|
||||||
|
|
||||||
for details in &passes {
|
for details in &passes {
|
||||||
load_pass_semantics(&mut uniform_semantics, &mut texture_semantics, details.0)
|
load_pass_semantics(&mut uniform_semantics, &mut texture_semantics, details.0)
|
||||||
}
|
}
|
||||||
|
|
||||||
// add float params
|
// add float params
|
||||||
for (index, parameter) in preset.parameters.iter().enumerate() {
|
for (_index, parameter) in preset.parameters.iter().enumerate() {
|
||||||
uniform_semantics.insert(parameter.name.clone(), UniformSemantic::Variable(SemanticMap {
|
uniform_semantics.insert(
|
||||||
semantics: VariableSemantics::FloatParameter,
|
parameter.name.clone(),
|
||||||
index: ()
|
UniformSemantic::Variable(SemanticMap {
|
||||||
}));
|
semantics: VariableSemantics::FloatParameter,
|
||||||
|
index: (),
|
||||||
|
}),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// add lut params
|
// add lut params
|
||||||
for (index, texture) in preset.textures.iter().enumerate() {
|
for (index, texture) in preset.textures.iter().enumerate() {
|
||||||
texture_semantics.insert(texture.name.clone(), SemanticMap {
|
texture_semantics.insert(
|
||||||
semantics: TextureSemantics::User,
|
texture.name.clone(),
|
||||||
index
|
SemanticMap {
|
||||||
});
|
semantics: TextureSemantics::User,
|
||||||
|
index,
|
||||||
|
},
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
let semantics = ReflectSemantics {
|
let semantics = ReflectSemantics {
|
||||||
uniform_semantics,
|
uniform_semantics,
|
||||||
non_uniform_semantics: texture_semantics
|
non_uniform_semantics: texture_semantics,
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut reflections = Vec::new();
|
let mut reflections = Vec::new();
|
||||||
let mut compiled = Vec::new();
|
let mut compiled = Vec::new();
|
||||||
|
|
||||||
for (index, (_, _, mut reflect)) in passes.into_iter().enumerate() {
|
for (index, (_, _, mut reflect)) in passes.into_iter().enumerate() {
|
||||||
let reflection = reflect.reflect(index, &semantics)
|
let reflection = reflect.reflect(index, &semantics).unwrap();
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
let hlsl = reflect.compile(None)
|
let hlsl = reflect.compile(None).unwrap();
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
eprintln!("{:#}", hlsl.vertex);
|
eprintln!("{:#}", hlsl.vertex);
|
||||||
|
|
||||||
|
@ -104,13 +121,10 @@ pub fn load(path: impl AsRef<Path>) -> Result<(), Box<dyn Error>>{
|
||||||
|
|
||||||
compiled.push(hlsl);
|
compiled.push(hlsl);
|
||||||
reflections.push(reflection);
|
reflections.push(reflection);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
eprintln!("{:#?}", reflections);
|
eprintln!("{:#?}", reflections);
|
||||||
|
|
||||||
|
|
||||||
// //todo: add the semantics for other shit (slang_process:68)
|
// //todo: add the semantics for other shit (slang_process:68)
|
||||||
// eprintln!("{:?}", preset);
|
// eprintln!("{:?}", preset);
|
||||||
// eprintln!("{:?}", reflect.reflect(&ReflectOptions {
|
// eprintln!("{:?}", reflect.reflect(&ReflectOptions {
|
||||||
|
@ -128,8 +142,6 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn load_preset() {
|
fn load_preset() {
|
||||||
|
load("../test/basic.slangp").unwrap();
|
||||||
load("../test/basic.slangp")
|
|
||||||
.unwrap();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,15 +1,16 @@
|
||||||
use std::collections::VecDeque;
|
|
||||||
use crate::binding::{UniformBinding, UniformLocation, VariableLocation};
|
use crate::binding::{UniformBinding, UniformLocation, VariableLocation};
|
||||||
use crate::filter_pass::FilterPass;
|
use crate::filter_pass::FilterPass;
|
||||||
use crate::framebuffer::{Framebuffer, GlImage, Viewport};
|
use crate::framebuffer::{Framebuffer, GlImage, Viewport};
|
||||||
|
use crate::quad_render::DrawQuad;
|
||||||
use crate::render_target::RenderTarget;
|
use crate::render_target::RenderTarget;
|
||||||
use crate::util;
|
use crate::util;
|
||||||
use crate::util::{InlineRingBuffer, Texture};
|
use crate::util::{InlineRingBuffer, Texture};
|
||||||
use gl::types::{GLenum, GLint, GLsizei, GLsizeiptr, GLuint};
|
use gl::types::{GLenum, GLint, GLsizei, GLsizeiptr, GLuint};
|
||||||
use librashader_common::image::Image;
|
use librashader_common::image::Image;
|
||||||
use librashader_common::{FilterMode, Size, WrapMode};
|
use librashader_common::{FilterMode, Size, WrapMode};
|
||||||
use librashader_presets::{ScaleType, ShaderPassConfig, ShaderPreset, TextureConfig};
|
use librashader_preprocess::ShaderSource;
|
||||||
use librashader_reflect::back::cross::{GlslangGlslContext, GlVersion};
|
use librashader_presets::{ShaderPassConfig, ShaderPreset, TextureConfig};
|
||||||
|
use librashader_reflect::back::cross::{GlVersion, GlslangGlslContext};
|
||||||
use librashader_reflect::back::targets::{CompilerBackend, FromCompilation, GLSL};
|
use librashader_reflect::back::targets::{CompilerBackend, FromCompilation, GLSL};
|
||||||
use librashader_reflect::back::CompileShader;
|
use librashader_reflect::back::CompileShader;
|
||||||
use librashader_reflect::reflect::semantics::{
|
use librashader_reflect::reflect::semantics::{
|
||||||
|
@ -18,10 +19,9 @@ use librashader_reflect::reflect::semantics::{
|
||||||
use librashader_reflect::reflect::{ReflectSemantics, ReflectShader, UniformSemantic};
|
use librashader_reflect::reflect::{ReflectSemantics, ReflectShader, UniformSemantic};
|
||||||
use rustc_hash::FxHashMap;
|
use rustc_hash::FxHashMap;
|
||||||
use spirv_cross::spirv::Decoration;
|
use spirv_cross::spirv::Decoration;
|
||||||
|
use std::collections::VecDeque;
|
||||||
use std::error::Error;
|
use std::error::Error;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use librashader_preprocess::ShaderSource;
|
|
||||||
use crate::quad_render::DrawQuad;
|
|
||||||
|
|
||||||
pub struct FilterChain {
|
pub struct FilterChain {
|
||||||
passes: Box<[FilterPass]>,
|
passes: Box<[FilterPass]>,
|
||||||
|
@ -42,7 +42,6 @@ pub struct FilterCommon {
|
||||||
pub(crate) draw_quad: DrawQuad,
|
pub(crate) draw_quad: DrawQuad,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
impl FilterChain {
|
impl FilterChain {
|
||||||
fn load_pass_semantics(
|
fn load_pass_semantics(
|
||||||
uniform_semantics: &mut FxHashMap<String, UniformSemantic>,
|
uniform_semantics: &mut FxHashMap<String, UniformSemantic>,
|
||||||
|
@ -125,8 +124,7 @@ type ShaderPassMeta<'a> = (
|
||||||
&'a ShaderPassConfig,
|
&'a ShaderPassConfig,
|
||||||
ShaderSource,
|
ShaderSource,
|
||||||
CompilerBackend<
|
CompilerBackend<
|
||||||
impl CompileShader<GLSL, Options = GlVersion, Context = GlslangGlslContext>
|
impl CompileShader<GLSL, Options = GlVersion, Context = GlslangGlslContext> + ReflectShader,
|
||||||
+ ReflectShader
|
|
||||||
>,
|
>,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -139,7 +137,10 @@ impl FilterChain {
|
||||||
let filters = FilterChain::init_passes(passes, &semantics)?;
|
let filters = FilterChain::init_passes(passes, &semantics)?;
|
||||||
|
|
||||||
let default_filter = filters.first().map(|f| f.config.filter).unwrap_or_default();
|
let default_filter = filters.first().map(|f| f.config.filter).unwrap_or_default();
|
||||||
let default_wrap = filters.first().map(|f| f.config.wrap_mode).unwrap_or_default();
|
let default_wrap = filters
|
||||||
|
.first()
|
||||||
|
.map(|f| f.config.wrap_mode)
|
||||||
|
.unwrap_or_default();
|
||||||
|
|
||||||
// initialize output framebuffers
|
// initialize output framebuffers
|
||||||
let mut output_framebuffers = Vec::new();
|
let mut output_framebuffers = Vec::new();
|
||||||
|
@ -147,7 +148,6 @@ impl FilterChain {
|
||||||
let mut output_textures = Vec::new();
|
let mut output_textures = Vec::new();
|
||||||
output_textures.resize_with(filters.len(), Texture::default);
|
output_textures.resize_with(filters.len(), Texture::default);
|
||||||
|
|
||||||
|
|
||||||
// initialize feedback framebuffers
|
// initialize feedback framebuffers
|
||||||
let mut feedback_framebuffers = Vec::new();
|
let mut feedback_framebuffers = Vec::new();
|
||||||
feedback_framebuffers.resize_with(filters.len(), || Framebuffer::new(1));
|
feedback_framebuffers.resize_with(filters.len(), || Framebuffer::new(1));
|
||||||
|
@ -193,7 +193,9 @@ impl FilterChain {
|
||||||
Self::load_from_preset(preset)
|
Self::load_from_preset(preset)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn load_preset(preset: &ShaderPreset) -> Result<(Vec<ShaderPassMeta>, ReflectSemantics), Box<dyn Error>> {
|
fn load_preset(
|
||||||
|
preset: &ShaderPreset,
|
||||||
|
) -> Result<(Vec<ShaderPassMeta>, ReflectSemantics), Box<dyn Error>> {
|
||||||
let mut uniform_semantics: FxHashMap<String, UniformSemantic> = Default::default();
|
let mut uniform_semantics: FxHashMap<String, UniformSemantic> = Default::default();
|
||||||
let mut texture_semantics: FxHashMap<String, SemanticMap<TextureSemantics>> =
|
let mut texture_semantics: FxHashMap<String, SemanticMap<TextureSemantics>> =
|
||||||
Default::default();
|
Default::default();
|
||||||
|
@ -203,8 +205,7 @@ impl FilterChain {
|
||||||
.iter()
|
.iter()
|
||||||
.map(|shader| {
|
.map(|shader| {
|
||||||
eprintln!("[gl] loading {}", &shader.name.display());
|
eprintln!("[gl] loading {}", &shader.name.display());
|
||||||
let source: ShaderSource =
|
let source: ShaderSource = ShaderSource::load(&shader.name)?;
|
||||||
ShaderSource::load(&shader.name)?;
|
|
||||||
|
|
||||||
let spirv = librashader_reflect::front::shaderc::compile_spirv(&source)?;
|
let spirv = librashader_reflect::front::shaderc::compile_spirv(&source)?;
|
||||||
let reflect = GLSL::from_compilation(spirv)?;
|
let reflect = GLSL::from_compilation(spirv)?;
|
||||||
|
@ -221,9 +222,7 @@ impl FilterChain {
|
||||||
Ok::<_, Box<dyn Error>>((shader, source, reflect))
|
Ok::<_, Box<dyn Error>>((shader, source, reflect))
|
||||||
})
|
})
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.collect::<Result<Vec<(&ShaderPassConfig,
|
.collect::<Result<Vec<(&ShaderPassConfig, ShaderSource, CompilerBackend<_>)>, _>>()?;
|
||||||
ShaderSource,
|
|
||||||
CompilerBackend<_>)>, _>>()?;
|
|
||||||
|
|
||||||
for details in &passes {
|
for details in &passes {
|
||||||
FilterChain::load_pass_semantics(
|
FilterChain::load_pass_semantics(
|
||||||
|
@ -529,7 +528,11 @@ impl FilterChain {
|
||||||
Ok(filters.into_boxed_slice())
|
Ok(filters.into_boxed_slice())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn init_history(filters: &[FilterPass], filter: FilterMode, wrap_mode: WrapMode) -> (VecDeque<Framebuffer>, Box<[Texture]>) {
|
fn init_history(
|
||||||
|
filters: &[FilterPass],
|
||||||
|
filter: FilterMode,
|
||||||
|
wrap_mode: WrapMode,
|
||||||
|
) -> (VecDeque<Framebuffer>, Box<[Texture]>) {
|
||||||
let mut required_images = 0;
|
let mut required_images = 0;
|
||||||
|
|
||||||
for pass in filters {
|
for pass in filters {
|
||||||
|
@ -556,7 +559,7 @@ impl FilterChain {
|
||||||
// not using frame history;
|
// not using frame history;
|
||||||
if required_images <= 1 {
|
if required_images <= 1 {
|
||||||
println!("[history] not using frame history");
|
println!("[history] not using frame history");
|
||||||
return (VecDeque::new(), Box::new([]))
|
return (VecDeque::new(), Box::new([]));
|
||||||
}
|
}
|
||||||
|
|
||||||
// history0 is aliased with the original
|
// history0 is aliased with the original
|
||||||
|
@ -570,7 +573,7 @@ impl FilterChain {
|
||||||
image: Default::default(),
|
image: Default::default(),
|
||||||
filter,
|
filter,
|
||||||
mip_filter: filter,
|
mip_filter: filter,
|
||||||
wrap_mode
|
wrap_mode,
|
||||||
});
|
});
|
||||||
|
|
||||||
(framebuffers, history_textures.into_boxed_slice())
|
(framebuffers, history_textures.into_boxed_slice())
|
||||||
|
@ -578,14 +581,12 @@ impl FilterChain {
|
||||||
|
|
||||||
fn push_history(&mut self, input: &GlImage) {
|
fn push_history(&mut self, input: &GlImage) {
|
||||||
if let Some(mut back) = self.history_framebuffers.pop_back() {
|
if let Some(mut back) = self.history_framebuffers.pop_back() {
|
||||||
|
if back.size != input.size || (input.format != 0 && input.format != back.format) {
|
||||||
if back.size != input.size
|
|
||||||
|| (input.format != 0 && input.format != back.format) {
|
|
||||||
eprintln!("[history] resizing");
|
eprintln!("[history] resizing");
|
||||||
back.init(input.size, input.format);
|
back.init(input.size, input.format);
|
||||||
}
|
}
|
||||||
|
|
||||||
back.copy_from(&input);
|
back.copy_from(input);
|
||||||
|
|
||||||
self.history_framebuffers.push_front(back)
|
self.history_framebuffers.push_front(back)
|
||||||
}
|
}
|
||||||
|
@ -598,7 +599,6 @@ impl FilterChain {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if self.passes.is_empty() {
|
if self.passes.is_empty() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -612,15 +612,25 @@ impl FilterChain {
|
||||||
let wrap_mode = self.passes[0].config.wrap_mode;
|
let wrap_mode = self.passes[0].config.wrap_mode;
|
||||||
|
|
||||||
// update history
|
// update history
|
||||||
for (texture, fbo) in self.common.history_textures.iter_mut().zip(self.history_framebuffers.iter()) {
|
for (texture, fbo) in self
|
||||||
|
.common
|
||||||
|
.history_textures
|
||||||
|
.iter_mut()
|
||||||
|
.zip(self.history_framebuffers.iter())
|
||||||
|
{
|
||||||
texture.image = fbo.as_texture(filter, wrap_mode).image;
|
texture.image = fbo.as_texture(filter, wrap_mode).image;
|
||||||
}
|
}
|
||||||
|
|
||||||
for ((texture, fbo), pass) in self.common.feedback_textures.iter_mut()
|
for ((texture, fbo), pass) in self
|
||||||
|
.common
|
||||||
|
.feedback_textures
|
||||||
|
.iter_mut()
|
||||||
.zip(self.feedback_framebuffers.iter())
|
.zip(self.feedback_framebuffers.iter())
|
||||||
.zip(self.passes.iter())
|
.zip(self.passes.iter())
|
||||||
{
|
{
|
||||||
texture.image = fbo.as_texture(pass.config.filter, pass.config.wrap_mode).image;
|
texture.image = fbo
|
||||||
|
.as_texture(pass.config.filter, pass.config.wrap_mode)
|
||||||
|
.image;
|
||||||
}
|
}
|
||||||
|
|
||||||
// shader_gl3: 2067
|
// shader_gl3: 2067
|
||||||
|
@ -675,7 +685,6 @@ impl FilterChain {
|
||||||
let target = target.as_texture(pass.config.filter, pass.config.wrap_mode);
|
let target = target.as_texture(pass.config.filter, pass.config.wrap_mode);
|
||||||
self.common.output_textures[index] = target;
|
self.common.output_textures[index] = target;
|
||||||
source = target;
|
source = target;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
assert_eq!(last.len(), 1);
|
assert_eq!(last.len(), 1);
|
||||||
|
@ -697,19 +706,21 @@ impl FilterChain {
|
||||||
&source,
|
&source,
|
||||||
RenderTarget::new(viewport.output, viewport.mvp),
|
RenderTarget::new(viewport.output, viewport.mvp),
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// swap feedback framebuffers with output
|
// swap feedback framebuffers with output
|
||||||
for (output, feedback) in self.output_framebuffers.iter_mut().zip(self.feedback_framebuffers.iter_mut()) {
|
for (output, feedback) in self
|
||||||
|
.output_framebuffers
|
||||||
|
.iter_mut()
|
||||||
|
.zip(self.feedback_framebuffers.iter_mut())
|
||||||
|
{
|
||||||
std::mem::swap(output, feedback);
|
std::mem::swap(output, feedback);
|
||||||
}
|
}
|
||||||
|
|
||||||
self.push_history(&input);
|
self.push_history(input);
|
||||||
unsafe {
|
unsafe {
|
||||||
gl::BindFramebuffer(gl::FRAMEBUFFER, 0);
|
gl::BindFramebuffer(gl::FRAMEBUFFER, 0);
|
||||||
gl::BindVertexArray(0);
|
gl::BindVertexArray(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,12 +4,12 @@ use librashader_reflect::back::ShaderCompilerOutput;
|
||||||
use librashader_reflect::reflect::ShaderReflection;
|
use librashader_reflect::reflect::ShaderReflection;
|
||||||
|
|
||||||
use librashader_common::{ShaderFormat, Size};
|
use librashader_common::{ShaderFormat, Size};
|
||||||
|
use librashader_preprocess::ShaderSource;
|
||||||
use librashader_presets::ShaderPassConfig;
|
use librashader_presets::ShaderPassConfig;
|
||||||
use librashader_reflect::reflect::semantics::{
|
use librashader_reflect::reflect::semantics::{
|
||||||
MemberOffset, TextureImage, TextureSemantics, VariableSemantics,
|
MemberOffset, TextureImage, TextureSemantics, VariableSemantics,
|
||||||
};
|
};
|
||||||
use rustc_hash::FxHashMap;
|
use rustc_hash::FxHashMap;
|
||||||
use librashader_preprocess::ShaderSource;
|
|
||||||
|
|
||||||
use crate::binding::{UniformBinding, UniformLocation, VariableLocation};
|
use crate::binding::{UniformBinding, UniformLocation, VariableLocation};
|
||||||
use crate::filter_chain::FilterCommon;
|
use crate::filter_chain::FilterCommon;
|
||||||
|
@ -392,8 +392,12 @@ impl FilterPass {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if let Some(binding) = self
|
||||||
if let Some(binding) = self.reflection.meta.texture_meta.get(&TextureSemantics::OriginalHistory.semantics(0)) {
|
.reflection
|
||||||
|
.meta
|
||||||
|
.texture_meta
|
||||||
|
.get(&TextureSemantics::OriginalHistory.semantics(0))
|
||||||
|
{
|
||||||
FilterPass::bind_texture(binding, original);
|
FilterPass::bind_texture(binding, original);
|
||||||
}
|
}
|
||||||
if let Some((location, offset)) = self
|
if let Some((location, offset)) = self
|
||||||
|
@ -421,10 +425,11 @@ impl FilterPass {
|
||||||
FilterPass::bind_texture(binding, output);
|
FilterPass::bind_texture(binding, output);
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some((location, offset)) = self
|
if let Some((location, offset)) = self.variable_bindings.get(
|
||||||
.variable_bindings
|
&TextureSemantics::OriginalHistory
|
||||||
.get(&TextureSemantics::OriginalHistory.semantics(index + 1).into())
|
.semantics(index + 1)
|
||||||
{
|
.into(),
|
||||||
|
) {
|
||||||
let (buffer, offset) = match offset {
|
let (buffer, offset) = match offset {
|
||||||
MemberOffset::Ubo(offset) => (&mut self.uniform_buffer, *offset),
|
MemberOffset::Ubo(offset) => (&mut self.uniform_buffer, *offset),
|
||||||
MemberOffset::PushConstant(offset) => (&mut self.push_buffer, *offset),
|
MemberOffset::PushConstant(offset) => (&mut self.push_buffer, *offset),
|
||||||
|
|
|
@ -34,7 +34,7 @@ impl Framebuffer {
|
||||||
max_levels,
|
max_levels,
|
||||||
levels: 0,
|
levels: 0,
|
||||||
handle: framebuffer,
|
handle: framebuffer,
|
||||||
is_raw: false
|
is_raw: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ impl Framebuffer {
|
||||||
max_levels: miplevels,
|
max_levels: miplevels,
|
||||||
levels: miplevels,
|
levels: miplevels,
|
||||||
handle,
|
handle,
|
||||||
is_raw: true
|
is_raw: true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -153,30 +153,51 @@ impl Framebuffer {
|
||||||
unsafe {
|
unsafe {
|
||||||
gl::BindFramebuffer(gl::FRAMEBUFFER, self.handle);
|
gl::BindFramebuffer(gl::FRAMEBUFFER, self.handle);
|
||||||
|
|
||||||
gl::FramebufferTexture2D(gl::READ_FRAMEBUFFER,
|
gl::FramebufferTexture2D(
|
||||||
gl::COLOR_ATTACHMENT0,
|
gl::READ_FRAMEBUFFER,
|
||||||
gl::TEXTURE_2D,
|
gl::COLOR_ATTACHMENT0,
|
||||||
image.handle, 0);
|
gl::TEXTURE_2D,
|
||||||
|
image.handle,
|
||||||
|
0,
|
||||||
|
);
|
||||||
|
|
||||||
gl::FramebufferTexture2D(gl::DRAW_FRAMEBUFFER,
|
gl::FramebufferTexture2D(
|
||||||
gl::COLOR_ATTACHMENT1,
|
gl::DRAW_FRAMEBUFFER,
|
||||||
gl::TEXTURE_2D,
|
gl::COLOR_ATTACHMENT1,
|
||||||
self.image, 0);
|
gl::TEXTURE_2D,
|
||||||
|
self.image,
|
||||||
|
0,
|
||||||
|
);
|
||||||
gl::DrawBuffer(gl::COLOR_ATTACHMENT1);
|
gl::DrawBuffer(gl::COLOR_ATTACHMENT1);
|
||||||
gl::BlitFramebuffer(0, 0, self.size.width as GLint, self.size.height as GLint,
|
gl::BlitFramebuffer(
|
||||||
0, 0, self.size.width as GLint, self.size.height as GLint,
|
0,
|
||||||
gl::COLOR_BUFFER_BIT, gl::NEAREST);
|
0,
|
||||||
|
self.size.width as GLint,
|
||||||
|
self.size.height as GLint,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
self.size.width as GLint,
|
||||||
|
self.size.height as GLint,
|
||||||
|
gl::COLOR_BUFFER_BIT,
|
||||||
|
gl::NEAREST,
|
||||||
|
);
|
||||||
|
|
||||||
// cleanup after ourselves.
|
// cleanup after ourselves.
|
||||||
gl::FramebufferTexture2D(gl::READ_FRAMEBUFFER,
|
gl::FramebufferTexture2D(
|
||||||
gl::COLOR_ATTACHMENT0,
|
gl::READ_FRAMEBUFFER,
|
||||||
gl::TEXTURE_2D,
|
gl::COLOR_ATTACHMENT0,
|
||||||
0, 0);
|
gl::TEXTURE_2D,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
);
|
||||||
|
|
||||||
gl::FramebufferTexture2D(gl::DRAW_FRAMEBUFFER,
|
gl::FramebufferTexture2D(
|
||||||
gl::COLOR_ATTACHMENT1,
|
gl::DRAW_FRAMEBUFFER,
|
||||||
gl::TEXTURE_2D,
|
gl::COLOR_ATTACHMENT1,
|
||||||
0, 0);
|
gl::TEXTURE_2D,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
);
|
||||||
|
|
||||||
// set this back to color_attachment 0
|
// set this back to color_attachment 0
|
||||||
gl::FramebufferTexture2D(
|
gl::FramebufferTexture2D(
|
||||||
|
|
|
@ -414,9 +414,7 @@ pub fn do_loop(
|
||||||
}
|
}
|
||||||
|
|
||||||
let fullscreen_fbo = [
|
let fullscreen_fbo = [
|
||||||
-1.0f32, -1.0, 0.0, 1.0,
|
-1.0f32, -1.0, 0.0, 1.0, -1.0, 0.0, -1.0, 1.0, 0.0, -1.0, 1.0, 0.0, 1.0, -1.0, 0.0,
|
||||||
-1.0, 0.0, -1.0, 1.0, 0.0,
|
|
||||||
-1.0, 1.0, 0.0, 1.0, -1.0, 0.0,
|
|
||||||
1.0, 1.0, 0.0,
|
1.0, 1.0, 0.0,
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -472,7 +470,6 @@ void main()
|
||||||
1,
|
1,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
while !window.should_close() {
|
while !window.should_close() {
|
||||||
glfw.poll_events();
|
glfw.poll_events();
|
||||||
for (_, event) in glfw::flush_messages(&events) {
|
for (_, event) in glfw::flush_messages(&events) {
|
||||||
|
@ -520,14 +517,7 @@ void main()
|
||||||
padded_size: Default::default(),
|
padded_size: Default::default(),
|
||||||
};
|
};
|
||||||
|
|
||||||
unsafe {
|
unsafe { filter.frame(framecount, &viewport, &rendered, false) }
|
||||||
filter.frame(
|
|
||||||
framecount,
|
|
||||||
&viewport,
|
|
||||||
&rendered,
|
|
||||||
false,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
// texture is done now.
|
// texture is done now.
|
||||||
|
@ -568,9 +558,7 @@ fn glfw_handle_event(window: &mut glfw::Window, event: glfw::WindowEvent) {
|
||||||
Event::Key(Key::Escape, _, Action::Press, _) => {
|
Event::Key(Key::Escape, _, Action::Press, _) => {
|
||||||
window.set_should_close(true);
|
window.set_should_close(true);
|
||||||
}
|
}
|
||||||
Event::Size(width, height) => {
|
Event::Size(width, height) => window.set_size(width, height),
|
||||||
window.set_size(width, height)
|
|
||||||
}
|
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,14 +6,14 @@ mod filter_chain;
|
||||||
mod filter_pass;
|
mod filter_pass;
|
||||||
mod framebuffer;
|
mod framebuffer;
|
||||||
mod hello_triangle;
|
mod hello_triangle;
|
||||||
|
mod quad_render;
|
||||||
mod render_target;
|
mod render_target;
|
||||||
mod util;
|
mod util;
|
||||||
mod quad_render;
|
|
||||||
|
|
||||||
pub use filter_chain::FilterChain;
|
pub use filter_chain::FilterChain;
|
||||||
pub use framebuffer::Viewport;
|
|
||||||
pub use framebuffer::GlImage;
|
|
||||||
pub use framebuffer::Framebuffer;
|
pub use framebuffer::Framebuffer;
|
||||||
|
pub use framebuffer::GlImage;
|
||||||
|
pub use framebuffer::Viewport;
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
|
@ -23,7 +23,9 @@ mod tests {
|
||||||
#[test]
|
#[test]
|
||||||
fn triangle() {
|
fn triangle() {
|
||||||
let (glfw, window, events, shader, vao) = hello_triangle::setup();
|
let (glfw, window, events, shader, vao) = hello_triangle::setup();
|
||||||
let mut filter = FilterChain::load_from_path("../test/slang-shaders/crt/crt-royale-fake-bloom.slangp").unwrap();
|
let mut filter =
|
||||||
|
FilterChain::load_from_path("../test/slang-shaders/crt/crt-royale-fake-bloom.slangp")
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
// FilterChain::load("../test/slang-shaders/crt/crt-royale.slangp").unwrap();
|
// FilterChain::load("../test/slang-shaders/crt/crt-royale.slangp").unwrap();
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
use gl::types::{GLsizeiptr, GLuint};
|
use gl::types::{GLsizeiptr, GLuint};
|
||||||
|
|
||||||
|
|
||||||
#[rustfmt::skip]
|
#[rustfmt::skip]
|
||||||
static QUAD_VBO_DATA: &[f32; 16] = &[
|
static QUAD_VBO_DATA: &[f32; 16] = &[
|
||||||
0.0f32, 0.0f32, 0.0f32, 0.0f32,
|
0.0f32, 0.0f32, 0.0f32, 0.0f32,
|
||||||
|
@ -10,7 +9,7 @@ static QUAD_VBO_DATA: &[f32; 16] = &[
|
||||||
];
|
];
|
||||||
|
|
||||||
pub struct DrawQuad {
|
pub struct DrawQuad {
|
||||||
pub vbo: GLuint
|
pub vbo: GLuint,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl DrawQuad {
|
impl DrawQuad {
|
||||||
|
@ -28,8 +27,6 @@ impl DrawQuad {
|
||||||
gl::BindBuffer(gl::ARRAY_BUFFER, 0);
|
gl::BindBuffer(gl::ARRAY_BUFFER, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
DrawQuad {
|
DrawQuad { vbo }
|
||||||
vbo
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
use crate::framebuffer::{Framebuffer, Viewport};
|
use crate::framebuffer::{Framebuffer, Viewport};
|
||||||
use crate::util::Texture;
|
|
||||||
|
|
||||||
#[rustfmt::skip]
|
#[rustfmt::skip]
|
||||||
static DEFAULT_MVP: &[f32] = &[
|
static DEFAULT_MVP: &[f32] = &[
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use crate::framebuffer::{Framebuffer, GlImage};
|
use crate::framebuffer::GlImage;
|
||||||
use gl::types::{GLenum, GLuint};
|
use gl::types::{GLenum, GLuint};
|
||||||
use librashader_common::{FilterMode, WrapMode};
|
use librashader_common::{FilterMode, WrapMode};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue