mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Fix most of the cargo check warnings
This commit is contained in:
parent
972a6f3605
commit
93ad05d237
@ -55,7 +55,7 @@ use crate::{
|
|||||||
ecs::{comp as vcomp, comp::HpFloaterList},
|
ecs::{comp as vcomp, comp::HpFloaterList},
|
||||||
hud::{img_ids::ImgsRot, prompt_dialog::DialogOutcomeEvent},
|
hud::{img_ids::ImgsRot, prompt_dialog::DialogOutcomeEvent},
|
||||||
i18n::Localization,
|
i18n::Localization,
|
||||||
render::{Consts, Globals, UiDrawer},
|
render::UiDrawer,
|
||||||
scene::camera::{self, Camera},
|
scene::camera::{self, Camera},
|
||||||
session::{
|
session::{
|
||||||
settings_change::{Chat as ChatChange, Interface as InterfaceChange, SettingsChange},
|
settings_change::{Chat as ChatChange, Interface as InterfaceChange, SettingsChange},
|
||||||
|
@ -44,7 +44,7 @@ impl<T: Copy + Pod> DynamicBuffer<T> {
|
|||||||
Self(buffer)
|
Self(buffer)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn update(&self, device: &wgpu::Device, queue: &wgpu::Queue, vals: &[T], offset: usize) {
|
pub fn update(&self, queue: &wgpu::Queue, vals: &[T], offset: usize) {
|
||||||
if !vals.is_empty() {
|
if !vals.is_empty() {
|
||||||
queue.write_buffer(
|
queue.write_buffer(
|
||||||
&self.buf,
|
&self.buf,
|
||||||
|
@ -18,14 +18,8 @@ impl<T: Copy + Pod> Consts<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Update the GPU-side value represented by this constant handle.
|
/// Update the GPU-side value represented by this constant handle.
|
||||||
pub fn update(
|
pub fn update(&mut self, queue: &wgpu::Queue, vals: &[T], offset: usize) {
|
||||||
&mut self,
|
self.buf.update(queue, vals, offset)
|
||||||
device: &wgpu::Device,
|
|
||||||
queue: &wgpu::Queue,
|
|
||||||
vals: &[T],
|
|
||||||
offset: usize,
|
|
||||||
) {
|
|
||||||
self.buf.update(device, queue, vals, offset)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn buf(&self) -> &wgpu::Buffer { &self.buf.buf }
|
pub fn buf(&self) -> &wgpu::Buffer { &self.buf.buf }
|
||||||
|
@ -18,14 +18,8 @@ impl<T: Copy + Pod> Instances<T> {
|
|||||||
// TODO: count vs len naming scheme??
|
// TODO: count vs len naming scheme??
|
||||||
pub fn count(&self) -> usize { self.buf.len() }
|
pub fn count(&self) -> usize { self.buf.len() }
|
||||||
|
|
||||||
pub fn update(
|
pub fn update(&mut self, queue: &wgpu::Queue, vals: &[T], offset: usize) {
|
||||||
&mut self,
|
self.buf.update(queue, vals, offset)
|
||||||
device: &wgpu::Device,
|
|
||||||
queue: &wgpu::Queue,
|
|
||||||
vals: &[T],
|
|
||||||
offset: usize,
|
|
||||||
) {
|
|
||||||
self.buf.update(device, queue, vals, offset)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn buf(&self) -> &wgpu::Buffer { &self.buf.buf }
|
pub fn buf(&self) -> &wgpu::Buffer { &self.buf.buf }
|
||||||
|
@ -61,14 +61,8 @@ impl<V: Vertex> DynamicModel<V> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn update(
|
pub fn update(&self, queue: &wgpu::Queue, mesh: &Mesh<V>, offset: usize) {
|
||||||
&self,
|
self.vbuf.update(queue, mesh.vertices(), offset)
|
||||||
device: &wgpu::Device,
|
|
||||||
queue: &wgpu::Queue,
|
|
||||||
mesh: &Mesh<V>,
|
|
||||||
offset: usize,
|
|
||||||
) {
|
|
||||||
self.vbuf.update(device, queue, mesh.vertices(), offset)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Create a model with a slice of a portion of this model to send to the
|
/// Create a model with a slice of a portion of this model to send to the
|
||||||
|
@ -1,10 +1,3 @@
|
|||||||
use super::{
|
|
||||||
super::{AaMode, Consts},
|
|
||||||
GlobalsLayouts,
|
|
||||||
};
|
|
||||||
use bytemuck::{Pod, Zeroable};
|
|
||||||
use vek::*;
|
|
||||||
|
|
||||||
pub struct BindGroup {
|
pub struct BindGroup {
|
||||||
pub(in super::super) bind_group: wgpu::BindGroup,
|
pub(in super::super) bind_group: wgpu::BindGroup,
|
||||||
}
|
}
|
||||||
|
@ -41,11 +41,10 @@ pub struct LodData {
|
|||||||
impl LodData {
|
impl LodData {
|
||||||
pub fn dummy(renderer: &mut Renderer) -> Self {
|
pub fn dummy(renderer: &mut Renderer) -> Self {
|
||||||
let map_size = Vec2::new(1, 1);
|
let map_size = Vec2::new(1, 1);
|
||||||
let map_border = [0.0, 0.0, 0.0, 0.0];
|
//let map_border = [0.0, 0.0, 0.0, 0.0];
|
||||||
let map_image = [0];
|
let map_image = [0];
|
||||||
let alt_image = [0];
|
let alt_image = [0];
|
||||||
let horizon_image = [0x_00_01_00_01];
|
let horizon_image = [0x_00_01_00_01];
|
||||||
//let map_border = [0.0, 0.0, 0.0, 0.0];
|
|
||||||
|
|
||||||
Self::new(
|
Self::new(
|
||||||
renderer,
|
renderer,
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use super::super::{AaMode, Consts, GlobalsLayouts};
|
use super::super::{Consts, GlobalsLayouts};
|
||||||
use bytemuck::{Pod, Zeroable};
|
use bytemuck::{Pod, Zeroable};
|
||||||
use vek::*;
|
use vek::*;
|
||||||
|
|
||||||
|
@ -79,7 +79,7 @@ pub fn create_col_lights(
|
|||||||
renderer: &mut Renderer,
|
renderer: &mut Renderer,
|
||||||
(col_lights, col_lights_size): &ColLightInfo,
|
(col_lights, col_lights_size): &ColLightInfo,
|
||||||
) -> Texture {
|
) -> Texture {
|
||||||
let mut texture_info = wgpu::TextureDescriptor {
|
let texture_info = wgpu::TextureDescriptor {
|
||||||
label: None,
|
label: None,
|
||||||
size: wgpu::Extent3d {
|
size: wgpu::Extent3d {
|
||||||
width: col_lights_size.x,
|
width: col_lights_size.x,
|
||||||
|
@ -1,12 +1,11 @@
|
|||||||
use super::{
|
use super::{
|
||||||
super::{
|
super::{
|
||||||
buffer::Buffer, AaMode, Bound, Consts, GlobalsLayouts, Mesh, Renderer, TerrainLayout,
|
buffer::Buffer, AaMode, GlobalsLayouts, Mesh, Renderer, TerrainLayout, Texture,
|
||||||
Texture, Vertex as VertexTrait,
|
Vertex as VertexTrait,
|
||||||
},
|
},
|
||||||
lod_terrain, GlobalModel,
|
lod_terrain, GlobalModel,
|
||||||
};
|
};
|
||||||
use bytemuck::{Pod, Zeroable};
|
use bytemuck::{Pod, Zeroable};
|
||||||
use core::fmt;
|
|
||||||
use std::mem;
|
use std::mem;
|
||||||
use vek::*;
|
use vek::*;
|
||||||
|
|
||||||
@ -88,9 +87,9 @@ 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, mut mesh: Mesh<Vertex>) -> Buffer<Vertex> {
|
pub fn create_verts_buffer(renderer: &mut Renderer, mesh: Mesh<Vertex>) -> Buffer<Vertex> {
|
||||||
renderer.ensure_sufficient_index_length::<Vertex>(VERT_PAGE_SIZE as usize);
|
renderer.ensure_sufficient_index_length::<Vertex>(VERT_PAGE_SIZE as usize);
|
||||||
// TODO: type buffer by Usage
|
// TODO: type Buffer by Usage
|
||||||
Buffer::new(
|
Buffer::new(
|
||||||
&renderer.device,
|
&renderer.device,
|
||||||
wgpu::BufferUsage::STORAGE,
|
wgpu::BufferUsage::STORAGE,
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
use super::super::{
|
use super::super::{Bound, Consts, GlobalsLayouts, Quad, Texture, Tri, Vertex as VertexTrait};
|
||||||
AaMode, Bound, Consts, GlobalsLayouts, Quad, Texture, Tri, Vertex as VertexTrait,
|
|
||||||
};
|
|
||||||
use bytemuck::{Pod, Zeroable};
|
use bytemuck::{Pod, Zeroable};
|
||||||
use std::mem;
|
use std::mem;
|
||||||
use vek::*;
|
use vek::*;
|
||||||
|
@ -21,12 +21,11 @@ use super::{
|
|||||||
mesh::Mesh,
|
mesh::Mesh,
|
||||||
model::{DynamicModel, Model},
|
model::{DynamicModel, Model},
|
||||||
pipelines::{
|
pipelines::{
|
||||||
blit, clouds, figure, fluid, lod_terrain, particle, postprocess, shadow, skybox, sprite,
|
blit, clouds, figure, fluid, postprocess, shadow, sprite, terrain, ui, GlobalsBindGroup,
|
||||||
terrain, ui, GlobalsBindGroup, GlobalsLayouts, ShadowTexturesBindGroup,
|
GlobalsLayouts, ShadowTexturesBindGroup,
|
||||||
},
|
},
|
||||||
texture::Texture,
|
texture::Texture,
|
||||||
AaMode, AddressMode, CloudMode, FilterMode, FluidMode, LightingMode, RenderError, RenderMode,
|
AaMode, AddressMode, FilterMode, RenderError, RenderMode, ShadowMapMode, ShadowMode, Vertex,
|
||||||
ShadowMapMode, ShadowMode, Vertex,
|
|
||||||
};
|
};
|
||||||
use common::assets::{self, AssetExt, AssetHandle};
|
use common::assets::{self, AssetExt, AssetHandle};
|
||||||
use common_base::span;
|
use common_base::span;
|
||||||
@ -61,8 +60,8 @@ struct Layouts {
|
|||||||
|
|
||||||
/// Render target views
|
/// Render target views
|
||||||
struct Views {
|
struct Views {
|
||||||
// NOTE: unused for now
|
// NOTE: unused for now, maybe... we will want it for something
|
||||||
win_depth: wgpu::TextureView,
|
_win_depth: wgpu::TextureView,
|
||||||
|
|
||||||
tgt_color: wgpu::TextureView,
|
tgt_color: wgpu::TextureView,
|
||||||
tgt_depth: wgpu::TextureView,
|
tgt_depth: wgpu::TextureView,
|
||||||
@ -503,7 +502,6 @@ impl Renderer {
|
|||||||
&self.depth_sampler,
|
&self.depth_sampler,
|
||||||
);
|
);
|
||||||
|
|
||||||
let mode = &self.mode;
|
|
||||||
// Get mutable reference to shadow views out of the current state
|
// Get mutable reference to shadow views out of the current state
|
||||||
let shadow_views = match &mut self.state {
|
let shadow_views = match &mut self.state {
|
||||||
State::Interface { shadow_views, .. } => {
|
State::Interface { shadow_views, .. } => {
|
||||||
@ -644,7 +642,7 @@ impl Renderer {
|
|||||||
usage: wgpu::TextureUsage::RENDER_ATTACHMENT,
|
usage: wgpu::TextureUsage::RENDER_ATTACHMENT,
|
||||||
});
|
});
|
||||||
// TODO: Consider no depth buffer for the final draw to the window?
|
// TODO: Consider no depth buffer for the final draw to the window?
|
||||||
let win_depth_view = tgt_depth_tex.create_view(&wgpu::TextureViewDescriptor {
|
let win_depth_view = win_depth_tex.create_view(&wgpu::TextureViewDescriptor {
|
||||||
label: None,
|
label: None,
|
||||||
format: Some(wgpu::TextureFormat::Depth32Float),
|
format: Some(wgpu::TextureFormat::Depth32Float),
|
||||||
dimension: Some(wgpu::TextureViewDimension::D2),
|
dimension: Some(wgpu::TextureViewDimension::D2),
|
||||||
@ -659,7 +657,7 @@ impl Renderer {
|
|||||||
tgt_color: tgt_color_view,
|
tgt_color: tgt_color_view,
|
||||||
tgt_depth: tgt_depth_view,
|
tgt_depth: tgt_depth_view,
|
||||||
tgt_color_pp: tgt_color_pp_view,
|
tgt_color_pp: tgt_color_pp_view,
|
||||||
win_depth: win_depth_view,
|
_win_depth: win_depth_view,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -701,6 +699,7 @@ impl Renderer {
|
|||||||
// 1.0); }
|
// 1.0); }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
// TODO: @Sharp what should this look like with wgpu?
|
||||||
/// NOTE: Supported by Vulkan (by default), DirectX 10+ (it seems--it's hard
|
/// NOTE: Supported by Vulkan (by default), DirectX 10+ (it seems--it's hard
|
||||||
/// to find proof of this, but Direct3D 10 apparently does it by
|
/// to find proof of this, but Direct3D 10 apparently does it by
|
||||||
/// default, and 11 definitely does, so I assume it's natively supported
|
/// default, and 11 definitely does, so I assume it's natively supported
|
||||||
@ -708,8 +707,8 @@ impl Renderer {
|
|||||||
/// there may be some GPUs that don't quite support it correctly, the
|
/// there may be some GPUs that don't quite support it correctly, the
|
||||||
/// impact is relatively small, so there is no reason not to enable it where
|
/// impact is relatively small, so there is no reason not to enable it where
|
||||||
/// available.
|
/// available.
|
||||||
fn enable_seamless_cube_maps() {
|
//fn enable_seamless_cube_maps() {
|
||||||
todo!()
|
//todo!()
|
||||||
// unsafe {
|
// unsafe {
|
||||||
// // NOTE: Currently just fail silently rather than complain if the
|
// // NOTE: Currently just fail silently rather than complain if the
|
||||||
// computer is on // a version lower than 3.2, where
|
// computer is on // a version lower than 3.2, where
|
||||||
@ -725,7 +724,7 @@ impl Renderer {
|
|||||||
// gl.Enable(gfx_gl::TEXTURE_CUBE_MAP_SEAMLESS);
|
// gl.Enable(gfx_gl::TEXTURE_CUBE_MAP_SEAMLESS);
|
||||||
// });
|
// });
|
||||||
// }
|
// }
|
||||||
}
|
//}
|
||||||
|
|
||||||
/// Start recording the frame
|
/// Start recording the frame
|
||||||
/// When the returned `Drawer` is dropped the recorded draw calls will be
|
/// When the returned `Drawer` is dropped the recorded draw calls will be
|
||||||
@ -930,25 +929,21 @@ impl Renderer {
|
|||||||
vals: &[T],
|
vals: &[T],
|
||||||
) -> Consts<T> {
|
) -> Consts<T> {
|
||||||
let mut consts = Consts::new(device, vals.len());
|
let mut consts = Consts::new(device, vals.len());
|
||||||
consts.update(device, queue, vals, 0);
|
consts.update(queue, vals, 0);
|
||||||
consts
|
consts
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Update a set of constants with the provided values.
|
/// Update a set of constants with the provided values.
|
||||||
pub fn update_consts<T: Copy + bytemuck::Pod>(&self, consts: &mut Consts<T>, vals: &[T]) {
|
pub fn update_consts<T: Copy + bytemuck::Pod>(&self, consts: &mut Consts<T>, vals: &[T]) {
|
||||||
consts.update(&self.device, &self.queue, vals, 0)
|
consts.update(&self.queue, vals, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn update_clouds_locals(&mut self, new_val: clouds::Locals) {
|
pub fn update_clouds_locals(&mut self, new_val: clouds::Locals) {
|
||||||
self.locals
|
self.locals.clouds.update(&self.queue, &[new_val], 0)
|
||||||
.clouds
|
|
||||||
.update(&self.device, &self.queue, &[new_val], 0)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn update_postprocess_locals(&mut self, new_val: postprocess::Locals) {
|
pub fn update_postprocess_locals(&mut self, new_val: postprocess::Locals) {
|
||||||
self.locals
|
self.locals.postprocess.update(&self.queue, &[new_val], 0)
|
||||||
.postprocess
|
|
||||||
.update(&self.device, &self.queue, &[new_val], 0)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Create a new set of instances with the provided values.
|
/// Create a new set of instances with the provided values.
|
||||||
@ -957,7 +952,7 @@ impl Renderer {
|
|||||||
vals: &[T],
|
vals: &[T],
|
||||||
) -> Result<Instances<T>, RenderError> {
|
) -> Result<Instances<T>, RenderError> {
|
||||||
let mut instances = Instances::new(&self.device, vals.len());
|
let mut instances = Instances::new(&self.device, vals.len());
|
||||||
instances.update(&self.device, &self.queue, vals, 0);
|
instances.update(&self.queue, vals, 0);
|
||||||
Ok(instances)
|
Ok(instances)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1015,7 +1010,7 @@ impl Renderer {
|
|||||||
|
|
||||||
/// Update a dynamic model with a mesh and a offset.
|
/// Update a dynamic model with a mesh and a offset.
|
||||||
pub fn update_model<V: Vertex>(&self, model: &DynamicModel<V>, mesh: &Mesh<V>, offset: usize) {
|
pub fn update_model<V: Vertex>(&self, model: &DynamicModel<V>, mesh: &Mesh<V>, offset: usize) {
|
||||||
model.update(&self.device, &self.queue, mesh, offset)
|
model.update(&self.queue, mesh, offset)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return the maximum supported texture size.
|
/// Return the maximum supported texture size.
|
||||||
@ -1055,7 +1050,6 @@ impl Renderer {
|
|||||||
);
|
);
|
||||||
|
|
||||||
tex.update(
|
tex.update(
|
||||||
&self.device,
|
|
||||||
&self.queue,
|
&self.queue,
|
||||||
[0; 2],
|
[0; 2],
|
||||||
[texture_info.size.width, texture_info.size.height],
|
[texture_info.size.width, texture_info.size.height],
|
||||||
@ -1073,7 +1067,7 @@ impl Renderer {
|
|||||||
sampler_info: &wgpu::SamplerDescriptor,
|
sampler_info: &wgpu::SamplerDescriptor,
|
||||||
) -> Texture {
|
) -> Texture {
|
||||||
let texture = Texture::new_raw(&self.device, texture_info, view_info, sampler_info);
|
let texture = Texture::new_raw(&self.device, texture_info, view_info, sampler_info);
|
||||||
texture.clear(&self.device, &self.queue); // Needs to be fully initialized for partial writes to work on Dx12 AMD
|
texture.clear(&self.queue); // Needs to be fully initialized for partial writes to work on Dx12 AMD
|
||||||
texture
|
texture
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1114,13 +1108,7 @@ impl Renderer {
|
|||||||
// TODO: generic over pixel type
|
// TODO: generic over pixel type
|
||||||
data: &[[u8; 4]],
|
data: &[[u8; 4]],
|
||||||
) {
|
) {
|
||||||
texture.update(
|
texture.update(&self.queue, offset, size, bytemuck::cast_slice(data))
|
||||||
&self.device,
|
|
||||||
&self.queue,
|
|
||||||
offset,
|
|
||||||
size,
|
|
||||||
bytemuck::cast_slice(data),
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Queue to obtain a screenshot on the next frame render
|
/// Queue to obtain a screenshot on the next frame render
|
||||||
@ -1144,7 +1132,7 @@ impl Renderer {
|
|||||||
std::path::Path::new(&file_name),
|
std::path::Path::new(&file_name),
|
||||||
&self.profile_times,
|
&self.profile_times,
|
||||||
) {
|
) {
|
||||||
error!("Failed to save GPU timing snapshot");
|
error!(?err, "Failed to save GPU timing snapshot");
|
||||||
} else {
|
} else {
|
||||||
info!("Saved GPU timing snapshot as: {}", file_name);
|
info!("Saved GPU timing snapshot as: {}", file_name);
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,11 @@
|
|||||||
use super::{
|
use super::{
|
||||||
super::{
|
super::{
|
||||||
buffer::Buffer,
|
buffer::Buffer,
|
||||||
consts::Consts,
|
|
||||||
instances::Instances,
|
instances::Instances,
|
||||||
model::{DynamicModel, Model, SubModel},
|
model::{DynamicModel, Model, SubModel},
|
||||||
pipelines::{
|
pipelines::{
|
||||||
blit, clouds, figure, fluid, lod_terrain, particle, postprocess, shadow, skybox,
|
blit, clouds, figure, fluid, lod_terrain, particle, shadow, skybox, sprite, terrain,
|
||||||
sprite, terrain, ui, ColLights, GlobalsBindGroup, Light, Shadow,
|
ui, ColLights, GlobalsBindGroup,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Renderer, ShadowMap, ShadowMapRenderer,
|
Renderer, ShadowMap, ShadowMapRenderer,
|
||||||
@ -111,7 +110,7 @@ impl<'frame> Drawer<'frame> {
|
|||||||
quad_index_buffer_u32: &renderer.quad_index_buffer_u32,
|
quad_index_buffer_u32: &renderer.quad_index_buffer_u32,
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut encoder =
|
let encoder =
|
||||||
ManualOwningScope::start("frame", &mut renderer.profiler, encoder, borrow.device);
|
ManualOwningScope::start("frame", &mut renderer.profiler, encoder, borrow.device);
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
@ -632,18 +631,15 @@ impl<'pass_ref, 'pass: 'pass_ref> TerrainDrawer<'pass_ref, 'pass> {
|
|||||||
col_lights: &'data Arc<ColLights<terrain::Locals>>,
|
col_lights: &'data Arc<ColLights<terrain::Locals>>,
|
||||||
locals: &'data terrain::BoundLocals,
|
locals: &'data terrain::BoundLocals,
|
||||||
) {
|
) {
|
||||||
let col_lights = if let Some(col_lights) = self
|
if self.col_lights
|
||||||
.col_lights
|
|
||||||
// Check if we are still using the same atlas texture as the previous drawn
|
// Check if we are still using the same atlas texture as the previous drawn
|
||||||
// chunk
|
// chunk
|
||||||
.filter(|current_col_lights| Arc::ptr_eq(current_col_lights, col_lights))
|
.filter(|current_col_lights| Arc::ptr_eq(current_col_lights, col_lights))
|
||||||
|
.is_none()
|
||||||
{
|
{
|
||||||
col_lights
|
|
||||||
} else {
|
|
||||||
self.render_pass
|
self.render_pass
|
||||||
.set_bind_group(3, &col_lights.bind_group, &[]); // TODO: put this in slot 2
|
.set_bind_group(3, &col_lights.bind_group, &[]); // TODO: put this in slot 2
|
||||||
self.col_lights = Some(col_lights);
|
self.col_lights = Some(col_lights);
|
||||||
col_lights
|
|
||||||
};
|
};
|
||||||
|
|
||||||
self.render_pass.set_bind_group(2, &locals.bind_group, &[]); // TODO: put this in slot 3
|
self.render_pass.set_bind_group(2, &locals.bind_group, &[]); // TODO: put this in slot 3
|
||||||
|
@ -204,7 +204,12 @@ impl ShaderModules {
|
|||||||
"lod.glsl" => lod.0.to_owned(),
|
"lod.glsl" => lod.0.to_owned(),
|
||||||
"anti-aliasing.glsl" => anti_alias.0.to_owned(),
|
"anti-aliasing.glsl" => anti_alias.0.to_owned(),
|
||||||
"cloud.glsl" => cloud.0.to_owned(),
|
"cloud.glsl" => cloud.0.to_owned(),
|
||||||
other => return Err(format!("Include {} is not defined", other)),
|
other => {
|
||||||
|
return Err(format!(
|
||||||
|
"Include {} in {} is not defined",
|
||||||
|
other, shader_name
|
||||||
|
));
|
||||||
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
@ -787,9 +792,10 @@ struct Task<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Represents in-progress task, drop when complete
|
/// Represents in-progress task, drop when complete
|
||||||
|
// NOTE: fields are unused because they are only used for their Drop impls
|
||||||
struct StartedTask<'a> {
|
struct StartedTask<'a> {
|
||||||
_span: common_base::ProfSpan,
|
_span: common_base::ProfSpan,
|
||||||
task: Task<'a>,
|
_task: Task<'a>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
@ -817,13 +823,14 @@ impl Progress {
|
|||||||
impl<'a> Task<'a> {
|
impl<'a> Task<'a> {
|
||||||
/// Start a task.
|
/// Start a task.
|
||||||
/// The name is used for profiling.
|
/// The name is used for profiling.
|
||||||
fn start(self, name: &str) -> StartedTask<'a> {
|
fn start(self, _name: &str) -> StartedTask<'a> {
|
||||||
|
// _name only used when tracy feature is activated
|
||||||
StartedTask {
|
StartedTask {
|
||||||
_span: {
|
_span: {
|
||||||
prof_span!(guard, name);
|
prof_span!(guard, _name);
|
||||||
guard
|
guard
|
||||||
},
|
},
|
||||||
task: self,
|
_task: self,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,9 +59,6 @@ impl Texture {
|
|||||||
usage: wgpu::TextureUsage::SAMPLED | wgpu::TextureUsage::COPY_DST,
|
usage: wgpu::TextureUsage::SAMPLED | wgpu::TextureUsage::COPY_DST,
|
||||||
});
|
});
|
||||||
|
|
||||||
let command_encoder =
|
|
||||||
device.create_command_encoder(&wgpu::CommandEncoderDescriptor { label: None });
|
|
||||||
|
|
||||||
queue.write_texture(
|
queue.write_texture(
|
||||||
wgpu::ImageCopyTexture {
|
wgpu::ImageCopyTexture {
|
||||||
texture: &tex,
|
texture: &tex,
|
||||||
@ -158,7 +155,7 @@ impl Texture {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let texture = Self::new_raw(device, &tex_info, &view_info, &sampler_info);
|
let texture = Self::new_raw(device, &tex_info, &view_info, &sampler_info);
|
||||||
texture.clear(device, queue); // Needs to be fully initialized for partial writes to work on Dx12 AMD
|
texture.clear(queue); // Needs to be fully initialized for partial writes to work on Dx12 AMD
|
||||||
texture
|
texture
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -183,7 +180,7 @@ impl Texture {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Clears the texture data to 0
|
/// Clears the texture data to 0
|
||||||
pub fn clear(&self, device: &wgpu::Device, queue: &wgpu::Queue) {
|
pub fn clear(&self, queue: &wgpu::Queue) {
|
||||||
let size = self.size;
|
let size = self.size;
|
||||||
let byte_len = size.width as usize
|
let byte_len = size.width as usize
|
||||||
* size.height as usize
|
* size.height as usize
|
||||||
@ -191,19 +188,12 @@ impl Texture {
|
|||||||
* self.format.describe().block_size as usize;
|
* self.format.describe().block_size as usize;
|
||||||
let zeros = vec![0; byte_len];
|
let zeros = vec![0; byte_len];
|
||||||
|
|
||||||
self.update(device, queue, [0, 0], [size.width, size.height], &zeros);
|
self.update(queue, [0, 0], [size.width, size.height], &zeros);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Update a texture with the given data (used for updating the glyph cache
|
/// Update a texture with the given data (used for updating the glyph cache
|
||||||
/// texture).
|
/// texture).
|
||||||
pub fn update(
|
pub fn update(&self, queue: &wgpu::Queue, offset: [u32; 2], size: [u32; 2], data: &[u8]) {
|
||||||
&self,
|
|
||||||
device: &wgpu::Device,
|
|
||||||
queue: &wgpu::Queue,
|
|
||||||
offset: [u32; 2],
|
|
||||||
size: [u32; 2],
|
|
||||||
data: &[u8],
|
|
||||||
) {
|
|
||||||
let bytes_per_pixel = self.format.describe().block_size as u32;
|
let bytes_per_pixel = self.format.describe().block_size as u32;
|
||||||
|
|
||||||
debug_assert_eq!(
|
debug_assert_eq!(
|
||||||
|
@ -9,8 +9,7 @@ use crate::{
|
|||||||
render::{
|
render::{
|
||||||
pipelines::{self, ColLights},
|
pipelines::{self, ColLights},
|
||||||
ColLightInfo, FigureBoneData, FigureDrawer, FigureLocals, FigureModel, FigureShadowDrawer,
|
ColLightInfo, FigureBoneData, FigureDrawer, FigureLocals, FigureModel, FigureShadowDrawer,
|
||||||
FirstPassDrawer, GlobalModel, LodData, Mesh, RenderError, Renderer, SubModel,
|
Mesh, RenderError, Renderer, SubModel, TerrainVertex,
|
||||||
TerrainVertex,
|
|
||||||
},
|
},
|
||||||
scene::{
|
scene::{
|
||||||
camera::{Camera, CameraMode, Dependents},
|
camera::{Camera, CameraMode, Dependents},
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
render::{
|
render::{
|
||||||
pipelines::lod_terrain::{LodData, Vertex},
|
pipelines::lod_terrain::{LodData, Vertex},
|
||||||
FirstPassDrawer, GlobalModel, LodTerrainVertex, Mesh, Model, Quad, Renderer,
|
FirstPassDrawer, LodTerrainVertex, Mesh, Model, Quad, Renderer,
|
||||||
},
|
},
|
||||||
settings::Settings,
|
settings::Settings,
|
||||||
};
|
};
|
||||||
|
@ -16,9 +16,9 @@ pub use self::{
|
|||||||
use crate::{
|
use crate::{
|
||||||
audio::{ambient::AmbientMgr, music::MusicMgr, sfx::SfxMgr, AudioFrontend},
|
audio::{ambient::AmbientMgr, music::MusicMgr, sfx::SfxMgr, AudioFrontend},
|
||||||
render::{
|
render::{
|
||||||
create_skybox_mesh, CloudsLocals, Consts, Drawer, FirstPassDrawer, GlobalModel, Globals,
|
create_skybox_mesh, CloudsLocals, Consts, Drawer, GlobalModel, Globals, GlobalsBindGroup,
|
||||||
GlobalsBindGroup, Light, Model, PointLightMatrix, PostProcessLocals, Renderer, Shadow,
|
Light, Model, PointLightMatrix, PostProcessLocals, Renderer, Shadow, ShadowLocals,
|
||||||
ShadowLocals, SkyboxVertex,
|
SkyboxVertex,
|
||||||
},
|
},
|
||||||
settings::Settings,
|
settings::Settings,
|
||||||
window::{AnalogGameInput, Event},
|
window::{AnalogGameInput, Event},
|
||||||
@ -1000,7 +1000,7 @@ impl Scene {
|
|||||||
shadow_mats.extend(lights.iter().flat_map(|light| {
|
shadow_mats.extend(lights.iter().flat_map(|light| {
|
||||||
// Now, construct the full projection matrix by making the light look at each
|
// Now, construct the full projection matrix by making the light look at each
|
||||||
// cube face.
|
// cube face.
|
||||||
let mut eye = Vec3::new(light.pos[0], light.pos[1], light.pos[2]) - focus_off;
|
let eye = Vec3::new(light.pos[0], light.pos[1], light.pos[2]) - focus_off;
|
||||||
orientations.iter().map(move |&(forward, up)| {
|
orientations.iter().map(move |&(forward, up)| {
|
||||||
// NOTE: We don't currently try to linearize point lights or need a separate
|
// NOTE: We don't currently try to linearize point lights or need a separate
|
||||||
// transform for them.
|
// transform for them.
|
||||||
|
@ -2,8 +2,8 @@ use super::{terrain::BlocksOfInterest, SceneData, Terrain};
|
|||||||
use crate::{
|
use crate::{
|
||||||
mesh::{greedy::GreedyMesh, segment::generate_mesh_base_vol_particle},
|
mesh::{greedy::GreedyMesh, segment::generate_mesh_base_vol_particle},
|
||||||
render::{
|
render::{
|
||||||
pipelines::particle::ParticleMode, GlobalModel, Instances, Light, LodData, Model,
|
pipelines::particle::ParticleMode, Instances, Light, Model, ParticleDrawer,
|
||||||
ParticleDrawer, ParticleInstance, ParticleVertex, Renderer,
|
ParticleInstance, ParticleVertex, Renderer,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
use common::{
|
use common::{
|
||||||
|
@ -11,10 +11,9 @@ use crate::{
|
|||||||
render::{
|
render::{
|
||||||
create_sprite_verts_buffer,
|
create_sprite_verts_buffer,
|
||||||
pipelines::{self, ColLights},
|
pipelines::{self, ColLights},
|
||||||
Buffer, ColLightInfo, Consts, Drawer, FirstPassDrawer, FluidVertex, FluidWaves,
|
Buffer, ColLightInfo, FirstPassDrawer, FluidVertex, FluidWaves, GlobalModel, Instances,
|
||||||
GlobalModel, Instances, LodData, Mesh, Model, RenderError, Renderer,
|
LodData, Mesh, Model, RenderError, Renderer, SpriteGlobalsBindGroup, SpriteInstance,
|
||||||
SpriteGlobalsBindGroup, SpriteInstance, SpriteVertex, TerrainLocals, TerrainShadowDrawer,
|
SpriteVertex, TerrainLocals, TerrainShadowDrawer, TerrainVertex, SPRITE_VERT_PAGE_SIZE,
|
||||||
TerrainVertex, Texture, SPRITE_VERT_PAGE_SIZE,
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -261,7 +260,7 @@ fn mesh_worker<V: BaseVol<Vox = Block> + RectRasterableVol + ReadVol + Debug + '
|
|||||||
.scaled_3d(SPRITE_SCALE)
|
.scaled_3d(SPRITE_SCALE)
|
||||||
.rotated_z(f32::consts::PI * 0.25 * ori as f32)
|
.rotated_z(f32::consts::PI * 0.25 * ori as f32)
|
||||||
.translated_3d(
|
.translated_3d(
|
||||||
(rel_pos.map(|e| e as f32) + Vec3::new(0.5, 0.5, 0.0))
|
rel_pos.map(|e| e as f32) + Vec3::new(0.5, 0.5, 0.0)
|
||||||
);
|
);
|
||||||
// Add an instance for each page in the sprite model
|
// Add an instance for each page in the sprite model
|
||||||
for page in sprite_data.vert_pages.clone() {
|
for page in sprite_data.vert_pages.clone() {
|
||||||
@ -296,12 +295,6 @@ fn mesh_worker<V: BaseVol<Vox = Block> + RectRasterableVol + ReadVol + Debug + '
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: may be unecessary
|
|
||||||
struct ChunkSpriteData {
|
|
||||||
// Instances
|
|
||||||
model: Instances<SpriteInstance>,
|
|
||||||
}
|
|
||||||
|
|
||||||
struct SpriteData {
|
struct SpriteData {
|
||||||
// Sprite vert page ranges that need to be drawn
|
// Sprite vert page ranges that need to be drawn
|
||||||
vert_pages: core::ops::Range<u32>,
|
vert_pages: core::ops::Range<u32>,
|
||||||
@ -413,7 +406,7 @@ impl SpriteRenderContext {
|
|||||||
let sprite_data: HashMap<(SpriteKind, usize), _> = SpriteKind::into_enum_iter()
|
let sprite_data: HashMap<(SpriteKind, usize), _> = SpriteKind::into_enum_iter()
|
||||||
.filter_map(|kind| Some((kind, kind.elim_case_pure(&sprite_config_.0).as_ref()?)))
|
.filter_map(|kind| Some((kind, kind.elim_case_pure(&sprite_config_.0).as_ref()?)))
|
||||||
.flat_map(|(kind, sprite_config)| {
|
.flat_map(|(kind, sprite_config)| {
|
||||||
let wind_sway = sprite_config.wind_sway;
|
// let wind_sway = sprite_config.wind_sway;
|
||||||
sprite_config.variations.iter().enumerate().map(
|
sprite_config.variations.iter().enumerate().map(
|
||||||
move |(
|
move |(
|
||||||
variation,
|
variation,
|
||||||
@ -512,7 +505,7 @@ impl SpriteRenderContext {
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
.map(|mut f| f(&mut greedy, &mut sprite_mesh))
|
.map(|f| f(&mut greedy, &mut sprite_mesh))
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
let sprite_col_lights = greedy.finalize();
|
let sprite_col_lights = greedy.finalize();
|
||||||
|
@ -494,7 +494,7 @@ fn upload_image(renderer: &mut Renderer, aabr: Aabr<u16>, tex: &Texture, image:
|
|||||||
fn create_image(
|
fn create_image(
|
||||||
renderer: &mut Renderer,
|
renderer: &mut Renderer,
|
||||||
image: RgbaImage,
|
image: RgbaImage,
|
||||||
border_color: Rgba<f32>,
|
_border_color: Rgba<f32>, // See TODO below
|
||||||
) -> (Texture, UiTextureBindGroup) {
|
) -> (Texture, UiTextureBindGroup) {
|
||||||
let tex = renderer
|
let tex = renderer
|
||||||
.create_texture(
|
.create_texture(
|
||||||
|
@ -15,8 +15,8 @@ use super::{
|
|||||||
};
|
};
|
||||||
use crate::{
|
use crate::{
|
||||||
render::{
|
render::{
|
||||||
create_ui_quad, create_ui_quad_vert_gradient, Consts, DynamicModel, Mesh, Renderer,
|
create_ui_quad, create_ui_quad_vert_gradient, DynamicModel, Mesh, Renderer, UiBoundLocals,
|
||||||
UiBoundLocals, UiDrawer, UiLocals, UiMode, UiVertex,
|
UiDrawer, UiLocals, UiMode, UiVertex,
|
||||||
},
|
},
|
||||||
Error,
|
Error,
|
||||||
};
|
};
|
||||||
|
@ -27,8 +27,8 @@ pub use widgets::{
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
render::{
|
render::{
|
||||||
create_ui_quad, create_ui_tri, Consts, DynamicModel, Globals, Mesh, RenderError, Renderer,
|
create_ui_quad, create_ui_tri, DynamicModel, Mesh, RenderError, Renderer, UiBoundLocals,
|
||||||
UiBoundLocals, UiDrawer, UiLocals, UiMode, UiVertex,
|
UiDrawer, UiLocals, UiMode, UiVertex,
|
||||||
},
|
},
|
||||||
window::Window,
|
window::Window,
|
||||||
Error,
|
Error,
|
||||||
|
Loading…
Reference in New Issue
Block a user