Files
LibretroAdmin b5da96cd78 vulkan: VMA is gone
The renderer's three allocation sites - textures, framebuffer
attachments and buffers - now go through vk_heap, and vk_mem_alloc.h and
its wrapper are out of the tree. The core is 182 KB smaller.

core/rend/vulkan/heap.{h,cpp} is what the renderer's classes hold: the
Allocation that gives its memory back when it goes, as before, and
VulkanHeap in place of VMAllocator. An allocation's pointer comes with
it, so MapMemory() is a load.

What each kind of memory asks for:

 - textures and attachments: device-local, falling back to whatever the
   image allows; a transient attachment first tries memory the device
   only backs if it has to
 - buffers and images the CPU fills: host-visible and coherent, on the
   device where the device has such memory. VMA was asked for
   host-visible only and nothing ever flushed, which was wrong on a
   device whose host-visible memory is not coherent
 - buffers the CPU reads back (render-to-texture readback): host-visible
   and host-cached. VMA put these in device memory seen through the bus
   on a discrete card, which is write-combined and slow to read

One block for images and one for the CPU's buffers are taken when the
device is set up, so a frame gets memory as an offset rather than from
the driver. A block is 64 MB, or an eighth of the device's memory where
that is less.

tools/threads/live.sh passes on the Vulkan renderer: the screenshot, the
save-state comparison with non-threaded rendering, and save, load and
reset back to back. A run under the Khronos validation layer reports
nothing. Software Vulkan only; not run on a GPU.
2026-10-05 17:32:12 +02:00

35 lines
1.4 KiB
C++

#define PVR_REGS_FOR_RENDERER // see hw/pvr/pvr_regs.h
/*
* Created on: Oct 3, 2019
Copyright 2019 flyinghead
This file is part of Flycast.
Flycast is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
Flycast is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Flycast. If not, see <https://www.gnu.org/licenses/>.
*/
#include "buffer.h"
#include "utils.h"
#include "vulkan_context.h"
BufferData::BufferData(vk::DeviceSize size, const vk::BufferUsageFlags& usage, const vk::MemoryPropertyFlags& propertyFlags)
: bufferSize(size), m_usage(usage), m_propertyFlags(propertyFlags)
{
VulkanContext *context = VulkanContext::Instance();
buffer = context->GetDevice().createBufferUnique(vk::BufferCreateInfo(vk::BufferCreateFlags(), size, usage));
allocation = context->GetHeap().AllocateForBuffer(*buffer,
!(propertyFlags & vk::MemoryPropertyFlagBits::eDeviceLocal),
(bool)(usage & vk::BufferUsageFlagBits::eTransferDst));
}