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

Signed-off-by: Zhiyi Zhang <zzhang@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Zhiyi Zhang 2020-03-10 17:30:50 +08:00 committed by Alexandre Julliard
parent 70aeb7e4b0
commit a8072e0841
7 changed files with 23 additions and 14 deletions

View File

@ -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_desc swapchain_desc;
struct wined3d_swapchain *wined3d_swapchain; struct wined3d_swapchain *wined3d_swapchain;
struct wined3d_adapter *wined3d_adapter;
struct d3d8_swapchain *d3d_swapchain; struct d3d8_swapchain *d3d_swapchain;
struct wined3d_caps caps; struct wined3d_caps caps;
unsigned int output_idx;
HRESULT hr; HRESULT hr;
static const enum wined3d_feature_level feature_levels[] = 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, 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->IDirect3DDevice8_iface.lpVtbl = &d3d8_device_vtbl;
device->device_parent.ops = &d3d8_wined3d_device_parent_ops; device->device_parent.ops = &d3d8_wined3d_device_parent_ops;
device->ref = 1; 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(); if (!(flags & D3DCREATE_FPU_PRESERVE)) setup_fpu();
wined3d_mutex_lock(); 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), focus_window, flags, 4, feature_levels, ARRAY_SIZE(feature_levels),
&device->device_parent, &device->wined3d_device))) &device->device_parent, &device->wined3d_device)))
{ {

View File

@ -4590,8 +4590,10 @@ HRESULT device_init(struct d3d9_device *device, struct d3d9 *parent, struct wine
D3DPRESENT_PARAMETERS *parameters, D3DDISPLAYMODEEX *mode) D3DPRESENT_PARAMETERS *parameters, D3DDISPLAYMODEEX *mode)
{ {
struct wined3d_swapchain_desc *swapchain_desc; struct wined3d_swapchain_desc *swapchain_desc;
struct wined3d_adapter *wined3d_adapter;
struct d3d9_swapchain *d3d_swapchain; struct d3d9_swapchain *d3d_swapchain;
struct wined3d_caps caps; struct wined3d_caps caps;
unsigned int output_idx;
unsigned i, count = 1; unsigned i, count = 1;
HRESULT hr; HRESULT hr;
@ -4606,6 +4608,10 @@ HRESULT device_init(struct d3d9_device *device, struct d3d9 *parent, struct wine
WINED3D_FEATURE_LEVEL_5, WINED3D_FEATURE_LEVEL_5,
}; };
output_idx = adapter;
if (output_idx >= parent->wined3d_output_count)
return D3DERR_INVALIDCALL;
if (mode) if (mode)
FIXME("Ignoring display mode.\n"); 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(); if (!(flags & D3DCREATE_FPU_PRESERVE)) setup_fpu();
wined3d_mutex_lock(); 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), focus_window, flags, 4, feature_levels, ARRAY_SIZE(feature_levels),
&device->device_parent, &device->wined3d_device))) &device->device_parent, &device->wined3d_device)))
{ {

View File

@ -5030,7 +5030,7 @@ HRESULT ddraw_init(struct ddraw *ddraw, DWORD flags, enum wined3d_device_type de
ddraw->flags |= DDRAW_NO3D; 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), NULL, 0, DDRAW_STRIDE_ALIGNMENT, feature_levels, ARRAY_SIZE(feature_levels),
&ddraw->device_parent, &ddraw->wined3d_device))) &ddraw->device_parent, &ddraw->wined3d_device)))
{ {

View File

@ -519,7 +519,7 @@ HRESULT dxgi_device_init(struct dxgi_device *device, struct dxgi_device_layer *l
IWineDXGIDeviceParent_Release(dxgi_device_parent); IWineDXGIDeviceParent_Release(dxgi_device_parent);
if (FAILED(hr = wined3d_device_create(dxgi_factory->wined3d, 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, (const enum wined3d_feature_level *)feature_levels, level_count,
wined3d_device_parent, &device->wined3d_device))) wined3d_device_parent, &device->wined3d_device)))
{ {

View File

@ -2319,24 +2319,19 @@ HRESULT CDECL wined3d_get_device_caps(const struct wined3d *wined3d, unsigned in
return WINED3D_OK; 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, 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, const enum wined3d_feature_level *feature_levels, unsigned int feature_level_count,
struct wined3d_device_parent *device_parent, struct wined3d_device **device) struct wined3d_device_parent *device_parent, struct wined3d_device **device)
{ {
const struct wined3d_adapter *adapter;
struct wined3d_device *object; struct wined3d_device *object;
HRESULT hr; 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", "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); 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, if (FAILED(hr = adapter->adapter_ops->adapter_create_device(wined3d, adapter,
device_type, focus_window, flags, surface_alignment, device_type, focus_window, flags, surface_alignment,
feature_levels, feature_level_count, device_parent, &object))) feature_levels, feature_level_count, device_parent, &object)))

View File

@ -42,7 +42,7 @@
@ cdecl wined3d_device_copy_resource(ptr ptr ptr) @ 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_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_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_decref(ptr)
@ cdecl wined3d_device_dispatch_compute(ptr long long long) @ cdecl wined3d_device_dispatch_compute(ptr long long long)
@ cdecl wined3d_device_dispatch_compute_indirect(ptr ptr long) @ cdecl wined3d_device_dispatch_compute_indirect(ptr ptr long)

View File

@ -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); 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, 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); 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, 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, const enum wined3d_feature_level *feature_levels, unsigned int feature_level_count,
struct wined3d_device_parent *device_parent, struct wined3d_device **device); struct wined3d_device_parent *device_parent, struct wined3d_device **device);