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);
// SamplerInfo {
// border: border_color,
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);
// SamplerInfo {
// border: [1.0, 0.0, 1.0, 0.0].into(),
Self {
map,
@ -118,43 +124,6 @@ impl LodData {
horizon,
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,
shadow_map: Option<ShadowMapRenderer>,
//dummy_shadow_tex: wgpu::TextureView,
layouts: Layouts,
figure_pipeline: figure::FigurePipeline,
@ -2305,9 +2305,9 @@ fn create_shader_module(
.compile_into_spirv(source, kind, file_name, "main", Some(options))
.map_err(|e| (file_name, e))?;
Ok(
device.create_shader_module(wgpu::ShaderModuleSource::SpirV(Cow::Borrowed(
spv.as_binary(),
))),
)
Ok(device.create_shader_module(&wgpu::ShaderModuleDescriptor {
label: Some(source),
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),
None => (&self.noise_tex, &self.noise_tex),
};
dbg!(self.shadow_map.is_some());
self.layouts.global.bind(
&self.device,
global_model,

View File

@ -5,8 +5,8 @@ use super::{
instances::Instances,
model::{DynamicModel, Model, SubModel},
pipelines::{
clouds, figure, fluid, particle, postprocess, skybox, sprite, terrain, ui, ColLights,
GlobalsBindGroup, Light, Shadow,
clouds, figure, fluid, lod_terrain, particle, postprocess, skybox, sprite, terrain, ui,
ColLights, GlobalsBindGroup, Light, Shadow,
},
},
Renderer,
@ -144,6 +144,13 @@ impl<'a> FirstPassDrawer<'a> {
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>(
&mut self,
model: SubModel<'b, terrain::Vertex>,

View File

@ -1,7 +1,7 @@
use crate::{
render::{
pipelines::lod_terrain::{LodData, Vertex},
GlobalModel, LodTerrainVertex, Mesh, Model, Quad, Renderer,
FirstPassDrawer, GlobalModel, LodTerrainVertex, Mesh, Model, Quad, Renderer,
},
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() {
//renderer.render_lod_terrain(&model, global, &self.locals,
// &self.data);
drawer.draw_lod_terrain(&model);
}
}
}

View File

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