more testing

This commit is contained in:
Isse 2023-10-28 17:53:35 +02:00
parent d29d22dd0a
commit 9903d2c545
47 changed files with 130 additions and 228 deletions

View File

@ -25,8 +25,8 @@ tracy-server-debuginfo = "run --bin veloren-server-cli --features tracy,simd --p
tracy-server-releasedebuginfo = "run --bin veloren-server-cli --features tracy,simd --profile releasedebuginfo" tracy-server-releasedebuginfo = "run --bin veloren-server-cli --features tracy,simd --profile releasedebuginfo"
tracy-test-server = "run --bin veloren-server-cli --no-default-features --features tracy,simd --profile no_overflow" tracy-test-server = "run --bin veloren-server-cli --no-default-features --features tracy,simd --profile no_overflow"
# voxygen # voxygen
test-voxygen = "run --bin veloren-voxygen --no-default-features --features simd,egui-ui,shaderc-from-source" test-voxygen = "run --bin veloren-voxygen --no-default-features --features simd,egui-ui"
tracy-voxygen = "run --bin veloren-voxygen --no-default-features --features tracy,simd,egui-ui,shaderc-from-source --profile no_overflow" tracy-voxygen = "run --bin veloren-voxygen --no-default-features --features tracy,simd,egui-ui --profile no_overflow"
dbg-voxygen = "run --bin veloren-voxygen --profile debuginfo" dbg-voxygen = "run --bin veloren-voxygen --profile debuginfo"
# misc # misc
swarm = "run --bin swarm --features client/bin_bot,client/tick_network --" swarm = "run --bin swarm --features client/bin_bot,client/tick_network --"

71
Cargo.lock generated
View File

@ -3646,7 +3646,6 @@ dependencies = [
"indexmap 2.0.0", "indexmap 2.0.0",
"log", "log",
"num-traits", "num-traits",
"petgraph 0.6.4",
"pp-rs", "pp-rs",
"rustc-hash", "rustc-hash",
"serde", "serde",
@ -5219,15 +5218,6 @@ version = "0.0.8"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "082f11ffa03bbef6c2c6ea6bea1acafaade2fd9050ae0234ab44a2153742b058" checksum = "082f11ffa03bbef6c2c6ea6bea1acafaade2fd9050ae0234ab44a2153742b058"
[[package]]
name = "roxmltree"
version = "0.14.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "921904a62e410e37e215c40381b7117f830d9d89ba60ab5236170541dd25646b"
dependencies = [
"xmlparser",
]
[[package]] [[package]]
name = "rstar" name = "rstar"
version = "0.10.0" version = "0.10.0"
@ -5677,25 +5667,6 @@ dependencies = [
"digest", "digest",
] ]
[[package]]
name = "shaderc"
version = "0.8.0"
source = "git+https://github.com/pythonesque/shaderc-rs?rev=f2605a02062834019bedff911aee2fd2998c49f9#f2605a02062834019bedff911aee2fd2998c49f9"
dependencies = [
"libc",
"shaderc-sys",
]
[[package]]
name = "shaderc-sys"
version = "0.8.0"
source = "git+https://github.com/pythonesque/shaderc-rs?rev=f2605a02062834019bedff911aee2fd2998c49f9#f2605a02062834019bedff911aee2fd2998c49f9"
dependencies = [
"cmake",
"libc",
"roxmltree",
]
[[package]] [[package]]
name = "sharded-slab" name = "sharded-slab"
version = "0.1.4" version = "0.1.4"
@ -7297,7 +7268,6 @@ dependencies = [
"rodio", "rodio",
"ron", "ron",
"serde", "serde",
"shaderc",
"slab", "slab",
"specs", "specs",
"strum", "strum",
@ -8485,12 +8455,6 @@ version = "0.8.16"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "47430998a7b5d499ccee752b41567bc3afc57e1327dc855b1a2aa44ce29b5fa1" checksum = "47430998a7b5d499ccee752b41567bc3afc57e1327dc855b1a2aa44ce29b5fa1"
[[package]]
name = "xmlparser"
version = "0.13.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4d25c75bf9ea12c4040a97f829154768bbbce366287e2dc044af160cd79a13fd"
[[package]] [[package]]
name = "yasna" name = "yasna"
version = "0.5.2" version = "0.5.2"
@ -8519,38 +8483,3 @@ dependencies = [
"quote 1.0.33", "quote 1.0.33",
"syn 2.0.32", "syn 2.0.32",
] ]
[[patch.unused]]
name = "gfx-backend-dx11"
version = "0.8.0"
source = "git+https://github.com/Imberflur/gfx.git?tag=veloren-fixes-v1#a8ba0a4859abb5f980b02480cb219030fb64530c"
[[patch.unused]]
name = "gfx-backend-dx12"
version = "0.8.0"
source = "git+https://github.com/Imberflur/gfx.git?tag=veloren-fixes-v1#a8ba0a4859abb5f980b02480cb219030fb64530c"
[[patch.unused]]
name = "gfx-backend-empty"
version = "0.8.0"
source = "git+https://github.com/Imberflur/gfx.git?tag=veloren-fixes-v1#a8ba0a4859abb5f980b02480cb219030fb64530c"
[[patch.unused]]
name = "gfx-backend-gl"
version = "0.8.1"
source = "git+https://github.com/Imberflur/gfx.git?tag=veloren-fixes-v1#a8ba0a4859abb5f980b02480cb219030fb64530c"
[[patch.unused]]
name = "gfx-backend-metal"
version = "0.8.1"
source = "git+https://github.com/Imberflur/gfx.git?tag=veloren-fixes-v1#a8ba0a4859abb5f980b02480cb219030fb64530c"
[[patch.unused]]
name = "gfx-backend-vulkan"
version = "0.8.0"
source = "git+https://github.com/Imberflur/gfx.git?tag=veloren-fixes-v1#a8ba0a4859abb5f980b02480cb219030fb64530c"
[[patch.unused]]
name = "gfx-hal"
version = "0.8.0"
source = "git+https://github.com/Imberflur/gfx.git?tag=veloren-fixes-v1#a8ba0a4859abb5f980b02480cb219030fb64530c"

View File

@ -163,14 +163,14 @@ vek = { git = "https://github.com/yoanlcq/vek.git", rev = "84d5cb65841d46599a986
ntapi = { git = "https://github.com/MSxDOS/ntapi.git", rev = "9f56b149c9e25796739157c0fce3e0007a7de6eb" } ntapi = { git = "https://github.com/MSxDOS/ntapi.git", rev = "9f56b149c9e25796739157c0fce3e0007a7de6eb" }
shred = { git = "https://github.com/amethyst/shred.git", rev = "5d52c6fc390dd04c12158633e77591f6523d1f85" } shred = { git = "https://github.com/amethyst/shred.git", rev = "5d52c6fc390dd04c12158633e77591f6523d1f85" }
[patch."https://github.com/gfx-rs/gfx"] # [patch."https://github.com/gfx-rs/gfx"]
gfx-hal = { git = "https://github.com/Imberflur/gfx.git", tag = "veloren-fixes-v1" } # gfx-hal = { git = "https://github.com/Imberflur/gfx.git", tag = "veloren-fixes-v1" }
gfx-backend-empty = { git = "https://github.com/Imberflur/gfx.git", tag = "veloren-fixes-v1" } # gfx-backend-empty = { git = "https://github.com/Imberflur/gfx.git", tag = "veloren-fixes-v1" }
gfx-backend-vulkan = { git = "https://github.com/Imberflur/gfx.git", tag = "veloren-fixes-v1" } # gfx-backend-vulkan = { git = "https://github.com/Imberflur/gfx.git", tag = "veloren-fixes-v1" }
gfx-backend-gl = { git = "https://github.com/Imberflur/gfx.git", tag = "veloren-fixes-v1" } # gfx-backend-gl = { git = "https://github.com/Imberflur/gfx.git", tag = "veloren-fixes-v1" }
gfx-backend-dx12 = { git = "https://github.com/Imberflur/gfx.git", tag = "veloren-fixes-v1" } # gfx-backend-dx12 = { git = "https://github.com/Imberflur/gfx.git", tag = "veloren-fixes-v1" }
gfx-backend-dx11 = { git = "https://github.com/Imberflur/gfx.git", tag = "veloren-fixes-v1" } # gfx-backend-dx11 = { git = "https://github.com/Imberflur/gfx.git", tag = "veloren-fixes-v1" }
gfx-backend-metal = { git = "https://github.com/Imberflur/gfx.git", tag = "veloren-fixes-v1" } # gfx-backend-metal = { git = "https://github.com/Imberflur/gfx.git", tag = "veloren-fixes-v1" }
# # use the latest fixes in naga (remove when updates trickle down to wgpu-rs) # # 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 = { git = "https://github.com/gfx-rs/naga.git", rev = "3a0f0144112ff621dd7f731bf455adf6cab19164" }

View File

@ -1,4 +1,4 @@
#version 430 core #version 440 core
layout(set = 0, binding = 0) layout(set = 0, binding = 0)
uniform texture2D t_src_color; uniform texture2D t_src_color;

View File

@ -1,4 +1,4 @@
#version 430 core #version 440 core
layout(location = 0) out vec2 uv; layout(location = 0) out vec2 uv;

View File

@ -1,4 +1,4 @@
#version 430 core #version 440 core
#include <constants.glsl> #include <constants.glsl>

View File

@ -1,4 +1,4 @@
#version 430 core #version 440 core
#include <constants.glsl> #include <constants.glsl>

View File

@ -1,4 +1,4 @@
#version 430 core #version 440 core
#define HAS_SHADOW_MAPS #define HAS_SHADOW_MAPS

View File

@ -1,4 +1,4 @@
#version 430 core #version 440 core
#include <globals.glsl> #include <globals.glsl>

View File

@ -1,4 +1,4 @@
#version 430 core #version 440 core
layout(set = 0, binding = 0) layout(set = 0, binding = 0)
uniform texture2D t_src_color; uniform texture2D t_src_color;

View File

@ -1,4 +1,4 @@
#version 430 core #version 440 core
layout(set = 0, binding = 0) layout(set = 0, binding = 0)
uniform texture2D t_src_color; uniform texture2D t_src_color;

View File

@ -1,4 +1,4 @@
#version 430 core #version 440 core
layout(set = 0, binding = 0) layout(set = 0, binding = 0)
uniform texture2D t_src_color; uniform texture2D t_src_color;

View File

@ -1,4 +1,4 @@
#version 430 core #version 440 core
#define FIGURE_SHADER #define FIGURE_SHADER

View File

@ -1,4 +1,4 @@
#version 430 core #version 440 core
#include <constants.glsl> #include <constants.glsl>

View File

@ -1,4 +1,4 @@
#version 430 core #version 440 core
#include <constants.glsl> #include <constants.glsl>

View File

@ -1,4 +1,4 @@
#version 430 core #version 440 core
#include <constants.glsl> #include <constants.glsl>

View File

@ -1,4 +1,4 @@
#version 430 core #version 440 core
#include <constants.glsl> #include <constants.glsl>

View File

@ -1,4 +1,4 @@
#version 430 core #version 440 core
#include <globals.glsl> #include <globals.glsl>

View File

@ -1,4 +1,4 @@
#version 430 core #version 440 core
// #extension ARB_texture_storage : enable // #extension ARB_texture_storage : enable
#include <constants.glsl> #include <constants.glsl>

View File

@ -1,4 +1,4 @@
#version 430 core #version 440 core
// #extension ARB_texture_storage : enable // #extension ARB_texture_storage : enable
#define FIGURE_SHADER #define FIGURE_SHADER

View File

@ -2,7 +2,7 @@
// //
// However, in the future we might apply some depth transforms here. // However, in the future we might apply some depth transforms here.
#version 430 core #version 440 core
// #extension ARB_texture_storage : enable // #extension ARB_texture_storage : enable
#include <constants.glsl> #include <constants.glsl>

View File

@ -1,4 +1,4 @@
#version 430 core #version 440 core
#include <constants.glsl> #include <constants.glsl>

View File

@ -1,4 +1,4 @@
#version 430 core #version 440 core
#include <constants.glsl> #include <constants.glsl>

View File

@ -1,4 +1,4 @@
#version 430 core #version 440 core
#include <constants.glsl> #include <constants.glsl>

View File

@ -1,4 +1,4 @@
#version 430 core #version 440 core
#include <constants.glsl> #include <constants.glsl>

View File

@ -1,4 +1,4 @@
#version 430 core #version 440 core
#include <constants.glsl> #include <constants.glsl>

View File

@ -1,4 +1,4 @@
#version 430 core #version 440 core
#include <constants.glsl> #include <constants.glsl>

View File

@ -1,4 +1,4 @@
#version 430 core #version 440 core
// #extension ARB_texture_storage : enable // #extension ARB_texture_storage : enable
#include <constants.glsl> #include <constants.glsl>

View File

@ -1,4 +1,4 @@
#version 430 core #version 440 core
#include <constants.glsl> #include <constants.glsl>

View File

@ -1,4 +1,4 @@
#version 430 core #version 440 core
#include <constants.glsl> #include <constants.glsl>

View File

@ -1,4 +1,4 @@
#version 430 core #version 440 core
#extension GL_EXT_samplerless_texture_functions : enable #extension GL_EXT_samplerless_texture_functions : enable
layout(set = 0, binding = 0) layout(set = 0, binding = 0)

View File

@ -1,4 +1,4 @@
#version 430 core #version 440 core
layout(push_constant) uniform Params { layout(push_constant) uniform Params {
// Size of the source image. // Size of the source image.

View File

@ -1,4 +1,4 @@
#version 430 core #version 440 core
// #extension ARB_texture_storage : enable // #extension ARB_texture_storage : enable
#include <constants.glsl> #include <constants.glsl>

View File

@ -1,4 +1,4 @@
#version 430 core #version 440 core
// #extension ARB_texture_storage : enable // #extension ARB_texture_storage : enable
#define FIGURE_SHADER #define FIGURE_SHADER

View File

@ -1,4 +1,4 @@
#version 430 core #version 440 core
#include <constants.glsl> #include <constants.glsl>

View File

@ -1,4 +1,4 @@
#version 430 core #version 440 core
#include <constants.glsl> #include <constants.glsl>

View File

@ -1,4 +1,4 @@
#version 430 core #version 440 core
#include <constants.glsl> #include <constants.glsl>

View File

@ -1,4 +1,4 @@
#version 430 core #version 440 core
#include <constants.glsl> #include <constants.glsl>

View File

@ -1,4 +1,4 @@
#version 430 core #version 440 core
// #extension GL_ARB_texture_storage : require // #extension GL_ARB_texture_storage : require
#include <constants.glsl> #include <constants.glsl>

View File

@ -1,4 +1,4 @@
#version 430 core #version 440 core
#include <constants.glsl> #include <constants.glsl>

View File

@ -1,4 +1,4 @@
#version 430 core #version 440 core
#include <constants.glsl> #include <constants.glsl>

View File

@ -1,4 +1,4 @@
#version 430 core #version 440 core
#include <globals.glsl> #include <globals.glsl>

View File

@ -1,4 +1,4 @@
#version 430 core #version 440 core
#include <globals.glsl> #include <globals.glsl>
#include <constants.glsl> #include <constants.glsl>

View File

@ -1,4 +1,4 @@
#version 430 core #version 440 core
#include <globals.glsl> #include <globals.glsl>

View File

@ -29,14 +29,13 @@ tracy = ["common-frontend/tracy", "client/tracy"]
tracy-memory = ["tracy"] # enables heap profiling with tracy tracy-memory = ["tracy"] # enables heap profiling with tracy
plugins = ["client/plugins", "common-assets/plugins"] plugins = ["client/plugins", "common-assets/plugins"]
egui-ui = ["voxygen-egui", "egui", "egui_wgpu_backend", "egui_winit_platform"] egui-ui = ["voxygen-egui", "egui", "egui_wgpu_backend", "egui_winit_platform"]
shaderc-from-source = ["shaderc/build-from-source"]
discord = ["discord-sdk"] discord = ["discord-sdk"]
bin_img-export = ["common-assets"] bin_img-export = ["common-assets"]
# We don't ship egui with published release builds so a separate feature is required that excludes it. # We don't ship egui with published release builds so a separate feature is required that excludes it.
default-publish = ["singleplayer", "native-dialog", "plugins", "discord", "simd"] default-publish = ["singleplayer", "native-dialog", "plugins", "discord", "simd"]
# Temp for bug on current wgpu version that has access violation in vulkan when constructing egui pipeline # Temp for bug on current wgpu version that has access violation in vulkan when constructing egui pipeline
default-no-egui = ["default-publish", "hot-reloading", "shaderc-from-source"] default-no-egui = ["default-publish", "hot-reloading"]
default = ["default-no-egui", "egui-ui"] default = ["default-no-egui", "egui-ui"]
[dependencies] [dependencies]
@ -57,12 +56,9 @@ voxygen-egui = {package = "veloren-voxygen-egui", path = "egui", optional = true
# Graphics # Graphics
winit = {version = "0.28.6", features = ["serde"]} winit = {version = "0.28.6", features = ["serde"]}
wgpu = { version = "=0.18.0", features = ["trace", "spirv", "glsl"] } wgpu = { version = "=0.18.0", features = ["trace", "glsl"] }
wgpu-profiler = "0.15.0" wgpu-profiler = "0.15.0"
bytemuck = { version="1.7", features=["derive"] } bytemuck = { version="1.7", features=["derive"] }
# shaderc = "0.8.0"
# Working around a current bug in shaderc that causes it to use the system installation even if we specify compile from source
shaderc = { git = "https://github.com/pythonesque/shaderc-rs", rev = "f2605a02062834019bedff911aee2fd2998c49f9" }
# cmake crate used by shaderc, newer version 0.1.46 uses a new cmake command that is not available in our CI cmake version # cmake crate used by shaderc, newer version 0.1.46 uses a new cmake command that is not available in our CI cmake version
# see https://github.com/alexcrichton/cmake-rs/issues/131 # see https://github.com/alexcrichton/cmake-rs/issues/131
cmake = "=0.1.45" cmake = "=0.1.45"

View File

@ -7,7 +7,7 @@ pub enum RenderError {
CustomError(String), CustomError(String),
CouldNotFindAdapter, CouldNotFindAdapter,
ErrorInitializingCompiler, ErrorInitializingCompiler,
ShaderError(String, shaderc::Error), // ShaderError(String, shaderc::Error),
ProfilerCreationError(wgpu_profiler::CreationError), ProfilerCreationError(wgpu_profiler::CreationError),
} }
@ -27,10 +27,10 @@ impl fmt::Debug for RenderError {
Self::CustomError(err) => f.debug_tuple("CustomError").field(err).finish(), Self::CustomError(err) => f.debug_tuple("CustomError").field(err).finish(),
Self::CouldNotFindAdapter => f.debug_tuple("CouldNotFindAdapter").finish(), Self::CouldNotFindAdapter => f.debug_tuple("CouldNotFindAdapter").finish(),
Self::ErrorInitializingCompiler => f.debug_tuple("ErrorInitializingCompiler").finish(), Self::ErrorInitializingCompiler => f.debug_tuple("ErrorInitializingCompiler").finish(),
Self::ShaderError(shader_name, err) => write!( // Self::ShaderError(shader_name, err) => write!(
f, // f,
"\"{shader_name}\" shader failed to compile due to the following error: {err}", // "\"{shader_name}\" shader failed to compile due to the following error: {err}",
), // ),
RenderError::ProfilerCreationError(err) => write!(f, "Profiler creation error: {err}"), RenderError::ProfilerCreationError(err) => write!(f, "Profiler creation error: {err}"),
} }
} }
@ -47,9 +47,3 @@ impl From<wgpu::BufferAsyncError> for RenderError {
impl From<wgpu::SurfaceError> for RenderError { impl From<wgpu::SurfaceError> for RenderError {
fn from(err: wgpu::SurfaceError) -> Self { Self::SurfaceError(err) } fn from(err: wgpu::SurfaceError) -> Self { Self::SurfaceError(err) }
} }
impl From<(&str, shaderc::Error)> for RenderError {
fn from((shader_name, err): (&str, shaderc::Error)) -> Self {
Self::ShaderError(shader_name.into(), err)
}
}

View File

@ -164,7 +164,6 @@ impl ShaderModules {
has_shadow_views: bool, has_shadow_views: bool,
) -> Result<Self, RenderError> { ) -> Result<Self, RenderError> {
prof_span!(_guard, "ShaderModules::new"); prof_span!(_guard, "ShaderModules::new");
use shaderc::{CompileOptions, Compiler, OptimizationLevel, ResolvedInclude, ShaderKind};
let constants = shaders.get("include.constants").unwrap(); let constants = shaders.get("include.constants").unwrap();
let globals = shaders.get("include.globals").unwrap(); let globals = shaders.get("include.globals").unwrap();
@ -280,45 +279,32 @@ impl ShaderModules {
}) })
.unwrap(); .unwrap();
let mut compiler = Compiler::new().ok_or(RenderError::ErrorInitializingCompiler)?; let defines = wgpu::naga::FastHashMap::from_iter([
let mut options = CompileOptions::new().ok_or(RenderError::ErrorInitializingCompiler)?; ("constants.glsl".to_string(), constants.clone()),
options.set_optimization_level(OptimizationLevel::Zero); ("globals.glsl".to_string(), globals.0.to_owned()),
options.set_forced_version_profile(430, shaderc::GlslProfile::Core); ("shadows.glsl".to_string(), shadows.0.to_owned()),
// options.set_generate_debug_info(); (
options.set_include_callback(move |name, _, shader_name, _| { "rain_occlusion.glsl".to_string(),
Ok(ResolvedInclude { rain_occlusion.0.to_owned(),
resolved_name: name.to_string(), ),
content: match name { ("sky.glsl".to_string(), sky.0.to_owned()),
"constants.glsl" => constants.clone(), ("light.glsl".to_string(), light.0.to_owned()),
"globals.glsl" => globals.0.to_owned(), ("srgb.glsl".to_string(), srgb.0.to_owned()),
"shadows.glsl" => shadows.0.to_owned(), ("random.glsl".to_string(), random.0.to_owned()),
"rain_occlusion.glsl" => rain_occlusion.0.to_owned(), ("lod.glsl".to_string(), lod.0.to_owned()),
"sky.glsl" => sky.0.to_owned(), ("anti-aliasing.glsl".to_string(), anti_alias.0.to_owned()),
"light.glsl" => light.0.to_owned(), ("cloud.glsl".to_string(), cloud.0.to_owned()),
"srgb.glsl" => srgb.0.to_owned(), ("point_glow.glsl".to_string(), point_glow.0.to_owned()),
"random.glsl" => random.0.to_owned(), ("fxaa.glsl".to_string(), fxaa.0.to_owned()),
"lod.glsl" => lod.0.to_owned(), ]);
"anti-aliasing.glsl" => anti_alias.0.to_owned(),
"cloud.glsl" => cloud.0.to_owned(),
"point_glow.glsl" => point_glow.0.to_owned(),
"fxaa.glsl" => fxaa.0.to_owned(),
other => {
return Err(format!(
"Include {} in {} is not defined",
other, shader_name
));
},
},
})
});
let mut create_shader = |name, kind| { let create_shader = |name, stage| {
let glsl = &shaders let glsl = &shaders
.get(name) .get(name)
.unwrap_or_else(|| panic!("Can't retrieve shader: {}", name)) .unwrap_or_else(|| panic!("Can't retrieve shader: {}", name))
.0; .0;
let file_name = format!("{}.glsl", name); let file_name = format!("{}.glsl", name);
create_shader_module(device, &mut compiler, glsl, kind, &file_name, &options) create_shader_module(device, defines.clone(), glsl, stage, &file_name)
}; };
let selected_fluid_shader = ["fluid-frag.", match pipeline_modes.fluid { let selected_fluid_shader = ["fluid-frag.", match pipeline_modes.fluid {
@ -327,68 +313,69 @@ impl ShaderModules {
}] }]
.concat(); .concat();
use wgpu::naga::ShaderStage;
Ok(Self { Ok(Self {
skybox_vert: create_shader("skybox-vert", ShaderKind::Vertex)?, skybox_vert: create_shader("skybox-vert", ShaderStage::Vertex)?,
skybox_frag: create_shader("skybox-frag", ShaderKind::Fragment)?, skybox_frag: create_shader("skybox-frag", ShaderStage::Fragment)?,
debug_vert: create_shader("debug-vert", ShaderKind::Vertex)?, debug_vert: create_shader("debug-vert", ShaderStage::Vertex)?,
debug_frag: create_shader("debug-frag", ShaderKind::Fragment)?, debug_frag: create_shader("debug-frag", ShaderStage::Fragment)?,
figure_vert: create_shader("figure-vert", ShaderKind::Vertex)?, figure_vert: create_shader("figure-vert", ShaderStage::Vertex)?,
figure_frag: create_shader("figure-frag", ShaderKind::Fragment)?, figure_frag: create_shader("figure-frag", ShaderStage::Fragment)?,
terrain_vert: create_shader("terrain-vert", ShaderKind::Vertex)?, terrain_vert: create_shader("terrain-vert", ShaderStage::Vertex)?,
terrain_frag: create_shader("terrain-frag", ShaderKind::Fragment)?, terrain_frag: create_shader("terrain-frag", ShaderStage::Fragment)?,
fluid_vert: create_shader("fluid-vert", ShaderKind::Vertex)?, fluid_vert: create_shader("fluid-vert", ShaderStage::Vertex)?,
fluid_frag: create_shader(&selected_fluid_shader, ShaderKind::Fragment)?, fluid_frag: create_shader(&selected_fluid_shader, ShaderStage::Fragment)?,
sprite_vert: create_shader("sprite-vert", ShaderKind::Vertex)?, sprite_vert: create_shader("sprite-vert", ShaderStage::Vertex)?,
sprite_frag: create_shader("sprite-frag", ShaderKind::Fragment)?, sprite_frag: create_shader("sprite-frag", ShaderStage::Fragment)?,
lod_object_vert: create_shader("lod-object-vert", ShaderKind::Vertex)?, lod_object_vert: create_shader("lod-object-vert", ShaderStage::Vertex)?,
lod_object_frag: create_shader("lod-object-frag", ShaderKind::Fragment)?, lod_object_frag: create_shader("lod-object-frag", ShaderStage::Fragment)?,
particle_vert: create_shader("particle-vert", ShaderKind::Vertex)?, particle_vert: create_shader("particle-vert", ShaderStage::Vertex)?,
particle_frag: create_shader("particle-frag", ShaderKind::Fragment)?, particle_frag: create_shader("particle-frag", ShaderStage::Fragment)?,
rope_vert: create_shader("rope-vert", ShaderKind::Vertex)?, rope_vert: create_shader("rope-vert", ShaderStage::Vertex)?,
rope_frag: create_shader("rope-frag", ShaderKind::Fragment)?, rope_frag: create_shader("rope-frag", ShaderStage::Fragment)?,
trail_vert: create_shader("trail-vert", ShaderKind::Vertex)?, trail_vert: create_shader("trail-vert", ShaderStage::Vertex)?,
trail_frag: create_shader("trail-frag", ShaderKind::Fragment)?, trail_frag: create_shader("trail-frag", ShaderStage::Fragment)?,
ui_vert: create_shader("ui-vert", ShaderKind::Vertex)?, ui_vert: create_shader("ui-vert", ShaderStage::Vertex)?,
ui_frag: create_shader("ui-frag", ShaderKind::Fragment)?, ui_frag: create_shader("ui-frag", ShaderStage::Fragment)?,
premultiply_alpha_vert: create_shader("premultiply-alpha-vert", ShaderKind::Vertex)?, premultiply_alpha_vert: create_shader("premultiply-alpha-vert", ShaderStage::Vertex)?,
premultiply_alpha_frag: create_shader("premultiply-alpha-frag", ShaderKind::Fragment)?, premultiply_alpha_frag: create_shader("premultiply-alpha-frag", ShaderStage::Fragment)?,
lod_terrain_vert: create_shader("lod-terrain-vert", ShaderKind::Vertex)?, lod_terrain_vert: create_shader("lod-terrain-vert", ShaderStage::Vertex)?,
lod_terrain_frag: create_shader("lod-terrain-frag", ShaderKind::Fragment)?, lod_terrain_frag: create_shader("lod-terrain-frag", ShaderStage::Fragment)?,
clouds_vert: create_shader("clouds-vert", ShaderKind::Vertex)?, clouds_vert: create_shader("clouds-vert", ShaderStage::Vertex)?,
clouds_frag: create_shader("clouds-frag", ShaderKind::Fragment)?, clouds_frag: create_shader("clouds-frag", ShaderStage::Fragment)?,
dual_downsample_filtered_frag: create_shader( dual_downsample_filtered_frag: create_shader(
"dual-downsample-filtered-frag", "dual-downsample-filtered-frag",
ShaderKind::Fragment, ShaderStage::Fragment,
)?, )?,
dual_downsample_frag: create_shader("dual-downsample-frag", ShaderKind::Fragment)?, dual_downsample_frag: create_shader("dual-downsample-frag", ShaderStage::Fragment)?,
dual_upsample_frag: create_shader("dual-upsample-frag", ShaderKind::Fragment)?, dual_upsample_frag: create_shader("dual-upsample-frag", ShaderStage::Fragment)?,
postprocess_vert: create_shader("postprocess-vert", ShaderKind::Vertex)?, postprocess_vert: create_shader("postprocess-vert", ShaderStage::Vertex)?,
postprocess_frag: create_shader("postprocess-frag", ShaderKind::Fragment)?, postprocess_frag: create_shader("postprocess-frag", ShaderStage::Fragment)?,
blit_vert: create_shader("blit-vert", ShaderKind::Vertex)?, blit_vert: create_shader("blit-vert", ShaderStage::Vertex)?,
blit_frag: create_shader("blit-frag", ShaderKind::Fragment)?, blit_frag: create_shader("blit-frag", ShaderStage::Fragment)?,
point_light_shadows_vert: create_shader( point_light_shadows_vert: create_shader(
"point-light-shadows-vert", "point-light-shadows-vert",
ShaderKind::Vertex, ShaderStage::Vertex,
)?, )?,
light_shadows_directed_vert: create_shader( light_shadows_directed_vert: create_shader(
"light-shadows-directed-vert", "light-shadows-directed-vert",
ShaderKind::Vertex, ShaderStage::Vertex,
)?, )?,
light_shadows_figure_vert: create_shader( light_shadows_figure_vert: create_shader(
"light-shadows-figure-vert", "light-shadows-figure-vert",
ShaderKind::Vertex, ShaderStage::Vertex,
)?, )?,
light_shadows_debug_vert: create_shader( light_shadows_debug_vert: create_shader(
"light-shadows-debug-vert", "light-shadows-debug-vert",
ShaderKind::Vertex, ShaderStage::Vertex,
)?, )?,
rain_occlusion_directed_vert: create_shader( rain_occlusion_directed_vert: create_shader(
"rain-occlusion-directed-vert", "rain-occlusion-directed-vert",
ShaderKind::Vertex, ShaderStage::Vertex,
)?, )?,
rain_occlusion_figure_vert: create_shader( rain_occlusion_figure_vert: create_shader(
"rain-occlusion-figure-vert", "rain-occlusion-figure-vert",
ShaderKind::Vertex, ShaderStage::Vertex,
)?, )?,
}) })
} }
@ -396,19 +383,14 @@ impl ShaderModules {
fn create_shader_module( fn create_shader_module(
device: &wgpu::Device, device: &wgpu::Device,
compiler: &mut shaderc::Compiler, defines: wgpu::naga::FastHashMap<String, String>,
source: &str, source: &str,
kind: shaderc::ShaderKind, stage: wgpu::naga::ShaderStage,
file_name: &str, file_name: &str,
options: &shaderc::CompileOptions,
) -> Result<wgpu::ShaderModule, RenderError> { ) -> Result<wgpu::ShaderModule, RenderError> {
prof_span!(_guard, "create_shader_modules"); prof_span!(_guard, "create_shader_modules");
use std::borrow::Cow; use std::borrow::Cow;
let spv = compiler
.compile_into_spirv(source, kind, file_name, "main", Some(options))
.map_err(|e| (file_name, e))?;
// Uncomment me to dump shaders to files // Uncomment me to dump shaders to files
// //
// std::fs::create_dir_all("dumpped-shaders").expect("Couldn't create shader // std::fs::create_dir_all("dumpped-shaders").expect("Couldn't create shader
@ -423,13 +405,14 @@ fn create_shader_module(
// .expect("Couldn't write shader out"); // .expect("Couldn't write shader out");
// let label = [file_name, "\n\n", source].concat(); // let label = [file_name, "\n\n", source].concat();
#[allow(unsafe_code)] Ok(device.create_shader_module(wgpu::ShaderModuleDescriptor {
Ok(unsafe { label: Some(file_name),
device.create_shader_module_unchecked(wgpu::ShaderModuleDescriptor { source: wgpu::ShaderSource::Glsl {
label: Some(file_name), shader: Cow::Borrowed(source),
source: wgpu::ShaderSource::SpirV(Cow::Borrowed(spv.as_binary())), stage,
}) defines,
}) },
}))
} }
/// Things needed to create a pipeline /// Things needed to create a pipeline