rt(wgpu): enable large thread size if possible

This commit is contained in:
chyyran 2024-02-15 20:52:25 -05:00 committed by Ronny Chan
parent edca0f1749
commit ba6c32e858
3 changed files with 38 additions and 30 deletions

36
Cargo.lock generated
View file

@ -166,7 +166,7 @@ checksum = "c980ee35e870bd1a4d2c8294d4c04d0499e67bca1e4b5cefcc693c2fa00caea9"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.48", "syn 2.0.49",
] ]
[[package]] [[package]]
@ -348,9 +348,9 @@ checksum = "832133bbabbbaa9fbdba793456a2827627a7d2b8fb96032fa1e7666d7895832b"
[[package]] [[package]]
name = "bumpalo" name = "bumpalo"
version = "3.14.0" version = "3.15.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec" checksum = "d32a994c2b3ca201d9b263612a374263f05e7adde37c4707f693dcd375076d1f"
[[package]] [[package]]
name = "bytecount" name = "bytecount"
@ -375,7 +375,7 @@ checksum = "965ab7eb5f8f97d2a083c799f3a1b994fc397b2fe2da5d1da1626ce15a39f2b1"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.48", "syn 2.0.49",
] ]
[[package]] [[package]]
@ -984,7 +984,7 @@ checksum = "1a5c6c585bc94aaf2c7b51dd4c2ba22680844aba4c687be581871a6f518c5742"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.48", "syn 2.0.49",
] ]
[[package]] [[package]]
@ -1149,9 +1149,9 @@ dependencies = [
[[package]] [[package]]
name = "glslang" name = "glslang"
version = "0.3.1" version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c5df6491e5d4c222a6373b892c1bea8d697fca0c087890f64f0e2975b3f8bb48" checksum = "c6287b8071643d2f88055233b1ecfec954819cd5f91ff4095d5f2e2739a37b3a"
dependencies = [ dependencies = [
"glslang-sys", "glslang-sys",
"once_cell", "once_cell",
@ -2085,7 +2085,7 @@ dependencies = [
"proc-macro-crate", "proc-macro-crate",
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.48", "syn 2.0.49",
] ]
[[package]] [[package]]
@ -2285,7 +2285,7 @@ dependencies = [
"pest_meta", "pest_meta",
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.48", "syn 2.0.49",
] ]
[[package]] [[package]]
@ -2317,9 +2317,9 @@ checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58"
[[package]] [[package]]
name = "pkg-config" name = "pkg-config"
version = "0.3.29" version = "0.3.30"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2900ede94e305130c13ddd391e0ab7cbaeb783945ae07a279c268cb05109c6cb" checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec"
[[package]] [[package]]
name = "platform-dirs" name = "platform-dirs"
@ -2739,7 +2739,7 @@ checksum = "33c85360c95e7d137454dc81d9a4ed2b8efd8fbe19cee57357b32b9771fccb67"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.48", "syn 2.0.49",
] ]
[[package]] [[package]]
@ -2926,9 +2926,9 @@ dependencies = [
[[package]] [[package]]
name = "syn" name = "syn"
version = "2.0.48" version = "2.0.49"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0f3531638e407dfc0814761abb7c00a5b54992b849452a0646b7f65c9f770f3f" checksum = "915aea9e586f80826ee59f8453c1101f9d1c4b3964cd2460185ee8e299ada496"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -2985,7 +2985,7 @@ checksum = "a953cb265bef375dae3de6663da4d3804eee9682ea80d8e2542529b73c531c81"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.48", "syn 2.0.49",
] ]
[[package]] [[package]]
@ -3184,7 +3184,7 @@ dependencies = [
"once_cell", "once_cell",
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.48", "syn 2.0.49",
"wasm-bindgen-shared", "wasm-bindgen-shared",
] ]
@ -3218,7 +3218,7 @@ checksum = "642f325be6301eb8107a83d12a8ac6c1e1c54345a7ef1a9261962dfefda09e66"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.48", "syn 2.0.49",
"wasm-bindgen-backend", "wasm-bindgen-backend",
"wasm-bindgen-shared", "wasm-bindgen-shared",
] ]
@ -3889,7 +3889,7 @@ checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.48", "syn 2.0.49",
] ]
[[package]] [[package]]

View file

@ -1,5 +1,5 @@
use crate::error::ShaderCompileError; use crate::error::ShaderCompileError;
use glslang::{CompilerOptions, ShaderInput}; use glslang::{CompilerOptions, ShaderInput, ShaderOptions};
use librashader_preprocess::ShaderSource; use librashader_preprocess::ShaderSource;
use crate::front::{ShaderInputCompiler, SpirvCompilation}; use crate::front::{ShaderInputCompiler, SpirvCompilation};

View file

@ -264,16 +264,11 @@ impl FilterChainWgpu {
semantics: &ShaderSemantics, semantics: &ShaderSemantics,
) -> error::Result<Box<[FilterPass]>> { ) -> error::Result<Box<[FilterPass]>> {
#[cfg(not(target_arch = "wasm32"))] #[cfg(not(target_arch = "wasm32"))]
let passes_iter = passes.into_par_iter(); let filter_creation_fn = || {
#[cfg(target_arch = "wasm32")] let passes_iter = passes.into_par_iter();
let passes_iter = passes.into_iter(); #[cfg(target_arch = "wasm32")]
let passes_iter = passes.into_iter();
let thread_pool = ThreadPoolBuilder::new()
.stack_size(10 * 1048576)
.build()
.unwrap();
let filters = thread_pool.install(|| {
let filters: Vec<error::Result<FilterPass>> = passes_iter let filters: Vec<error::Result<FilterPass>> = passes_iter
.enumerate() .enumerate()
.map(|(index, (config, source, mut reflect))| { .map(|(index, (config, source, mut reflect))| {
@ -333,9 +328,22 @@ impl FilterChainWgpu {
}) })
.collect(); .collect();
filters filters
}); };
#[cfg(target_arch = "wasm32")]
let filters = filter_creation_fn();
#[cfg(not(target_arch = "wasm32"))]
let filters = if let Ok(thread_pool) = ThreadPoolBuilder::new()
// naga compilations can possibly use degenerate stack sizes.
.stack_size(10 * 1048576)
.build()
{
thread_pool.install(|| filter_creation_fn())
} else {
filter_creation_fn()
};
//
let filters: error::Result<Vec<FilterPass>> = filters.into_iter().collect(); let filters: error::Result<Vec<FilterPass>> = filters.into_iter().collect();
let filters = filters?; let filters = filters?;
Ok(filters.into_boxed_slice()) Ok(filters.into_boxed_slice())