aboutsummaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorValentin Popov <valentin@popov.link>2026-07-18 14:19:07 +0300
committerValentin Popov <valentin@popov.link>2026-07-18 14:19:07 +0300
commit438aaebcbc5c963d378d297bfb13e2af24b12084 (patch)
tree06e53f63862eaf21c64220491cde1606e8a4d9b1 /apps
parent733bfcf6fa2e17dbc94487fb1b9eb4f896e53845 (diff)
downloadfparkan-438aaebcbc5c963d378d297bfb13e2af24b12084.tar.xz
fparkan-438aaebcbc5c963d378d297bfb13e2af24b12084.zip
feat(render): support full-scene 32-bit indices
Diffstat (limited to 'apps')
-rw-r--r--apps/fparkan-game/src/main.rs39
1 files changed, 29 insertions, 10 deletions
diff --git a/apps/fparkan-game/src/main.rs b/apps/fparkan-game/src/main.rs
index af5d7ed..850b509 100644
--- a/apps/fparkan-game/src/main.rs
+++ b/apps/fparkan-game/src/main.rs
@@ -465,28 +465,24 @@ fn append_static_preview_component(
component: VulkanStaticMesh,
selector_remap: &[(u16, u16)],
) -> Result<(), String> {
- let vertex_base = u16::try_from(target.vertices.len()).map_err(|_| {
- "static preview exceeds the available 16-bit vertex index space".to_string()
- })?;
+ let vertex_base = u32::try_from(target.vertices.len())
+ .map_err(|_| "static preview vertex count exceeds u32".to_string())?;
let first_index_base = u32::try_from(target.indices.len())
.map_err(|_| "static preview index count exceeds u32".to_string())?;
target
.vertices
.len()
.checked_add(component.vertices.len())
- .filter(|count| *count <= usize::from(u16::MAX) + 1)
- .ok_or_else(|| {
- "static preview exceeds the available 16-bit vertex index space".to_string()
- })?;
+ .ok_or_else(|| "static preview vertex count exceeds addressable memory".to_string())?;
target.vertices.extend(component.vertices);
target.indices.extend(
component
.indices
.into_iter()
.map(|index| {
- index.checked_add(vertex_base).ok_or_else(|| {
- "static preview exceeds the available 16-bit vertex index space".to_string()
- })
+ index
+ .checked_add(vertex_base)
+ .ok_or_else(|| "static preview vertex index exceeds u32".to_string())
})
.collect::<Result<Vec<_>, _>>()?,
);
@@ -1293,6 +1289,29 @@ mod tests {
}
#[test]
+ fn static_preview_component_merge_keeps_indices_above_u16() -> Result<(), String> {
+ let vertex = fparkan_render_vulkan::VulkanStaticVertex {
+ position: [0.0, 0.0, 0.0],
+ color: [1.0, 1.0, 1.0],
+ uv: [0.0, 0.0],
+ };
+ let mut merged = VulkanStaticMesh {
+ vertices: vec![vertex; usize::from(u16::MAX) + 1],
+ indices: Vec::new(),
+ draw_ranges: Vec::new(),
+ };
+
+ append_static_preview_component(
+ &mut merged,
+ VulkanStaticMesh::smoke_triangle(),
+ &[(0, 0)],
+ )?;
+
+ assert_eq!(merged.indices, vec![65_536, 65_537, 65_538]);
+ Ok(())
+ }
+
+ #[test]
fn render_commands_follow_snapshot_order() -> Result<(), String> {
let snapshot = WorldSnapshot {
tick: Tick(7),