Signed-off-by: Zhiyi Zhang zzhang@codeweavers.com --- dlls/d3d8/device.c | 9 ++++++++- dlls/d3d9/device.c | 9 ++++++++- dlls/ddraw/ddraw.c | 2 +- dlls/dxgi/device.c | 2 +- dlls/wined3d/directx.c | 11 +++-------- dlls/wined3d/wined3d.spec | 2 +- include/wine/wined3d.h | 2 +- 7 files changed, 23 insertions(+), 14 deletions(-)
diff --git a/dlls/d3d8/device.c b/dlls/d3d8/device.c index d6253a4a2bf..02b010c22a4 100644 --- a/dlls/d3d8/device.c +++ b/dlls/d3d8/device.c @@ -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))) { diff --git a/dlls/d3d9/device.c b/dlls/d3d9/device.c index 8ffe04c94d7..84c119d3e0d 100644 --- a/dlls/d3d9/device.c +++ b/dlls/d3d9/device.c @@ -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))) { diff --git a/dlls/ddraw/ddraw.c b/dlls/ddraw/ddraw.c index 17a02bbc05d..d3a536e4127 100644 --- a/dlls/ddraw/ddraw.c +++ b/dlls/ddraw/ddraw.c @@ -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))) { diff --git a/dlls/dxgi/device.c b/dlls/dxgi/device.c index 4b23155754d..5edd431199a 100644 --- a/dlls/dxgi/device.c +++ b/dlls/dxgi/device.c @@ -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))) { diff --git a/dlls/wined3d/directx.c b/dlls/wined3d/directx.c index 208e00b839f..ecfa444e050 100644 --- a/dlls/wined3d/directx.c +++ b/dlls/wined3d/directx.c @@ -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))) diff --git a/dlls/wined3d/wined3d.spec b/dlls/wined3d/wined3d.spec index 3530a11f8d3..d4b0a147262 100644 --- a/dlls/wined3d/wined3d.spec +++ b/dlls/wined3d/wined3d.spec @@ -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) diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h index fbcc6bb332e..5ff935dd8ea 100644 --- a/include/wine/wined3d.h +++ b/include/wine/wined3d.h @@ -2310,7 +2310,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);