summaryrefslogtreecommitdiff
path: root/client/src/render
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2025-01-27 15:26:00 +0100
committermetamuffin <metamuffin@disroot.org>2025-01-27 15:26:00 +0100
commitc121d94f0b27bc04ffbdca55cd0939c1401d5a2e (patch)
tree67ac9da1f994c24b9a3e8e8d2adc2e334d2e34a5 /client/src/render
parent6b5c44d58e6c6d3df360396a0897290fc603699b (diff)
downloadweareserver-c121d94f0b27bc04ffbdca55cd0939c1401d5a2e.tar
weareserver-c121d94f0b27bc04ffbdca55cd0939c1401d5a2e.tar.bz2
weareserver-c121d94f0b27bc04ffbdca55cd0939c1401d5a2e.tar.zst
clippy: fixes and ignores
Diffstat (limited to 'client/src/render')
-rw-r--r--client/src/render/scene/demand_map.rs6
-rw-r--r--client/src/render/scene/draw.rs2
-rw-r--r--client/src/render/scene/mod.rs24
-rw-r--r--client/src/render/scene/textures.rs10
-rw-r--r--client/src/render/ui.rs48
5 files changed, 47 insertions, 43 deletions
diff --git a/client/src/render/scene/demand_map.rs b/client/src/render/scene/demand_map.rs
index c27eaac..dc73142 100644
--- a/client/src/render/scene/demand_map.rs
+++ b/client/src/render/scene/demand_map.rs
@@ -29,6 +29,12 @@ struct DemandMapState<K, V> {
needed: HashSet<K>,
size_metric: usize,
}
+impl<K: Hash + Eq + Clone, V: Clone> Default for DemandMap<K, V> {
+ fn default() -> Self {
+ Self::new()
+ }
+}
+
impl<K: Hash + Eq + Clone, V: Clone> DemandMap<K, V> {
pub fn new() -> Self {
Self {
diff --git a/client/src/render/scene/draw.rs b/client/src/render/scene/draw.rs
index 1109401..b2bf19e 100644
--- a/client/src/render/scene/draw.rs
+++ b/client/src/render/scene/draw.rs
@@ -53,7 +53,7 @@ impl ScenePipeline {
},
})],
depth_stencil_attachment: Some(RenderPassDepthStencilAttachment {
- view: &depth,
+ view: depth,
depth_ops: Some(Operations {
load: LoadOp::Clear(1.),
store: StoreOp::Store,
diff --git a/client/src/render/scene/mod.rs b/client/src/render/scene/mod.rs
index 16eecfc..7743409 100644
--- a/client/src/render/scene/mod.rs
+++ b/client/src/render/scene/mod.rs
@@ -293,13 +293,11 @@ impl ScenePreparer {
}) {
tex_albedo = Some(bg)
}
- } else {
- if let Some((_tex, bg)) = self
- .placeholder_textures
- .try_get(TextureIdentityKind::Multiply)
- {
- tex_albedo = Some(bg)
- }
+ } else if let Some((_tex, bg)) = self
+ .placeholder_textures
+ .try_get(TextureIdentityKind::Multiply)
+ {
+ tex_albedo = Some(bg)
}
let mut tex_normal = None;
if let Some(normalres) = part.tex_normal {
@@ -309,13 +307,11 @@ impl ScenePreparer {
}) {
tex_normal = Some(bg)
}
- } else {
- if let Some((_tex, bg)) = self
- .placeholder_textures
- .try_get(TextureIdentityKind::Normal)
- {
- tex_normal = Some(bg)
- }
+ } else if let Some((_tex, bg)) = self
+ .placeholder_textures
+ .try_get(TextureIdentityKind::Normal)
+ {
+ tex_normal = Some(bg)
}
let material = self.materials.try_get({
diff --git a/client/src/render/scene/textures.rs b/client/src/render/scene/textures.rs
index 4f2b01c..462cb53 100644
--- a/client/src/render/scene/textures.rs
+++ b/client/src/render/scene/textures.rs
@@ -27,8 +27,8 @@ use std::{
use wgpu::{
AddressMode, BindGroup, BindGroupDescriptor, BindGroupEntry, BindGroupLayout, BindingResource,
Color, ColorTargetState, ColorWrites, CommandEncoderDescriptor, Device, Extent3d, FilterMode,
- ImageDataLayout, LoadOp, Operations, Queue, RenderPassColorAttachment, RenderPassDescriptor,
- RenderPipeline, SamplerDescriptor, StoreOp, Texture, TextureAspect, TextureDescriptor,
+ LoadOp, Operations, Queue, RenderPassColorAttachment, RenderPassDescriptor, RenderPipeline,
+ SamplerDescriptor, StoreOp, TexelCopyBufferLayout, Texture, TextureAspect, TextureDescriptor,
TextureDimension, TextureFormat, TextureUsages, TextureViewDescriptor, include_wgsl,
};
@@ -193,7 +193,7 @@ fn create_texture(
});
let bind_group = device.create_bind_group(&BindGroupDescriptor {
label: None,
- layout: &bgl,
+ layout: bgl,
entries: &[
BindGroupEntry {
binding: 0,
@@ -246,7 +246,7 @@ fn create_texture(
queue.write_texture(
texture.as_image_copy(),
data,
- ImageDataLayout {
+ TexelCopyBufferLayout {
bytes_per_row: Some(width * 4),
rows_per_image: None,
offset: 0,
@@ -287,7 +287,7 @@ fn create_texture(
occlusion_query_set: None,
});
- rpass.set_pipeline(&mip_pipeline);
+ rpass.set_pipeline(mip_pipeline);
rpass.set_bind_group(0, &mip_bind_group, &[]);
rpass.draw(0..3, 0..1);
}
diff --git a/client/src/render/ui.rs b/client/src/render/ui.rs
index 4de2633..29e9461 100644
--- a/client/src/render/ui.rs
+++ b/client/src/render/ui.rs
@@ -33,12 +33,12 @@ use wgpu::{
BindGroupLayoutDescriptor, BindGroupLayoutEntry, BindingResource, BindingType, BlendState,
Buffer, BufferDescriptor, BufferUsages, ColorTargetState, ColorWrites, CommandEncoder,
CompareFunction, DepthStencilState, Device, Extent3d, FilterMode, FragmentState, FrontFace,
- ImageCopyTexture, ImageDataLayout, IndexFormat, LoadOp, MultisampleState, Operations, Origin3d,
- PipelineCompilationOptions, PipelineLayout, PipelineLayoutDescriptor, PolygonMode,
- PrimitiveState, PrimitiveTopology, PushConstantRange, Queue, RenderPassColorAttachment,
- RenderPassDepthStencilAttachment, RenderPassDescriptor, RenderPipeline,
- RenderPipelineDescriptor, SamplerBindingType, SamplerDescriptor, ShaderStages, StoreOp,
- SurfaceConfiguration, Texture, TextureAspect, TextureDescriptor, TextureDimension,
+ IndexFormat, LoadOp, MultisampleState, Operations, Origin3d, PipelineCompilationOptions,
+ PipelineLayout, PipelineLayoutDescriptor, PolygonMode, PrimitiveState, PrimitiveTopology,
+ PushConstantRange, Queue, RenderPassColorAttachment, RenderPassDepthStencilAttachment,
+ RenderPassDescriptor, RenderPipeline, RenderPipelineDescriptor, SamplerBindingType,
+ SamplerDescriptor, ShaderStages, StoreOp, SurfaceConfiguration, TexelCopyBufferLayout,
+ TexelCopyTextureInfo, Texture, TextureAspect, TextureDescriptor, TextureDimension,
TextureFormat, TextureSampleType, TextureUsages, TextureView, TextureViewDescriptor,
TextureViewDimension, VertexBufferLayout, VertexState, VertexStepMode, include_wgsl,
util::{DeviceExt, TextureDataOrder},
@@ -133,7 +133,7 @@ impl UiRenderer {
fn create_pipeline(
device: &Device,
- pipeline_layout: &PipelineLayout,
+ layout: &PipelineLayout,
format: TextureFormat,
sample_count: u32,
) -> RenderPipeline {
@@ -141,7 +141,7 @@ impl UiRenderer {
let vert_shader = device.create_shader_module(include_wgsl!("shaders/vertex_ui.wgsl"));
device.create_render_pipeline(&RenderPipelineDescriptor {
label: Some("ui pipeline"),
- layout: Some(&pipeline_layout),
+ layout: Some(layout),
fragment: Some(FragmentState {
module: &frag_shader,
entry_point: Some("main"),
@@ -241,12 +241,12 @@ impl UiRenderer {
ImageData::Font(font_image) => font_image.srgba_pixels(None).collect(),
};
- if let Some((_texbg, tex, texsize)) = textures.get_mut(&texid) {
+ if let Some((_texbg, texture, texsize)) = textures.get_mut(&texid) {
let pos = delta.pos.unwrap_or([0, 0]);
debug!("updating UI texture at {pos:?}");
self.queue.write_texture(
- ImageCopyTexture {
- texture: &tex,
+ TexelCopyTextureInfo {
+ texture,
mip_level: 0,
origin: Origin3d {
x: pos[0] as u32,
@@ -256,7 +256,7 @@ impl UiRenderer {
aspect: TextureAspect::All,
},
bytemuck::cast_slice::<_, u8>(&pixels),
- ImageDataLayout {
+ TexelCopyBufferLayout {
offset: 0,
bytes_per_row: Some(texsize[0] * 4),
rows_per_image: None,
@@ -344,7 +344,7 @@ impl UiRenderer {
},
})],
depth_stencil_attachment: Some(RenderPassDepthStencilAttachment {
- view: &depth,
+ view: depth,
depth_ops: Some(Operations {
load: LoadOp::Load,
store: StoreOp::Store,
@@ -356,17 +356,19 @@ impl UiRenderer {
rpass.set_pipeline(&self.pipeline);
- let mut raw_input = egui::RawInput::default();
- raw_input.viewport_id = surfaces.keys().next().copied().unwrap();
- raw_input.viewports = surfaces
- .keys()
- .map(|k| {
- (*k, ViewportInfo {
- native_pixels_per_point: Some(2.),
- ..Default::default()
+ let raw_input = egui::RawInput {
+ viewport_id: surfaces.keys().next().copied().unwrap(),
+ viewports: surfaces
+ .keys()
+ .map(|k| {
+ (*k, ViewportInfo {
+ native_pixels_per_point: Some(2.),
+ ..Default::default()
+ })
})
- })
- .collect();
+ .collect(),
+ ..Default::default()
+ };
let mut surfaces_closed = Vec::new();
for (viewport_id, surf) in surfaces.iter_mut() {