mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-10-17 16:30:30 +02:00
Give the Vulkan allocator one owning thread
Readback buffers are allocated when the readback is recorded rather than on the render thread, so only the thread that records frames touches VMA. The allocator is created externally synchronized, and VMA is built with no-op mutexes and plain counters instead of std::mutex and std::atomic. Headless runs Vulkan offscreen in builds without SDL too, and CI runs the headless tests on lavapipe, skipping the pixel tests a hardware backend doesn't match the software references on. sleep_ms and sleep_us go, with the thread manager test waiting on an event instead, and so does the unused portable-file-dialogs header.
This commit is contained in:
1 parent
f1208a7a5a
commit
b570567b88
18 files changed
+173
-2003
No files matched your search
@@ -1703,6 +1703,26 @@ void VulkanQueueRunner::ResizeReadbackBuffer(CachedReadback *readback, VkDeviceS
|
||||
readback->isCoherent = (memoryType.propertyFlags & VK_MEMORY_PROPERTY_HOST_COHERENT_BIT) != 0;
|
||||
}
|
||||
|
||||
CachedReadback *VulkanQueueRunner::PrepareReadback(FrameData &frameData, VKRFramebuffer *src, int width, int height, bool delayed) {
|
||||
// TODO: Handle different readback formats!
|
||||
const VkDeviceSize size = sizeof(uint32_t) * (VkDeviceSize)width * (VkDeviceSize)height;
|
||||
CachedReadback *cached = &syncReadback_;
|
||||
if (delayed) {
|
||||
ReadbackKey key;
|
||||
key.framebuf = src;
|
||||
key.width = width;
|
||||
key.height = height;
|
||||
if (!frameData.readbacks_.Get(key, &cached)) {
|
||||
cached = new CachedReadback();
|
||||
cached->bufferSize = 0;
|
||||
cached->createdFrame = frameData.frameId;
|
||||
frameData.readbacks_.Insert(key, cached);
|
||||
}
|
||||
}
|
||||
ResizeReadbackBuffer(cached, size);
|
||||
return cached;
|
||||
}
|
||||
|
||||
void VulkanQueueRunner::PerformReadback(const VKRStep &step, VkCommandBuffer cmd, FrameData &frameData) {
|
||||
VkImage image;
|
||||
VkImageLayout copyLayout;
|
||||
@@ -1736,28 +1756,7 @@ void VulkanQueueRunner::PerformReadback(const VKRStep &step, VkCommandBuffer cmd
|
||||
|
||||
recordBarrier_.Flush(cmd);
|
||||
|
||||
// TODO: Handle different readback formats!
|
||||
u32 readbackSizeInBytes = sizeof(uint32_t) * step.readback.srcRect.extent.width * step.readback.srcRect.extent.height;
|
||||
|
||||
CachedReadback *cached = nullptr;
|
||||
|
||||
if (step.readback.delayed) {
|
||||
ReadbackKey key;
|
||||
key.framebuf = step.readback.src;
|
||||
key.width = step.readback.srcRect.extent.width;
|
||||
key.height = step.readback.srcRect.extent.height;
|
||||
|
||||
// See if there's already a buffer we can reuse
|
||||
if (!frameData.readbacks_.Get(key, &cached)) {
|
||||
cached = new CachedReadback();
|
||||
cached->bufferSize = 0;
|
||||
frameData.readbacks_.Insert(key, cached);
|
||||
}
|
||||
} else {
|
||||
cached = &syncReadback_;
|
||||
}
|
||||
|
||||
ResizeReadbackBuffer(cached, readbackSizeInBytes);
|
||||
CachedReadback *cached = step.readback.dst;
|
||||
|
||||
VkBufferImageCopy region{};
|
||||
region.imageOffset = { step.readback.srcRect.offset.x, step.readback.srcRect.offset.y, 0 };
|
||||
@@ -1792,8 +1791,6 @@ void VulkanQueueRunner::PerformReadbackImage(const VKRStep &step, VkCommandBuffe
|
||||
recordBarrier_.TransitionColorImageAuto(step.readback_image.image, &layout, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, 0, 1, 1);
|
||||
recordBarrier_.Flush(cmd);
|
||||
|
||||
ResizeReadbackBuffer(&syncReadback_, sizeof(uint32_t) * step.readback_image.srcRect.extent.width * step.readback_image.srcRect.extent.height);
|
||||
|
||||
VkBufferImageCopy region{};
|
||||
region.imageOffset = { step.readback_image.srcRect.offset.x, step.readback_image.srcRect.offset.y, 0 };
|
||||
region.imageExtent = { step.readback_image.srcRect.extent.width, step.readback_image.srcRect.extent.height, 1 };
|
||||
@@ -1827,7 +1824,7 @@ bool VulkanQueueRunner::CopyReadbackBuffer(FrameData &frameData, VKRFramebuffer
|
||||
key.width = width;
|
||||
key.height = height;
|
||||
CachedReadback *cached;
|
||||
if (frameData.readbacks_.Get(key, &cached)) {
|
||||
if (frameData.readbacks_.Get(key, &cached) && cached->createdFrame != frameData.frameId) {
|
||||
readback = cached;
|
||||
} else {
|
||||
// Didn't have a cached image ready yet
|
||||
|
||||
Reference in new issue
Block a user