2020-12-05 13:08:24 +01:00
|
|
|
#include "stdafx.h"
|
2019-12-07 14:28:35 +01:00
|
|
|
#include "VKCommandStream.h"
|
2021-09-23 21:54:50 +02:00
|
|
|
#include "vkutils/descriptors.h"
|
2021-01-09 19:46:50 +01:00
|
|
|
#include "vkutils/sync.h"
|
2021-09-23 21:54:50 +02:00
|
|
|
|
2020-10-30 21:26:22 +01:00
|
|
|
#include "Emu/IdManager.h"
|
|
|
|
|
#include "Emu/RSX/RSXOffload.h"
|
2021-09-23 21:54:50 +02:00
|
|
|
#include "Emu/RSX/RSXThread.h"
|
|
|
|
|
#include "Emu/system_config.h"
|
2019-12-07 14:28:35 +01:00
|
|
|
|
|
|
|
|
namespace vk
|
|
|
|
|
{
|
|
|
|
|
// global submit guard to prevent race condition on queue submit
|
|
|
|
|
shared_mutex g_submit_mutex;
|
|
|
|
|
|
|
|
|
|
void acquire_global_submit_lock()
|
|
|
|
|
{
|
|
|
|
|
g_submit_mutex.lock();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void release_global_submit_lock()
|
|
|
|
|
{
|
|
|
|
|
g_submit_mutex.unlock();
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-28 19:42:38 +02:00
|
|
|
FORCE_INLINE
|
2022-01-30 12:56:22 +01:00
|
|
|
static void queue_submit_impl(const queue_submit_t& submit_info)
|
2021-09-28 19:42:38 +02:00
|
|
|
{
|
2022-02-11 18:57:19 +01:00
|
|
|
ensure(submit_info.pfence);
|
2021-09-28 19:42:38 +02:00
|
|
|
acquire_global_submit_lock();
|
2022-01-30 12:56:22 +01:00
|
|
|
VkSubmitInfo info
|
|
|
|
|
{
|
|
|
|
|
.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO,
|
|
|
|
|
.pNext = nullptr,
|
|
|
|
|
.waitSemaphoreCount = submit_info.wait_semaphores_count,
|
|
|
|
|
.pWaitSemaphores = submit_info.wait_semaphores.data(),
|
|
|
|
|
.pWaitDstStageMask = submit_info.wait_stages.data(),
|
|
|
|
|
.commandBufferCount = 1,
|
|
|
|
|
.pCommandBuffers = &submit_info.commands,
|
|
|
|
|
.signalSemaphoreCount = submit_info.signal_semaphores_count,
|
|
|
|
|
.pSignalSemaphores = submit_info.signal_semaphores.data()
|
|
|
|
|
};
|
|
|
|
|
|
2022-02-11 18:57:19 +01:00
|
|
|
vkQueueSubmit(submit_info.queue, 1, &info, submit_info.pfence->handle);
|
2021-09-28 19:42:38 +02:00
|
|
|
release_global_submit_lock();
|
|
|
|
|
|
|
|
|
|
// Signal fence
|
2022-02-11 18:57:19 +01:00
|
|
|
submit_info.pfence->signal_flushed();
|
2021-09-28 19:42:38 +02:00
|
|
|
}
|
|
|
|
|
|
2022-01-30 12:56:22 +01:00
|
|
|
void queue_submit(const queue_submit_t& submit_info, VkBool32 flush)
|
2019-12-07 14:28:35 +01:00
|
|
|
{
|
2022-05-14 16:43:43 +02:00
|
|
|
rsx::get_current_renderer()->get_stats().submit_count++;
|
|
|
|
|
|
2021-09-28 19:42:38 +02:00
|
|
|
// Access to this method must be externally synchronized.
|
|
|
|
|
// Offloader is guaranteed to never call this for async flushes.
|
|
|
|
|
vk::descriptors::flush();
|
2021-09-23 21:54:50 +02:00
|
|
|
|
2019-12-07 14:28:35 +01:00
|
|
|
if (!flush && g_cfg.video.multithreaded_rsx)
|
|
|
|
|
{
|
2022-01-30 12:56:22 +01:00
|
|
|
auto packet = new queue_submit_t(submit_info);
|
2021-03-02 12:59:19 +01:00
|
|
|
g_fxo->get<rsx::dma_manager>().backend_ctrl(rctrl_queue_submit, packet);
|
2019-12-07 14:28:35 +01:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2022-01-30 12:56:22 +01:00
|
|
|
queue_submit_impl(submit_info);
|
2019-12-07 14:28:35 +01:00
|
|
|
}
|
|
|
|
|
}
|
2021-09-28 19:42:38 +02:00
|
|
|
|
2022-01-30 12:56:22 +01:00
|
|
|
void queue_submit(const queue_submit_t* packet)
|
2021-09-28 19:42:38 +02:00
|
|
|
{
|
|
|
|
|
// Flush-only version used by asynchronous submit processing (MTRSX)
|
2022-01-30 12:56:22 +01:00
|
|
|
queue_submit_impl(*packet);
|
2021-09-28 19:42:38 +02:00
|
|
|
}
|
2019-12-07 14:28:35 +01:00
|
|
|
}
|