d3d9: Introduce a helper function to create a wined3d_swapchain_desc from D3DPRESENT_PARAMETERS.

This commit is contained in:
Henri Verbeet 2012-07-03 12:59:39 +02:00 committed by Alexandre Julliard
parent 18126eeb4f
commit 003ab4d3e0

View file

@ -181,6 +181,27 @@ static UINT vertex_count_from_primitive_count(D3DPRIMITIVETYPE primitive_type, U
}
}
static void wined3d_swapchain_desc_from_present_parameters(struct wined3d_swapchain_desc *swapchain_desc,
const D3DPRESENT_PARAMETERS *present_parameters)
{
swapchain_desc->backbuffer_width = present_parameters->BackBufferWidth;
swapchain_desc->backbuffer_height = present_parameters->BackBufferHeight;
swapchain_desc->backbuffer_format = wined3dformat_from_d3dformat(present_parameters->BackBufferFormat);
swapchain_desc->backbuffer_count = max(1, present_parameters->BackBufferCount);
swapchain_desc->multisample_type = present_parameters->MultiSampleType;
swapchain_desc->multisample_quality = present_parameters->MultiSampleQuality;
swapchain_desc->swap_effect = present_parameters->SwapEffect;
swapchain_desc->device_window = present_parameters->hDeviceWindow;
swapchain_desc->windowed = present_parameters->Windowed;
swapchain_desc->enable_auto_depth_stencil = present_parameters->EnableAutoDepthStencil;
swapchain_desc->auto_depth_stencil_format
= wined3dformat_from_d3dformat(present_parameters->AutoDepthStencilFormat);
swapchain_desc->flags = present_parameters->Flags;
swapchain_desc->refresh_rate = present_parameters->FullScreen_RefreshRateInHz;
swapchain_desc->swap_interval = present_parameters->PresentationInterval;
swapchain_desc->auto_restore_display_mode = TRUE;
}
static inline struct d3d9_device *impl_from_IDirect3DDevice9Ex(IDirect3DDevice9Ex *iface)
{
return CONTAINING_RECORD(iface, struct d3d9_device, IDirect3DDevice9Ex_iface);
@ -453,22 +474,7 @@ static HRESULT WINAPI DECLSPEC_HOTPATCH d3d9_device_CreateAdditionalSwapChain(ID
TRACE("iface %p, present_parameters %p, swapchain %p.\n",
iface, present_parameters, swapchain);
desc.backbuffer_width = present_parameters->BackBufferWidth;
desc.backbuffer_height = present_parameters->BackBufferHeight;
desc.backbuffer_format = wined3dformat_from_d3dformat(present_parameters->BackBufferFormat);
desc.backbuffer_count = max(1, present_parameters->BackBufferCount);
desc.multisample_type = present_parameters->MultiSampleType;
desc.multisample_quality = present_parameters->MultiSampleQuality;
desc.swap_effect = present_parameters->SwapEffect;
desc.device_window = present_parameters->hDeviceWindow;
desc.windowed = present_parameters->Windowed;
desc.enable_auto_depth_stencil = present_parameters->EnableAutoDepthStencil;
desc.auto_depth_stencil_format = wined3dformat_from_d3dformat(present_parameters->AutoDepthStencilFormat);
desc.flags = present_parameters->Flags;
desc.refresh_rate = present_parameters->FullScreen_RefreshRateInHz;
desc.swap_interval = present_parameters->PresentationInterval;
desc.auto_restore_display_mode = TRUE;
wined3d_swapchain_desc_from_present_parameters(&desc, present_parameters);
if (SUCCEEDED(hr = d3d9_swapchain_create(device, &desc, &object)))
*swapchain = &object->IDirect3DSwapChain9_iface;
@ -569,38 +575,13 @@ static HRESULT WINAPI DECLSPEC_HOTPATCH d3d9_device_Reset(IDirect3DDevice9Ex *if
TRACE("iface %p, present_parameters %p.\n", iface, present_parameters);
/* Reset states that hold a COM object. WineD3D holds an internal reference to set objects, because
* such objects can still be used for rendering after their external d3d9 object has been destroyed.
* These objects must not be enumerated. Unsetting them tells WineD3D that the application will not
* make use of the hidden reference and destroys the objects.
*
* Unsetting them is no problem, because the states are supposed to be reset anyway. If the validation
* below fails, the device is considered "lost", and _Reset and _Release are the only allowed calls
*/
wined3d_mutex_lock();
swapchain_desc.backbuffer_width = present_parameters->BackBufferWidth;
swapchain_desc.backbuffer_height = present_parameters->BackBufferHeight;
swapchain_desc.backbuffer_format = wined3dformat_from_d3dformat(present_parameters->BackBufferFormat);
swapchain_desc.backbuffer_count = max(1, present_parameters->BackBufferCount);
swapchain_desc.multisample_type = present_parameters->MultiSampleType;
swapchain_desc.multisample_quality = present_parameters->MultiSampleQuality;
swapchain_desc.swap_effect = present_parameters->SwapEffect;
swapchain_desc.device_window = present_parameters->hDeviceWindow;
swapchain_desc.windowed = present_parameters->Windowed;
swapchain_desc.enable_auto_depth_stencil = present_parameters->EnableAutoDepthStencil;
swapchain_desc.auto_depth_stencil_format = wined3dformat_from_d3dformat(present_parameters->AutoDepthStencilFormat);
swapchain_desc.flags = present_parameters->Flags;
swapchain_desc.refresh_rate = present_parameters->FullScreen_RefreshRateInHz;
swapchain_desc.swap_interval = present_parameters->PresentationInterval;
swapchain_desc.auto_restore_display_mode = TRUE;
wined3d_swapchain_desc_from_present_parameters(&swapchain_desc, present_parameters);
hr = wined3d_device_reset(device->wined3d_device, &swapchain_desc, reset_enum_callback);
if (FAILED(hr))
device->not_reset = TRUE;
else
device->not_reset = FALSE;
wined3d_mutex_unlock();
return hr;
@ -3426,22 +3407,7 @@ HRESULT device_init(struct d3d9_device *device, struct d3d9 *parent, struct wine
for (i = 0; i < count; ++i)
{
swapchain_desc[i].backbuffer_width = parameters[i].BackBufferWidth;
swapchain_desc[i].backbuffer_height = parameters[i].BackBufferHeight;
swapchain_desc[i].backbuffer_format = wined3dformat_from_d3dformat(parameters[i].BackBufferFormat);
swapchain_desc[i].backbuffer_count = max(1, parameters[i].BackBufferCount);
swapchain_desc[i].multisample_type = parameters[i].MultiSampleType;
swapchain_desc[i].multisample_quality = parameters[i].MultiSampleQuality;
swapchain_desc[i].swap_effect = parameters[i].SwapEffect;
swapchain_desc[i].device_window = parameters[i].hDeviceWindow;
swapchain_desc[i].windowed = parameters[i].Windowed;
swapchain_desc[i].enable_auto_depth_stencil = parameters[i].EnableAutoDepthStencil;
swapchain_desc[i].auto_depth_stencil_format =
wined3dformat_from_d3dformat(parameters[i].AutoDepthStencilFormat);
swapchain_desc[i].flags = parameters[i].Flags;
swapchain_desc[i].refresh_rate = parameters[i].FullScreen_RefreshRateInHz;
swapchain_desc[i].swap_interval = parameters[i].PresentationInterval;
swapchain_desc[i].auto_restore_display_mode = TRUE;
wined3d_swapchain_desc_from_present_parameters(&swapchain_desc[i], &parameters[i]);
}
hr = wined3d_device_init_3d(device->wined3d_device, swapchain_desc);