Remove wgpu patch/update wgpu, rebase fixes, remove use of deprecated

vek functions for left, right, up, down, forward_rh, forward_lh
This commit is contained in:
Imbris 2021-01-01 14:35:59 -05:00 committed by Avi Weinstock
parent 855101d72a
commit 72e6fe89df
17 changed files with 39 additions and 39 deletions

View File

@ -110,8 +110,3 @@ nativeBuildInputs = ["pkg-config"]
# macos CI fix isn't merged yet # macos CI fix isn't merged yet
winit = { git = "https://gitlab.com/veloren/winit.git", branch = "macos-test-spiffed" } winit = { git = "https://gitlab.com/veloren/winit.git", branch = "macos-test-spiffed" }
vek = { git = "https://gitlab.com/veloren/vek.git", branch = "fix_intrinsics2" } vek = { git = "https://gitlab.com/veloren/vek.git", branch = "fix_intrinsics2" }
# Pending https://github.com/gfx-rs/wgpu/pull/1080
[patch.'https://github.com/gfx-rs/wgpu']
wgpu-core = { git="https://github.com/JCapucho/wgpu" }
wgpu-types = { git="https://github.com/JCapucho/wgpu" }

View File

@ -648,6 +648,6 @@ vec3 greedy_extract_col_light_attr(texture2D t_col_light, sampler s_col_light, v
vec3 greedy_extract_col_light_glow(texture2D t_col_light, sampler s_col_light, vec2 f_uv_pos, out float f_light, out float f_glow) { vec3 greedy_extract_col_light_glow(texture2D t_col_light, sampler s_col_light, vec2 f_uv_pos, out float f_light, out float f_glow) {
uint f_attr; uint f_attr;
return greedy_extract_col_light_attr(t_col_light, f_uv_pos, f_light, f_glow, f_attr); return greedy_extract_col_light_attr(t_col_light, s_col_light, f_uv_pos, f_light, f_glow, f_attr);
} }
#endif #endif

View File

@ -150,7 +150,7 @@ impl<'a> GreedyMesh<'a> {
FO: for<'r> FnMut(&'r mut D, Vec3<i32>) -> bool + 'a, FO: for<'r> FnMut(&'r mut D, Vec3<i32>) -> bool + 'a,
FS: for<'r> FnMut(&'r mut D, Vec3<i32>, Vec3<i32>, Vec2<Vec3<i32>>) -> Option<(bool, M)>, FS: for<'r> FnMut(&'r mut D, Vec3<i32>, Vec3<i32>, Vec2<Vec3<i32>>) -> Option<(bool, M)>,
FP: FnMut(Vec2<u16>, Vec2<Vec2<u16>>, Vec3<f32>, Vec2<Vec3<f32>>, Vec3<f32>, &M), FP: FnMut(Vec2<u16>, Vec2<Vec2<u16>>, Vec3<f32>, Vec2<Vec3<f32>>, Vec3<f32>, &M),
FT: for<'r> FnMut(&'r mut D, Vec3<i32>, u8, u8) -> <<ColLightFmt as gfx::format::Formatted>::Surface as gfx::format::SurfaceTyped>::DataType + 'a, FT: for<'r> FnMut(&'r mut D, Vec3<i32>, u8, u8) -> [u8; 4] + 'a,
{ {
span!(_guard, "push", "GreedyMesh::push"); span!(_guard, "push", "GreedyMesh::push");
let cont = greedy_mesh( let cont = greedy_mesh(
@ -211,7 +211,7 @@ where
FO: for<'r> FnMut(&'r mut D, Vec3<i32>) -> bool + 'a, FO: for<'r> FnMut(&'r mut D, Vec3<i32>) -> bool + 'a,
FS: for<'r> FnMut(&'r mut D, Vec3<i32>, Vec3<i32>, Vec2<Vec3<i32>>) -> Option<(bool, M)>, FS: for<'r> FnMut(&'r mut D, Vec3<i32>, Vec3<i32>, Vec2<Vec3<i32>>) -> Option<(bool, M)>,
FP: FnMut(Vec2<u16>, Vec2<Vec2<u16>>, Vec3<f32>, Vec2<Vec3<f32>>, Vec3<f32>, &M), FP: FnMut(Vec2<u16>, Vec2<Vec2<u16>>, Vec3<f32>, Vec2<Vec3<f32>>, Vec3<f32>, &M),
FT: for<'r> FnMut(&'r mut D, Vec3<i32>, u8, u8) -> <<ColLightFmt as gfx::format::Formatted>::Surface as gfx::format::SurfaceTyped>::DataType + 'a, FT: for<'r> FnMut(&'r mut D, Vec3<i32>, u8, u8) -> [u8; 4] + 'a,
{ {
span!(_guard, "greedy_mesh"); span!(_guard, "greedy_mesh");
// TODO: Collect information to see if we can choose a good value here. // TODO: Collect information to see if we can choose a good value here.

View File

@ -148,7 +148,7 @@ impl CloudsPipeline {
layout: &CloudsLayout, layout: &CloudsLayout,
aa_mode: AaMode, aa_mode: AaMode,
) -> Self { ) -> Self {
common::span!(_guard, "CloudsPipeline::new"); common_base::span!(_guard, "CloudsPipeline::new");
let render_pipeline_layout = let render_pipeline_layout =
device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor { device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: Some("Clouds pipeline layout"), label: Some("Clouds pipeline layout"),

View File

@ -178,7 +178,7 @@ impl FigurePipeline {
layout: &FigureLayout, layout: &FigureLayout,
aa_mode: AaMode, aa_mode: AaMode,
) -> Self { ) -> Self {
common::span!(_guard, "FigurePipeline::new"); common_base::span!(_guard, "FigurePipeline::new");
let render_pipeline_layout = let render_pipeline_layout =
device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor { device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: Some("Figure pipeline layout"), label: Some("Figure pipeline layout"),

View File

@ -121,7 +121,7 @@ impl FluidPipeline {
terrain_layout: &TerrainLayout, terrain_layout: &TerrainLayout,
aa_mode: AaMode, aa_mode: AaMode,
) -> Self { ) -> Self {
common::span!(_guard, "FluidPipeline::new"); common_base::span!(_guard, "FluidPipeline::new");
let render_pipeline_layout = let render_pipeline_layout =
device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor { device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: Some("Fluid pipeline layout"), label: Some("Fluid pipeline layout"),

View File

@ -181,7 +181,7 @@ impl ParticlePipeline {
global_layout: &GlobalsLayouts, global_layout: &GlobalsLayouts,
aa_mode: AaMode, aa_mode: AaMode,
) -> Self { ) -> Self {
common::span!(_guard, "ParticlePipeline::new"); common_base::span!(_guard, "ParticlePipeline::new");
let render_pipeline_layout = let render_pipeline_layout =
device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor { device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: Some("Particle pipeline layout"), label: Some("Particle pipeline layout"),

View File

@ -116,7 +116,7 @@ impl PostProcessPipeline {
layout: &PostProcessLayout, layout: &PostProcessLayout,
aa_mode: AaMode, aa_mode: AaMode,
) -> Self { ) -> Self {
common::span!(_guard, "PostProcessPipeline::new"); common_base::span!(_guard, "PostProcessPipeline::new");
let render_pipeline_layout = let render_pipeline_layout =
device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor { device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: Some("Post process pipeline layout"), label: Some("Post process pipeline layout"),

View File

@ -137,7 +137,7 @@ impl ShadowFigurePipeline {
figure_layout: &FigureLayout, figure_layout: &FigureLayout,
aa_mode: AaMode, aa_mode: AaMode,
) -> Self { ) -> Self {
common::span!(_guard, "new"); common_base::span!(_guard, "new");
let render_pipeline_layout = let render_pipeline_layout =
device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor { device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {

View File

@ -39,7 +39,7 @@ impl SkyboxPipeline {
layouts: &GlobalsLayouts, layouts: &GlobalsLayouts,
aa_mode: AaMode, aa_mode: AaMode,
) -> Self { ) -> Self {
common::span!(_guard, "SkyboxPipeline::new"); common_base::span!(_guard, "SkyboxPipeline::new");
let render_pipeline_layout = let render_pipeline_layout =
device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor { device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: Some("Skybox pipeline layout"), label: Some("Skybox pipeline layout"),

View File

@ -212,7 +212,7 @@ impl SpritePipeline {
terrain_layout: &TerrainLayout, terrain_layout: &TerrainLayout,
aa_mode: AaMode, aa_mode: AaMode,
) -> Self { ) -> Self {
common::span!(_guard, "SpritePipeline::new"); common_base::span!(_guard, "SpritePipeline::new");
let render_pipeline_layout = let render_pipeline_layout =
device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor { device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: Some("Sprite pipeline layout"), label: Some("Sprite pipeline layout"),

View File

@ -212,7 +212,7 @@ impl TerrainPipeline {
layout: &TerrainLayout, layout: &TerrainLayout,
aa_mode: AaMode, aa_mode: AaMode,
) -> Self { ) -> Self {
common::span!(_guard, "TerrainPipeline::new"); common_base::span!(_guard, "TerrainPipeline::new");
let render_pipeline_layout = let render_pipeline_layout =
device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor { device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: Some("Terrain pipeline layout"), label: Some("Terrain pipeline layout"),

View File

@ -67,10 +67,10 @@ impl assets::Compound for Shaders {
"include.cloud.none", "include.cloud.none",
"include.cloud.regular", "include.cloud.regular",
"figure-vert", "figure-vert",
"light-shadows-vert",
"light-shadows-directed-vert",
"light-shadows-figure-vert", "light-shadows-figure-vert",
"light-shadows-directed-vert",
"light-shadows-directed-frag", "light-shadows-directed-frag",
"point-light-shadows-vert",
"skybox-vert", "skybox-vert",
"skybox-frag", "skybox-frag",
"figure-frag", "figure-frag",
@ -97,7 +97,7 @@ impl assets::Compound for Shaders {
]; ];
let shaders = shaders let shaders = shaders
.into_iter() .iter()
.map(|shader| { .map(|shader| {
let full_specifier = ["voxygen.shaders.", shader].concat(); let full_specifier = ["voxygen.shaders.", shader].concat();
let asset = AssetExt::load(&full_specifier)?; let asset = AssetExt::load(&full_specifier)?;
@ -327,7 +327,6 @@ impl Renderer {
| wgpu::Features::ADDRESS_MODE_CLAMP_TO_BORDER | wgpu::Features::ADDRESS_MODE_CLAMP_TO_BORDER
| wgpu::Features::PUSH_CONSTANTS, | wgpu::Features::PUSH_CONSTANTS,
limits, limits,
shader_validation: true,
}, },
None, None,
))?; ))?;
@ -780,6 +779,7 @@ impl Renderer {
}); });
let mut clear = |tex: &Texture| { let mut clear = |tex: &Texture| {
encoder.begin_render_pass(&wgpu::RenderPassDescriptor { encoder.begin_render_pass(&wgpu::RenderPassDescriptor {
label: Some("Clear dummy shadow texture"),
color_attachments: &[], color_attachments: &[],
depth_stencil_attachment: Some(wgpu::RenderPassDepthStencilAttachmentDescriptor { depth_stencil_attachment: Some(wgpu::RenderPassDepthStencilAttachmentDescriptor {
attachment: &tex.view, attachment: &tex.view,
@ -2135,7 +2135,10 @@ fn create_pipelines(
}); });
let mut create_shader = |name, kind| { let mut create_shader = |name, kind| {
let glsl = &shaders.get(name).unwrap().0; let glsl = &shaders
.get(name)
.unwrap_or_else(|| panic!("Can't retrieve shader: {}", name))
.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, &mut compiler, glsl, kind, &file_name, &options)
}; };
@ -2359,6 +2362,6 @@ fn create_shader_module(
Ok(device.create_shader_module(&wgpu::ShaderModuleDescriptor { Ok(device.create_shader_module(&wgpu::ShaderModuleDescriptor {
label: Some(source), label: Some(source),
source: wgpu::ShaderSource::SpirV(Cow::Borrowed(spv.as_binary())), source: wgpu::ShaderSource::SpirV(Cow::Borrowed(spv.as_binary())),
experimental_translation: false, flags: wgpu::ShaderFlags::VALIDATION,
})) }))
} }

View File

@ -43,6 +43,7 @@ impl<'a> Drawer<'a> {
.as_mut() .as_mut()
.unwrap() .unwrap()
.begin_render_pass(&wgpu::RenderPassDescriptor { .begin_render_pass(&wgpu::RenderPassDescriptor {
label: Some("shadow pass"),
color_attachments: &[], color_attachments: &[],
depth_stencil_attachment: Some( depth_stencil_attachment: Some(
wgpu::RenderPassDepthStencilAttachmentDescriptor { wgpu::RenderPassDepthStencilAttachmentDescriptor {
@ -74,6 +75,7 @@ impl<'a> Drawer<'a> {
.as_mut() .as_mut()
.unwrap() .unwrap()
.begin_render_pass(&wgpu::RenderPassDescriptor { .begin_render_pass(&wgpu::RenderPassDescriptor {
label: Some("first pass"),
color_attachments: &[wgpu::RenderPassColorAttachmentDescriptor { color_attachments: &[wgpu::RenderPassColorAttachmentDescriptor {
attachment: &self.renderer.tgt_color_view, attachment: &self.renderer.tgt_color_view,
resolve_target: None, resolve_target: None,
@ -109,6 +111,7 @@ impl<'a> Drawer<'a> {
.as_mut() .as_mut()
.unwrap() .unwrap()
.begin_render_pass(&wgpu::RenderPassDescriptor { .begin_render_pass(&wgpu::RenderPassDescriptor {
label: Some("second pass (clouds)"),
color_attachments: &[wgpu::RenderPassColorAttachmentDescriptor { color_attachments: &[wgpu::RenderPassColorAttachmentDescriptor {
attachment: &self.renderer.tgt_color_pp_view, attachment: &self.renderer.tgt_color_pp_view,
resolve_target: None, resolve_target: None,
@ -135,6 +138,7 @@ impl<'a> Drawer<'a> {
.as_mut() .as_mut()
.unwrap() .unwrap()
.begin_render_pass(&wgpu::RenderPassDescriptor { .begin_render_pass(&wgpu::RenderPassDescriptor {
label: Some("third pass (postprocess + ui)"),
color_attachments: &[wgpu::RenderPassColorAttachmentDescriptor { color_attachments: &[wgpu::RenderPassColorAttachmentDescriptor {
attachment: &self.tex.view, attachment: &self.tex.view,
resolve_target: None, resolve_target: None,
@ -180,11 +184,13 @@ impl<'a> Drawer<'a> {
array_layer_count: NonZeroU32::new(1), array_layer_count: NonZeroU32::new(1),
}); });
let label = format!("point shadow face: {} pass", face);
let mut render_pass = let mut render_pass =
self.encoder self.encoder
.as_mut() .as_mut()
.unwrap() .unwrap()
.begin_render_pass(&wgpu::RenderPassDescriptor { .begin_render_pass(&wgpu::RenderPassDescriptor {
label: Some(&label),
color_attachments: &[], color_attachments: &[],
depth_stencil_attachment: Some( depth_stencil_attachment: Some(
wgpu::RenderPassDepthStencilAttachmentDescriptor { wgpu::RenderPassDepthStencilAttachmentDescriptor {

View File

@ -4772,9 +4772,9 @@ impl FigureMgr {
) )
.join() .join()
// Don't render dead entities // Don't render dead entities
.filter(|(_, _, _, health, _)| health.map_or(true, |h| !h.is_dead)) .filter(|(_, _, _, health, _, _)| health.map_or(true, |h| !h.is_dead))
// Don't render player // Don't render player
.filter(|(entity, _, _, _, _)| *entity != player_entity) .filter(|(entity, _, _, _, _, _)| *entity != player_entity)
{ {
if let Some((bound, model, col_lights)) = self.get_model_for_render( if let Some((bound, model, col_lights)) = self.get_model_for_render(
tick, tick,

View File

@ -740,14 +740,10 @@ impl Scene {
v_p.z = 0.0; v_p.z = 0.0;
v_p.normalize(); v_p.normalize();
let l_r: math::Mat4<f32> = if factor > EPSILON_UPSILON { let l_r: math::Mat4<f32> = if factor > EPSILON_UPSILON {
<<<<<<< HEAD
math::Mat4::look_at_rh(math::Vec3::zero(), -math::Vec3::unit_z(), v_p)
=======
// NOTE: Our coordinates are now in left-handed space, but v_p isn't; however, // NOTE: Our coordinates are now in left-handed space, but v_p isn't; however,
// v_p has no z component, so we don't have to adjust it for left-handed // v_p has no z component, so we don't have to adjust it for left-handed
// spaces. // spaces.
math::Mat4::look_at_lh(math::Vec3::zero(), math::Vec3::forward_lh(), v_p) math::Mat4::look_at_lh(math::Vec3::zero(), math::Vec3::unit_z(), v_p)
>>>>>>> 00820cebc (Fix directed shadows, mostly.)
} else { } else {
math::Mat4::identity() math::Mat4::identity()
}; };
@ -788,23 +784,23 @@ impl Scene {
// moves from view-space (right-handed) to world-space (right-handed). // moves from view-space (right-handed) to world-space (right-handed).
let view_point = view_inv let view_point = view_inv
* math::Vec4::from_point( * math::Vec4::from_point(
math::Vec3::forward_rh() * p_z, /* + math::Vec4::unit_w() */ -math::Vec3::unit_z() * p_z, /* + math::Vec4::unit_w() */
); );
let view_plane = view_mat.transposed() * math::Vec4::forward_rh(); let view_plane = view_mat.transposed() * -math::Vec4::unit_z();
// moves from rotated light space (left-handed) to world space (right-handed). // moves from rotated light space (left-handed) to world space (right-handed).
let light_point = light_all_inv let light_point = light_all_inv
* math::Vec4::from_point( * math::Vec4::from_point(
math::Vec3::up() * p_y, /* + math::Vec4::unit_w() */ math::Vec3::unit_y() * p_y, /* + math::Vec4::unit_w() */
); );
let light_plane = light_all_mat.transposed() * math::Vec4::up(); let light_plane = light_all_mat.transposed() * math::Vec4::unit_y();
// moves from rotated light space (left-handed) to world space (right-handed). // moves from rotated light space (left-handed) to world space (right-handed).
let shadow_point = light_all_inv let shadow_point = light_all_inv
* math::Vec4::from_point( * math::Vec4::from_point(
math::Vec3::right() * p_x, /* + math::Vec4::unit_w() */ math::Vec3::unit_x() * p_x, /* + math::Vec4::unit_w() */
); );
let shadow_plane = light_all_mat.transposed() * math::Vec4::right(); let shadow_plane = light_all_mat.transposed() * math::Vec4::unit_x();
// Find the point at the intersection of the three planes; note that since the // Find the point at the intersection of the three planes; note that since the
// equations are already in right-handed world space, we don't need to negate // equations are already in right-handed world space, we don't need to negate
@ -848,8 +844,8 @@ impl Scene {
// NOTE: I don't think the w component should be anything but 1 here, but // NOTE: I don't think the w component should be anything but 1 here, but
// better safe than sorry. // better safe than sorry.
( (
f64::from(z0.homogenized().dot(math::Vec4::forward_rh())), f64::from(z0.homogenized().dot(-math::Vec4::unit_z())),
f64::from(z1.homogenized().dot(math::Vec4::forward_rh())), f64::from(z1.homogenized().dot(-math::Vec4::unit_z())),
) )
}; };