dxgi: Factor out dxgi_validate_swapchain_desc().
Signed-off-by: Józef Kucia <jkucia@codeweavers.com> Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
d1bc257ad8
commit
e36af9284f
|
@ -182,6 +182,8 @@ HRESULT d3d12_swapchain_create(IWineDXGIFactory *factory, ID3D12CommandQueue *qu
|
|||
const DXGI_SWAP_CHAIN_DESC1 *swapchain_desc, const DXGI_SWAP_CHAIN_FULLSCREEN_DESC *fullscreen_desc,
|
||||
IDXGISwapChain1 **swapchain) DECLSPEC_HIDDEN;
|
||||
|
||||
BOOL dxgi_validate_swapchain_desc(const DXGI_SWAP_CHAIN_DESC1 *desc) DECLSPEC_HIDDEN;
|
||||
|
||||
/* IDXGISurface */
|
||||
struct dxgi_surface
|
||||
{
|
||||
|
|
|
@ -251,7 +251,6 @@ static HRESULT STDMETHODCALLTYPE dxgi_factory_CreateSwapChainForHwnd(IWineDXGIFa
|
|||
IDXGIOutput *output, IDXGISwapChain1 **swapchain)
|
||||
{
|
||||
ID3D12CommandQueue *command_queue;
|
||||
unsigned int min_buffer_count;
|
||||
IWineDXGIDevice *dxgi_device;
|
||||
HRESULT hr;
|
||||
|
||||
|
@ -270,35 +269,8 @@ static HRESULT STDMETHODCALLTYPE dxgi_factory_CreateSwapChainForHwnd(IWineDXGIFa
|
|||
return DXGI_ERROR_UNSUPPORTED;
|
||||
}
|
||||
|
||||
switch (desc->SwapEffect)
|
||||
{
|
||||
case DXGI_SWAP_EFFECT_DISCARD:
|
||||
case DXGI_SWAP_EFFECT_SEQUENTIAL:
|
||||
min_buffer_count = 1;
|
||||
break;
|
||||
|
||||
case DXGI_SWAP_EFFECT_FLIP_DISCARD:
|
||||
case DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL:
|
||||
min_buffer_count = 2;
|
||||
|
||||
if (desc->SampleDesc.Count != 1 || desc->SampleDesc.Quality)
|
||||
{
|
||||
WARN("Invalid sample desc %u, %u for swap effect %#x.\n",
|
||||
desc->SampleDesc.Count, desc->SampleDesc.Quality, desc->SwapEffect);
|
||||
if (!dxgi_validate_swapchain_desc(desc))
|
||||
return DXGI_ERROR_INVALID_CALL;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
WARN("Invalid swap effect %u used.\n", desc->SwapEffect);
|
||||
return DXGI_ERROR_INVALID_CALL;
|
||||
}
|
||||
|
||||
if (desc->BufferCount < min_buffer_count || desc->BufferCount > DXGI_MAX_SWAP_CHAIN_BUFFERS)
|
||||
{
|
||||
WARN("BufferCount is %u.\n", desc->BufferCount);
|
||||
return DXGI_ERROR_INVALID_CALL;
|
||||
}
|
||||
|
||||
if (output)
|
||||
FIXME("Ignoring output %p.\n", output);
|
||||
|
|
|
@ -55,6 +55,43 @@ static DXGI_SWAP_EFFECT dxgi_swap_effect_from_wined3d(enum wined3d_swap_effect s
|
|||
}
|
||||
}
|
||||
|
||||
BOOL dxgi_validate_swapchain_desc(const DXGI_SWAP_CHAIN_DESC1 *desc)
|
||||
{
|
||||
unsigned int min_buffer_count;
|
||||
|
||||
switch (desc->SwapEffect)
|
||||
{
|
||||
case DXGI_SWAP_EFFECT_DISCARD:
|
||||
case DXGI_SWAP_EFFECT_SEQUENTIAL:
|
||||
min_buffer_count = 1;
|
||||
break;
|
||||
|
||||
case DXGI_SWAP_EFFECT_FLIP_DISCARD:
|
||||
case DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL:
|
||||
min_buffer_count = 2;
|
||||
|
||||
if (desc->SampleDesc.Count != 1 || desc->SampleDesc.Quality)
|
||||
{
|
||||
WARN("Invalid sample desc %u, %u for swap effect %#x.\n",
|
||||
desc->SampleDesc.Count, desc->SampleDesc.Quality, desc->SwapEffect);
|
||||
return FALSE;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
WARN("Invalid swap effect %u used.\n", desc->SwapEffect);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (desc->BufferCount < min_buffer_count || desc->BufferCount > DXGI_MAX_SWAP_CHAIN_BUFFERS)
|
||||
{
|
||||
WARN("BufferCount is %u.\n", desc->BufferCount);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static inline struct d3d11_swapchain *d3d11_swapchain_from_IDXGISwapChain1(IDXGISwapChain1 *iface)
|
||||
{
|
||||
return CONTAINING_RECORD(iface, struct d3d11_swapchain, IDXGISwapChain1_iface);
|
||||
|
|
Loading…
Reference in New Issue