summaryrefslogtreecommitdiff
path: root/engine/src/rendering/shader
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2026-09-22 18:22:46 +0200
committerHampusM <hampus@hampusmat.com>2026-09-22 18:22:46 +0200
commitc73ab25c9dbe40284cfd38beaf31e2a20a9810de (patch)
tree51c5817a0c252a172c03a47e36886e563a4e623d /engine/src/rendering/shader
parent2ccda0cd5f81909fddc74d95f960f781a64bcae1 (diff)
refactor(engine): fix portion of clippy lints
Diffstat (limited to 'engine/src/rendering/shader')
-rw-r--r--engine/src/rendering/shader/cursor.rs26
1 files changed, 16 insertions, 10 deletions
diff --git a/engine/src/rendering/shader/cursor.rs b/engine/src/rendering/shader/cursor.rs
index 49f6b47..551830d 100644
--- a/engine/src/rendering/shader/cursor.rs
+++ b/engine/src/rendering/shader/cursor.rs
@@ -2,7 +2,7 @@ use std::borrow::Cow;
use std::fmt::Display;
use std::hint::cold_path;
-use circular_buffer::FixedCircularBuffer;
+use circular_buffer::HeapCircularBuffer;
use crate::color::{Color, Rgb, Rgba};
use crate::data_types::matrix::Matrix;
@@ -27,6 +27,7 @@ pub struct Cursor<'a>
impl<'a> Cursor<'a>
{
+ #[must_use]
pub fn new(var_layout: VariableLayout<'a>) -> Self
{
let binding_location = BindingLocation {
@@ -38,10 +39,11 @@ impl<'a> Cursor<'a>
Self {
type_layout: var_layout.type_layout().unwrap(),
binding_location,
- location_path: LocationPath::default(),
+ location_path: LocationPath::new(),
}
}
+ #[must_use]
pub fn field(&self, name: impl Into<Cow<'static, str>>) -> Self
{
let name = name.into();
@@ -100,6 +102,7 @@ impl<'a> Cursor<'a>
}
}
+ #[must_use]
pub fn element(mut self, index: usize) -> Self
{
let element_type_layout = self.type_layout.element_type_layout().unwrap();
@@ -125,15 +128,23 @@ impl<'a> Cursor<'a>
}
/// Shader cursor location.
-#[derive(Debug, Clone, Default)]
+#[derive(Debug, Clone)]
pub struct LocationPath
{
- locations: FixedCircularBuffer<Location, 16>,
+ locations: HeapCircularBuffer<Location>,
is_truncated: bool,
}
impl LocationPath
{
+ fn new() -> Self
+ {
+ Self {
+ locations: HeapCircularBuffer::with_capacity(16),
+ is_truncated: false,
+ }
+ }
+
fn push(&mut self, location: Location)
{
if self.locations.push_back(location).is_some() {
@@ -231,12 +242,7 @@ impl BindingValue
Self::Float(_) => {
ty_kind == TypeKind::Scalar && scalar_ty == Some(ScalarType::Float32)
}
- Self::FVec3(_) => {
- ty_kind == TypeKind::Vector
- && element_scalar_ty == Some(ScalarType::Float32)
- && element_cnt == Some(3)
- }
- Self::Color(Color::Rgb(_)) => {
+ Self::FVec3(_) | Self::Color(Color::Rgb(_)) => {
ty_kind == TypeKind::Vector
&& element_scalar_ty == Some(ScalarType::Float32)
&& element_cnt == Some(3)