address/remove TODOs, fix comment typos, enable wgpu/trace feature by default (So no recompile is needed to collect an API trace)

This commit is contained in:
Imbris 2021-05-12 23:59:51 -04:00 committed by Avi Weinstock
parent 8a5a59bcb7
commit aa47b960b1
27 changed files with 60 additions and 89 deletions

7
Cargo.lock generated
View File

@ -184,6 +184,9 @@ name = "arrayvec"
version = "0.5.2" version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b" checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b"
dependencies = [
"serde",
]
[[package]] [[package]]
name = "as-slice" name = "as-slice"
@ -6651,6 +6654,7 @@ dependencies = [
"naga", "naga",
"parking_lot 0.11.1", "parking_lot 0.11.1",
"raw-window-handle", "raw-window-handle",
"serde",
"smallvec", "smallvec",
"wasm-bindgen", "wasm-bindgen",
"wasm-bindgen-futures", "wasm-bindgen-futures",
@ -6684,6 +6688,8 @@ dependencies = [
"parking_lot 0.11.1", "parking_lot 0.11.1",
"profiling", "profiling",
"raw-window-handle", "raw-window-handle",
"ron",
"serde",
"smallvec", "smallvec",
"thiserror", "thiserror",
"wgpu-types", "wgpu-types",
@ -6705,6 +6711,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aa248d90c8e6832269b8955bf800e8241f942c25e18a235b7752226804d21556" checksum = "aa248d90c8e6832269b8955bf800e8241f942c25e18a235b7752226804d21556"
dependencies = [ dependencies = [
"bitflags", "bitflags",
"serde",
] ]
[[package]] [[package]]

View File

@ -27,6 +27,7 @@ void main() {
float(gl_VertexIndex % 2) * 4.0 - 1.0 float(gl_VertexIndex % 2) * 4.0 - 1.0
); );
// Flip y and transform into 0.0 to 1.0 range
uv = (v_pos * vec2(1.0, -1.0) + 1.0) * 0.5; uv = (v_pos * vec2(1.0, -1.0) + 1.0) * 0.5;
gl_Position = vec4(v_pos, 0.0, 1.0); gl_Position = vec4(v_pos, 0.0, 1.0);

View File

@ -24,7 +24,7 @@ layout(std140, set = 0, binding = 0) uniform u_globals {
// 1 - ThirdPerson // 1 - ThirdPerson
uint cam_mode; uint cam_mode;
float sprite_render_distance; float sprite_render_distance;
float gloabls_dummy; // Fix alignment. float globals_dummy; // Fix alignment.
}; };
// Specifies the pattern used in the player dithering // Specifies the pattern used in the player dithering

View File

@ -45,7 +45,7 @@ i18n = {package = "veloren-i18n", path = "i18n"}
# Graphics # Graphics
winit = {version = "0.24.0", features = ["serde"]} winit = {version = "0.24.0", features = ["serde"]}
wgpu = "0.8.1" wgpu = { version = "0.8.1", features = ["trace"] }
wgpu-profiler = { git = "https://github.com/Imberflur/wgpu-profiler", tag = "wgpu-0.8" } wgpu-profiler = { git = "https://github.com/Imberflur/wgpu-profiler", tag = "wgpu-0.8" }
bytemuck = { version="1.4", features=["derive"] } bytemuck = { version="1.4", features=["derive"] }
shaderc = "0.6.2" shaderc = "0.6.2"

View File

