=?UTF-8?Q?J=C3=B3zef=20Kucia=20?=: dxgi: Validate swapchain desc in d3d12_swapchain_ResizeBuffers().
Alexandre Julliard
julliard at winehq.org
Tue Sep 18 15:14:31 CDT 2018
Module: wine
Branch: master
Commit: a53681829becdea71376b94e0964950546ac9595
URL: https://source.winehq.org/git/wine.git/?a=commit;h=a53681829becdea71376b94e0964950546ac9595
Author: Józef Kucia <jkucia at codeweavers.com>
Date: Tue Sep 18 16:06:01 2018 +0200
dxgi: Validate swapchain desc in d3d12_swapchain_ResizeBuffers().
Signed-off-by: Józef Kucia <jkucia at codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
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 57d6b24..5d2cb4a 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);
More information about the wine-cvs
mailing list