aboutsummaryrefslogtreecommitdiff
path: root/adapters
diff options
context:
space:
mode:
Diffstat (limited to 'adapters')
-rw-r--r--adapters/fparkan-render-vulkan/src/asset_mesh.rs16
-rw-r--r--adapters/fparkan-render-vulkan/src/ffi/resources.rs2
-rw-r--r--adapters/fparkan-render-vulkan/src/ffi/smoke.rs2
-rw-r--r--adapters/fparkan-render-vulkan/src/ffi/smoke_types.rs12
4 files changed, 16 insertions, 16 deletions
diff --git a/adapters/fparkan-render-vulkan/src/asset_mesh.rs b/adapters/fparkan-render-vulkan/src/asset_mesh.rs
index 7a2f8ba..d74e79c 100644
--- a/adapters/fparkan-render-vulkan/src/asset_mesh.rs
+++ b/adapters/fparkan-render-vulkan/src/asset_mesh.rs
@@ -251,7 +251,7 @@ pub fn project_land_msh_to_static_mesh(
.ok_or(VulkanAssetMeshError::IndexOutOfRange)?,
);
for face in &terrain.faces {
- indices.extend(face.vertices);
+ indices.extend(face.vertices.map(u32::from));
}
if indices.is_empty() {
return Err(VulkanAssetMeshError::EmptyGeometry);
@@ -280,7 +280,7 @@ pub fn project_land_msh_to_static_mesh_in_xy_frame(
.ok_or(VulkanAssetMeshError::IndexOutOfRange)?,
);
for face in &terrain.faces {
- indices.extend(face.vertices);
+ indices.extend(face.vertices.map(u32::from));
}
if indices.is_empty() {
return Err(VulkanAssetMeshError::EmptyGeometry);
@@ -357,7 +357,7 @@ pub fn project_land_msh_to_static_mesh_in_world_space(
})
}
-fn static_terrain_indices(terrain: &LandMeshDocument) -> Result<Vec<u16>, VulkanAssetMeshError> {
+fn static_terrain_indices(terrain: &LandMeshDocument) -> Result<Vec<u32>, VulkanAssetMeshError> {
let mut indices = Vec::with_capacity(
terrain
.faces
@@ -366,7 +366,7 @@ fn static_terrain_indices(terrain: &LandMeshDocument) -> Result<Vec<u16>, Vulkan
.ok_or(VulkanAssetMeshError::IndexOutOfRange)?,
);
for face in &terrain.faces {
- indices.extend(face.vertices);
+ indices.extend(face.vertices.map(u32::from));
}
if indices.is_empty() {
return Err(VulkanAssetMeshError::EmptyGeometry);
@@ -391,7 +391,7 @@ fn static_terrain_draw_ranges(
fn static_model_indices_and_ranges(
model: &ModelAsset,
-) -> Result<(Vec<u16>, Vec<VulkanStaticDrawRange>), VulkanAssetMeshError> {
+) -> Result<(Vec<u32>, Vec<VulkanStaticDrawRange>), VulkanAssetMeshError> {
let mut indices = Vec::new();
let mut draw_ranges = Vec::with_capacity(model.batches.len());
for batch in &model.batches {
@@ -411,7 +411,7 @@ fn static_model_indices_and_ranges(
.base_vertex
.checked_add(u32::from(raw_index))
.ok_or(VulkanAssetMeshError::IndexOutOfRange)?;
- indices.push(u16::try_from(index).map_err(|_| VulkanAssetMeshError::IndexOutOfRange)?);
+ indices.push(index);
}
draw_ranges.push(VulkanStaticDrawRange {
first_index,
@@ -429,7 +429,7 @@ fn static_model_indices_and_ranges(
fn static_mesh_xy_bounds(
positions: &[[f32; 3]],
- indices: &[u16],
+ indices: &[u32],
) -> Result<(f32, f32, f32, f32), VulkanAssetMeshError> {
let mut min_x = f32::INFINITY;
let mut max_x = f32::NEG_INFINITY;
@@ -437,7 +437,7 @@ fn static_mesh_xy_bounds(
let mut max_y = f32::NEG_INFINITY;
for &index in indices {
let position = positions
- .get(usize::from(index))
+ .get(usize::try_from(index).map_err(|_| VulkanAssetMeshError::IndexOutOfRange)?)
.ok_or(VulkanAssetMeshError::IndexOutOfRange)?;
if !position.iter().all(|value| value.is_finite()) {
return Err(VulkanAssetMeshError::NonFinitePosition);
diff --git a/adapters/fparkan-render-vulkan/src/ffi/resources.rs b/adapters/fparkan-render-vulkan/src/ffi/resources.rs
index b7e84bd..1d38503 100644
--- a/adapters/fparkan-render-vulkan/src/ffi/resources.rs
+++ b/adapters/fparkan-render-vulkan/src/ffi/resources.rs
@@ -236,7 +236,7 @@ pub(super) fn create_static_mesh_index_buffer(
device: &VulkanLogicalDeviceProbe,
mesh: &VulkanStaticMesh,
) -> Result<VulkanAllocatedBuffer, VulkanSmokeRendererError> {
- let mut bytes = Vec::with_capacity(mesh.indices.len() * std::mem::size_of::<u16>());
+ let mut bytes = Vec::with_capacity(mesh.indices.len() * std::mem::size_of::<u32>());
for &index in &mesh.indices {
bytes.extend_from_slice(&index.to_ne_bytes());
}
diff --git a/adapters/fparkan-render-vulkan/src/ffi/smoke.rs b/adapters/fparkan-render-vulkan/src/ffi/smoke.rs
index 63066b4..f7c72b6 100644
--- a/adapters/fparkan-render-vulkan/src/ffi/smoke.rs
+++ b/adapters/fparkan-render-vulkan/src/ffi/smoke.rs
@@ -701,7 +701,7 @@ impl VulkanSmokeRenderer {
command_buffer,
self.index_buffer_ref()?.buffer,
0,
- vk::IndexType::UINT16,
+ vk::IndexType::UINT32,
);
let clip_from_world = matrix_bytes(self.camera.clip_from_world);
device.device().cmd_push_constants(
diff --git a/adapters/fparkan-render-vulkan/src/ffi/smoke_types.rs b/adapters/fparkan-render-vulkan/src/ffi/smoke_types.rs
index 47cab7d..2ca517b 100644
--- a/adapters/fparkan-render-vulkan/src/ffi/smoke_types.rs
+++ b/adapters/fparkan-render-vulkan/src/ffi/smoke_types.rs
@@ -126,7 +126,7 @@ pub struct VulkanStaticMesh {
/// Vertex data in pipeline order.
pub vertices: Vec<VulkanStaticVertex>,
/// Triangle-list indices into [`Self::vertices`].
- pub indices: Vec<u16>,
+ pub indices: Vec<u32>,
/// Source-preserving triangle draw ranges in [`Self::indices`].
pub draw_ranges: Vec<VulkanStaticDrawRange>,
}
@@ -296,11 +296,11 @@ impl VulkanStaticMesh {
if usize::try_from(expected_first).ok() != Some(self.indices.len()) {
return Err("static mesh draw ranges must cover all indices");
}
- if self
- .indices
- .iter()
- .any(|&index| usize::from(index) >= self.vertices.len())
- {
+ if self.indices.iter().any(|&index| {
+ usize::try_from(index)
+ .ok()
+ .is_none_or(|index| index >= self.vertices.len())
+ }) {
return Err("static mesh index exceeds vertex count");
}
Ok(())