Commit c98725cc authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

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

parent 003ab4d3
...@@ -39,17 +39,12 @@ ...@@ -39,17 +39,12 @@
#include "d3d9.h" #include "d3d9.h"
#include "wine/wined3d.h" #include "wine/wined3d.h"
/* ===========================================================================
Internal use
=========================================================================== */
extern HRESULT vdecl_convert_fvf(DWORD FVF, D3DVERTEXELEMENT9 **ppVertexElements) DECLSPEC_HIDDEN; extern HRESULT vdecl_convert_fvf(DWORD FVF, D3DVERTEXELEMENT9 **ppVertexElements) DECLSPEC_HIDDEN;
D3DFORMAT d3dformat_from_wined3dformat(enum wined3d_format_id format) DECLSPEC_HIDDEN; D3DFORMAT d3dformat_from_wined3dformat(enum wined3d_format_id format) DECLSPEC_HIDDEN;
enum wined3d_format_id wined3dformat_from_d3dformat(D3DFORMAT format) DECLSPEC_HIDDEN; enum wined3d_format_id wined3dformat_from_d3dformat(D3DFORMAT format) DECLSPEC_HIDDEN;
void present_parameters_from_wined3d_swapchain_desc(D3DPRESENT_PARAMETERS *present_parameters,
const struct wined3d_swapchain_desc *swapchain_desc) DECLSPEC_HIDDEN;
/* ===========================================================================
Macros
=========================================================================== */
/* Not nice, but it lets wined3d support different versions of directx */
#define WINECAPSTOD3D9CAPS(_pD3D9Caps, _pWineCaps) \ #define WINECAPSTOD3D9CAPS(_pD3D9Caps, _pWineCaps) \
_pD3D9Caps->DeviceType = (D3DDEVTYPE) _pWineCaps->DeviceType; \ _pD3D9Caps->DeviceType = (D3DDEVTYPE) _pWineCaps->DeviceType; \
_pD3D9Caps->AdapterOrdinal = _pWineCaps->AdapterOrdinal; \ _pD3D9Caps->AdapterOrdinal = _pWineCaps->AdapterOrdinal; \
......
...@@ -181,6 +181,26 @@ static UINT vertex_count_from_primitive_count(D3DPRIMITIVETYPE primitive_type, U ...@@ -181,6 +181,26 @@ static UINT vertex_count_from_primitive_count(D3DPRIMITIVETYPE primitive_type, U
} }
} }
void present_parameters_from_wined3d_swapchain_desc(D3DPRESENT_PARAMETERS *present_parameters,
const struct wined3d_swapchain_desc *swapchain_desc)
{
present_parameters->BackBufferWidth = swapchain_desc->backbuffer_width;
present_parameters->BackBufferHeight = swapchain_desc->backbuffer_height;
present_parameters->BackBufferFormat = d3dformat_from_wined3dformat(swapchain_desc->backbuffer_format);
present_parameters->BackBufferCount = swapchain_desc->backbuffer_count;
present_parameters->MultiSampleType = swapchain_desc->multisample_type;
present_parameters->MultiSampleQuality = swapchain_desc->multisample_quality;
present_parameters->SwapEffect = swapchain_desc->swap_effect;
present_parameters->hDeviceWindow = swapchain_desc->device_window;
present_parameters->Windowed = swapchain_desc->windowed;
present_parameters->EnableAutoDepthStencil = swapchain_desc->enable_auto_depth_stencil;
present_parameters->AutoDepthStencilFormat
= d3dformat_from_wined3dformat(swapchain_desc->auto_depth_stencil_format);
present_parameters->Flags = swapchain_desc->flags;
present_parameters->FullScreen_RefreshRateInHz = swapchain_desc->refresh_rate;
present_parameters->PresentationInterval = swapchain_desc->swap_interval;
}
static void wined3d_swapchain_desc_from_present_parameters(struct wined3d_swapchain_desc *swapchain_desc, static void wined3d_swapchain_desc_from_present_parameters(struct wined3d_swapchain_desc *swapchain_desc,
const D3DPRESENT_PARAMETERS *present_parameters) const D3DPRESENT_PARAMETERS *present_parameters)
{ {
...@@ -477,21 +497,7 @@ static HRESULT WINAPI DECLSPEC_HOTPATCH d3d9_device_CreateAdditionalSwapChain(ID ...@@ -477,21 +497,7 @@ static HRESULT WINAPI DECLSPEC_HOTPATCH d3d9_device_CreateAdditionalSwapChain(ID
wined3d_swapchain_desc_from_present_parameters(&desc, present_parameters); wined3d_swapchain_desc_from_present_parameters(&desc, present_parameters);
if (SUCCEEDED(hr = d3d9_swapchain_create(device, &desc, &object))) if (SUCCEEDED(hr = d3d9_swapchain_create(device, &desc, &object)))
*swapchain = &object->IDirect3DSwapChain9_iface; *swapchain = &object->IDirect3DSwapChain9_iface;
present_parameters_from_wined3d_swapchain_desc(present_parameters, &desc);
present_parameters->BackBufferWidth = desc.backbuffer_width;
present_parameters->BackBufferHeight = desc.backbuffer_height;
present_parameters->BackBufferFormat = d3dformat_from_wined3dformat(desc.backbuffer_format);
present_parameters->BackBufferCount = desc.backbuffer_count;
present_parameters->MultiSampleType = desc.multisample_type;
present_parameters->MultiSampleQuality = desc.multisample_quality;
present_parameters->SwapEffect = desc.swap_effect;
present_parameters->hDeviceWindow = desc.device_window;
present_parameters->Windowed = desc.windowed;
present_parameters->EnableAutoDepthStencil = desc.enable_auto_depth_stencil;
present_parameters->AutoDepthStencilFormat = d3dformat_from_wined3dformat(desc.auto_depth_stencil_format);
present_parameters->Flags = desc.flags;
present_parameters->FullScreen_RefreshRateInHz = desc.refresh_rate;
present_parameters->PresentationInterval = desc.swap_interval;
return hr; return hr;
} }
...@@ -3425,21 +3431,7 @@ HRESULT device_init(struct d3d9_device *device, struct d3d9 *parent, struct wine ...@@ -3425,21 +3431,7 @@ HRESULT device_init(struct d3d9_device *device, struct d3d9 *parent, struct wine
for (i = 0; i < count; ++i) for (i = 0; i < count; ++i)
{ {
parameters[i].BackBufferWidth = swapchain_desc[i].backbuffer_width; present_parameters_from_wined3d_swapchain_desc(&parameters[i], &swapchain_desc[i]);
parameters[i].BackBufferHeight = swapchain_desc[i].backbuffer_height;
parameters[i].BackBufferFormat = d3dformat_from_wined3dformat(swapchain_desc[i].backbuffer_format);
parameters[i].BackBufferCount = swapchain_desc[i].backbuffer_count;
parameters[i].MultiSampleType = swapchain_desc[i].multisample_type;
parameters[i].MultiSampleQuality = swapchain_desc[i].multisample_quality;
parameters[i].SwapEffect = swapchain_desc[i].swap_effect;
parameters[i].hDeviceWindow = swapchain_desc[i].device_window;
parameters[i].Windowed = swapchain_desc[i].windowed;
parameters[i].EnableAutoDepthStencil = swapchain_desc[i].enable_auto_depth_stencil;
parameters[i].AutoDepthStencilFormat =
d3dformat_from_wined3dformat(swapchain_desc[i].auto_depth_stencil_format);
parameters[i].Flags = swapchain_desc[i].flags;
parameters[i].FullScreen_RefreshRateInHz = swapchain_desc[i].refresh_rate;
parameters[i].PresentationInterval = swapchain_desc[i].swap_interval;
} }
HeapFree(GetProcessHeap(), 0, swapchain_desc); HeapFree(GetProcessHeap(), 0, swapchain_desc);
......
...@@ -215,21 +215,7 @@ static HRESULT WINAPI d3d9_swapchain_GetPresentParameters(IDirect3DSwapChain9 *i ...@@ -215,21 +215,7 @@ static HRESULT WINAPI d3d9_swapchain_GetPresentParameters(IDirect3DSwapChain9 *i
wined3d_mutex_lock(); wined3d_mutex_lock();
hr = wined3d_swapchain_get_desc(swapchain->wined3d_swapchain, &desc); hr = wined3d_swapchain_get_desc(swapchain->wined3d_swapchain, &desc);
wined3d_mutex_unlock(); wined3d_mutex_unlock();
present_parameters_from_wined3d_swapchain_desc(parameters, &desc);
parameters->BackBufferWidth = desc.backbuffer_width;
parameters->BackBufferHeight = desc.backbuffer_height;
parameters->BackBufferFormat = d3dformat_from_wined3dformat(desc.backbuffer_format);
parameters->BackBufferCount = desc.backbuffer_count;
parameters->MultiSampleType = desc.multisample_type;
parameters->MultiSampleQuality = desc.multisample_quality;
parameters->SwapEffect = desc.swap_effect;
parameters->hDeviceWindow = desc.device_window;
parameters->Windowed = desc.windowed;
parameters->EnableAutoDepthStencil = desc.enable_auto_depth_stencil;
parameters->AutoDepthStencilFormat = d3dformat_from_wined3dformat(desc.auto_depth_stencil_format);
parameters->Flags = desc.flags;
parameters->FullScreen_RefreshRateInHz = desc.refresh_rate;
parameters->PresentationInterval = desc.swap_interval;
return hr; return hr;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment