feat(render): support full-scene 32-bit indices
This commit is contained in:
@@ -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());
|
||||
}
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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(())
|
||||
|
||||
Reference in New Issue
Block a user