diff --git a/Cargo.lock b/Cargo.lock index 6e236f4c2d..f7cf4d7688 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3863,7 +3863,7 @@ dependencies = [ [[package]] name = "naga" version = "0.14.2" -source = "git+https://github.com/IsseW/wgpu?rev=5ea160164#5ea16016402bb83b4ccd7ac8e6d4b0a2f85da6a0" +source = "git+https://github.com/Imberflur/wgpu.git?tag=0.18-with-fixes-for-veloren-v1#df527ef82e2eba827eda9278caa583506a06aa87" dependencies = [ "bit-set", "bitflags 2.4.2", @@ -8110,7 +8110,7 @@ dependencies = [ [[package]] name = "wgpu" version = "0.18.0" -source = "git+https://github.com/IsseW/wgpu?rev=5ea160164#5ea16016402bb83b4ccd7ac8e6d4b0a2f85da6a0" +source = "git+https://github.com/Imberflur/wgpu.git?tag=0.18-with-fixes-for-veloren-v1#df527ef82e2eba827eda9278caa583506a06aa87" dependencies = [ "arrayvec", "cfg-if 1.0.0", @@ -8118,7 +8118,7 @@ dependencies = [ "js-sys", "log", "naga", - "parking_lot 0.12.1", + "parking_lot 0.11.2", "profiling", "raw-window-handle 0.5.2", "serde", @@ -8135,7 +8135,7 @@ dependencies = [ [[package]] name = "wgpu-core" version = "0.18.1" -source = "git+https://github.com/IsseW/wgpu?rev=5ea160164#5ea16016402bb83b4ccd7ac8e6d4b0a2f85da6a0" +source = "git+https://github.com/Imberflur/wgpu.git?tag=0.18-with-fixes-for-veloren-v1#df527ef82e2eba827eda9278caa583506a06aa87" dependencies = [ "arrayvec", "bit-vec", @@ -8143,7 +8143,7 @@ dependencies = [ "codespan-reporting", "log", "naga", - "parking_lot 0.12.1", + "parking_lot 0.11.2", "profiling", "raw-window-handle 0.5.2", "ron", @@ -8159,7 +8159,7 @@ dependencies = [ [[package]] name = "wgpu-hal" version = "0.18.1" -source = "git+https://github.com/IsseW/wgpu?rev=5ea160164#5ea16016402bb83b4ccd7ac8e6d4b0a2f85da6a0" +source = "git+https://github.com/Imberflur/wgpu.git?tag=0.18-with-fixes-for-veloren-v1#df527ef82e2eba827eda9278caa583506a06aa87" dependencies = [ "android_system_properties", "arrayvec", @@ -8178,13 +8178,13 @@ dependencies = [ "js-sys", "khronos-egl", "libc", - "libloading 0.8.1", + "libloading 0.7.4", "log", "metal", "naga", "objc", "once_cell", - "parking_lot 0.12.1", + "parking_lot 0.11.2", "profiling", "range-alloc", "raw-window-handle 0.5.2", @@ -8211,7 +8211,7 @@ dependencies = [ [[package]] name = "wgpu-types" version = "0.18.0" -source = "git+https://github.com/IsseW/wgpu?rev=5ea160164#5ea16016402bb83b4ccd7ac8e6d4b0a2f85da6a0" +source = "git+https://github.com/Imberflur/wgpu.git?tag=0.18-with-fixes-for-veloren-v1#df527ef82e2eba827eda9278caa583506a06aa87" dependencies = [ "bitflags 2.4.2", "js-sys", diff --git a/Cargo.toml b/Cargo.toml index e8d8062b7f..d13e9ccbbb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -157,13 +157,14 @@ async-trait = "0.1.42" [patch.crates-io] shred = { git = "https://github.com/amethyst/shred.git", rev = "5d52c6fc390dd04c12158633e77591f6523d1f85" } -# This is needed because of an issue with spirv & naga in wgpu 0.18, and there's an issue -# with uint in uniforms for gl. -wgpu = { git = "https://github.com/IsseW/wgpu", rev = "5ea160164" } +# This is needed because of: +# * an issue with spirv & naga in wgpu 0.18 (I assume this is fixed upstream but not in 0.18) +# * an issue with uint in uniforms for gl. (potentially fixed in 0.19?) +# * an issue with releasing current context on Windows opengl (fixed in 0.19.1) +# * another spirv issue: unused builtins not always being removed. (upstream PR open) +wgpu = { git = "https://github.com/Imberflur/wgpu.git", tag = "0.18-with-fixes-for-veloren-v1" } +# wgpu = { path = "../wgpu/wgpu" } -# # use the latest fixes in naga (remove when updates trickle down to wgpu-rs) -# naga = { git = "https://github.com/gfx-rs/naga.git", rev = "3a0f0144112ff621dd7f731bf455adf6cab19164" } -# naga = { path = "../naga" } # keyboard-keynames = { git = "https://gitlab.com/Capucho/keyboard-keynames.git", rev = "7b1375ee4ea01d0e0b80c419cb27f0498e67df3a" } # # Uncomment this to use a local fork of winit (for testing purposes) @@ -174,6 +175,5 @@ wgpu = { git = "https://github.com/IsseW/wgpu", rev = "5ea160164" } # wgpu-hal = { path = "../wgpu/wgpu-hal" } # wgpu-core = { path = "../wgpu/wgpu-core" } # wgpu-types = { path = "../wgpu/wgpu-types" } +# naga = { path = "../wgpu/naga" } -[patch."https://github.com/gfx-rs/naga"] -# naga = { path = "../naga" } diff --git a/assets/voxygen/shaders/terrain-frag.glsl b/assets/voxygen/shaders/terrain-frag.glsl index 54651233d4..f226656e4f 100644 --- a/assets/voxygen/shaders/terrain-frag.glsl +++ b/assets/voxygen/shaders/terrain-frag.glsl @@ -27,7 +27,6 @@ layout(location = 0) in vec3 f_pos; // in vec3 f_chunk_pos; // #ifdef FLUID_MODE_SHINY layout(location = 1) flat in uint f_pos_norm; -layout(location = 2) flat in float f_load_time; // #else // const uint f_pos_norm = 0u; // #endif diff --git a/assets/voxygen/shaders/terrain-vert.glsl b/assets/voxygen/shaders/terrain-vert.glsl index 2fbbb52009..bd5c1315e2 100644 --- a/assets/voxygen/shaders/terrain-vert.glsl +++ b/assets/voxygen/shaders/terrain-vert.glsl @@ -49,7 +49,6 @@ uniform u_locals { layout(location = 0) out vec3 f_pos; // #ifdef FLUID_MODE_SHINY layout(location = 1) flat out uint f_pos_norm; -layout(location = 2) flat out float f_load_time; // #if (SHADOW_MODE == SHADOW_MODE_MAP) // out vec4 sun_pos; @@ -77,8 +76,6 @@ void main() { f_pos = (model_mat * vec4(f_chunk_pos, 1.0)).xyz - focus_off.xyz; - f_load_time = load_time; - vec3 v_pos = f_pos; // Terrain 'pop-in' effect diff --git a/assets/voxygen/shaders/trail-frag.glsl b/assets/voxygen/shaders/trail-frag.glsl index 42e2c5bcf5..7cbfcaf55b 100644 --- a/assets/voxygen/shaders/trail-frag.glsl +++ b/assets/voxygen/shaders/trail-frag.glsl @@ -20,8 +20,6 @@ #include -layout(location = 0) in vec3 f_pos; - layout(location = 0) out vec4 tgt_color; #include diff --git a/assets/voxygen/shaders/trail-vert.glsl b/assets/voxygen/shaders/trail-vert.glsl index e474ac048c..59aebae52c 100644 --- a/assets/voxygen/shaders/trail-vert.glsl +++ b/assets/voxygen/shaders/trail-vert.glsl @@ -4,10 +4,6 @@ layout(location = 0) in vec3 v_pos; -layout(location = 0) out vec3 f_pos; - void main() { - f_pos = v_pos; - - gl_Position = all_mat * vec4(f_pos - focus_off.xyz, 1); + gl_Position = all_mat * vec4(v_pos - focus_off.xyz, 1); } diff --git a/voxygen/src/render/renderer/pipeline_creation.rs b/voxygen/src/render/renderer/pipeline_creation.rs index a348ba287b..e2ce5e7b83 100644 --- a/voxygen/src/render/renderer/pipeline_creation.rs +++ b/voxygen/src/render/renderer/pipeline_creation.rs @@ -14,6 +14,7 @@ use super::{ }; use common_base::{prof_span, prof_span_alloc}; use std::sync::Arc; +use tracing::info; /// All the pipelines pub struct Pipelines { @@ -282,7 +283,26 @@ impl ShaderModules { let mut compiler = Compiler::new().ok_or(RenderError::ErrorInitializingCompiler)?; let mut options = CompileOptions::new().ok_or(RenderError::ErrorInitializingCompiler)?; - options.set_optimization_level(OptimizationLevel::Zero); + use std::sync::OnceLock; + static OPTS: OnceLock = OnceLock::new(); + let shaderc_opts = *OPTS.get_or_init(|| { + match std::env::var("VOXYGEN_SHADERC_OPTS").as_ref().map(|s| &**s) { + Ok("0" | "no") => { + info!("Disabled optimization by shaderc."); + false + }, + Ok("1" | "yes") | Ok(_) | Err(_) => { + info!("Enabled optimization by shaderc."); + true + }, + } + }); + + if shaderc_opts { + options.set_optimization_level(OptimizationLevel::Performance); + } else { + options.set_optimization_level(OptimizationLevel::Zero); + } options.set_forced_version_profile(430, shaderc::GlslProfile::Core); // options.set_generate_debug_info(); options.set_include_callback(move |name, _, shader_name, _| {