mirror of
git://source.winehq.org/git/wine.git
synced 2024-11-05 18:01:34 +00:00
dxgi: Factor out d3d11_swapchain_create() function.
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
eae33d5595
commit
02c49ea3c0
3 changed files with 70 additions and 51 deletions
|
@ -173,6 +173,8 @@ struct d3d11_swapchain
|
|||
IDXGIOutput *target;
|
||||
};
|
||||
|
||||
HRESULT d3d11_swapchain_create(IWineDXGIDevice *device, HWND window, const DXGI_SWAP_CHAIN_DESC1 *swapchain_desc,
|
||||
const DXGI_SWAP_CHAIN_FULLSCREEN_DESC *fullscreen_desc, IDXGISwapChain1 **swapchain) DECLSPEC_HIDDEN;
|
||||
HRESULT d3d11_swapchain_init(struct d3d11_swapchain *swapchain, struct dxgi_device *device,
|
||||
struct wined3d_swapchain_desc *desc, BOOL implicit) DECLSPEC_HIDDEN;
|
||||
|
||||
|
|
|
@ -250,8 +250,6 @@ static HRESULT STDMETHODCALLTYPE dxgi_factory_CreateSwapChainForHwnd(IWineDXGIFa
|
|||
const DXGI_SWAP_CHAIN_FULLSCREEN_DESC *fullscreen_desc,
|
||||
IDXGIOutput *output, IDXGISwapChain1 **swapchain)
|
||||
{
|
||||
struct wined3d_swapchain *wined3d_swapchain;
|
||||
struct wined3d_swapchain_desc wined3d_desc;
|
||||
unsigned int min_buffer_count;
|
||||
IWineDXGIDevice *dxgi_device;
|
||||
HRESULT hr;
|
||||
|
@ -275,22 +273,12 @@ static HRESULT STDMETHODCALLTYPE dxgi_factory_CreateSwapChainForHwnd(IWineDXGIFa
|
|||
switch (swapchain_desc->SwapEffect)
|
||||
{
|
||||
case DXGI_SWAP_EFFECT_DISCARD:
|
||||
wined3d_desc.swap_effect = WINED3D_SWAP_EFFECT_DISCARD;
|
||||
min_buffer_count = 1;
|
||||
break;
|
||||
|
||||
case DXGI_SWAP_EFFECT_SEQUENTIAL:
|
||||
wined3d_desc.swap_effect = WINED3D_SWAP_EFFECT_SEQUENTIAL;
|
||||
min_buffer_count = 1;
|
||||
break;
|
||||
|
||||
case DXGI_SWAP_EFFECT_FLIP_DISCARD:
|
||||
wined3d_desc.swap_effect = WINED3D_SWAP_EFFECT_FLIP_DISCARD;
|
||||
min_buffer_count = 2;
|
||||
break;
|
||||
|
||||
case DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL:
|
||||
wined3d_desc.swap_effect = WINED3D_SWAP_EFFECT_FLIP_SEQUENTIAL;
|
||||
min_buffer_count = 2;
|
||||
break;
|
||||
|
||||
|
@ -305,49 +293,15 @@ static HRESULT STDMETHODCALLTYPE dxgi_factory_CreateSwapChainForHwnd(IWineDXGIFa
|
|||
return DXGI_ERROR_INVALID_CALL;
|
||||
}
|
||||
|
||||
if (FAILED(hr = IUnknown_QueryInterface(device, &IID_IWineDXGIDevice, (void **)&dxgi_device)))
|
||||
if (SUCCEEDED(IUnknown_QueryInterface(device, &IID_IWineDXGIDevice, (void **)&dxgi_device)))
|
||||
{
|
||||
ERR("This is not the device we're looking for\n");
|
||||
hr = d3d11_swapchain_create(dxgi_device, window, swapchain_desc, fullscreen_desc, swapchain);
|
||||
IWineDXGIDevice_Release(dxgi_device);
|
||||
return hr;
|
||||
}
|
||||
|
||||
if (swapchain_desc->Scaling != DXGI_SCALING_STRETCH)
|
||||
FIXME("Ignoring scaling %#x.\n", swapchain_desc->Scaling);
|
||||
if (swapchain_desc->AlphaMode != DXGI_ALPHA_MODE_IGNORE)
|
||||
FIXME("Ignoring alpha mode %#x.\n", swapchain_desc->AlphaMode);
|
||||
if (fullscreen_desc && fullscreen_desc->ScanlineOrdering)
|
||||
FIXME("Unhandled scanline ordering %#x.\n", fullscreen_desc->ScanlineOrdering);
|
||||
if (fullscreen_desc && fullscreen_desc->Scaling)
|
||||
FIXME("Unhandled mode scaling %#x.\n", fullscreen_desc->Scaling);
|
||||
|
||||
wined3d_desc.backbuffer_width = swapchain_desc->Width;
|
||||
wined3d_desc.backbuffer_height = swapchain_desc->Height;
|
||||
wined3d_desc.backbuffer_format = wined3dformat_from_dxgi_format(swapchain_desc->Format);
|
||||
wined3d_desc.backbuffer_count = swapchain_desc->BufferCount;
|
||||
wined3d_desc.backbuffer_usage = wined3d_usage_from_dxgi_usage(swapchain_desc->BufferUsage);
|
||||
wined3d_sample_desc_from_dxgi(&wined3d_desc.multisample_type,
|
||||
&wined3d_desc.multisample_quality, &swapchain_desc->SampleDesc);
|
||||
wined3d_desc.device_window = window;
|
||||
wined3d_desc.windowed = fullscreen_desc ? fullscreen_desc->Windowed : TRUE;
|
||||
wined3d_desc.enable_auto_depth_stencil = FALSE;
|
||||
wined3d_desc.auto_depth_stencil_format = 0;
|
||||
wined3d_desc.flags = wined3d_swapchain_flags_from_dxgi(swapchain_desc->Flags);
|
||||
wined3d_desc.refresh_rate = fullscreen_desc ? dxgi_rational_to_uint(&fullscreen_desc->RefreshRate) : 0;
|
||||
wined3d_desc.auto_restore_display_mode = TRUE;
|
||||
|
||||
hr = IWineDXGIDevice_create_swapchain(dxgi_device, &wined3d_desc, FALSE, &wined3d_swapchain);
|
||||
IWineDXGIDevice_Release(dxgi_device);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
WARN("Failed to create swapchain, hr %#x.\n", hr);
|
||||
return hr;
|
||||
}
|
||||
|
||||
wined3d_mutex_lock();
|
||||
*swapchain = wined3d_swapchain_get_parent(wined3d_swapchain);
|
||||
wined3d_mutex_unlock();
|
||||
|
||||
return S_OK;
|
||||
ERR("This is not the device we're looking for.\n");
|
||||
return DXGI_ERROR_UNSUPPORTED;
|
||||
}
|
||||
|
||||
static HRESULT STDMETHODCALLTYPE dxgi_factory_CreateSwapChainForCoreWindow(IWineDXGIFactory *iface,
|
||||
|
|
|
@ -733,3 +733,66 @@ cleanup:
|
|||
IWineDXGIDevice_Release(swapchain->device);
|
||||
return hr;
|
||||
}
|
||||
|
||||
HRESULT d3d11_swapchain_create(IWineDXGIDevice *device, HWND window, const DXGI_SWAP_CHAIN_DESC1 *swapchain_desc,
|
||||
const DXGI_SWAP_CHAIN_FULLSCREEN_DESC *fullscreen_desc, IDXGISwapChain1 **swapchain)
|
||||
{
|
||||
struct wined3d_swapchain *wined3d_swapchain;
|
||||
struct wined3d_swapchain_desc wined3d_desc;
|
||||
HRESULT hr;
|
||||
|
||||
if (swapchain_desc->Scaling != DXGI_SCALING_STRETCH)
|
||||
FIXME("Ignoring scaling %#x.\n", swapchain_desc->Scaling);
|
||||
if (swapchain_desc->AlphaMode != DXGI_ALPHA_MODE_IGNORE)
|
||||
FIXME("Ignoring alpha mode %#x.\n", swapchain_desc->AlphaMode);
|
||||
if (fullscreen_desc && fullscreen_desc->ScanlineOrdering)
|
||||
FIXME("Unhandled scanline ordering %#x.\n", fullscreen_desc->ScanlineOrdering);
|
||||
if (fullscreen_desc && fullscreen_desc->Scaling)
|
||||
FIXME("Unhandled mode scaling %#x.\n", fullscreen_desc->Scaling);
|
||||
|
||||
switch (swapchain_desc->SwapEffect)
|
||||
{
|
||||
case DXGI_SWAP_EFFECT_DISCARD:
|
||||
wined3d_desc.swap_effect = WINED3D_SWAP_EFFECT_DISCARD;
|
||||
break;
|
||||
case DXGI_SWAP_EFFECT_SEQUENTIAL:
|
||||
wined3d_desc.swap_effect = WINED3D_SWAP_EFFECT_SEQUENTIAL;
|
||||
break;
|
||||
case DXGI_SWAP_EFFECT_FLIP_DISCARD:
|
||||
wined3d_desc.swap_effect = WINED3D_SWAP_EFFECT_FLIP_DISCARD;
|
||||
break;
|
||||
case DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL:
|
||||
wined3d_desc.swap_effect = WINED3D_SWAP_EFFECT_FLIP_SEQUENTIAL;
|
||||
break;
|
||||
default:
|
||||
WARN("Invalid swap effect %#x.\n", swapchain_desc->SwapEffect);
|
||||
return DXGI_ERROR_INVALID_CALL;
|
||||
}
|
||||
|
||||
wined3d_desc.backbuffer_width = swapchain_desc->Width;
|
||||
wined3d_desc.backbuffer_height = swapchain_desc->Height;
|
||||
wined3d_desc.backbuffer_format = wined3dformat_from_dxgi_format(swapchain_desc->Format);
|
||||
wined3d_desc.backbuffer_count = swapchain_desc->BufferCount;
|
||||
wined3d_desc.backbuffer_usage = wined3d_usage_from_dxgi_usage(swapchain_desc->BufferUsage);
|
||||
wined3d_sample_desc_from_dxgi(&wined3d_desc.multisample_type,
|
||||
&wined3d_desc.multisample_quality, &swapchain_desc->SampleDesc);
|
||||
wined3d_desc.device_window = window;
|
||||
wined3d_desc.windowed = fullscreen_desc ? fullscreen_desc->Windowed : TRUE;
|
||||
wined3d_desc.enable_auto_depth_stencil = FALSE;
|
||||
wined3d_desc.auto_depth_stencil_format = 0;
|
||||
wined3d_desc.flags = wined3d_swapchain_flags_from_dxgi(swapchain_desc->Flags);
|
||||
wined3d_desc.refresh_rate = fullscreen_desc ? dxgi_rational_to_uint(&fullscreen_desc->RefreshRate) : 0;
|
||||
wined3d_desc.auto_restore_display_mode = TRUE;
|
||||
|
||||
if (FAILED(hr = IWineDXGIDevice_create_swapchain(device, &wined3d_desc, FALSE, &wined3d_swapchain)))
|
||||
{
|
||||
WARN("Failed to create swapchain, hr %#x.\n", hr);
|
||||
return hr;
|
||||
}
|
||||
|
||||
wined3d_mutex_lock();
|
||||
*swapchain = wined3d_swapchain_get_parent(wined3d_swapchain);
|
||||
wined3d_mutex_unlock();
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue