vk: Clean up around vkQueueSubmit handling

- Explicitly declare one version for CB flush and the other for Async flush
- Always flush descriptors on CB flush in case of page fault handling.
  Other threads other than offloader can also enter the method and require normal flow.
- Fix overlapping interrupt IDs.
- Minor formatting fixes
This commit is contained in:
kd-11 2021-09-28 20:42:38 +03:00 committed by kd-11
parent 3d49976b3c
commit dc8fc9fc79
6 changed files with 41 additions and 30 deletions

View file

@ -87,7 +87,7 @@ namespace rsx
void clear()
{
m_data.store(0);
m_data.release(0);
}
};
}

View file

@ -23,19 +23,8 @@ namespace vk
g_submit_mutex.unlock();
}
void queue_submit(VkQueue queue, const VkSubmitInfo* info, fence* pfence, VkBool32 flush)
{
if (rsx::get_current_renderer()->is_current_thread())
{
vk::descriptors::flush();
}
if (!flush && g_cfg.video.multithreaded_rsx)
{
auto packet = new submit_packet(queue, pfence, info);
g_fxo->get<rsx::dma_manager>().backend_ctrl(rctrl_queue_submit, packet);
}
else
FORCE_INLINE
static void queue_submit_impl(VkQueue queue, const VkSubmitInfo* info, fence* pfence)
{
acquire_global_submit_lock();
vkQueueSubmit(queue, 1, info, pfence->handle);
@ -44,5 +33,27 @@ namespace vk
// Signal fence
pfence->signal_flushed();
}
void queue_submit(VkQueue queue, const VkSubmitInfo* info, fence* pfence, VkBool32 flush)
{
// Access to this method must be externally synchronized.
// Offloader is guaranteed to never call this for async flushes.
vk::descriptors::flush();
if (!flush && g_cfg.video.multithreaded_rsx)
{
auto packet = new submit_packet(queue, pfence, info);
g_fxo->get<rsx::dma_manager>().backend_ctrl(rctrl_queue_submit, packet);
}
else
{
queue_submit_impl(queue, info, pfence);
}
}
void queue_submit(const vk::submit_packet* packet)
{
// Flush-only version used by asynchronous submit processing (MTRSX)
queue_submit_impl(packet->queue, &packet->submit_info, packet->pfence);
}
}

View file

@ -760,7 +760,7 @@ bool VKGSRender::on_access_violation(u32 address, bool is_writing)
}
bool has_queue_ref = false;
if (!is_current_thread())
if (!is_current_thread()) [[likely]]
{
// Always submit primary cb to ensure state consistency (flush pending changes such as image transitions)
vm::temporary_unlock();
@ -2340,8 +2340,8 @@ void VKGSRender::renderctl(u32 request_code, void* args)
{
case vk::rctrl_queue_submit:
{
auto packet = reinterpret_cast<vk::submit_packet*>(args);
vk::queue_submit(packet->queue, &packet->submit_info, packet->pfence, VK_TRUE);
const auto packet = reinterpret_cast<vk::submit_packet*>(args);
vk::queue_submit(packet);
free(packet);
break;
}

View file

@ -32,13 +32,13 @@ namespace vk
class image;
class instance;
class render_device;
struct submit_packet;
//VkAllocationCallbacks default_callbacks();
enum runtime_state
{
uninterruptible = 1,
heap_dirty = 2,
heap_changed = 3
heap_changed = 4,
};
const vk::render_device *get_current_renderer();
@ -54,7 +54,7 @@ namespace vk
// Sync helpers around vkQueueSubmit
void acquire_global_submit_lock();
void release_global_submit_lock();
void queue_submit(VkQueue queue, const VkSubmitInfo* info, fence* pfence, VkBool32 flush = VK_FALSE);
void queue_submit(const vk::submit_packet* packet);
template<class T>
T* get_compute_task();

View file

@ -6,7 +6,7 @@
namespace vk
{
// This queue flushing method to be implemented by the backend as behavior depends on config
void queue_submit(VkQueue queue, const VkSubmitInfo* info, fence* pfence, VkBool32 flush = VK_FALSE);
void queue_submit(VkQueue queue, const VkSubmitInfo* info, fence* pfence, VkBool32 flush);
void command_pool::create(vk::render_device& dev, u32 queue_family_id)
{