1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-02-20 19:54:19 +01:00

[dxvk] Fix synchronization around vkDeviceWaitIdle

From the spec:
	"Host access to all VkQueue objects created
	from device must be externally synchronized"

We were not doing that, which could cause hangs and
all sorts of issues when recreating the swap chain
on Nvidia GPUs.
This commit is contained in:
Philip Rebohle 2019-11-19 23:12:07 +01:00
parent 4fff2343c1
commit ceddbaf7c4
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
4 changed files with 8 additions and 6 deletions

View File

@ -364,6 +364,8 @@ namespace dxvk {
void D3D11SwapChain::RecreateSwapChain(BOOL Vsync) {
// Ensure that we can safely destroy the swap chain
m_device->waitForSubmission(&m_presentStatus);
m_device->waitForIdle();
m_presentStatus.result = VK_SUCCESS;
vk::PresenterDesc presenterDesc;

View File

@ -237,10 +237,10 @@ namespace dxvk {
void DxvkDevice::waitForIdle() {
m_submissionQueue.synchronize();
this->lockSubmission();
if (m_vkd->vkDeviceWaitIdle(m_vkd->device()) != VK_SUCCESS)
Logger::err("DxvkDevice: waitForIdle: Operation failed");
this->unlockSubmission();
}

View File

@ -198,7 +198,7 @@ namespace dxvk::vk {
// Create one set of semaphores per swap image
m_semaphores.resize(m_info.imageCount);
for (uint32_t i = 0; i < m_info.imageCount; i++) {
for (uint32_t i = 0; i < m_semaphores.size(); i++) {
VkFenceCreateInfo fenceInfo;
fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO;
fenceInfo.pNext = nullptr;
@ -399,8 +399,6 @@ namespace dxvk::vk {
void Presenter::destroySwapchain() {
m_vkd->vkDeviceWaitIdle(m_vkd->device());
for (const auto& img : m_images)
m_vkd->vkDestroyImageView(m_vkd->device(), img.view, nullptr);

View File

@ -160,7 +160,9 @@ namespace dxvk::vk {
/**
* \brief Changes presenter properties
*
* Recreates the swap chain immediately.
* Recreates the swap chain immediately. Note that
* no swap chain resources must be in use by the
* GPU at the time this is called.
* \param [in] desc Swap chain description
*/
VkResult recreateSwapChain(