Vulkan/Context: Don't write timestamp on an unreset query

This commit is contained in:
Connor McLaughlin 2022-05-11 18:01:43 +10:00 committed by refractionpcsx2
parent cd0b349496
commit 38c48e8b6a
2 changed files with 32 additions and 26 deletions

View File

@ -1009,7 +1009,7 @@ namespace Vulkan
}
}
if (m_gpu_timing_enabled)
if (m_gpu_timing_enabled && resources.timestamp_written)
{
vkCmdWriteTimestamp(m_current_command_buffer, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, m_timestamp_query_pool, m_current_frame * 2 + 1);
}
@ -1184,15 +1184,9 @@ namespace Vulkan
if (res != VK_SUCCESS)
LOG_VULKAN_ERROR(res, "vkResetDescriptorPool failed: ");
m_current_frame = index;
m_current_command_buffer = resources.command_buffers[1];
resources.fence_counter = m_next_fence_counter++;
resources.init_buffer_used = false;
// using the lower 32 bits of the fence index should be sufficient here, I hope...
vmaSetCurrentFrameIndex(m_allocator, static_cast<u32>(m_next_fence_counter));
if (m_gpu_timing_enabled)
{
if (resources.timestamp_written)
{
std::array<u64, 2> timestamps;
res = vkGetQueryPoolResults(m_device, m_timestamp_query_pool, index * 2, static_cast<u32>(timestamps.size()),
@ -1210,10 +1204,21 @@ namespace Vulkan
{
LOG_VULKAN_ERROR(res, "vkGetQueryPoolResults failed: ");
}
vkCmdResetQueryPool(m_current_command_buffer, m_timestamp_query_pool, index * 2, 2);
vkCmdWriteTimestamp(m_current_command_buffer, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, m_timestamp_query_pool, index * 2);
}
vkCmdResetQueryPool(resources.command_buffers[1], m_timestamp_query_pool, index * 2, 2);
vkCmdWriteTimestamp(resources.command_buffers[1], VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, m_timestamp_query_pool, index * 2);
}
resources.fence_counter = m_next_fence_counter++;
resources.init_buffer_used = false;
resources.timestamp_written = m_gpu_timing_enabled;
m_current_frame = index;
m_current_command_buffer = resources.command_buffers[1];
// using the lower 32 bits of the fence index should be sufficient here, I hope...
vmaSetCurrentFrameIndex(m_allocator, static_cast<u32>(m_next_fence_counter));
}
void Context::ExecuteCommandBuffer(bool wait_for_completion)

View File

@ -274,6 +274,7 @@ namespace Vulkan
u64 fence_counter = 0;
bool init_buffer_used = false;
bool needs_fence_wait = false;
bool timestamp_written = false;
std::vector<std::function<void()>> cleanup_resources;
};