From 0a9fa16855eaace7cec6a076cf0f05d348c107b7 Mon Sep 17 00:00:00 2001 From: chyyran Date: Fri, 14 Jun 2024 17:18:43 -0400 Subject: [PATCH] rt: update for new TAIT scope rules --- Cargo.lock | 360 ++++++++++++++++-- librashader-runtime-d3d11/src/filter_chain.rs | 44 ++- librashader-runtime-d3d12/src/filter_chain.rs | 86 +++-- librashader-runtime-d3d9/src/filter_chain.rs | 43 ++- .../src/filter_chain/filter_impl.rs | 44 ++- .../src/gl/gl46/framebuffer.rs | 2 +- librashader-runtime-mtl/src/filter_chain.rs | 28 +- librashader-runtime-vk/src/filter_chain.rs | 44 ++- librashader-runtime-wgpu/Cargo.toml | 2 +- librashader-runtime-wgpu/src/filter_chain.rs | 28 +- 10 files changed, 515 insertions(+), 166 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7a1c0b2..0429a18 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -57,6 +57,12 @@ dependencies = [ "memchr", ] +[[package]] +name = "aligned-vec" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4aa90d7ce82d4be67b64039a3d588d38dbcc6736577de4a847025ce5b0c468d1" + [[package]] name = "allocator-api2" version = "0.2.18" @@ -99,6 +105,29 @@ dependencies = [ "libc", ] +[[package]] +name = "anyhow" +version = "1.0.82" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f538837af36e6f6a9be0faa67f9a314f8119e4e4b5867c6ab40ed60360142519" + +[[package]] +name = "arbitrary" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d5a26814d8dcb93b0e5a0ff3c6d80a8843bafb21b39e8e18a6f05471870e110" + +[[package]] +name = "arg_enum_proc_macro" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ae92a5119aa49cdbcf6b9f893fe4e1d98b04ccbf82ee0584ad948a44a734dea" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.66", +] + [[package]] name = "array-concat" version = "0.5.3" @@ -189,6 +218,29 @@ version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" +[[package]] +name = "av1-grain" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6678909d8c5d46a42abcf571271e15fdbc0a225e3646cf23762cd415046c78bf" +dependencies = [ + "anyhow", + "arrayvec", + "log", + "nom", + "num-rational", + "v_frame", +] + +[[package]] +name = "avif-serialize" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "876c75a42f6364451a033496a14c44bffe41f5f4a8236f697391f11024e596d2" +dependencies = [ + "arrayvec", +] + [[package]] name = "base64" version = "0.13.1" @@ -247,6 +299,12 @@ version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" +[[package]] +name = "bitstream-io" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bdba4ac537b9346c50122b6e9f9b0d2bd721e04c6032e1d15f53ce0747b054c" + [[package]] name = "bitvec" version = "1.0.1" @@ -322,6 +380,12 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "832133bbabbbaa9fbdba793456a2827627a7d2b8fb96032fa1e7666d7895832b" +[[package]] +name = "built" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6a6c0b39c38fd754ac338b00a88066436389c0f029da5d37d1e01091d9b7c17" + [[package]] name = "bumpalo" version = "3.16.0" @@ -414,7 +478,7 @@ dependencies = [ "serde_json", "syn 1.0.109", "tempfile", - "toml", + "toml 0.5.11", ] [[package]] @@ -434,6 +498,16 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6d43a04d8753f35258c91f8ec639f792891f748a1edbd759cf1dcea3382ad83c" +[[package]] +name = "cfg-expr" +version = "0.15.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d067ad48b8650848b989a59a86c6c36a995d02d2bf778d45c3c5d57bc2718f02" +dependencies = [ + "smallvec", + "target-lexicon", +] + [[package]] name = "cfg-if" version = "1.0.0" @@ -627,7 +701,7 @@ dependencies = [ "rust-ini", "serde", "serde_json", - "toml", + "toml 0.5.11", "yaml-rust", ] @@ -1304,24 +1378,6 @@ dependencies = [ "objc2 0.5.1", ] -[[package]] -name = "image" -version = "0.24.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5690139d2f55868e080017335e4b94cb7414274c74f1669c84fb5feba2c9f69d" -dependencies = [ - "bytemuck", - "byteorder", - "color_quant", - "exr", - "gif", - "jpeg-decoder", - "num-traits", - "png", - "qoi", - "tiff", -] - [[package]] name = "image" version = "0.25.1" @@ -1331,10 +1387,15 @@ dependencies = [ "bytemuck", "byteorder", "color_quant", + "exr", "gif", "image-webp", "num-traits", "png", + "qoi", + "ravif", + "rayon", + "rgb", "tiff", "zune-core", "zune-jpeg", @@ -1350,6 +1411,12 @@ dependencies = [ "thiserror", ] +[[package]] +name = "imgref" +version = "1.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44feda355f4159a7c757171a77de25daf6411e217b4cabd03bd6650690468126" + [[package]] name = "indexmap" version = "1.9.3" @@ -1370,6 +1437,17 @@ dependencies = [ "hashbrown 0.14.5", ] +[[package]] +name = "interpolate_name" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c34819042dc3d3971c46c2190835914dfbe0c3c13f61449b2997f4e9722dfa60" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.66", +] + [[package]] name = "is-terminal" version = "0.4.12" @@ -1381,6 +1459,15 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "itertools" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569" +dependencies = [ + "either", +] + [[package]] name = "itoa" version = "1.0.11" @@ -1423,9 +1510,6 @@ name = "jpeg-decoder" version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f5d4a7da358eff58addd2877a45865158f0d78c911d43a5784ceb7bbf52833b0" -dependencies = [ - "rayon", -] [[package]] name = "js-sys" @@ -1482,6 +1566,17 @@ version = "0.2.155" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" +[[package]] +name = "libfuzzer-sys" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a96cfd5557eb82f2b83fed4955246c988d331975a002961b07c81584d107e7f7" +dependencies = [ + "arbitrary", + "cc", + "once_cell", +] + [[package]] name = "libloading" version = "0.7.4" @@ -1642,7 +1737,7 @@ version = "0.2.7" dependencies = [ "array-concat", "bytemuck", - "image 0.25.1", + "image", "librashader-common", "librashader-preprocess", "librashader-presets", @@ -1777,7 +1872,7 @@ dependencies = [ "bytemuck", "config", "env_logger", - "image 0.24.9", + "image", "librashader-common", "librashader-preprocess", "librashader-presets", @@ -1859,6 +1954,15 @@ version = "0.4.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" +[[package]] +name = "loop9" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fae87c125b03c1d2c0150c90365d7d6bcc53fb73a9acaef207d2d065860f062" +dependencies = [ + "imgref", +] + [[package]] name = "mach-siegbert-vogt-dxcsa" version = "0.1.3" @@ -1883,6 +1987,16 @@ version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2532096657941c2fea9c289d370a250971c689d4f143798ff67113ec042024a5" +[[package]] +name = "maybe-rayon" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ea1f30cedd69f0a2954655f7188c6a834246d2bcf1e315e2ac40c4b24dc9519" +dependencies = [ + "cfg-if", + "rayon", +] + [[package]] name = "memchr" version = "2.7.4" @@ -1982,6 +2096,12 @@ dependencies = [ "jni-sys", ] +[[package]] +name = "new_debug_unreachable" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "650eef8c711430f1a879fdd01d4745a7deea475becfb90269c06775983bbf086" + [[package]] name = "nom" version = "7.1.3" @@ -2003,6 +2123,12 @@ dependencies = [ "nom", ] +[[package]] +name = "noop_proc_macro" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0676bb32a98c1a483ce53e500a81ad9c3d5b3f7c920c28c24e9cb0980d0b5bc8" + [[package]] name = "num" version = "0.4.3" @@ -2036,6 +2162,17 @@ dependencies = [ "num-traits", ] +[[package]] +name = "num-derive" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed3955f1a9c7c0c15e092f9c887db08b1fc683305fdf6eb6684f22555355e202" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.66", +] + [[package]] name = "num-integer" version = "0.1.46" @@ -2372,7 +2509,7 @@ version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6d37c51ca738a55da99dc0c4a34860fd675453b8b36209178c2249bb13651284" dependencies = [ - "toml_edit", + "toml_edit 0.21.1", ] [[package]] @@ -2413,6 +2550,19 @@ name = "profiling" version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "43d84d1d7a6ac92673717f9f6d1518374ef257669c24ebc5ac25d5033828be58" +dependencies = [ + "profiling-procmacros", +] + +[[package]] +name = "profiling-procmacros" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8021cf59c8ec9c432cfc2526ac6b8aa508ecaf29cd415f271b8406c1b851c3fd" +dependencies = [ + "quote", + "syn 2.0.66", +] [[package]] name = "qoi" @@ -2423,6 +2573,12 @@ dependencies = [ "bytemuck", ] +[[package]] +name = "quick-error" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a993555f31e5a609f617c12db6250dedcac1b0a85076912c436e6fc9b2c8e6a3" + [[package]] name = "quick-xml" version = "0.31.0" @@ -2483,6 +2639,56 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8a99fddc9f0ba0a85884b8d14e3592853e787d581ca1816c91349b10e4eeab" +[[package]] +name = "rav1e" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd87ce80a7665b1cce111f8a16c1f3929f6547ce91ade6addf4ec86a8dda5ce9" +dependencies = [ + "arbitrary", + "arg_enum_proc_macro", + "arrayvec", + "av1-grain", + "bitstream-io", + "built", + "cfg-if", + "interpolate_name", + "itertools", + "libc", + "libfuzzer-sys", + "log", + "maybe-rayon", + "new_debug_unreachable", + "noop_proc_macro", + "num-derive", + "num-traits", + "once_cell", + "paste", + "profiling", + "rand", + "rand_chacha", + "simd_helpers", + "system-deps", + "thiserror", + "v_frame", + "wasm-bindgen", +] + +[[package]] +name = "ravif" +version = "0.11.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc13288f5ab39e6d7c9d501759712e6969fcc9734220846fc9ed26cae2cc4234" +dependencies = [ + "avif-serialize", + "imgref", + "loop9", + "quick-error", + "rav1e", + "rayon", + "rgb", +] + [[package]] name = "raw-window-handle" version = "0.4.3" @@ -2609,6 +2815,15 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "19b30a45b0cd0bcca8037f3d0dc3421eaf95327a17cad11964fb8179b4fc4832" +[[package]] +name = "rgb" +version = "0.8.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05aaa8004b64fd573fc9d002f4e632d51ad4f026c2b5ba95fcb6c2f32c2c47d8" +dependencies = [ + "bytemuck", +] + [[package]] name = "ron" version = "0.7.1" @@ -2736,6 +2951,15 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_spanned" +version = "0.6.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "79e674e01f999af37c49f70a6ede167a8a60b2503e56c5599532a65baa5969a0" +dependencies = [ + "serde", +] + [[package]] name = "sha2" version = "0.10.8" @@ -2753,6 +2977,15 @@ version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d66dc143e6b11c1eddc06d5c423cfc97062865baf299914ab64caa38182078fe" +[[package]] +name = "simd_helpers" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95890f873bec569a0362c235787f3aca6e1e887302ba4840839bcc6459c42da6" +dependencies = [ + "quote", +] + [[package]] name = "slab" version = "0.4.9" @@ -2898,12 +3131,31 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "system-deps" +version = "6.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8e9199467bcbc77c6a13cc6e32a6af21721ab8c96aa0261856c4fda5a4433f0" +dependencies = [ + "cfg-expr", + "heck", + "pkg-config", + "toml 0.8.14", + "version-compare", +] + [[package]] name = "tap" version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" +[[package]] +name = "target-lexicon" +version = "0.12.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1fc403891a21bcfb7c37834ba66a547a8f402146eba7265b5a6d88059c9ff2f" + [[package]] name = "tempfile" version = "3.10.1" @@ -3011,11 +3263,26 @@ dependencies = [ "serde", ] +[[package]] +name = "toml" +version = "0.8.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f49eb2ab21d2f26bd6db7bf383edc527a7ebaee412d17af4d40fdccd442f335" +dependencies = [ + "serde", + "serde_spanned", + "toml_datetime", + "toml_edit 0.22.14", +] + [[package]] name = "toml_datetime" version = "0.6.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4badfd56924ae69bcc9039335b2e017639ce3f9b001c393c1b2d1ef846ce2cbf" +dependencies = [ + "serde", +] [[package]] name = "toml_edit" @@ -3025,7 +3292,20 @@ checksum = "6a8534fd7f78b5405e860340ad6575217ce99f38d4d5c8f2442cb5ecb50090e1" dependencies = [ "indexmap 2.2.6", "toml_datetime", - "winnow", + "winnow 0.5.40", +] + +[[package]] +name = "toml_edit" +version = "0.22.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f21c7aaf97f1bd9ca9d4f9e73b0a6c74bd5afef56f2bc931943a6e1c37e04e38" +dependencies = [ + "indexmap 2.2.6", + "serde", + "serde_spanned", + "toml_datetime", + "winnow 0.6.13", ] [[package]] @@ -3092,6 +3372,23 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eb066959b24b5196ae73cb057f45598450d2c5f71460e98c49b738086eff9c06" +[[package]] +name = "v_frame" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6f32aaa24bacd11e488aa9ba66369c7cd514885742c9fe08cfe85884db3e92b" +dependencies = [ + "aligned-vec", + "num-traits", + "wasm-bindgen", +] + +[[package]] +name = "version-compare" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "579a42fc0b8e0c63b76519a339be31bed574929511fa53c1a3acae26eb258f29" + [[package]] name = "version_check" version = "0.9.4" @@ -3749,6 +4046,15 @@ dependencies = [ "memchr", ] +[[package]] +name = "winnow" +version = "0.6.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59b5e5f6c299a3c7890b876a2a587f3115162487e704907d9b6cd29473052ba1" +dependencies = [ + "memchr", +] + [[package]] name = "wyz" version = "0.5.1" diff --git a/librashader-runtime-d3d11/src/filter_chain.rs b/librashader-runtime-d3d11/src/filter_chain.rs index 4b82392..533e645 100644 --- a/librashader-runtime-d3d11/src/filter_chain.rs +++ b/librashader-runtime-d3d11/src/filter_chain.rs @@ -75,28 +75,34 @@ pub(crate) struct FilterCommon { pub(crate) draw_quad: DrawQuad, } -type ShaderPassMeta = - ShaderPassArtifact + Send>; -fn compile_passes( - shaders: Vec, - textures: &[TextureConfig], - disable_cache: bool, -) -> Result<(Vec, ShaderSemantics), FilterChainError> { - let (passes, semantics) = if !disable_cache { - HLSL::compile_preset_passes::< - CachedCompilation, - SpirvCross, - FilterChainError, - >(shaders, &textures)? - } else { - HLSL::compile_preset_passes::( - shaders, &textures, - )? - }; +mod compile { + use super::*; + pub type ShaderPassMeta = + ShaderPassArtifact + Send>; - Ok((passes, semantics)) + pub fn compile_passes( + shaders: Vec, + textures: &[TextureConfig], + disable_cache: bool, + ) -> Result<(Vec, ShaderSemantics), FilterChainError> { + let (passes, semantics) = if !disable_cache { + HLSL::compile_preset_passes::< + CachedCompilation, + SpirvCross, + FilterChainError, + >(shaders, &textures)? + } else { + HLSL::compile_preset_passes::( + shaders, &textures, + )? + }; + + Ok((passes, semantics)) + } } +use compile::{compile_passes, ShaderPassMeta}; + impl FilterChainD3D11 { /// Load the shader preset at the given path into a filter chain. pub unsafe fn load_from_path( diff --git a/librashader-runtime-d3d12/src/filter_chain.rs b/librashader-runtime-d3d12/src/filter_chain.rs index 98663e0..5641de1 100644 --- a/librashader-runtime-d3d12/src/filter_chain.rs +++ b/librashader-runtime-d3d12/src/filter_chain.rs @@ -146,49 +146,57 @@ impl Drop for FrameResiduals { } } -type DxilShaderPassMeta = - ShaderPassArtifact + Send>; -fn compile_passes_dxil( - shaders: Vec, - textures: &[TextureConfig], - disable_cache: bool, -) -> Result<(Vec, ShaderSemantics), FilterChainError> { - let (passes, semantics) = if !disable_cache { - DXIL::compile_preset_passes::< - CachedCompilation, - SpirvCross, - FilterChainError, - >(shaders, &textures)? - } else { - DXIL::compile_preset_passes::( - shaders, &textures, - )? - }; +mod compile { + use super::*; + pub type DxilShaderPassMeta = + ShaderPassArtifact + Send>; - Ok((passes, semantics)) -} -type HlslShaderPassMeta = - ShaderPassArtifact + Send>; -fn compile_passes_hlsl( - shaders: Vec, - textures: &[TextureConfig], - disable_cache: bool, -) -> Result<(Vec, ShaderSemantics), FilterChainError> { - let (passes, semantics) = if !disable_cache { - HLSL::compile_preset_passes::< - CachedCompilation, - SpirvCross, - FilterChainError, - >(shaders, &textures)? - } else { - HLSL::compile_preset_passes::( - shaders, &textures, - )? - }; + pub fn compile_passes_dxil( + shaders: Vec, + textures: &[TextureConfig], + disable_cache: bool, + ) -> Result<(Vec, ShaderSemantics), FilterChainError> { + let (passes, semantics) = if !disable_cache { + DXIL::compile_preset_passes::< + CachedCompilation, + SpirvCross, + FilterChainError, + >(shaders, &textures)? + } else { + DXIL::compile_preset_passes::( + shaders, &textures, + )? + }; - Ok((passes, semantics)) + Ok((passes, semantics)) + } + + pub type HlslShaderPassMeta = + ShaderPassArtifact + Send>; + + pub fn compile_passes_hlsl( + shaders: Vec, + textures: &[TextureConfig], + disable_cache: bool, + ) -> Result<(Vec, ShaderSemantics), FilterChainError> { + let (passes, semantics) = if !disable_cache { + HLSL::compile_preset_passes::< + CachedCompilation, + SpirvCross, + FilterChainError, + >(shaders, &textures)? + } else { + HLSL::compile_preset_passes::( + shaders, &textures, + )? + }; + + Ok((passes, semantics)) + } } +use compile::{compile_passes_dxil, compile_passes_hlsl, DxilShaderPassMeta, HlslShaderPassMeta}; + impl FilterChainD3D12 { /// Load the shader preset at the given path into a filter chain. pub unsafe fn load_from_path( diff --git a/librashader-runtime-d3d9/src/filter_chain.rs b/librashader-runtime-d3d9/src/filter_chain.rs index f17bd68..fcbff44 100644 --- a/librashader-runtime-d3d9/src/filter_chain.rs +++ b/librashader-runtime-d3d9/src/filter_chain.rs @@ -63,29 +63,34 @@ pub struct FilterChainD3D9 { default_options: FrameOptionsD3D9, } -type ShaderPassMeta = - ShaderPassArtifact + Send>; +mod compile { + use super::*; + pub type ShaderPassMeta = + ShaderPassArtifact + Send>; -fn compile_passes( - shaders: Vec, - textures: &[TextureConfig], - disable_cache: bool, -) -> Result<(Vec, ShaderSemantics), FilterChainError> { - let (passes, semantics) = if !disable_cache { - HLSL::compile_preset_passes::< - CachedCompilation, - SpirvCross, - FilterChainError, - >(shaders, &textures)? - } else { - HLSL::compile_preset_passes::( - shaders, &textures, - )? - }; + pub fn compile_passes( + shaders: Vec, + textures: &[TextureConfig], + disable_cache: bool, + ) -> Result<(Vec, ShaderSemantics), FilterChainError> { + let (passes, semantics) = if !disable_cache { + HLSL::compile_preset_passes::< + CachedCompilation, + SpirvCross, + FilterChainError, + >(shaders, &textures)? + } else { + HLSL::compile_preset_passes::( + shaders, &textures, + )? + }; - Ok((passes, semantics)) + Ok((passes, semantics)) + } } +use compile::{compile_passes, ShaderPassMeta}; + impl FilterChainD3D9 { fn init_passes( device: &IDirect3DDevice9, diff --git a/librashader-runtime-gl/src/filter_chain/filter_impl.rs b/librashader-runtime-gl/src/filter_chain/filter_impl.rs index fcf66c1..3da0d51 100644 --- a/librashader-runtime-gl/src/filter_chain/filter_impl.rs +++ b/librashader-runtime-gl/src/filter_chain/filter_impl.rs @@ -92,28 +92,34 @@ impl FilterChainImpl { } } -type ShaderPassMeta = - ShaderPassArtifact>; -fn compile_passes( - shaders: Vec, - textures: &[TextureConfig], - disable_cache: bool, -) -> Result<(Vec, ShaderSemantics), FilterChainError> { - let (passes, semantics) = if !disable_cache { - GLSL::compile_preset_passes::< - CachedCompilation, - SpirvCross, - FilterChainError, - >(shaders, &textures)? - } else { - GLSL::compile_preset_passes::( - shaders, &textures, - )? - }; +mod compile { + use super::*; + pub type ShaderPassMeta = + ShaderPassArtifact>; - Ok((passes, semantics)) + pub fn compile_passes( + shaders: Vec, + textures: &[TextureConfig], + disable_cache: bool, + ) -> Result<(Vec, ShaderSemantics), FilterChainError> { + let (passes, semantics) = if !disable_cache { + GLSL::compile_preset_passes::< + CachedCompilation, + SpirvCross, + FilterChainError, + >(shaders, &textures)? + } else { + GLSL::compile_preset_passes::( + shaders, &textures, + )? + }; + + Ok((passes, semantics)) + } } +use compile::{compile_passes, ShaderPassMeta}; + impl FilterChainImpl { /// Load a filter chain from a pre-parsed `ShaderPreset`. pub(crate) unsafe fn load_from_preset( diff --git a/librashader-runtime-gl/src/gl/gl46/framebuffer.rs b/librashader-runtime-gl/src/gl/gl46/framebuffer.rs index d0187d1..07c919e 100644 --- a/librashader-runtime-gl/src/gl/gl46/framebuffer.rs +++ b/librashader-runtime-gl/src/gl/gl46/framebuffer.rs @@ -187,4 +187,4 @@ impl FramebufferInterface for Gl46Framebuffer { } Ok(()) } -} \ No newline at end of file +} diff --git a/librashader-runtime-mtl/src/filter_chain.rs b/librashader-runtime-mtl/src/filter_chain.rs index 4a8134f..a84d1f4 100644 --- a/librashader-runtime-mtl/src/filter_chain.rs +++ b/librashader-runtime-mtl/src/filter_chain.rs @@ -40,19 +40,25 @@ use std::collections::VecDeque; use std::fmt::{Debug, Formatter}; use std::path::Path; -type ShaderPassMeta = - ShaderPassArtifact + Send>; -fn compile_passes( - shaders: Vec, - textures: &[TextureConfig], -) -> Result<(Vec, ShaderSemantics), FilterChainError> { - let (passes, semantics) = - MSL::compile_preset_passes::( - shaders, &textures, - )?; - Ok((passes, semantics)) +mod compile { + use super::*; + pub type ShaderPassMeta = + ShaderPassArtifact + Send>; + + pub fn compile_passes( + shaders: Vec, + textures: &[TextureConfig], + ) -> Result<(Vec, ShaderSemantics), FilterChainError> { + let (passes, semantics) = + MSL::compile_preset_passes::( + shaders, &textures, + )?; + Ok((passes, semantics)) + } } +use compile::{compile_passes, ShaderPassMeta}; + /// A Metal filter chain. pub struct FilterChainMetal { pub(crate) common: FilterCommon, diff --git a/librashader-runtime-vk/src/filter_chain.rs b/librashader-runtime-vk/src/filter_chain.rs index d12ee50..83667c1 100644 --- a/librashader-runtime-vk/src/filter_chain.rs +++ b/librashader-runtime-vk/src/filter_chain.rs @@ -209,28 +209,34 @@ impl Drop for FrameResiduals { } } -type ShaderPassMeta = - ShaderPassArtifact + Send>; -fn compile_passes( - shaders: Vec, - textures: &[TextureConfig], - disable_cache: bool, -) -> Result<(Vec, ShaderSemantics), FilterChainError> { - let (passes, semantics) = if !disable_cache { - SPIRV::compile_preset_passes::< - CachedCompilation, - SpirvCross, - FilterChainError, - >(shaders, &textures)? - } else { - SPIRV::compile_preset_passes::( - shaders, &textures, - )? - }; +mod compile { + use super::*; + pub type ShaderPassMeta = + ShaderPassArtifact + Send>; - Ok((passes, semantics)) + pub fn compile_passes( + shaders: Vec, + textures: &[TextureConfig], + disable_cache: bool, + ) -> Result<(Vec, ShaderSemantics), FilterChainError> { + let (passes, semantics) = if !disable_cache { + SPIRV::compile_preset_passes::< + CachedCompilation, + SpirvCross, + FilterChainError, + >(shaders, &textures)? + } else { + SPIRV::compile_preset_passes::( + shaders, &textures, + )? + }; + + Ok((passes, semantics)) + } } +use compile::{compile_passes, ShaderPassMeta}; + impl FilterChainVulkan { /// Load the shader preset at the given path into a filter chain. pub unsafe fn load_from_path( diff --git a/librashader-runtime-wgpu/Cargo.toml b/librashader-runtime-wgpu/Cargo.toml index ae0daf1..31303e5 100644 --- a/librashader-runtime-wgpu/Cargo.toml +++ b/librashader-runtime-wgpu/Cargo.toml @@ -21,7 +21,7 @@ librashader-reflect = { path = "../librashader-reflect", version = "0.2.7", feat librashader-runtime = { path = "../librashader-runtime" , version = "0.2.7" } wgpu = { version = "0.20.0", default-features = false, features = ["wgsl"] } -image = "0.24.7" +image = "0.25.1" thiserror = "1.0.50" bytemuck = { version = "1.14.0", features = ["derive"] } array-concat = "0.5.2" diff --git a/librashader-runtime-wgpu/src/filter_chain.rs b/librashader-runtime-wgpu/src/filter_chain.rs index 0e36cb8..8530819 100644 --- a/librashader-runtime-wgpu/src/filter_chain.rs +++ b/librashader-runtime-wgpu/src/filter_chain.rs @@ -38,19 +38,25 @@ use crate::options::{FilterChainOptionsWgpu, FrameOptionsWgpu}; use crate::samplers::SamplerSet; use crate::texture::{InputImage, OwnedImage}; -type ShaderPassMeta = - ShaderPassArtifact + Send>; -fn compile_passes( - shaders: Vec, - textures: &[TextureConfig], -) -> Result<(Vec, ShaderSemantics), FilterChainError> { - let (passes, semantics) = - WGSL::compile_preset_passes::( - shaders, &textures, - )?; - Ok((passes, semantics)) +mod compile { + use super::*; + pub type ShaderPassMeta = + ShaderPassArtifact + Send>; + + pub fn compile_passes( + shaders: Vec, + textures: &[TextureConfig], + ) -> Result<(Vec, ShaderSemantics), FilterChainError> { + let (passes, semantics) = + WGSL::compile_preset_passes::( + shaders, &textures, + )?; + Ok((passes, semantics)) + } } +use compile::{compile_passes, ShaderPassMeta}; + /// A wgpu filter chain. pub struct FilterChainWgpu { pub(crate) common: FilterCommon,