[PATCH 5/8] dxgi: Validate swapchain desc in d3d12_swapchain_ResizeBuffers().

Józef Kucia jkucia at codeweavers.com
Tue Sep 18 09:06:01 CDT 2018


Signed-off-by: Józef Kucia <jkucia at codeweavers.com>
---
 dlls/dxgi/swapchain.c | 28 +++++++++++++++-------------
 1 file changed, 15 insertions(+), 13 deletions(-)

diff --git a/dlls/dxgi/swapchain.c b/dlls/dxgi/swapchain.c
index 57d6b245c452..5d2cb4aa535a 100644
--- a/dlls/dxgi/swapchain.c
+++ b/dlls/dxgi/swapchain.c
@@ -1786,7 +1786,7 @@ static HRESULT STDMETHODCALLTYPE d3d12_swapchain_ResizeBuffers(IDXGISwapChain3 *
         UINT buffer_count, UINT width, UINT height, DXGI_FORMAT format, UINT flags)
 {
     struct d3d12_swapchain *swapchain = d3d12_swapchain_from_IDXGISwapChain3(iface);
-    DXGI_SWAP_CHAIN_DESC1 *desc;
+    DXGI_SWAP_CHAIN_DESC1 *desc, new_desc;
     unsigned int i;
     ULONG refcount;
     HRESULT hr;
@@ -1808,9 +1808,10 @@ static HRESULT STDMETHODCALLTYPE d3d12_swapchain_ResizeBuffers(IDXGISwapChain3 *
     }
 
     desc = &swapchain->desc;
+    new_desc = swapchain->desc;
 
-    if (!buffer_count)
-        buffer_count = desc->BufferCount;
+    if (buffer_count)
+        new_desc.BufferCount = buffer_count;
     if (!width || !height)
     {
         RECT client_rect;
@@ -1826,20 +1827,21 @@ static HRESULT STDMETHODCALLTYPE d3d12_swapchain_ResizeBuffers(IDXGISwapChain3 *
         if (!height)
             height = client_rect.bottom;
     }
-    if (!format)
-        format = desc->Format;
+    new_desc.Width = width;
+    new_desc.Height = height;
 
-    if (desc->Width == width && desc->Height == height
-            && desc->Format == format && desc->BufferCount == buffer_count)
-        return S_OK;
+    if (format)
+        new_desc.Format = format;
 
-    d3d12_swapchain_destroy_buffers(swapchain);
+    if (!dxgi_validate_swapchain_desc(&new_desc))
+        return DXGI_ERROR_INVALID_CALL;
 
-    desc->Width = width;
-    desc->Height = height;
-    desc->Format = format;
-    desc->BufferCount = buffer_count;
+    if (desc->Width == new_desc.Width && desc->Height == new_desc.Height
+            && desc->Format == new_desc.Format && desc->BufferCount == new_desc.BufferCount)
+        return S_OK;
 
+    d3d12_swapchain_destroy_buffers(swapchain);
+    swapchain->desc = new_desc;
     if (FAILED(hr = d3d12_swapchain_create_vulkan_swapchain(swapchain)))
     {
         ERR("Failed to recreate Vulkan swapchain, hr %#x.\n", hr);
-- 
2.16.4




More information about the wine-devel mailing list