From: Joshua Simmons Date: Wed, 12 Jul 2023 22:31:02 +0000 (+0200) Subject: narcissus-gpu: Use arena to avoid heap allocation in begin_rendering X-Git-Url: https://git.nega.tv//gitweb.cgi?a=commitdiff_plain;h=b1a25da89f2b5740b39de22dfd2187c1a9f858e1;p=josh%2Fnarcissus narcissus-gpu: Use arena to avoid heap allocation in begin_rendering --- diff --git a/libs/narcissus-gpu/src/backend/vulkan/mod.rs b/libs/narcissus-gpu/src/backend/vulkan/mod.rs index f3759ab..2a35d61 100644 --- a/libs/narcissus-gpu/src/backend/vulkan/mod.rs +++ b/libs/narcissus-gpu/src/backend/vulkan/mod.rs @@ -2910,12 +2910,11 @@ impl Device for VulkanDevice { } fn cmd_begin_rendering(&self, cmd_buffer: &mut CmdBuffer, desc: &crate::RenderingDesc) { + let arena = HybridArena::<1024>::new(); let cmd_buffer = self.cmd_buffer_mut(cmd_buffer); - let color_attachments = desc - .color_attachments - .iter() - .map(|attachment| { + let color_attachments = + arena.alloc_slice_fill_iter(desc.color_attachments.iter().map(|attachment| { let image_view = match self.image_pool.lock().get(attachment.image.0).unwrap() { VulkanImageHolder::Unique(image) => image.view, VulkanImageHolder::Shared(image) => image.view, @@ -2978,8 +2977,7 @@ impl Device for VulkanDevice { clear_value, ..default() } - }) - .collect::>(); + })); let depth_attachment = desc.depth_attachment.as_ref().map(|attachment| { let image_view = match self.image_pool.lock().get(attachment.image.0).unwrap() { @@ -3015,7 +3013,7 @@ impl Device for VulkanDevice { }, layer_count: 1, view_mask: 0, - color_attachments: color_attachments.as_slice().into(), + color_attachments: color_attachments.into(), depth_attachment: depth_attachment.as_ref(), stencil_attachment: None, ..default()