Skip to content

Commit

Permalink
Clippy lints
Browse files Browse the repository at this point in the history
  • Loading branch information
JMS55 committed Oct 24, 2023
1 parent 3552ca0 commit e72283f
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
4 changes: 3 additions & 1 deletion crates/bevy_pbr/src/material.rs
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,9 @@ where

let sd = ShaderDefVal::UInt("MESHLET_BIND_GROUP".into(), 1);
descriptor.vertex.shader_defs.push(sd.clone());
descriptor.fragment.as_mut().map(|f| f.shader_defs.push(sd));
if let Some(f) = descriptor.fragment.as_mut() {
f.shader_defs.push(sd)
}
} else {
descriptor.layout.insert(1, self.material_layout.clone());
}
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_pbr/src/meshlet/from_mesh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ impl MeshletMesh {
}
let vertex_buffer_layout = &mesh.get_mesh_vertex_buffer_layout();
if vertex_buffer_layout.attribute_ids()
!= &[
!= [
Mesh::ATTRIBUTE_POSITION.id,
Mesh::ATTRIBUTE_NORMAL.id,
Mesh::ATTRIBUTE_UV_0.id,
Expand Down
6 changes: 3 additions & 3 deletions crates/bevy_pbr/src/meshlet/persistent_buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,12 @@ impl<T: PersistentGpuBufferable> PersistentGpuBuffer<T> {
}
}

/// SAFETY: All data must be a multiple of wgpu::COPY_BUFFER_ALIGNMENT bytes.
/// The size given by size_in_bytes() must match as_bytes_le().
/// SAFETY: All data must be a multiple of `wgpu::COPY_BUFFER_ALIGNMENT` bytes.
/// The size given by `size_in_bytes()` must match `as_bytes_le()`.
pub trait PersistentGpuBufferable {
type ExtraData;

fn size_in_bytes(&self) -> u64;

fn as_bytes_le<'a>(&'a self, extra_data: Self::ExtraData) -> Cow<'a, [u8]>;
fn as_bytes_le(&self, extra_data: Self::ExtraData) -> Cow<'_, [u8]>;
}
8 changes: 4 additions & 4 deletions crates/bevy_pbr/src/meshlet/psb_impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ impl PersistentGpuBufferable for Arc<[u8]> {
self.len() as u64
}

fn as_bytes_le<'a>(&'a self, _: Self::ExtraData) -> Cow<'a, [u8]> {
fn as_bytes_le(&self, _: Self::ExtraData) -> Cow<'_, [u8]> {
Cow::Borrowed(self)
}
}
Expand All @@ -20,7 +20,7 @@ impl PersistentGpuBufferable for Arc<[u32]> {
self.len() as u64 * 4
}

fn as_bytes_le<'a>(&'a self, offset: Self::ExtraData) -> Cow<'a, [u8]> {
fn as_bytes_le(&self, offset: Self::ExtraData) -> Cow<'_, [u8]> {
let offset = offset as u32 / 48;

self.iter()
Expand All @@ -36,7 +36,7 @@ impl PersistentGpuBufferable for Arc<[Meshlet]> {
self.len() as u64 * 16
}

fn as_bytes_le<'a>(&'a self, (vertex_offset, index_offset): Self::ExtraData) -> Cow<'a, [u8]> {
fn as_bytes_le(&self, (vertex_offset, index_offset): Self::ExtraData) -> Cow<'_, [u8]> {
let vertex_offset = vertex_offset as u32 / 4;
let index_offset = index_offset as u32;

Expand All @@ -59,7 +59,7 @@ impl PersistentGpuBufferable for Arc<[MeshletBoundingSphere]> {
self.len() as u64 * 16
}

fn as_bytes_le<'a>(&'a self, _: Self::ExtraData) -> Cow<'a, [u8]> {
fn as_bytes_le(&self, _: Self::ExtraData) -> Cow<'_, [u8]> {
Cow::Borrowed(bytemuck::cast_slice(self))
}
}

0 comments on commit e72283f

Please sign in to comment.