mirror of
git://source.winehq.org/git/wine.git
synced 2024-09-06 07:00:41 +00:00
d3d9: Pass a wined3d_swapchain_desc structure to swapchain_init().
This commit is contained in:
parent
e97dc9f33d
commit
2457d34314
|
@ -184,7 +184,7 @@ struct d3d9_swapchain
|
|||
IDirect3DDevice9Ex *parent_device;
|
||||
};
|
||||
|
||||
HRESULT d3d9_swapchain_create(struct d3d9_device *device, D3DPRESENT_PARAMETERS *present_parameters,
|
||||
HRESULT d3d9_swapchain_create(struct d3d9_device *device, struct wined3d_swapchain_desc *desc,
|
||||
struct d3d9_swapchain **swapchain) DECLSPEC_HIDDEN;
|
||||
|
||||
struct d3d9_surface
|
||||
|
|
|
@ -446,15 +446,47 @@ static HRESULT WINAPI DECLSPEC_HOTPATCH d3d9_device_CreateAdditionalSwapChain(ID
|
|||
D3DPRESENT_PARAMETERS *present_parameters, IDirect3DSwapChain9 **swapchain)
|
||||
{
|
||||
struct d3d9_device *device = impl_from_IDirect3DDevice9Ex(iface);
|
||||
struct wined3d_swapchain_desc desc;
|
||||
struct d3d9_swapchain *object;
|
||||
HRESULT hr;
|
||||
|
||||
TRACE("iface %p, present_parameters %p, swapchain %p.\n",
|
||||
iface, present_parameters, swapchain);
|
||||
|
||||
if (SUCCEEDED(hr = d3d9_swapchain_create(device, present_parameters, &object)))
|
||||
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;
|
||||
|
||||
if (SUCCEEDED(hr = d3d9_swapchain_create(device, &desc, &object)))
|
||||
*swapchain = &object->IDirect3DSwapChain9_iface;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -550,7 +582,7 @@ static HRESULT WINAPI DECLSPEC_HOTPATCH d3d9_device_Reset(IDirect3DDevice9Ex *if
|
|||
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 = present_parameters->BackBufferCount;
|
||||
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;
|
||||
|
@ -3274,29 +3306,12 @@ static HRESULT CDECL device_parent_create_swapchain(struct wined3d_device_parent
|
|||
struct wined3d_swapchain_desc *desc, struct wined3d_swapchain **swapchain)
|
||||
{
|
||||
struct d3d9_device *device = device_from_device_parent(device_parent);
|
||||
D3DPRESENT_PARAMETERS local_parameters;
|
||||
struct d3d9_swapchain *d3d_swapchain;
|
||||
HRESULT hr;
|
||||
|
||||
TRACE("device_parent %p, desc %p, swapchain %p\n", device_parent, desc, swapchain);
|
||||
|
||||
/* Copy the presentation parameters */
|
||||
local_parameters.BackBufferWidth = desc->backbuffer_width;
|
||||
local_parameters.BackBufferHeight = desc->backbuffer_height;
|
||||
local_parameters.BackBufferFormat = d3dformat_from_wined3dformat(desc->backbuffer_format);
|
||||
local_parameters.BackBufferCount = desc->backbuffer_count;
|
||||
local_parameters.MultiSampleType = desc->multisample_type;
|
||||
local_parameters.MultiSampleQuality = desc->multisample_quality;
|
||||
local_parameters.SwapEffect = desc->swap_effect;
|
||||
local_parameters.hDeviceWindow = desc->device_window;
|
||||
local_parameters.Windowed = desc->windowed;
|
||||
local_parameters.EnableAutoDepthStencil = desc->enable_auto_depth_stencil;
|
||||
local_parameters.AutoDepthStencilFormat = d3dformat_from_wined3dformat(desc->auto_depth_stencil_format);
|
||||
local_parameters.Flags = desc->flags;
|
||||
local_parameters.FullScreen_RefreshRateInHz = desc->refresh_rate;
|
||||
local_parameters.PresentationInterval = desc->swap_interval;
|
||||
|
||||
hr = d3d9_swapchain_create(device, &local_parameters, &d3d_swapchain);
|
||||
hr = d3d9_swapchain_create(device, desc, &d3d_swapchain);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
WARN("Failed to create swapchain, hr %#x.\n", hr);
|
||||
|
@ -3308,22 +3323,6 @@ static HRESULT CDECL device_parent_create_swapchain(struct wined3d_device_parent
|
|||
wined3d_swapchain_incref(*swapchain);
|
||||
IDirect3DSwapChain9_Release(&d3d_swapchain->IDirect3DSwapChain9_iface);
|
||||
|
||||
/* Copy back the presentation parameters */
|
||||
desc->backbuffer_width = local_parameters.BackBufferWidth;
|
||||
desc->backbuffer_height = local_parameters.BackBufferHeight;
|
||||
desc->backbuffer_format = wined3dformat_from_d3dformat(local_parameters.BackBufferFormat);
|
||||
desc->backbuffer_count = local_parameters.BackBufferCount;
|
||||
desc->multisample_type = local_parameters.MultiSampleType;
|
||||
desc->multisample_quality = local_parameters.MultiSampleQuality;
|
||||
desc->swap_effect = local_parameters.SwapEffect;
|
||||
desc->device_window = local_parameters.hDeviceWindow;
|
||||
desc->windowed = local_parameters.Windowed;
|
||||
desc->enable_auto_depth_stencil = local_parameters.EnableAutoDepthStencil;
|
||||
desc->auto_depth_stencil_format = wined3dformat_from_d3dformat(local_parameters.AutoDepthStencilFormat);
|
||||
desc->flags = local_parameters.Flags;
|
||||
desc->refresh_rate = local_parameters.FullScreen_RefreshRateInHz;
|
||||
desc->swap_interval = local_parameters.PresentationInterval;
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
||||
|
@ -3430,7 +3429,7 @@ HRESULT device_init(struct d3d9_device *device, struct d3d9 *parent, struct wine
|
|||
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 = parameters[i].BackBufferCount;
|
||||
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;
|
||||
|
|
|
@ -260,51 +260,19 @@ static const struct wined3d_parent_ops d3d9_swapchain_wined3d_parent_ops =
|
|||
};
|
||||
|
||||
static HRESULT swapchain_init(struct d3d9_swapchain *swapchain, struct d3d9_device *device,
|
||||
D3DPRESENT_PARAMETERS *present_parameters)
|
||||
struct wined3d_swapchain_desc *desc)
|
||||
{
|
||||
struct wined3d_swapchain_desc desc;
|
||||
HRESULT hr;
|
||||
|
||||
swapchain->refcount = 1;
|
||||
swapchain->IDirect3DSwapChain9_iface.lpVtbl = &d3d9_swapchain_vtbl;
|
||||
|
||||
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_mutex_lock();
|
||||
hr = wined3d_swapchain_create(device->wined3d_device, &desc,
|
||||
hr = wined3d_swapchain_create(device->wined3d_device, desc,
|
||||
WINED3D_SURFACE_TYPE_OPENGL, swapchain, &d3d9_swapchain_wined3d_parent_ops,
|
||||
&swapchain->wined3d_swapchain);
|
||||
wined3d_mutex_unlock();
|
||||
|
||||
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;
|
||||
|
||||
if (FAILED(hr))
|
||||
{
|
||||
WARN("Failed to create wined3d swapchain, hr %#x.\n", hr);
|
||||
|
@ -317,7 +285,7 @@ static HRESULT swapchain_init(struct d3d9_swapchain *swapchain, struct d3d9_devi
|
|||
return D3D_OK;
|
||||
}
|
||||
|
||||
HRESULT d3d9_swapchain_create(struct d3d9_device *device, D3DPRESENT_PARAMETERS *present_parameters,
|
||||
HRESULT d3d9_swapchain_create(struct d3d9_device *device, struct wined3d_swapchain_desc *desc,
|
||||
struct d3d9_swapchain **swapchain)
|
||||
{
|
||||
struct d3d9_swapchain *object;
|
||||
|
@ -329,7 +297,7 @@ HRESULT d3d9_swapchain_create(struct d3d9_device *device, D3DPRESENT_PARAMETERS
|
|||
return E_OUTOFMEMORY;
|
||||
}
|
||||
|
||||
if (FAILED(hr = swapchain_init(object, device, present_parameters)))
|
||||
if (FAILED(hr = swapchain_init(object, device, desc)))
|
||||
{
|
||||
WARN("Failed to initialize swapchain, hr %#x.\n", hr);
|
||||
HeapFree(GetProcessHeap(), 0, object);
|
||||
|
|
Loading…
Reference in a new issue