use librashader always

This commit is contained in:
Alex Janka 2023-10-23 13:08:09 +11:00
parent dc95861a82
commit a4ded97b06
9 changed files with 216 additions and 415 deletions

5
.vscode/settings.json vendored Normal file
View file

@ -0,0 +1,5 @@
{
"files.associations": {
"*.slang": "txt"
},
}

176
Cargo.lock generated
View file

@ -326,7 +326,7 @@ version = "0.68.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "726e4313eb6ec35d2730258ad4e15b547ee75d6afaa1361a922e78e59b7d8078"
dependencies = [
"bitflags 2.4.0",
"bitflags 2.4.1",
"cexpr",
"clang-sys",
"lazy_static",
@ -363,9 +363,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
[[package]]
name = "bitflags"
version = "2.4.0"
version = "2.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635"
checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07"
dependencies = [
"serde",
]
@ -691,12 +691,6 @@ dependencies = [
"libc",
]
[[package]]
name = "core-foundation-sys"
version = "0.6.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e7ca8a5221364ef15ce201e8ed2f609fc312682a8f4e0e3d4aa5879764e0fa3b"
[[package]]
name = "core-foundation-sys"
version = "0.7.0"
@ -772,12 +766,12 @@ dependencies = [
[[package]]
name = "coreaudio-rs"
version = "0.11.2"
version = "0.11.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cb17e2d1795b1996419648915df94bc7103c28f7b48062d7acf4652fc371b2ff"
checksum = "321077172d79c662f64f5071a03120748d5bb652f5231570141be24cfcd2bace"
dependencies = [
"bitflags 1.3.2",
"core-foundation-sys 0.6.2",
"core-foundation-sys 0.8.4",
"coreaudio-sys",
]
@ -975,10 +969,11 @@ checksum = "0c87e182de0887fd5361989c677c4e8f5000cd9491d6d563161a8f3a5519fc7f"
[[package]]
name = "deranged"
version = "0.3.8"
version = "0.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f2696e8a945f658fd14dc3b87242e6b80cd0f36ff04ea560fa39082368847946"
checksum = "0f32d04922c60427da6f9fef14d042d9edddef64cb9d4ce0d64d0685fbeb1fd3"
dependencies = [
"powerfmt",
"serde",
]
@ -1105,9 +1100,9 @@ dependencies = [
[[package]]
name = "flate2"
version = "1.0.27"
version = "1.0.28"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c6c98ee8095e9d1dcbf2fcc6d95acccb90d1c81db1e44725c6a984b1dbdfb010"
checksum = "46303f565772937ffe1d394a4fac6f411c6013172fadde9dcdb1e147a086940e"
dependencies = [
"crc32fast",
"miniz_oxide",
@ -1279,6 +1274,8 @@ dependencies = [
"futures",
"itertools",
"librashader",
"librashader-common",
"librashader-presets",
"naga 0.13.0",
"num-traits",
"pixels",
@ -1321,7 +1318,7 @@ dependencies = [
"fnv",
"gilrs-core",
"log",
"uuid 1.4.1",
"uuid 1.5.0",
"vec_map",
]
@ -1338,7 +1335,7 @@ dependencies = [
"libudev-sys",
"log",
"nix 0.26.4",
"uuid 1.4.1",
"uuid 1.5.0",
"vec_map",
"wasm-bindgen",
"web-sys",
@ -1419,9 +1416,9 @@ version = "0.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cc11df1ace8e7e564511f53af41f3e42ddc95b56fd07b3f4445d2a6048bc682c"
dependencies = [
"bitflags 2.4.0",
"bitflags 2.4.1",
"gpu-descriptor-types",
"hashbrown 0.14.1",
"hashbrown 0.14.2",
]
[[package]]
@ -1430,7 +1427,7 @@ version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6bf0b36e6f090b7e1d8a4b49c0cb81c1f8376f72198c65dd3ad9ff3556b8b78c"
dependencies = [
"bitflags 2.4.0",
"bitflags 2.4.1",
]
[[package]]
@ -1441,9 +1438,9 @@ checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888"
[[package]]
name = "hashbrown"
version = "0.14.1"
version = "0.14.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7dfda62a12f55daeae5015f81b0baea145391cb4520f86c248fc615d72640d12"
checksum = "f93e7192158dbcda357bdec5fb5788eebf8bbac027f3f33e719d29135ae84156"
dependencies = [
"ahash",
"allocator-api2",
@ -1455,7 +1452,7 @@ version = "0.8.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e8094feaf31ff591f651a2664fb9cfd92bba7a60ce3197265e9482ebe753c8f7"
dependencies = [
"hashbrown 0.14.1",
"hashbrown 0.14.2",
]
[[package]]
@ -1502,16 +1499,16 @@ checksum = "dfa686283ad6dd069f105e5ab091b04c62850d3e4cf5d67debad1933f55023df"
[[package]]
name = "iana-time-zone"
version = "0.1.57"
version = "0.1.58"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2fad5b825842d2b38bd206f3e81d6957625fd7f0a361e345c30e01a0ae2dd613"
checksum = "8326b86b6cff230b97d0d312a6c40a60726df3332e721f72a1b035f451663b20"
dependencies = [
"android_system_properties",
"core-foundation-sys 0.8.4",
"iana-time-zone-haiku",
"js-sys",
"wasm-bindgen",
"windows 0.48.0",
"windows-core",
]
[[package]]
@ -1564,7 +1561,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8adf3ddd720272c6ea8bf59463c04e0f93d0bbf7c5439b691bca2987e0270897"
dependencies = [
"equivalent",
"hashbrown 0.14.1",
"hashbrown 0.14.2",
"serde",
]
@ -1753,7 +1750,7 @@ dependencies = [
[[package]]
name = "librashader"
version = "0.1.4"
source = "git+https://github.com/italicsjenga/librashader#c5aac6615a395b752ae702da807a1a078bb00aae"
source = "git+https://github.com/italicsjenga/librashader#cdf98df0e30c5ffb74eeb3091aeb89642c5f9824"
dependencies = [
"ash",
"librashader-cache",
@ -1768,7 +1765,7 @@ dependencies = [
[[package]]
name = "librashader-cache"
version = "0.1.4"
source = "git+https://github.com/italicsjenga/librashader#c5aac6615a395b752ae702da807a1a078bb00aae"
source = "git+https://github.com/italicsjenga/librashader#cdf98df0e30c5ffb74eeb3091aeb89642c5f9824"
dependencies = [
"bincode",
"blake3",
@ -1784,7 +1781,7 @@ dependencies = [
[[package]]
name = "librashader-common"
version = "0.1.4"
source = "git+https://github.com/italicsjenga/librashader#c5aac6615a395b752ae702da807a1a078bb00aae"
source = "git+https://github.com/italicsjenga/librashader#cdf98df0e30c5ffb74eeb3091aeb89642c5f9824"
dependencies = [
"ash",
"num-traits",
@ -1793,7 +1790,7 @@ dependencies = [
[[package]]
name = "librashader-preprocess"
version = "0.1.4"
source = "git+https://github.com/italicsjenga/librashader#c5aac6615a395b752ae702da807a1a078bb00aae"
source = "git+https://github.com/italicsjenga/librashader#cdf98df0e30c5ffb74eeb3091aeb89642c5f9824"
dependencies = [
"encoding_rs",
"librashader-common",
@ -1805,7 +1802,7 @@ dependencies = [
[[package]]
name = "librashader-presets"
version = "0.1.4"
source = "git+https://github.com/italicsjenga/librashader#c5aac6615a395b752ae702da807a1a078bb00aae"
source = "git+https://github.com/italicsjenga/librashader#cdf98df0e30c5ffb74eeb3091aeb89642c5f9824"
dependencies = [
"librashader-common",
"nom",
@ -1817,7 +1814,7 @@ dependencies = [
[[package]]
name = "librashader-reflect"
version = "0.1.4"
source = "git+https://github.com/italicsjenga/librashader#c5aac6615a395b752ae702da807a1a078bb00aae"
source = "git+https://github.com/italicsjenga/librashader#cdf98df0e30c5ffb74eeb3091aeb89642c5f9824"
dependencies = [
"bitflags 1.3.2",
"bytemuck",
@ -1834,7 +1831,7 @@ dependencies = [
[[package]]
name = "librashader-runtime"
version = "0.1.4"
source = "git+https://github.com/italicsjenga/librashader#c5aac6615a395b752ae702da807a1a078bb00aae"
source = "git+https://github.com/italicsjenga/librashader#cdf98df0e30c5ffb74eeb3091aeb89642c5f9824"
dependencies = [
"bytemuck",
"image",
@ -1849,7 +1846,7 @@ dependencies = [
[[package]]
name = "librashader-runtime-vk"
version = "0.1.4"
source = "git+https://github.com/italicsjenga/librashader#c5aac6615a395b752ae702da807a1a078bb00aae"
source = "git+https://github.com/italicsjenga/librashader#cdf98df0e30c5ffb74eeb3091aeb89642c5f9824"
dependencies = [
"ash",
"bytemuck",
@ -1916,9 +1913,9 @@ checksum = "da2479e8c062e40bf0066ffa0bc823de0a9368974af99c9f6df941d2c231e03f"
[[package]]
name = "lock_api"
version = "0.4.10"
version = "0.4.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c1cc9717a20b1bb222f333e6a92fd32f7d8a18ddc5a3191a11af45dcbf4dcd16"
checksum = "3c168f8615b12bc01f9c17e2eb0cc07dcae1940121185446edc3744920e8ef45"
dependencies = [
"autocfg",
"scopeguard",
@ -2111,7 +2108,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c1ceaaa4eedaece7e4ec08c55c640ba03dbb73fb812a6570a59bcf1930d0f70e"
dependencies = [
"bit-set",
"bitflags 2.4.0",
"bitflags 2.4.1",
"codespan-reporting",
"hexf-parse",
"indexmap 1.9.3",
@ -2296,7 +2293,7 @@ version = "0.27.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2eb04e9c688eff1c89d72b407f168cf79bb9e867a9d3323ed6c01519eb9cc053"
dependencies = [
"bitflags 2.4.0",
"bitflags 2.4.1",
"cfg-if 1.0.0",
"libc",
]
@ -2575,13 +2572,13 @@ dependencies = [
[[package]]
name = "parking_lot_core"
version = "0.9.8"
version = "0.9.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "93f00c865fe7cabf650081affecd3871070f26767e7b2070a3ffae14c654b447"
checksum = "4c42a9226546d68acdd9c0a280d17ce19bfe27a46bf68784e4066115788d008e"
dependencies = [
"cfg-if 1.0.0",
"libc",
"redox_syscall 0.3.5",
"redox_syscall 0.4.1",
"smallvec",
"windows-targets 0.48.5",
]
@ -2673,9 +2670,9 @@ dependencies = [
[[package]]
name = "plist"
version = "1.5.0"
version = "1.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bdc0001cfea3db57a2e24bc0d818e9e20e554b5f97fabb9bc231dc240269ae06"
checksum = "9a4a0cfc5fb21a09dc6af4bf834cf10d4a32fccd9e2ea468c4b1751a097487aa"
dependencies = [
"base64",
"indexmap 1.9.3",
@ -2704,6 +2701,12 @@ version = "0.2.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5da3b0203fd7ee5720aa0b5e790b591aa5d3f41c3ed2c34a3a393382198af2f7"
[[package]]
name = "powerfmt"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391"
[[package]]
name = "ppv-lite86"
version = "0.2.17"
@ -2737,9 +2740,9 @@ checksum = "f89dff0959d98c9758c88826cc002e2c3d0b9dfac4139711d1f30de442f1139b"
[[package]]
name = "quick-xml"
version = "0.29.0"
version = "0.30.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "81b9228215d82c7b61490fec1de287136b5de6f5700f6e58ea9ad61a7964ca51"
checksum = "eff6510e86862b57b210fd8cbe8ed3f0d7d600b9c2863cd4549a2e033c66e956"
dependencies = [
"memchr",
]
@ -2845,6 +2848,15 @@ dependencies = [
"bitflags 1.3.2",
]
[[package]]
name = "redox_syscall"
version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa"
dependencies = [
"bitflags 1.3.2",
]
[[package]]
name = "redox_users"
version = "0.4.3"
@ -2867,9 +2879,9 @@ dependencies = [
[[package]]
name = "regex"
version = "1.10.0"
version = "1.10.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d119d7c7ca818f8a53c300863d4f87566aac09943aef5b355bb83969dae75d87"
checksum = "380b951a9c5e80ddfd6136919eef32310721aa4aacd4889a8d39124b026ab343"
dependencies = [
"aho-corasick",
"memchr",
@ -2879,9 +2891,9 @@ dependencies = [
[[package]]
name = "regex-automata"
version = "0.4.1"
version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "465c6fc0621e4abc4187a2bda0937bfd4f722c2730b29562e19689ea796c9a4b"
checksum = "5f804c7828047e88b2d32e2d7fe5a105da8ee3264f01902f796c8e067dc2483f"
dependencies = [
"aho-corasick",
"memchr",
@ -2890,9 +2902,9 @@ dependencies = [
[[package]]
name = "regex-syntax"
version = "0.8.1"
version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "56d84fdd47036b038fc80dd333d10b6aab10d5d31f4a366e20014def75328d33"
checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f"
[[package]]
name = "renderdoc-sys"
@ -2925,7 +2937,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b91f7eff05f748767f183df4320a63d6936e9c6107d97c9e6bdd9784f4289c94"
dependencies = [
"base64",
"bitflags 2.4.0",
"bitflags 2.4.1",
"serde",
"serde_derive",
]
@ -2976,11 +2988,11 @@ checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
[[package]]
name = "rustix"
version = "0.38.19"
version = "0.38.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "745ecfa778e66b2b63c88a61cb36e0eea109e803b0b86bf9879fbc77c70e86ed"
checksum = "67ce50cb2e16c2903e30d1cbccfd8387a74b9d4c938b6a4c5ec6cc7556f7a8a0"
dependencies = [
"bitflags 2.4.0",
"bitflags 2.4.1",
"errno",
"libc",
"linux-raw-sys",
@ -3070,18 +3082,18 @@ checksum = "cd0b0ec5f1c1ca621c432a25813d8d60c88abe6d3e08a3eb9cf37d97a0fe3d73"
[[package]]
name = "serde"
version = "1.0.188"
version = "1.0.189"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf9e0fcba69a370eed61bcf2b728575f726b50b55cba78064753d708ddc7549e"
checksum = "8e422a44e74ad4001bdc8eede9a4570ab52f71190e9c076d14369f38b9200537"
dependencies = [
"serde_derive",
]
[[package]]
name = "serde_derive"
version = "1.0.188"
version = "1.0.189"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4eca7ac642d82aa35b60049a6eccb4be6be75e599bd2e9adb5f875a737654af2"
checksum = "1e48d1f918009ce3145511378cf68d613e3b3d9137d67272562080d68a2b32d5"
dependencies = [
"proc-macro2",
"quote",
@ -3110,9 +3122,9 @@ dependencies = [
[[package]]
name = "serde_with"
version = "3.3.0"
version = "3.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1ca3b16a3d82c4088f343b7480a93550b3eabe1a358569c2dfe38bbcead07237"
checksum = "64cd236ccc1b7a29e7e2739f27c0b2dd199804abc4290e32f59f3b68d6405c23"
dependencies = [
"base64",
"chrono",
@ -3127,9 +3139,9 @@ dependencies = [
[[package]]
name = "serde_with_macros"
version = "3.3.0"
version = "3.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2e6be15c453eb305019bfa438b1593c731f36a289a7853f7707ee29e870b3b3c"
checksum = "93634eb5f75a2323b16de4748022ac4297f9e76b6dced2be287a099f41b5e788"
dependencies = [
"darling",
"proc-macro2",
@ -3293,18 +3305,18 @@ dependencies = [
[[package]]
name = "thiserror"
version = "1.0.49"
version = "1.0.50"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1177e8c6d7ede7afde3585fd2513e611227efd6481bd78d2e82ba1ce16557ed4"
checksum = "f9a7210f5c9a7156bb50aa36aed4c95afb51df0df00713949448cf9e97d382d2"
dependencies = [
"thiserror-impl",
]
[[package]]
name = "thiserror-impl"
version = "1.0.49"
version = "1.0.50"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "10712f02019e9288794769fba95cd6847df9874d49d871d062172f9dd41bc4cc"
checksum = "266b2e40bc00e5a6c09c3584011e08b06f123c00362c92b975ba9843aaaa14b8"
dependencies = [
"proc-macro2",
"quote",
@ -3324,14 +3336,15 @@ dependencies = [
[[package]]
name = "time"
version = "0.3.29"
version = "0.3.30"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "426f806f4089c493dcac0d24c29c01e2c38baf8e30f1b716ee37e83d200b18fe"
checksum = "c4a34ab300f2dee6e562c10a046fc05e358b29f9bf92277f30c3c8d82275f6f5"
dependencies = [
"deranged",
"itoa",
"libc",
"num_threads",
"powerfmt",
"serde",
"time-core",
"time-macros",
@ -3481,9 +3494,9 @@ dependencies = [
[[package]]
name = "uuid"
version = "1.4.1"
version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "79daa5ed5740825c40b389c5e50312b9c86df53fccd33f281df655642b43869d"
checksum = "88ad59a7560b41a70d191093a945f0b87bc1deeda46fb237479708a1d6b6cdfc"
[[package]]
name = "vcpkg"
@ -3819,9 +3832,9 @@ dependencies = [
[[package]]
name = "wide"
version = "0.7.12"
version = "0.7.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ebecebefc38ff1860b4bc47550bbfa63af5746061cf0d29fcd7fa63171602598"
checksum = "c68938b57b33da363195412cfc5fc37c9ed49aa9cfe2156fde64b8d2c9498242"
dependencies = [
"bytemuck",
"safe_arch",
@ -3903,15 +3916,6 @@ dependencies = [
"windows-targets 0.42.2",
]
[[package]]
name = "windows"
version = "0.48.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e686886bc078bc1b0b600cac0147aadb815089b6e4da64016cbd754b6342700f"
dependencies = [
"windows-targets 0.48.5",
]
[[package]]
name = "windows"
version = "0.51.1"
@ -4109,9 +4113,9 @@ dependencies = [
[[package]]
name = "winnow"
version = "0.5.16"
version = "0.5.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "037711d82167854aff2018dfd193aa0fef5370f456732f0d5a0c59b0f1b4b907"
checksum = "a3b801d0e0a6726477cc207f60162da452f3a95adb368399bef20a946e06f65c"
dependencies = [
"memchr",
]

View file

@ -16,11 +16,5 @@ librashader-presets = { git = "https://github.com/italicsjenga/librashader" }
librashader-preprocess = { git = "https://github.com/italicsjenga/librashader" }
librashader-reflect = { git = "https://github.com/italicsjenga/librashader" }
librashader-runtime = { git = "https://github.com/italicsjenga/librashader" }
# librashader-runtime-d3d11 = { git = "https://github.com/italicsjenga/librashader" }
# librashader-runtime-d3d12 = { git = "https://github.com/italicsjenga/librashader" }
# librashader-runtime-gl = { git = "https://github.com/italicsjenga/librashader" }
librashader-runtime-vk = { git = "https://github.com/italicsjenga/librashader" }
librashader-cache = { git = "https://github.com/italicsjenga/librashader" }
# librashader-capi = { git = "https://github.com/italicsjenga/librashader" }
# librashader-build-script = { git = "https://github.com/italicsjenga/librashader" }
# ash = { git = "https://github.com/ash-rs/ash" }

View file

@ -12,6 +12,8 @@ vulkan-renderer = [
"dep:raw-window-handle",
"dep:naga",
"dep:librashader",
"dep:librashader-presets",
"dep:librashader-common",
]
vulkan-static = ["dep:ash-molten", "vulkan-renderer"]
pixels-renderer = ["dep:pixels"]
@ -34,6 +36,8 @@ raw-window-handle = { version = "0.5", optional = true }
librashader = { version = "0.1", optional = true, default-features = false, features = [
"runtime-vk",
] }
librashader-presets = { version = "0.1", optional = true }
librashader-common = { version = "0.1", optional = true }
directories = { version = "5.0", optional = true }
ron = { version = "0.8", optional = true }

View file

@ -1,62 +0,0 @@
fn main() -> Result<(), Box<dyn std::error::Error>> {
#[cfg(feature = "vulkan-renderer")]
{
let host_triple = std::env::var("HOST").unwrap();
let target_triple = std::env::var("TARGET").unwrap();
if host_triple != target_triple {
// cross compile
if !host_triple.contains("windows") && target_triple.contains("x86_64-pc-windows") {
println!(
"cargo:rustc-link-search={}",
std::env::var("VULKAN_SDK_WIN")
.expect("Could not find windows vulkan sdk path")
);
println!(
"cargo:rustc-link-search={}",
std::env::var("SHADERC_WIN").expect("Could not find windows shaderc path")
);
}
}
const SHADER_SRC_DIR: &str = "src/renderer/vulkan/shaders";
const SHADER_OUT_DIR: &str = "shaders";
println!("cargo:rerun-if-changed={}", SHADER_SRC_DIR);
std::fs::create_dir_all(SHADER_OUT_DIR)?;
for shader in std::fs::read_dir(SHADER_SRC_DIR)?.filter_map(|v| v.ok()) {
if shader.file_type()?.is_file() {
let in_path = shader.path();
if in_path
.extension()
.is_some_and(|e| e.to_string_lossy() == "wgsl")
{
let out_path = format!(
"{}/{}.spv",
SHADER_OUT_DIR,
in_path.file_stem().unwrap().to_string_lossy()
);
let module = naga::front::wgsl::parse_str(&std::fs::read_to_string(in_path)?)?;
let info = naga::valid::Validator::new(Default::default(), Default::default())
.validate(&module)?;
let spv =
naga::back::spv::write_vec(&module, &info, &Default::default(), None)?;
let compiled =
spv.iter()
.fold(Vec::with_capacity(spv.len() * 4), |mut v, w| {
v.extend_from_slice(&w.to_le_bytes());
v
});
std::fs::write(out_path, compiled.as_slice())?;
}
}
}
}
Ok(())
}

View file

@ -1,23 +0,0 @@
struct VsOutput {
@location(0) tex_coord_out: vec2<f32>,
@builtin(position) position: vec4<f32>,
}
@vertex
fn vs_main(
@location(0) position: vec2<f32>,
) -> VsOutput {
var out: VsOutput;
out.tex_coord_out = fma(position, vec2<f32>(0.5, -0.5), vec2<f32>(0.5, 0.5));
out.position = vec4<f32>(position, 0.0, 1.0);
return out;
}
@group(0) @binding(0) var tex: texture_2d<f32>;
@group(0) @binding(1) var tex_sampler: sampler;
@fragment
fn fs_main(@location(0) coord: vec2<f32>) -> @location(0) vec4<f32> {
return textureSample(tex, tex_sampler, coord);
}

View file

@ -0,0 +1,35 @@
#version 450
layout(push_constant) uniform Push
{
vec4 SourceSize;
vec4 OriginalSize;
vec4 OutputSize;
uint FrameCount;
} params;
layout(std140, set = 0, binding = 0) uniform UBO
{
mat4 MVP;
} global;
#pragma stage vertex
layout(location = 0) in vec4 Position;
layout(location = 1) in vec2 TexCoord;
layout(location = 0) out vec2 vTexCoord;
void main()
{
gl_Position = global.MVP * Position;
vTexCoord = TexCoord;
}
#pragma stage fragment
layout(location = 0) in vec2 vTexCoord;
layout(location = 0) out vec4 FragColor;
layout(set = 0, binding = 2) uniform sampler2D Source;
void main()
{
FragColor = vec4(texture(Source, vTexCoord).rgb, 1.0);
}

View file

@ -247,8 +247,6 @@ pub(super) struct SwapchainData {
pub(super) format: vk::SurfaceFormatKHR,
pub(super) surface_resolution: vk::Extent2D,
pub(super) present_image_views: Vec<vk::ImageView>,
pub(super) viewports: [vk::Viewport; 1],
pub(super) scissors: [vk::Rect2D; 1],
pub(super) sampler: vk::Sampler,
pub(super) shader_input_texture_memory: vk::DeviceMemory,
pub(super) shader_input_tex_image_view: vk::ImageView,
@ -591,8 +589,6 @@ impl SwapchainData {
format,
surface_resolution,
present_image_views,
viewports,
scissors,
sampler,
shader_input_texture_memory,
shader_input_tex_image_view,

View file

@ -2,11 +2,7 @@ use ash::{util::Align, vk, Entry, Instance};
use ash_window::enumerate_required_extensions;
use librashader::runtime::vk::{FilterChain, FilterChainOptions, FrameOptions, VulkanObjects};
use raw_window_handle::{HasRawDisplayHandle, HasRawWindowHandle, RawDisplayHandle};
use std::{
mem::{self, ManuallyDrop},
path::PathBuf,
sync::Arc,
};
use std::{mem::ManuallyDrop, path::PathBuf, sync::Arc};
use crate::connect::ResolutionData;
@ -27,7 +23,6 @@ mod utils;
// https://github.com/ash-rs/ash/blob/master/examples/src/lib.rs
// https://github.com/ash-rs/ash/blob/master/examples/src/bin/texture.rs
const SHADER: &[u8] = include_bytes!(concat!(env!("CARGO_MANIFEST_DIR"), "/shaders/shader.spv"));
const VERTICES: [Vertex; 3] = [Vertex(-1.0, -1.0), Vertex(3.0, -1.0), Vertex(-1.0, 3.0)];
pub struct RendererBackendManager {
@ -103,7 +98,7 @@ impl Drop for RendererBackendManager {
pub struct RendererBackend {
inner: ManuallyDrop<VulkanWindowInner>,
filter_chain: ManuallyDrop<Option<FilterChain>>,
filter_chain: ManuallyDrop<FilterChain>,
manager: Arc<RendererBackendManager>,
}
@ -129,23 +124,59 @@ impl RendererBackend {
) -> Self {
let inner = unsafe { VulkanWindowInner::new(resolutions, window, manager.as_ref()) };
let filter_chain = options.shader_path.map(|path| {
let filter_chain_options = FilterChainOptions {
frames_in_flight: 0,
force_no_mipmaps: false,
use_render_pass: true,
disable_cache: false,
};
let filter_chain_options = FilterChainOptions {
frames_in_flight: 0,
force_no_mipmaps: false,
use_render_pass: true,
disable_cache: false,
};
let vulkan = VulkanObjects::try_from((
inner.vulkan_data.pdevice,
manager.instance.clone(),
inner.vulkan_data.device.clone(),
))
.unwrap();
unsafe { FilterChain::load_from_path(path, vulkan, Some(&filter_chain_options)) }
.unwrap()
});
let vulkan = VulkanObjects::try_from((
inner.vulkan_data.pdevice,
manager.instance.clone(),
inner.vulkan_data.device.clone(),
))
.unwrap();
let filter_chain = match options.shader_path {
Some(path) => {
unsafe { FilterChain::load_from_path(path, vulkan, Some(&filter_chain_options)) }
.unwrap()
}
None => unsafe {
let preset = librashader_presets::ShaderPreset {
shader_count: 1,
shaders: vec![librashader_presets::ShaderPassConfig {
id: 0,
name: librashader_common::ShaderStorage::String(
include_str!("./shaders/stock.slang").to_string(),
),
alias: None,
filter: librashader::FilterMode::Nearest,
wrap_mode: librashader::WrapMode::ClampToBorder,
frame_count_mod: 0,
srgb_framebuffer: false,
float_framebuffer: false,
mipmap_input: false,
scaling: librashader_presets::Scale2D {
valid: false,
x: librashader_presets::Scaling {
scale_type: librashader_presets::ScaleType::Input,
factor: librashader_presets::ScaleFactor::Float(1.0),
},
y: librashader_presets::Scaling {
scale_type: librashader_presets::ScaleType::Input,
factor: librashader_presets::ScaleFactor::Float(1.0),
},
},
}],
textures: vec![],
parameters: vec![],
};
FilterChain::load_from_preset(preset, vulkan, Some(&filter_chain_options))
}
.unwrap(),
};
Self {
inner: ManuallyDrop::new(inner),
@ -178,9 +209,6 @@ struct VulkanWindowInner {
vulkan_data: VulkanData,
vertex_input_buffer: vk::Buffer,
renderpass: vk::RenderPass,
pipeline_layout: vk::PipelineLayout,
graphics_pipelines: Vec<vk::Pipeline>,
shader_module: vk::ShaderModule,
vertex_input_buffer_memory: vk::DeviceMemory,
swapchain: SwapchainData,
surface: SurfaceData,
@ -199,7 +227,7 @@ impl VulkanWindowInner {
let vulkan_data = VulkanData::new(manager, &surface);
let (swapchain, viewport_state_info) =
let (swapchain, _viewport_state_info) =
SwapchainData::new(resolutions, manager, &surface, &vulkan_data);
let renderpass_attachments = [vk::AttachmentDescription {
@ -292,111 +320,6 @@ impl VulkanWindowInner {
.bind_buffer_memory(vertex_input_buffer, vertex_input_buffer_memory, 0)
.unwrap();
let shader = ash::util::read_spv(&mut std::io::Cursor::new(SHADER)).unwrap();
let shader_info = vk::ShaderModuleCreateInfo::builder().code(&shader).build();
let shader_module = vulkan_data
.device
.create_shader_module(&shader_info, None)
.expect("Error creating shader module");
let layout_create_info = vk::PipelineLayoutCreateInfo::builder()
.set_layouts(&vulkan_data.desc_set_layouts)
.build();
let pipeline_layout = vulkan_data
.device
.create_pipeline_layout(&layout_create_info, None)
.unwrap();
let vertex_shader_entry_name = std::ffi::CStr::from_bytes_with_nul_unchecked(b"vs_main\0");
let fragment_shader_entry_name =
std::ffi::CStr::from_bytes_with_nul_unchecked(b"fs_main\0");
let shader_stage_create_infos = [
vk::PipelineShaderStageCreateInfo {
module: shader_module,
p_name: vertex_shader_entry_name.as_ptr(),
stage: vk::ShaderStageFlags::VERTEX,
..Default::default()
},
vk::PipelineShaderStageCreateInfo {
module: shader_module,
p_name: fragment_shader_entry_name.as_ptr(),
stage: vk::ShaderStageFlags::FRAGMENT,
..Default::default()
},
];
let vertex_input_binding_descriptions = [vk::VertexInputBindingDescription {
binding: 0,
stride: mem::size_of::<Vertex>() as u32,
input_rate: vk::VertexInputRate::VERTEX,
}];
let vertex_input_attribute_descriptions = [vk::VertexInputAttributeDescription {
location: 0,
binding: 0,
format: vk::Format::R32G32B32A32_SFLOAT,
offset: 0,
}];
let vertex_input_state_info = vk::PipelineVertexInputStateCreateInfo::builder()
.vertex_attribute_descriptions(&vertex_input_attribute_descriptions)
.vertex_binding_descriptions(&vertex_input_binding_descriptions)
.build();
let vertex_input_assembly_state_info = vk::PipelineInputAssemblyStateCreateInfo {
topology: vk::PrimitiveTopology::TRIANGLE_LIST,
..Default::default()
};
let rasterization_info = vk::PipelineRasterizationStateCreateInfo {
front_face: vk::FrontFace::COUNTER_CLOCKWISE,
line_width: 1.0,
polygon_mode: vk::PolygonMode::FILL,
..Default::default()
};
let multisample_state_info = vk::PipelineMultisampleStateCreateInfo::builder()
.rasterization_samples(vk::SampleCountFlags::TYPE_1)
.build();
let color_blend_attachment_states = [vk::PipelineColorBlendAttachmentState {
blend_enable: 0,
src_color_blend_factor: vk::BlendFactor::SRC_COLOR,
dst_color_blend_factor: vk::BlendFactor::ONE_MINUS_DST_COLOR,
color_blend_op: vk::BlendOp::ADD,
src_alpha_blend_factor: vk::BlendFactor::ZERO,
dst_alpha_blend_factor: vk::BlendFactor::ZERO,
alpha_blend_op: vk::BlendOp::ADD,
color_write_mask: vk::ColorComponentFlags::RGBA,
}];
let color_blend_state = vk::PipelineColorBlendStateCreateInfo::builder()
.logic_op(vk::LogicOp::CLEAR)
.attachments(&color_blend_attachment_states)
.build();
let dynamic_state = [vk::DynamicState::VIEWPORT, vk::DynamicState::SCISSOR];
let dynamic_state_info = vk::PipelineDynamicStateCreateInfo::builder()
.dynamic_states(&dynamic_state)
.build();
let graphic_pipeline_infos = vk::GraphicsPipelineCreateInfo::builder()
.stages(&shader_stage_create_infos)
.vertex_input_state(&vertex_input_state_info)
.input_assembly_state(&vertex_input_assembly_state_info)
.viewport_state(&viewport_state_info)
.rasterization_state(&rasterization_info)
.multisample_state(&multisample_state_info)
.color_blend_state(&color_blend_state)
.dynamic_state(&dynamic_state_info)
.layout(pipeline_layout)
.render_pass(renderpass)
.build();
let graphics_pipelines = vulkan_data
.device
.create_graphics_pipelines(vk::PipelineCache::null(), &[graphic_pipeline_infos], None)
.unwrap();
let image_ptr = vulkan_data
.device
.map_memory(
@ -415,9 +338,6 @@ impl VulkanWindowInner {
Self {
vertex_input_buffer,
renderpass,
pipeline_layout,
graphics_pipelines,
shader_module,
vertex_input_buffer_memory,
swapchain,
surface,
@ -537,7 +457,7 @@ impl VulkanWindowInner {
unsafe fn render(
&mut self,
filter_chain: &mut Option<FilterChain>,
filter_chain: &mut FilterChain,
resolutions: ResolutionData,
manager: &RendererBackendManager,
) {
@ -555,18 +475,6 @@ impl VulkanWindowInner {
self.resize(resolutions, manager);
return;
}
let clear_values = [vk::ClearValue {
color: vk::ClearColorValue {
float32: [0.0, 0.0, 0.0, 0.0],
},
}];
let render_pass_begin_info = vk::RenderPassBeginInfo::builder()
.render_pass(self.renderpass)
.framebuffer(self.framebuffers.framebuffers[present_index as usize])
.render_area(self.swapchain.surface_resolution.into())
.clear_values(&clear_values)
.build();
begin_commandbuffer(
&self.vulkan_data.device,
@ -574,82 +482,32 @@ impl VulkanWindowInner {
self.vulkan_data.draw_commands_reuse_fence,
);
match filter_chain {
Some(filter_chain) => {
filter_chain
.frame(
&librashader::runtime::vk::VulkanImage {
image: self.swapchain.shader_input_texture,
size: self.swapchain.shader_input_image_extent.into(),
format: SHADER_INPUT_FORMAT,
},
&librashader::runtime::Viewport {
x: 0.,
y: 0.,
mvp: None,
output: librashader::runtime::vk::VulkanImage {
image: self.swapchain.present_images[present_index as usize],
size: self.swapchain.surface_resolution.into(),
format: self.swapchain.format.format,
},
},
self.vulkan_data.draw_command_buffer,
self.frame_counter,
Some(&FrameOptions {
clear_history: true,
frame_direction: 0,
}),
)
.unwrap();
self.frame_counter += 1;
}
None => {
self.vulkan_data.device.cmd_begin_render_pass(
self.vulkan_data.draw_command_buffer,
&render_pass_begin_info,
vk::SubpassContents::INLINE,
);
self.vulkan_data.device.cmd_bind_descriptor_sets(
self.vulkan_data.draw_command_buffer,
vk::PipelineBindPoint::GRAPHICS,
self.pipeline_layout,
0,
&self.vulkan_data.descriptor_sets[..],
&[],
);
self.vulkan_data.device.cmd_bind_pipeline(
self.vulkan_data.draw_command_buffer,
vk::PipelineBindPoint::GRAPHICS,
self.graphics_pipelines[0],
);
self.vulkan_data.device.cmd_set_viewport(
self.vulkan_data.draw_command_buffer,
0,
&self.swapchain.viewports,
);
self.vulkan_data.device.cmd_set_scissor(
self.vulkan_data.draw_command_buffer,
0,
&self.swapchain.scissors,
);
self.vulkan_data.device.cmd_bind_vertex_buffers(
self.vulkan_data.draw_command_buffer,
0,
&[self.vertex_input_buffer],
&[0],
);
self.vulkan_data.device.cmd_draw(
self.vulkan_data.draw_command_buffer,
VERTICES.len() as u32,
1,
0,
1,
);
self.vulkan_data
.device
.cmd_end_render_pass(self.vulkan_data.draw_command_buffer);
}
}
filter_chain
.frame(
&librashader::runtime::vk::VulkanImage {
image: self.swapchain.shader_input_texture,
size: self.swapchain.shader_input_image_extent.into(),
format: SHADER_INPUT_FORMAT,
},
&librashader::runtime::Viewport {
x: 0.,
y: 0.,
mvp: None,
output: librashader::runtime::vk::VulkanImage {
image: self.swapchain.present_images[present_index as usize],
size: self.swapchain.surface_resolution.into(),
format: self.swapchain.format.format,
},
},
self.vulkan_data.draw_command_buffer,
self.frame_counter,
Some(&FrameOptions {
clear_history: true,
frame_direction: 0,
}),
)
.unwrap();
self.frame_counter += 1;
submit_commandbuffer(
&self.vulkan_data.device,
@ -681,16 +539,6 @@ impl Drop for VulkanWindowInner {
unsafe {
self.vulkan_data.device.device_wait_idle().unwrap();
for pipeline in &self.graphics_pipelines {
self.vulkan_data.device.destroy_pipeline(*pipeline, None);
}
self.vulkan_data
.device
.destroy_pipeline_layout(self.pipeline_layout, None);
self.vulkan_data
.device
.destroy_shader_module(self.shader_module, None);
self.vulkan_data
.device
.free_memory(self.vertex_input_buffer_memory, None);