summaryrefslogtreecommitdiff
path: root/engine/src/rendering/shader/cursor.rs
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2026-10-11 16:57:12 +0200
committerHampusM <hampus@hampusmat.com>2026-10-11 16:57:12 +0200
commit7c55cefc6b7b1da19b2bbe7f43daaba4f816f27d (patch)
tree177d4f3d6278d1d4dfc07c2c2d5e0614154bb2c7 /engine/src/rendering/shader/cursor.rs
parentea1dc69432a5cf41f6d438151ddbd672d646b13d (diff)
fix(engine): add type & bounds checks in shader cursor element fnHEADmaster
Diffstat (limited to 'engine/src/rendering/shader/cursor.rs')
-rw-r--r--engine/src/rendering/shader/cursor.rs7
1 files changed, 7 insertions, 0 deletions
diff --git a/engine/src/rendering/shader/cursor.rs b/engine/src/rendering/shader/cursor.rs
index 551830d..24d0135 100644
--- a/engine/src/rendering/shader/cursor.rs
+++ b/engine/src/rendering/shader/cursor.rs
@@ -105,6 +105,13 @@ impl<'a> Cursor<'a>
#[must_use]
pub fn element(mut self, index: usize) -> Self
{
+ debug_assert_eq!(self.type_layout.kind(), TypeKind::Array);
+
+ debug_assert!(
+ index < self.type_layout.element_cnt().unwrap_or(0),
+ "Array element index {index} is out of bounds"
+ );
+
let element_type_layout = self.type_layout.element_type_layout().unwrap();
self.binding_location.byte_offset += index * element_type_layout.stride();