feat: 显存分配器迁移到 VMA(P1 路线第一项)

- vendored VulkanMemoryAllocator 子模块,唯一实现编译单元 VmaImpl.cpp
- MemoryAllocator 重写为 VMA 后端:接口从"Allocate(reqs)+手绑"升级为
  "创建即分配即绑定"(CreateBuffer/CreateImage/Destroy/Flush),
  VMA 要求资源与内存成对释放,约束成单一出口
- Buffer/Texture/RenderGraph 三处调用方迁移;staging 持久映射 + 按分配
  精确 flush(原来按整块 flush)
- 获得:TLSF 通用分配、DedicatedAllocation 自动启用、memory budget 感知、
  内存别名基础(TAA/复用前置)
- 编译零错误、validation 零警告、8 秒冒烟通过
This commit is contained in:
2026-09-23 12:51:11 +08:00
parent 6f10fd624d
commit 0de8498350
12 changed files with 200 additions and 295 deletions
+6 -9
View File
@@ -45,8 +45,7 @@ namespace Engine::RG {
for (auto& img : images) {
if (!img->valid) continue;
vkDevice.destroyImageView(img->view);
vkDevice.destroyImage(img->image);
m_Allocator.Free(img->allocation);
m_Allocator.Destroy(img->allocation); // image 资源与显存成对释放
}
}
m_Pool.clear();
@@ -530,8 +529,7 @@ namespace Engine::RG {
for (auto& img : it->second) {
if (!img->valid) continue;
vkDevice.destroyImageView(img->view);
vkDevice.destroyImage(img->image);
m_Allocator.Free(img->allocation);
m_Allocator.Destroy(img->allocation);
}
it = m_Pool.erase(it);
} else {
@@ -576,11 +574,10 @@ namespace Engine::RG {
.setSharingMode(vk::SharingMode::eExclusive)
.setInitialLayout(vk::ImageLayout::eUndefined);
img->image = vkDevice.createImage(imageInfo);
auto reqs = vkDevice.getImageMemoryRequirements(img->image);
img->allocation = m_Allocator.Allocate(reqs, vk::MemoryPropertyFlagBits::eDeviceLocal);
vkDevice.bindImageMemory(img->image, img->allocation.Memory, img->allocation.Offset);
// VMA:创建 + 分配 + 绑定一步完成
img->allocation = m_Allocator.CreateImage(imageInfo,
vk::MemoryPropertyFlagBits::eDeviceLocal);
img->image = img->allocation.Image;
vk::ImageViewCreateInfo viewInfo;
viewInfo.setImage(img->image)