From 47e15c6083bac22fe7380594400e577504df86b1 Mon Sep 17 00:00:00 2001 From: Julian Orth Date: Tue, 30 Sep 2025 18:43:44 +0200 Subject: [PATCH] vulkan: pre-heat allocations --- src/gfx_apis/vulkan/allocator.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/gfx_apis/vulkan/allocator.rs b/src/gfx_apis/vulkan/allocator.rs index bff766b3..66a2a79c 100644 --- a/src/gfx_apis/vulkan/allocator.rs +++ b/src/gfx_apis/vulkan/allocator.rs @@ -4,7 +4,7 @@ use { gfx_apis::vulkan::{ VulkanError, device::VulkanDevice, instance::API_VERSION, renderer::VulkanRenderer, }, - utils::{numcell::NumCell, ptr_ext::MutPtrExt}, + utils::{numcell::NumCell, page_size::page_size, ptr_ext::MutPtrExt}, }, ash::{ Device, @@ -304,6 +304,19 @@ impl CpuWork for AllocWork { self.usage, self.map, ); + if self.usage.contains(UsageFlags::UPLOAD) + && let Ok(r) = &r + && let Some(ptr) = r.ptr + { + let page_size = page_size() as u64; + let mut offset = 0; + while offset < r.block.size() { + unsafe { + *ptr.add(offset as usize) = 0; + } + offset += page_size; + } + } self.res = Some(r); None }