@ -2194,7 +2194,7 @@ impl Hud {
let gpu_timings = global_state.window.renderer().timings(); let gpu_timings = global_state.window.renderer().timings();
if !gpu_timings.is_empty() { if !gpu_timings.is_empty() {
let num_timings = gpu_timings.len(); let num_timings = gpu_timings.len();
// Make sure we have enoung ids // Make sure we have enough ids
if self.ids.gpu_timings.len() < num_timings { if self.ids.gpu_timings.len() < num_timings {
self.ids self.ids
.gpu_timings .gpu_timings

View File

@ -11,7 +11,6 @@ pub enum RenderError {
} }
use std::fmt; use std::fmt;
// TODO: just impl and use Display?
impl fmt::Debug for RenderError { impl fmt::Debug for RenderError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self { match self {

View File

@ -9,7 +9,7 @@ pub struct Instances<T: Copy + Pod> {
impl<T: Copy + Pod> Instances<T> { impl<T: Copy + Pod> Instances<T> {
pub fn new(device: &wgpu::Device, len: usize) -> Self { pub fn new(device: &wgpu::Device, len: usize) -> Self {
Self { Self {
// TODO: examine if we have Intances that are not updated (e.g. sprites) and if there // TODO: examine if we have Instances that are not updated (e.g. sprites) and if there
// would be any gains from separating those out // would be any gains from separating those out
buf: DynamicBuffer::new(device, len, wgpu::BufferUsage::VERTEX), buf: DynamicBuffer::new(device, len, wgpu::BufferUsage::VERTEX),
} }

View File

@ -33,9 +33,8 @@ pub use self::{
shadow::{Locals as ShadowLocals, PointLightMatrix}, shadow::{Locals as ShadowLocals, PointLightMatrix},
skybox::{create_mesh as create_skybox_mesh, Vertex as SkyboxVertex}, skybox::{create_mesh as create_skybox_mesh, Vertex as SkyboxVertex},
sprite::{ sprite::{
create_verts_buffer as create_sprite_verts_buffer, Instance as SpriteInstance, Instance as SpriteInstance, SpriteGlobalsBindGroup, SpriteVerts,
SpriteGlobalsBindGroup, Vertex as SpriteVertex, Vertex as SpriteVertex, VERT_PAGE_SIZE as SPRITE_VERT_PAGE_SIZE,
VERT_PAGE_SIZE as SPRITE_VERT_PAGE_SIZE,
}, },
terrain::{Locals as TerrainLocals, TerrainLayout, Vertex as TerrainVertex}, terrain::{Locals as TerrainLocals, TerrainLayout, Vertex as TerrainVertex},
ui::{ ui::{

View File

@ -158,7 +158,6 @@ impl CloudsPipeline {
let samples = match aa_mode { let samples = match aa_mode {
AaMode::None | AaMode::Fxaa => 1, AaMode::None | AaMode::Fxaa => 1,
// TODO: Ensure sampling in the shader is exactly between the 4 texels
AaMode::MsaaX4 => 4, AaMode::MsaaX4 => 4,
AaMode::MsaaX8 => 8, AaMode::MsaaX8 => 8,
AaMode::MsaaX16 => 16, AaMode::MsaaX16 => 16,

View File

@ -71,7 +71,6 @@ impl DebugPipeline {
let samples = match aa_mode { let samples = match aa_mode {
AaMode::None | AaMode::Fxaa => 1, AaMode::None | AaMode::Fxaa => 1,
// TODO: Ensure sampling in the shader is exactly between the 4 texels
AaMode::MsaaX4 => 4, AaMode::MsaaX4 => 4,
AaMode::MsaaX8 => 8, AaMode::MsaaX8 => 8,
AaMode::MsaaX16 => 16, AaMode::MsaaX16 => 16,

View File

@ -192,7 +192,6 @@ impl FigurePipeline {
let samples = match aa_mode { let samples = match aa_mode {
AaMode::None | AaMode::Fxaa => 1, AaMode::None | AaMode::Fxaa => 1,
// TODO: Ensure sampling in the shader is exactly between the 4 texels
AaMode::MsaaX4 => 4, AaMode::MsaaX4 => 4,
AaMode::MsaaX8 => 8, AaMode::MsaaX8 => 8,
AaMode::MsaaX16 => 16, AaMode::MsaaX16 => 16,

View File

@ -74,7 +74,6 @@ impl FluidPipeline {
let samples = match aa_mode { let samples = match aa_mode {
AaMode::None | AaMode::Fxaa => 1, AaMode::None | AaMode::Fxaa => 1,
// TODO: Ensure sampling in the shader is exactly between the 4 texels
AaMode::MsaaX4 => 4, AaMode::MsaaX4 => 4,
AaMode::MsaaX8 => 8, AaMode::MsaaX8 => 8,
AaMode::MsaaX16 => 16, AaMode::MsaaX16 => 16,

View File

@ -163,7 +163,6 @@ impl LodTerrainPipeline {
let samples = match aa_mode { let samples = match aa_mode {
AaMode::None | AaMode::Fxaa => 1, AaMode::None | AaMode::Fxaa => 1,
// TODO: Ensure sampling in the shader is exactly between the 4 texels
AaMode::MsaaX4 => 4, AaMode::MsaaX4 => 4,
AaMode::MsaaX8 => 8, AaMode::MsaaX8 => 8,
AaMode::MsaaX16 => 16, AaMode::MsaaX16 => 16,

View File

@ -191,7 +191,6 @@ impl ParticlePipeline {
let samples = match aa_mode { let samples = match aa_mode {
AaMode::None | AaMode::Fxaa => 1, AaMode::None | AaMode::Fxaa => 1,
// TODO: Ensure sampling in the shader is exactly between the 4 texels
AaMode::MsaaX4 => 4, AaMode::MsaaX4 => 4,
AaMode::MsaaX8 => 8, AaMode::MsaaX8 => 8,
AaMode::MsaaX16 => 16, AaMode::MsaaX16 => 16,

View File

@ -147,7 +147,6 @@ impl ShadowFigurePipeline {
let samples = match aa_mode { let samples = match aa_mode {
AaMode::None | AaMode::Fxaa => 1, AaMode::None | AaMode::Fxaa => 1,
// TODO: Ensure sampling in the shader is exactly between the 4 texels
AaMode::MsaaX4 => 4, AaMode::MsaaX4 => 4,
AaMode::MsaaX8 => 8, AaMode::MsaaX8 => 8,
AaMode::MsaaX16 => 16, AaMode::MsaaX16 => 16,
@ -221,7 +220,6 @@ impl ShadowPipeline {
let samples = match aa_mode { let samples = match aa_mode {
AaMode::None | AaMode::Fxaa => 1, AaMode::None | AaMode::Fxaa => 1,
// TODO: Ensure sampling in the shader is exactly between the 4 texels
AaMode::MsaaX4 => 4, AaMode::MsaaX4 => 4,
AaMode::MsaaX8 => 8, AaMode::MsaaX8 => 8,
AaMode::MsaaX16 => 16, AaMode::MsaaX16 => 16,
@ -297,7 +295,6 @@ impl PointShadowPipeline {
let samples = match aa_mode { let samples = match aa_mode {
AaMode::None | AaMode::Fxaa => 1, AaMode::None | AaMode::Fxaa => 1,
// TODO: Ensure sampling in the shader is exactly between the 4 texels
AaMode::MsaaX4 => 4, AaMode::MsaaX4 => 4,
AaMode::MsaaX8 => 8, AaMode::MsaaX8 => 8,
AaMode::MsaaX16 => 16, AaMode::MsaaX16 => 16,

View File

@ -50,7 +50,6 @@ impl SkyboxPipeline {
let samples = match aa_mode { let samples = match aa_mode {
AaMode::None | AaMode::Fxaa => 1, AaMode::None | AaMode::Fxaa => 1,
// TODO: Ensure sampling in the shader is exactly between the 4 texels
AaMode::MsaaX4 => 4, AaMode::MsaaX4 => 4,
AaMode::MsaaX8 => 8, AaMode::MsaaX8 => 8,
AaMode::MsaaX16 => 16, AaMode::MsaaX16 => 16,
@ -111,12 +110,11 @@ impl SkyboxPipeline {
} }
} }
// TODO: generate mesh in vertex shader #[rustfmt::skip]
pub fn create_mesh() -> Mesh<Vertex> { pub fn create_mesh() -> Mesh<Vertex> {
let mut mesh = Mesh::new(); let mut mesh = Mesh::new();
// -x // -x
#[rustfmt::skip]
mesh.push_quad(Quad::new( mesh.push_quad(Quad::new(
Vertex { pos: [-1.0, -1.0, -1.0] }, Vertex { pos: [-1.0, -1.0, -1.0] },
Vertex { pos: [-1.0, 1.0, -1.0] }, Vertex { pos: [-1.0, 1.0, -1.0] },
@ -124,7 +122,6 @@ pub fn create_mesh() -> Mesh<Vertex> {
Vertex { pos: [-1.0, -1.0, 1.0] }, Vertex { pos: [-1.0, -1.0, 1.0] },
)); ));
// +x // +x
#[rustfmt::skip]
mesh.push_quad(Quad::new( mesh.push_quad(Quad::new(
Vertex { pos: [ 1.0, -1.0, 1.0] }, Vertex { pos: [ 1.0, -1.0, 1.0] },
Vertex { pos: [ 1.0, 1.0, 1.0] }, Vertex { pos: [ 1.0, 1.0, 1.0] },
@ -132,7 +129,6 @@ pub fn create_mesh() -> Mesh<Vertex> {
Vertex { pos: [ 1.0, -1.0, -1.0] }, Vertex { pos: [ 1.0, -1.0, -1.0] },
)); ));
// -y // -y
#[rustfmt::skip]
mesh.push_quad(Quad::new( mesh.push_quad(Quad::new(
Vertex { pos: [ 1.0, -1.0, -1.0] }, Vertex { pos: [ 1.0, -1.0, -1.0] },
Vertex { pos: [-1.0, -1.0, -1.0] }, Vertex { pos: [-1.0, -1.0, -1.0] },
@ -140,7 +136,6 @@ pub fn create_mesh() -> Mesh<Vertex> {
Vertex { pos: [ 1.0, -1.0, 1.0] }, Vertex { pos: [ 1.0, -1.0, 1.0] },
)); ));
// +y // +y
#[rustfmt::skip]
mesh.push_quad(Quad::new( mesh.push_quad(Quad::new(
Vertex { pos: [ 1.0, 1.0, 1.0] }, Vertex { pos: [ 1.0, 1.0, 1.0] },
Vertex { pos: [-1.0, 1.0, 1.0] }, Vertex { pos: [-1.0, 1.0, 1.0] },
@ -148,7 +143,6 @@ pub fn create_mesh() -> Mesh<Vertex> {
Vertex { pos: [ 1.0, 1.0, -1.0] }, Vertex { pos: [ 1.0, 1.0, -1.0] },
)); ));
// -z // -z
#[rustfmt::skip]
mesh.push_quad(Quad::new( mesh.push_quad(Quad::new(
Vertex { pos: [-1.0, -1.0, -1.0] }, Vertex { pos: [-1.0, -1.0, -1.0] },
Vertex { pos: [ 1.0, -1.0, -1.0] }, Vertex { pos: [ 1.0, -1.0, -1.0] },
@ -156,7 +150,6 @@ pub fn create_mesh() -> Mesh<Vertex> {
Vertex { pos: [-1.0, 1.0, -1.0] }, Vertex { pos: [-1.0, 1.0, -1.0] },
)); ));
// +z // +z
#[rustfmt::skip]
mesh.push_quad(Quad::new( mesh.push_quad(Quad::new(
Vertex { pos: [-1.0, 1.0, 1.0] }, Vertex { pos: [-1.0, 1.0, 1.0] },
Vertex { pos: [ 1.0, 1.0, 1.0] }, Vertex { pos: [ 1.0, 1.0, 1.0] },

View File

@ -1,7 +1,6 @@
use super::{ use super::{
super::{ super::{
buffer::Buffer, AaMode, GlobalsLayouts, Mesh, Renderer, TerrainLayout, Texture, buffer::Buffer, AaMode, GlobalsLayouts, Mesh, TerrainLayout, Texture, Vertex as VertexTrait,
Vertex as VertexTrait,
}, },
lod_terrain, GlobalModel, lod_terrain, GlobalModel,
}; };
@ -77,14 +76,19 @@ impl VertexTrait for Vertex {
const STRIDE: wgpu::BufferAddress = mem::size_of::<Self>() as wgpu::BufferAddress; const STRIDE: wgpu::BufferAddress = mem::size_of::<Self>() as wgpu::BufferAddress;
} }
pub fn create_verts_buffer(renderer: &mut Renderer, mesh: Mesh<Vertex>) -> Buffer<Vertex> { pub struct SpriteVerts(Buffer<Vertex>);
renderer.ensure_sufficient_index_length::<Vertex>(VERT_PAGE_SIZE as usize); //pub struct SpriteVerts(Texture);
// TODO: type Buffer by Usage
Buffer::new( pub(in super::super) fn create_verts_buffer(
&renderer.device, device: &wgpu::Device,
mesh: Mesh<Vertex>,
) -> SpriteVerts {
// TODO: type Buffer by wgpu::BufferUsage
SpriteVerts(Buffer::new(
&device,
wgpu::BufferUsage::STORAGE, wgpu::BufferUsage::STORAGE,
mesh.vertices(), mesh.vertices(),
) ))
} }
#[repr(C)] #[repr(C)]
@ -203,8 +207,7 @@ impl SpriteLayout {
global_model: &GlobalModel, global_model: &GlobalModel,
lod_data: &lod_terrain::LodData, lod_data: &lod_terrain::LodData,
noise: &Texture, noise: &Texture,
//sprite_verts: &Texture, sprite_verts: &SpriteVerts,
sprite_verts: &Buffer<Vertex>,
) -> wgpu::BindGroup { ) -> wgpu::BindGroup {
let mut entries = GlobalsLayouts::bind_base_globals(global_model, lod_data, noise); let mut entries = GlobalsLayouts::bind_base_globals(global_model, lod_data, noise);
@ -212,7 +215,7 @@ impl SpriteLayout {
// sprite_verts // sprite_verts
wgpu::BindGroupEntry { wgpu::BindGroupEntry {
binding: 12, binding: 12,
resource: sprite_verts.buf.as_entire_binding(), resource: sprite_verts.0.buf.as_entire_binding(),
}, },
]); ]);
@ -229,7 +232,7 @@ impl SpriteLayout {
global_model: &GlobalModel, global_model: &GlobalModel,
lod_data: &lod_terrain::LodData, lod_data: &lod_terrain::LodData,
noise: &Texture, noise: &Texture,
sprite_verts: &Buffer<Vertex>, sprite_verts: &SpriteVerts,
) -> SpriteGlobalsBindGroup { ) -> SpriteGlobalsBindGroup {
let bind_group = let bind_group =
self.bind_globals_inner(device, global_model, lod_data, noise, sprite_verts); self.bind_globals_inner(device, global_model, lod_data, noise, sprite_verts);
@ -268,7 +271,6 @@ impl SpritePipeline {
let samples = match aa_mode { let samples = match aa_mode {
AaMode::None | AaMode::Fxaa => 1, AaMode::None | AaMode::Fxaa => 1,
// TODO: Ensure sampling in the shader is exactly between the 4 texels
AaMode::MsaaX4 => 4, AaMode::MsaaX4 => 4,
AaMode::MsaaX8 => 8, AaMode::MsaaX8 => 8,
AaMode::MsaaX16 => 16, AaMode::MsaaX16 => 16,

View File

@ -229,7 +229,6 @@ impl TerrainPipeline {
let samples = match aa_mode { let samples = match aa_mode {
AaMode::None | AaMode::Fxaa => 1, AaMode::None | AaMode::Fxaa => 1,
// TODO: Ensure sampling in the shader is exactly between the 4 texels
AaMode::MsaaX4 => 4, AaMode::MsaaX4 => 4,
AaMode::MsaaX8 => 8, AaMode::MsaaX8 => 8,
AaMode::MsaaX16 => 16, AaMode::MsaaX16 => 16,

View File

@ -100,8 +100,7 @@ enum State {
/// GPU, along with pipeline state objects (PSOs) needed to renderer different /// GPU, along with pipeline state objects (PSOs) needed to renderer different
/// kinds of models to the screen. /// kinds of models to the screen.
pub struct Renderer { pub struct Renderer {
// TODO: remove pub(super) device: Arc<wgpu::Device>,
pub(super) device: Arc<wgpu::Device>,
queue: wgpu::Queue, queue: wgpu::Queue,
surface: wgpu::Surface, surface: wgpu::Surface,
swap_chain: wgpu::SwapChain, swap_chain: wgpu::SwapChain,
@ -165,7 +164,7 @@ impl Renderer {
_ => None, _ => None,
}) })
.unwrap_or( .unwrap_or(
wgpu::BackendBit::PRIMARY, /* | wgpu::BackendBit::SECONDARY */ (wgpu::BackendBit::PRIMARY | wgpu::BackendBit::SECONDARY) & !wgpu::BackendBit::GL,
); );
let instance = wgpu::Instance::new(backend_bit); let instance = wgpu::Instance::new(backend_bit);
@ -198,9 +197,6 @@ impl Renderer {
features: wgpu::Features::DEPTH_CLAMPING features: wgpu::Features::DEPTH_CLAMPING
| wgpu::Features::ADDRESS_MODE_CLAMP_TO_BORDER | wgpu::Features::ADDRESS_MODE_CLAMP_TO_BORDER
| wgpu::Features::PUSH_CONSTANTS | wgpu::Features::PUSH_CONSTANTS
// TODO: make optional based on enabling profiling setting?
// woould require recreating the device/queue if this setting changes
// alternatively it could be a compile time feature toggle
| (adapter.features() & wgpu_profiler::GpuProfiler::REQUIRED_WGPU_FEATURES), | (adapter.features() & wgpu_profiler::GpuProfiler::REQUIRED_WGPU_FEATURES),
limits, limits,
}, },
@ -567,8 +563,6 @@ impl Renderer {
.into_tuple(); .into_tuple();
let (width, height, sample_count) = match mode.aa { let (width, height, sample_count) = match mode.aa {
AaMode::None | AaMode::Fxaa => (upscaled.0, upscaled.1, 1), AaMode::None | AaMode::Fxaa => (upscaled.0, upscaled.1, 1),
// TODO: Ensure sampling in the shader is exactly between the 4 texels
// TODO: Figure out how to do upscaling correctly with SSAA
AaMode::MsaaX4 => (upscaled.0, upscaled.1, 4), AaMode::MsaaX4 => (upscaled.0, upscaled.1, 4),
AaMode::MsaaX8 => (upscaled.0, upscaled.1, 8), AaMode::MsaaX8 => (upscaled.0, upscaled.1, 8),
AaMode::MsaaX16 => (upscaled.0, upscaled.1, 16), AaMode::MsaaX16 => (upscaled.0, upscaled.1, 16),
@ -982,6 +976,11 @@ impl Renderer {
} }
} }
pub fn create_sprite_verts(&mut self, mesh: Mesh<sprite::Vertex>) -> sprite::SpriteVerts {
self.ensure_sufficient_index_length::<sprite::Vertex>(sprite::VERT_PAGE_SIZE as usize);
sprite::create_verts_buffer(&self.device, mesh)
}
/// Create a new model from the provided mesh. /// Create a new model from the provided mesh.
/// If the provided mesh is empty this returns None /// If the provided mesh is empty this returns None
pub fn create_model<V: Vertex>(&mut self, mesh: &Mesh<V>) -> Option<Model<V>> { pub fn create_model<V: Vertex>(&mut self, mesh: &Mesh<V>) -> Option<Model<V>> {
@ -1125,6 +1124,8 @@ impl Renderer {
} }
} }
// Consider reenabling at some time
//
// /// Queue the rendering of the player silhouette in the upcoming frame. // /// Queue the rendering of the player silhouette in the upcoming frame.
// pub fn render_player_shadow( // pub fn render_player_shadow(
// &mut self, // &mut self,

View File

@ -1,6 +1,5 @@
use super::{ use super::{
super::{ super::{
buffer::Buffer,
pipelines::{ pipelines::{
debug, figure, lod_terrain, shadow, sprite, terrain, ui, ColLights, GlobalModel, debug, figure, lod_terrain, shadow, sprite, terrain, ui, ColLights, GlobalModel,
GlobalsBindGroup, GlobalsBindGroup,
@ -25,7 +24,7 @@ impl Renderer {
&self, &self,
global_model: &GlobalModel, global_model: &GlobalModel,
lod_data: &lod_terrain::LodData, lod_data: &lod_terrain::LodData,
sprite_verts: &Buffer<sprite::Vertex>, sprite_verts: &sprite::SpriteVerts,
) -> sprite::SpriteGlobalsBindGroup { ) -> sprite::SpriteGlobalsBindGroup {
self.layouts.sprite.bind_globals( self.layouts.sprite.bind_globals(
&self.device, &self.device,

View File

@ -49,7 +49,7 @@ impl<'frame> Pipelines<'frame> {
} }
// Borrow the fields we need from the renderer so that the GpuProfiler can be // Borrow the fields we need from the renderer so that the GpuProfiler can be
// dijointly borrowed mutably // disjointly borrowed mutably
struct RendererBorrow<'frame> { struct RendererBorrow<'frame> {
queue: &'frame wgpu::Queue, queue: &'frame wgpu::Queue,
device: &'frame wgpu::Device, device: &'frame wgpu::Device,
@ -405,7 +405,7 @@ impl<'frame> Drop for Drawer<'frame> {
fn drop(&mut self) { fn drop(&mut self) {
let mut encoder = self.encoder.take().unwrap(); let mut encoder = self.encoder.take().unwrap();
// If taking a screenshota and the blit pipeline is available // If taking a screenshot and the blit pipeline is available
// NOTE: blit pipeline should always be available for now so we don't report an // NOTE: blit pipeline should always be available for now so we don't report an
// error if it isn't // error if it isn't
if let Some((screenshot, blit)) = self if let Some((screenshot, blit)) = self

View File

@ -204,7 +204,6 @@ impl ShadowMap {
usage: wgpu::TextureUsage::SAMPLED | wgpu::TextureUsage::RENDER_ATTACHMENT, usage: wgpu::TextureUsage::SAMPLED | wgpu::TextureUsage::RENDER_ATTACHMENT,
}; };
//TODO: (0, levels - 1), ?? from master
let point_shadow_view = wgpu::TextureViewDescriptor { let point_shadow_view = wgpu::TextureViewDescriptor {
label: None, label: None,
format: Some(wgpu::TextureFormat::Depth24Plus), format: Some(wgpu::TextureFormat::Depth24Plus),

View File

@ -168,20 +168,9 @@ fn handle_main_events_cleared(
if let Some(last) = states.last_mut() { if let Some(last) = states.last_mut() {
span!(guard, "Render"); span!(guard, "Render");
let renderer = global_state.window.renderer_mut(); let renderer = global_state.window.renderer_mut();
// // Clear the shadow maps.
// renderer.clear_shadows();
// // Clear the screen
// renderer.clear();
// Render the screen using the global renderer // Render the screen using the global renderer
last.render(renderer, &global_state.settings); last.render(renderer, &global_state.settings);
// Finish the frame.
// TODO: do this as part of dropping rendering thing
//global_state.window.renderer_mut().flush().unwrap();
// // Display the frame on the window.
// global_state
// .window
// .swap_buffers()
// .expect("Failed to swap window buffers!");
drop(guard); drop(guard);
} }

View File

@ -77,7 +77,7 @@ fn clamp_and_modulate(ori: Vec3<f32>) -> Vec3<f32> {
/// The only requirements on n and f are: 1/n ≠ 1/f, and 0 ≤ 1/n * 1/f. /// The only requirements on n and f are: 1/n ≠ 1/f, and 0 ≤ 1/n * 1/f.
/// ///
/// This ensures that the near and far plane are not identical (or else your /// This ensures that the near and far plane are not identical (or else your
/// projection would not covver any distance), and that they have the same sign /// projection would not cover any distance), and that they have the same sign
/// (or else we cannot rely on clipping to properly fix your scene). This also /// (or else we cannot rely on clipping to properly fix your scene). This also
/// ensures that at least one of 1/n and 1/f is not 0, and by construction it /// ensures that at least one of 1/n and 1/f is not 0, and by construction it
/// guarantees that neither n nor f are 0; these are required in order to make /// guarantees that neither n nor f are 0; these are required in order to make

View File

@ -5267,7 +5267,7 @@ impl FigureColLights {
(0, 0), (0, 0),
gfx::format::Swizzle::new(), gfx::format::Swizzle::new(),
gfx::texture::SamplerInfo::new( gfx::texture::SamplerInfo::new(
gfx::texture::FilterMetho>:Bilinear, gfx::texture::FilterMethod::Bilinear,
gfx::texture::WrapMode::Clamp, gfx::texture::WrapMode::Clamp,
), ),
)?; )?;

View File

@ -31,7 +31,8 @@ impl Lod {
client.world_data().lod_alt.raw(), client.world_data().lod_alt.raw(),
client.world_data().lod_horizon.raw(), client.world_data().lod_horizon.raw(),
settings.graphics.lod_detail.max(100).min(2500), settings.graphics.lod_detail.max(100).min(2500),
// water_color().into_array().into(), /* TODO: figure out how we want to do this without color borders?
* water_color().into_array().into(), */
), ),
} }
} }

View File

@ -9,10 +9,9 @@ use crate::{
terrain::{generate_mesh, SUNLIGHT}, terrain::{generate_mesh, SUNLIGHT},
}, },
render::{ render::{
create_sprite_verts_buffer,
pipelines::{self, ColLights}, pipelines::{self, ColLights},
Buffer, ColLightInfo, FirstPassDrawer, FluidVertex, GlobalModel, Instances, LodData, Mesh, ColLightInfo, FirstPassDrawer, FluidVertex, GlobalModel, Instances, LodData, Mesh, Model,
Model, RenderError, Renderer, SpriteGlobalsBindGroup, SpriteInstance, SpriteVertex, RenderError, Renderer, SpriteGlobalsBindGroup, SpriteInstance, SpriteVertex, SpriteVerts,
TerrainLocals, TerrainShadowDrawer, TerrainVertex, SPRITE_VERT_PAGE_SIZE, TerrainLocals, TerrainShadowDrawer, TerrainVertex, SPRITE_VERT_PAGE_SIZE,
}, },
}; };
@ -372,7 +371,7 @@ pub struct SpriteRenderContext {
// Maps sprite kind + variant to data detailing how to render it // Maps sprite kind + variant to data detailing how to render it
sprite_data: Arc<HashMap<(SpriteKind, usize), [SpriteData; SPRITE_LOD_LEVELS]>>, sprite_data: Arc<HashMap<(SpriteKind, usize), [SpriteData; SPRITE_LOD_LEVELS]>>,
sprite_col_lights: Arc<ColLights<pipelines::sprite::Locals>>, sprite_col_lights: Arc<ColLights<pipelines::sprite::Locals>>,
sprite_verts_buffer: Arc<Buffer<SpriteVertex>>, sprite_verts_buffer: Arc<SpriteVerts>,
} }
pub type SpriteRenderContextLazy = Box<dyn FnMut(&mut Renderer) -> SpriteRenderContext>; pub type SpriteRenderContextLazy = Box<dyn FnMut(&mut Renderer) -> SpriteRenderContext>;
@ -521,7 +520,7 @@ impl SpriteRenderContext {
let sprite_col_lights = renderer.sprite_bind_col_light(sprite_col_lights); let sprite_col_lights = renderer.sprite_bind_col_light(sprite_col_lights);
// Write sprite model to a 1D texture // Write sprite model to a 1D texture
let sprite_verts_buffer = create_sprite_verts_buffer(renderer, sprite_mesh); let sprite_verts_buffer = renderer.create_sprite_verts(sprite_mesh);
Self { Self {
// TODO: these are all Arcs, would it makes sense to factor out the Arc? // TODO: these are all Arcs, would it makes sense to factor out the Arc?
@ -1069,20 +1068,12 @@ impl<V: RectRasterableVol> Terrain<V> {
// data structure (convert the mesh to a model first of course). // data structure (convert the mesh to a model first of course).
Some(todo) if response.started_tick <= todo.started_tick => { Some(todo) if response.started_tick <= todo.started_tick => {
let started_tick = todo.started_tick; let started_tick = todo.started_tick;
let sprite_instances = {
let mut iter = response.sprite_instances.iter().map(|instances| { let sprite_instances = response.sprite_instances.map(|instances| {
renderer renderer
.create_instances(instances) .create_instances(&instances)
.expect("Failed to upload chunk sprite instances to the GPU!") .expect("Failed to upload chunk sprite instances to the GPU!")
}); });
[
iter.next().unwrap(),
iter.next().unwrap(),
iter.next().unwrap(),
iter.next().unwrap(),
iter.next().unwrap(),
]
};
if let Some(mesh) = response.mesh { if let Some(mesh) = response.mesh {
// Full update, insert the whole chunk. // Full update, insert the whole chunk.