Commit a8072e08 authored by Zhiyi Zhang's avatar Zhiyi Zhang Committed by Alexandre Julliard

wined3d: Pass a struct wined3d_adapter pointer to wined3d_device_create().

parent 70aeb7e4
......@@ -3658,8 +3658,10 @@ HRESULT device_init(struct d3d8_device *device, struct d3d8 *parent, struct wine
{
struct wined3d_swapchain_desc swapchain_desc;
struct wined3d_swapchain *wined3d_swapchain;
struct wined3d_adapter *wined3d_adapter;
struct d3d8_swapchain *d3d_swapchain;
struct wined3d_caps caps;
unsigned int output_idx;
HRESULT hr;
static const enum wined3d_feature_level feature_levels[] =
......@@ -3670,6 +3672,10 @@ HRESULT device_init(struct d3d8_device *device, struct d3d8 *parent, struct wine
WINED3D_FEATURE_LEVEL_5,
};
output_idx = adapter;
if (output_idx >= parent->wined3d_output_count)
return D3DERR_INVALIDCALL;
device->IDirect3DDevice8_iface.lpVtbl = &d3d8_device_vtbl;
device->device_parent.ops = &d3d8_wined3d_device_parent_ops;
device->ref = 1;
......@@ -3684,7 +3690,8 @@ HRESULT device_init(struct d3d8_device *device, struct d3d8 *parent, struct wine
if (!(flags & D3DCREATE_FPU_PRESERVE)) setup_fpu();
wined3d_mutex_lock();
if (FAILED(hr = wined3d_device_create(wined3d, adapter, device_type,
wined3d_adapter = wined3d_output_get_adapter(parent->wined3d_outputs[output_idx]);
if (FAILED(hr = wined3d_device_create(wined3d, wined3d_adapter, device_type,
focus_window, flags, 4, feature_levels, ARRAY_SIZE(feature_levels),
&device->device_parent, &device->wined3d_device)))
{
......
......@@ -4590,8 +4590,10 @@ HRESULT device_init(struct d3d9_device *device, struct d3d9 *parent, struct wine
D3DPRESENT_PARAMETERS *parameters, D3DDISPLAYMODEEX *mode)
{
struct wined3d_swapchain_desc *swapchain_desc;
struct wined3d_adapter *wined3d_adapter;
struct d3d9_swapchain *d3d_swapchain;
struct wined3d_caps caps;
unsigned int output_idx;
unsigned i, count = 1;
HRESULT hr;
......@@ -4606,6 +4608,10 @@ HRESULT device_init(struct d3d9_device *device, struct d3d9 *parent, struct wine
WINED3D_FEATURE_LEVEL_5,
};
output_idx = adapter;
if (output_idx >= parent->wined3d_output_count)
return D3DERR_INVALIDCALL;
if (mode)
FIXME("Ignoring display mode.\n");
......@@ -4616,7 +4622,8 @@ HRESULT device_init(struct d3d9_device *device, struct d3d9 *parent, struct wine
if (!(flags & D3DCREATE_FPU_PRESERVE)) setup_fpu();
wined3d_mutex_lock();
if (FAILED(hr = wined3d_device_create(wined3d, adapter, device_type,
wined3d_adapter = wined3d_output_get_adapter(parent->wined3d_outputs[output_idx]);
if (FAILED(hr = wined3d_device_create(wined3d, wined3d_adapter, device_type,
focus_window, flags, 4, feature_levels, ARRAY_SIZE(feature_levels),
&device->device_parent, &device->wined3d_device)))
{
......
......@@ -5030,7 +5030,7 @@ HRESULT ddraw_init(struct ddraw *ddraw, DWORD flags, enum wined3d_device_type de
ddraw->flags |= DDRAW_NO3D;
}
if (FAILED(hr = wined3d_device_create(ddraw->wined3d, WINED3DADAPTER_DEFAULT, device_type,
if (FAILED(hr = wined3d_device_create(ddraw->wined3d, ddraw->wined3d_adapter, device_type,
NULL, 0, DDRAW_STRIDE_ALIGNMENT, feature_levels, ARRAY_SIZE(feature_levels),
&ddraw->device_parent, &ddraw->wined3d_device)))
{
......
......@@ -519,7 +519,7 @@ HRESULT dxgi_device_init(struct dxgi_device *device, struct dxgi_device_layer *l
IWineDXGIDeviceParent_Release(dxgi_device_parent);
if (FAILED(hr = wined3d_device_create(dxgi_factory->wined3d,
dxgi_adapter->ordinal, WINED3D_DEVICE_TYPE_HAL, NULL, 0, 4,
dxgi_adapter->wined3d_adapter, WINED3D_DEVICE_TYPE_HAL, NULL, 0, 4,
(const enum wined3d_feature_level *)feature_levels, level_count,
wined3d_device_parent, &device->wined3d_device)))
{
......
......@@ -2319,24 +2319,19 @@ HRESULT CDECL wined3d_get_device_caps(const struct wined3d *wined3d, unsigned in
return WINED3D_OK;
}
HRESULT CDECL wined3d_device_create(struct wined3d *wined3d, unsigned int adapter_idx,
HRESULT CDECL wined3d_device_create(struct wined3d *wined3d, struct wined3d_adapter *adapter,
enum wined3d_device_type device_type, HWND focus_window, DWORD flags, BYTE surface_alignment,
const enum wined3d_feature_level *feature_levels, unsigned int feature_level_count,
struct wined3d_device_parent *device_parent, struct wined3d_device **device)
{
const struct wined3d_adapter *adapter;
struct wined3d_device *object;
HRESULT hr;
TRACE("wined3d %p, adapter_idx %u, device_type %#x, focus_window %p, flags %#x, "
TRACE("wined3d %p, adapter %p, device_type %#x, focus_window %p, flags %#x, "
"surface_alignment %u, feature_levels %p, feature_level_count %u, device_parent %p, device %p.\n",
wined3d, adapter_idx, device_type, focus_window, flags, surface_alignment,
wined3d, adapter, device_type, focus_window, flags, surface_alignment,
feature_levels, feature_level_count, device_parent, device);
if (adapter_idx >= wined3d->adapter_count)
return WINED3DERR_INVALIDCALL;
adapter = wined3d->adapters[adapter_idx];
if (FAILED(hr = adapter->adapter_ops->adapter_create_device(wined3d, adapter,
device_type, focus_window, flags, surface_alignment,
feature_levels, feature_level_count, device_parent, &object)))
......
......@@ -42,7 +42,7 @@
@ cdecl wined3d_device_copy_resource(ptr ptr ptr)
@ cdecl wined3d_device_copy_sub_resource_region(ptr ptr long long long long ptr long ptr long)
@ cdecl wined3d_device_copy_uav_counter(ptr ptr long ptr)
@ cdecl wined3d_device_create(ptr long long ptr long long ptr long ptr ptr)
@ cdecl wined3d_device_create(ptr ptr long ptr long long ptr long ptr ptr)
@ cdecl wined3d_device_decref(ptr)
@ cdecl wined3d_device_dispatch_compute(ptr long long long)
@ cdecl wined3d_device_dispatch_compute_indirect(ptr ptr long)
......
......@@ -2312,7 +2312,7 @@ HRESULT __cdecl wined3d_device_copy_sub_resource_region(struct wined3d_device *d
unsigned int src_sub_resource_idx, const struct wined3d_box *src_box, unsigned int flags);
void __cdecl wined3d_device_copy_uav_counter(struct wined3d_device *device,
struct wined3d_buffer *dst_buffer, unsigned int offset, struct wined3d_unordered_access_view *uav);
HRESULT __cdecl wined3d_device_create(struct wined3d *wined3d, unsigned int adapter_idx,
HRESULT __cdecl wined3d_device_create(struct wined3d *wined3d, struct wined3d_adapter *adapter,
enum wined3d_device_type device_type, HWND focus_window, DWORD behaviour_flags, BYTE surface_alignment,
const enum wined3d_feature_level *feature_levels, unsigned int feature_level_count,
struct wined3d_device_parent *device_parent, struct wined3d_device **device);
......
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