Signed-off-by: Józef Kucia jkucia@codeweavers.com --- dlls/dxgi/swapchain.c | 64 +++++++++++++++++++------------------------ 1 file changed, 28 insertions(+), 36 deletions(-)
diff --git a/dlls/dxgi/swapchain.c b/dlls/dxgi/swapchain.c index f2f89b9f7a84..22feeaeb825f 100644 --- a/dlls/dxgi/swapchain.c +++ b/dlls/dxgi/swapchain.c @@ -1411,7 +1411,7 @@ static HRESULT d3d12_swapchain_create_buffers(struct d3d12_swapchain *swapchain, return S_OK; }
-static HRESULT d3d12_swapchain_acquire_next_image(struct d3d12_swapchain *swapchain) +static VkResult d3d12_swapchain_acquire_next_image(struct d3d12_swapchain *swapchain) { const struct dxgi_vk_funcs *vk_funcs = &swapchain->vk_funcs; VkDevice vk_device = swapchain->vk_device; @@ -1422,21 +1422,18 @@ static HRESULT d3d12_swapchain_acquire_next_image(struct d3d12_swapchain *swapch VK_NULL_HANDLE, vk_fence, &swapchain->current_buffer_index)) < 0) { ERR("Failed to acquire next Vulkan image, vr %d.\n", vr); - return hresult_from_vk_result(vr); + return vr; }
if ((vr = vk_funcs->p_vkWaitForFences(vk_device, 1, &vk_fence, VK_TRUE, UINT64_MAX)) != VK_SUCCESS) { ERR("Failed to wait for fence, vr %d.\n", vr); - return hresult_from_vk_result(vr); + return vr; } if ((vr = vk_funcs->p_vkResetFences(vk_device, 1, &vk_fence)) < 0) - { ERR("Failed to reset fence, vr %d.\n", vr); - return hresult_from_vk_result(vr); - }
- return S_OK; + return vr; }
static void d3d12_swapchain_destroy_buffers(struct d3d12_swapchain *swapchain, BOOL destroy_user_buffers) @@ -1594,6 +1591,23 @@ static HRESULT d3d12_swapchain_create_vulkan_swapchain(struct d3d12_swapchain *s return d3d12_swapchain_create_buffers(swapchain, vk_swapchain_format, vk_format); }
+static HRESULT d3d12_swapchain_recreate_vulkan_swapchain(struct d3d12_swapchain *swapchain) +{ + VkResult vr; + HRESULT hr; + + if (FAILED(hr = d3d12_swapchain_create_vulkan_swapchain(swapchain))) + { + ERR("Failed to recreate Vulkan swapchain, hr %#x.\n", hr); + return hr; + } + + if ((vr = d3d12_swapchain_acquire_next_image(swapchain)) < 0) + ERR("Failed to acquire Vulkan image after recreating swapchain, vr %d.\n", vr); + + return hresult_from_vk_result(vr); +} + static inline struct d3d12_swapchain *d3d12_swapchain_from_IDXGISwapChain3(IDXGISwapChain3 *iface) { return CONTAINING_RECORD(iface, struct d3d12_swapchain, IDXGISwapChain3_iface); @@ -1811,7 +1825,6 @@ static HRESULT STDMETHODCALLTYPE d3d12_swapchain_ResizeBuffers(IDXGISwapChain3 * DXGI_SWAP_CHAIN_DESC1 *desc, new_desc; unsigned int i; ULONG refcount; - HRESULT hr;
TRACE("iface %p, buffer_count %u, width %u, height %u, format %s, flags %#x.\n", iface, buffer_count, width, height, debug_dxgi_format(format), flags); @@ -1864,13 +1877,7 @@ static HRESULT STDMETHODCALLTYPE d3d12_swapchain_ResizeBuffers(IDXGISwapChain3 *
d3d12_swapchain_destroy_buffers(swapchain, TRUE); swapchain->desc = new_desc; - if (FAILED(hr = d3d12_swapchain_create_vulkan_swapchain(swapchain))) - { - ERR("Failed to recreate Vulkan swapchain, hr %#x.\n", hr); - return hr; - } - - return d3d12_swapchain_acquire_next_image(swapchain); + return d3d12_swapchain_recreate_vulkan_swapchain(swapchain); }
static HRESULT STDMETHODCALLTYPE d3d12_swapchain_ResizeTarget(IDXGISwapChain3 *iface, @@ -1971,7 +1978,6 @@ static HRESULT d3d12_swapchain_set_sync_interval(struct d3d12_swapchain *swapcha unsigned int sync_interval) { VkPresentModeKHR present_mode; - HRESULT hr;
switch (sync_interval) { @@ -2011,16 +2017,8 @@ static HRESULT d3d12_swapchain_set_sync_interval(struct d3d12_swapchain *swapcha }
d3d12_swapchain_destroy_buffers(swapchain, FALSE); - swapchain->present_mode = present_mode; - - if (FAILED(hr = d3d12_swapchain_create_vulkan_swapchain(swapchain))) - { - ERR("Failed to recreate Vulkan swapchain, hr %#x.\n", hr); - return hr; - } - - return d3d12_swapchain_acquire_next_image(swapchain); + return d3d12_swapchain_recreate_vulkan_swapchain(swapchain); }
static VkResult d3d12_swapchain_queue_present(struct d3d12_swapchain *swapchain, VkQueue vk_queue) @@ -2116,13 +2114,7 @@ static HRESULT STDMETHODCALLTYPE d3d12_swapchain_Present1(IDXGISwapChain3 *iface TRACE("Recreating Vulkan swapchain.\n");
d3d12_swapchain_destroy_buffers(swapchain, FALSE); - if (FAILED(hr = d3d12_swapchain_create_vulkan_swapchain(swapchain))) - { - ERR("Failed to recreate Vulkan swapchain, hr %#x.\n", hr); - return hr; - } - - if (FAILED(hr = d3d12_swapchain_acquire_next_image(swapchain))) + if (FAILED(hr = d3d12_swapchain_recreate_vulkan_swapchain(swapchain))) return hr;
if (!(vk_queue = vkd3d_acquire_vk_queue(swapchain->command_queue))) @@ -2143,7 +2135,8 @@ static HRESULT STDMETHODCALLTYPE d3d12_swapchain_Present1(IDXGISwapChain3 *iface return hresult_from_vk_result(vr); }
- return d3d12_swapchain_acquire_next_image(swapchain); + vr = d3d12_swapchain_acquire_next_image(swapchain); + return hresult_from_vk_result(vr); }
static BOOL STDMETHODCALLTYPE d3d12_swapchain_IsTemporaryMonoSupported(IDXGISwapChain3 *iface) @@ -2575,11 +2568,10 @@ static HRESULT d3d12_swapchain_init(struct d3d12_swapchain *swapchain, IWineDXGI } swapchain->vk_fence = vk_fence;
- if (FAILED(hr = d3d12_swapchain_acquire_next_image(swapchain))) + if ((vr = d3d12_swapchain_acquire_next_image(swapchain)) < 0) { - WARN("Failed to acquire Vulkan image, hr %#x.\n", hr); d3d12_swapchain_destroy(swapchain); - return hr; + return hresult_from_vk_result(vr); }
IWineDXGIFactory_AddRef(swapchain->factory = factory);
Hi,
While running your changed tests on Windows, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=48527
Your paranoid android.
=== debian9 (build log) ===
error: patch failed: dlls/dxgi/swapchain.c:1067 error: patch failed: dlls/dxgi/swapchain.c:1422 Task: Patch failed to apply
=== debian9 (build log) ===
error: patch failed: dlls/dxgi/swapchain.c:1067 error: patch failed: dlls/dxgi/swapchain.c:1422 Task: Patch failed to apply