Start lod, update wgpu to fix viewport count validation error

This commit is contained in:
Imbris 2020-12-06 14:01:46 -05:00 committed by Avi Weinstock
parent b8a5e0e3b9
commit 7048e57a2b
6 changed files with 28 additions and 52 deletions

View File

@ -109,8 +109,14 @@ impl LodData {
) )
}; };
let map = create_texture(wgpu::TextureFormat::Rgba8UnormSrgb, lod_base); let map = create_texture(wgpu::TextureFormat::Rgba8UnormSrgb, lod_base);
// SamplerInfo {
// border: border_color,
let alt = create_texture(wgpu::TextureFormat::Rg16Uint, lod_alt); let alt = create_texture(wgpu::TextureFormat::Rg16Uint, lod_alt);
// SamplerInfo {
// border: [0.0, 0.0, 0.0, 0.0].into(),
let horizon = create_texture(wgpu::TextureFormat::Rgba8Unorm, lod_horizon); let horizon = create_texture(wgpu::TextureFormat::Rgba8Unorm, lod_horizon);
// SamplerInfo {
// border: [1.0, 0.0, 1.0, 0.0].into(),
Self { Self {
map, map,
@ -118,43 +124,6 @@ impl LodData {
horizon, horizon,
tgt_detail, tgt_detail,
} }
// Self {
// map: renderer
// .create_texture_immutable_raw(
// kind,
// gfx::texture::Mipmap::Provided,
// &[gfx::memory::cast_slice(lod_base)],
// SamplerInfo {
// border: border_color,
// ..info
// },
// )
// .expect("Failed to generate map texture"),
// alt: renderer
// .create_texture_immutable_raw(
// kind,
// gfx::texture::Mipmap::Provided,
// &[gfx::memory::cast_slice(lod_alt)],
// SamplerInfo {
// border: [0.0, 0.0, 0.0, 0.0].into(),
// ..info
// },
// )
// .expect("Failed to generate alt texture"),
// horizon: renderer
// .create_texture_immutable_raw(
// kind,
// gfx::texture::Mipmap::Provided,
// &[gfx::memory::cast_slice(lod_horizon)],
// SamplerInfo {
// border: [1.0, 0.0, 1.0, 0.0].into(),
// ..info
// },
// )
// .expect("Failed to generate horizon texture"),
// tgt_detail,
// }
} }
} }

View File

@ -229,7 +229,7 @@ pub struct Renderer {
sampler: wgpu::Sampler, sampler: wgpu::Sampler,
shadow_map: Option<ShadowMapRenderer>, shadow_map: Option<ShadowMapRenderer>,
//dummy_shadow_tex: wgpu::TextureView,
layouts: Layouts, layouts: Layouts,
figure_pipeline: figure::FigurePipeline, figure_pipeline: figure::FigurePipeline,
@ -2305,9 +2305,9 @@ fn create_shader_module(
.compile_into_spirv(source, kind, file_name, "main", Some(options)) .compile_into_spirv(source, kind, file_name, "main", Some(options))
.map_err(|e| (file_name, e))?; .map_err(|e| (file_name, e))?;
Ok( Ok(device.create_shader_module(&wgpu::ShaderModuleDescriptor {
device.create_shader_module(wgpu::ShaderModuleSource::SpirV(Cow::Borrowed( label: Some(source),
spv.as_binary(), source: wgpu::ShaderSource::SpirV(Cow::Borrowed(spv.as_binary())),
))), experimental_translation: false,
) }))
} }

View File

@ -17,7 +17,7 @@ impl Renderer {
Some(shadow_map) => (&shadow_map.point_depth, &shadow_map.directed_depth), Some(shadow_map) => (&shadow_map.point_depth, &shadow_map.directed_depth),
None => (&self.noise_tex, &self.noise_tex), None => (&self.noise_tex, &self.noise_tex),
}; };
dbg!(self.shadow_map.is_some());
self.layouts.global.bind( self.layouts.global.bind(
&self.device, &self.device,
global_model, global_model,

View File

@ -5,8 +5,8 @@ use super::{
instances::Instances, instances::Instances,
model::{DynamicModel, Model, SubModel}, model::{DynamicModel, Model, SubModel},
pipelines::{ pipelines::{
clouds, figure, fluid, particle, postprocess, skybox, sprite, terrain, ui, ColLights, clouds, figure, fluid, lod_terrain, particle, postprocess, skybox, sprite, terrain, ui,
GlobalsBindGroup, Light, Shadow, ColLights, GlobalsBindGroup, Light, Shadow,
}, },
}, },
Renderer, Renderer,
@ -144,6 +144,13 @@ impl<'a> FirstPassDrawer<'a> {
self.render_pass.draw(0..model.len() as u32, 0..1); self.render_pass.draw(0..model.len() as u32, 0..1);
} }
pub fn draw_lod_terrain<'b: 'a>(&mut self, model: &'b Model<lod_terrain::Vertex>) {
self.render_pass
.set_pipeline(&self.renderer.lod_terrain_pipeline.pipeline);
self.render_pass.set_vertex_buffer(0, model.buf().slice(..));
self.render_pass.draw(0..model.len() as u32, 0..1);
}
pub fn draw_figure<'b: 'a>( pub fn draw_figure<'b: 'a>(
&mut self, &mut self,
model: SubModel<'b, terrain::Vertex>, model: SubModel<'b, terrain::Vertex>,

View File

@ -1,7 +1,7 @@
use crate::{ use crate::{
render::{ render::{
pipelines::lod_terrain::{LodData, Vertex}, pipelines::lod_terrain::{LodData, Vertex},
GlobalModel, LodTerrainVertex, Mesh, Model, Quad, Renderer, FirstPassDrawer, GlobalModel, LodTerrainVertex, Mesh, Model, Quad, Renderer,
}, },
settings::Settings, settings::Settings,
}; };
@ -59,10 +59,9 @@ impl Lod {
} }
} }
pub fn render(&self, renderer: &mut Renderer, global: &GlobalModel) { pub fn render<'a>(&'a self, drawer: &mut FirstPassDrawer<'a>) {
if let Some((_, model)) = self.model.as_ref() { if let Some((_, model)) = self.model.as_ref() {
//renderer.render_lod_terrain(&model, global, &self.locals, drawer.draw_lod_terrain(&model);
// &self.data);
} }
} }
} }

View File

@ -1030,8 +1030,9 @@ impl Scene {
global, global,
lod, lod,
camera_data, camera_data,
); );*/
self.lod.render(renderer, global);*/
self.lod.render(drawer);
// Render the skybox. // Render the skybox.
drawer.draw_skybox(&self.skybox.model); drawer.draw_skybox(&self.skybox.model);