Signed-off-by: Zhiyi Zhang zzhang@codeweavers.com --- dlls/d3d8/directx.c | 8 +++++++- dlls/d3d9/directx.c | 8 +++++++- dlls/wined3d/directx.c | 27 +++++++++++++-------------- dlls/wined3d/wined3d.spec | 2 +- include/wine/wined3d.h | 7 ++++--- 5 files changed, 32 insertions(+), 20 deletions(-)
diff --git a/dlls/d3d8/directx.c b/dlls/d3d8/directx.c index d515caffd25..13bf7b031c1 100644 --- a/dlls/d3d8/directx.c +++ b/dlls/d3d8/directx.c @@ -213,16 +213,22 @@ static HRESULT WINAPI d3d8_CheckDeviceType(IDirect3D8 *iface, UINT adapter, D3DD D3DFORMAT display_format, D3DFORMAT backbuffer_format, BOOL windowed) { struct d3d8 *d3d8 = impl_from_IDirect3D8(iface); + unsigned int output_idx; HRESULT hr;
TRACE("iface %p, adapter %u, device_type %#x, display_format %#x, backbuffer_format %#x, windowed %#x.\n", iface, adapter, device_type, display_format, backbuffer_format, windowed);
+ output_idx = adapter; + if (output_idx >= d3d8->wined3d_output_count) + return D3DERR_INVALIDCALL; + if (!windowed && display_format != D3DFMT_X8R8G8B8 && display_format != D3DFMT_R5G6B5) return WINED3DERR_NOTAVAILABLE;
wined3d_mutex_lock(); - hr = wined3d_check_device_type(d3d8->wined3d, adapter, device_type, wined3dformat_from_d3dformat(display_format), + hr = wined3d_check_device_type(d3d8->wined3d, d3d8->wined3d_outputs[output_idx], device_type, + wined3dformat_from_d3dformat(display_format), wined3dformat_from_d3dformat(backbuffer_format), windowed); wined3d_mutex_unlock();
diff --git a/dlls/d3d9/directx.c b/dlls/d3d9/directx.c index 700c3cb1456..4dbdaeef718 100644 --- a/dlls/d3d9/directx.c +++ b/dlls/d3d9/directx.c @@ -236,17 +236,23 @@ static HRESULT WINAPI d3d9_CheckDeviceType(IDirect3D9Ex *iface, UINT adapter, D3 D3DFORMAT display_format, D3DFORMAT backbuffer_format, BOOL windowed) { struct d3d9 *d3d9 = impl_from_IDirect3D9Ex(iface); + unsigned int output_idx; HRESULT hr;
TRACE("iface %p, adapter %u, device_type %#x, display_format %#x, backbuffer_format %#x, windowed %#x.\n", iface, adapter, device_type, display_format, backbuffer_format, windowed);
+ output_idx = adapter; + if (output_idx >= d3d9->wined3d_output_count) + return D3DERR_INVALIDCALL; + /* Others than that not supported by d3d9, but reported by wined3d for ddraw. Filter them out. */ if (!windowed && display_format != D3DFMT_X8R8G8B8 && display_format != D3DFMT_R5G6B5) return WINED3DERR_NOTAVAILABLE;
wined3d_mutex_lock(); - hr = wined3d_check_device_type(d3d9->wined3d, adapter, device_type, wined3dformat_from_d3dformat(display_format), + hr = wined3d_check_device_type(d3d9->wined3d, d3d9->wined3d_outputs[output_idx], device_type, + wined3dformat_from_d3dformat(display_format), wined3dformat_from_d3dformat(backbuffer_format), windowed); wined3d_mutex_unlock();
diff --git a/dlls/wined3d/directx.c b/dlls/wined3d/directx.c index 3f46bb6a283..8053f9dc53e 100644 --- a/dlls/wined3d/directx.c +++ b/dlls/wined3d/directx.c @@ -1783,19 +1783,17 @@ HRESULT CDECL wined3d_check_device_format_conversion(const struct wined3d_output return WINED3D_OK; }
-HRESULT CDECL wined3d_check_device_type(const struct wined3d *wined3d, UINT adapter_idx, - enum wined3d_device_type device_type, enum wined3d_format_id display_format, - enum wined3d_format_id backbuffer_format, BOOL windowed) +HRESULT CDECL wined3d_check_device_type(const struct wined3d *wined3d, + const struct wined3d_output *output, enum wined3d_device_type device_type, + enum wined3d_format_id display_format, enum wined3d_format_id backbuffer_format, + BOOL windowed) { BOOL present_conversion = wined3d->flags & WINED3D_PRESENT_CONVERSION;
- TRACE("wined3d %p, adapter_idx %u, device_type %s, display_format %s, backbuffer_format %s, windowed %#x.\n", - wined3d, adapter_idx, debug_d3ddevicetype(device_type), debug_d3dformat(display_format), + TRACE("wined3d %p, output %p, device_type %s, display_format %s, backbuffer_format %s, windowed %#x.\n", + wined3d, output, debug_d3ddevicetype(device_type), debug_d3dformat(display_format), debug_d3dformat(backbuffer_format), windowed);
- if (adapter_idx >= wined3d->adapter_count) - return WINED3DERR_INVALIDCALL; - /* The task of this function is to check whether a certain display / backbuffer format * combination is available on the given adapter. In fullscreen mode microsoft specified * that the display format shouldn't provide alpha and that ignoring alpha the backbuffer @@ -1815,8 +1813,8 @@ HRESULT CDECL wined3d_check_device_type(const struct wined3d *wined3d, UINT adap if (!windowed) { /* If the requested display format is not available, don't continue. */ - if (!wined3d_output_get_mode_count(&wined3d->adapters[adapter_idx]->outputs[0], - display_format, WINED3D_SCANLINE_ORDERING_UNKNOWN)) + if (!wined3d_output_get_mode_count(output, display_format, + WINED3D_SCANLINE_ORDERING_UNKNOWN)) { TRACE("No available modes for display format %s.\n", debug_d3dformat(display_format)); return WINED3DERR_NOTAVAILABLE; @@ -1839,8 +1837,8 @@ HRESULT CDECL wined3d_check_device_type(const struct wined3d *wined3d, UINT adap if (backbuffer_format == WINED3DFMT_UNKNOWN) backbuffer_format = display_format;
- if (FAILED(wined3d_check_device_format_conversion(&wined3d->adapters[adapter_idx]->outputs[0], - device_type, backbuffer_format, display_format))) + if (FAILED(wined3d_check_device_format_conversion(output, device_type, backbuffer_format, + display_format))) { TRACE("Format conversion from %s to %s not supported.\n", debug_d3dformat(backbuffer_format), debug_d3dformat(display_format)); @@ -1886,8 +1884,9 @@ HRESULT CDECL wined3d_check_device_type(const struct wined3d *wined3d, UINT adap }
/* Validate that the back buffer format is usable for render targets. */ - if (FAILED(wined3d_check_device_format(wined3d, adapter_idx, device_type, display_format, - 0, WINED3D_BIND_RENDER_TARGET, WINED3D_RTYPE_TEXTURE_2D, backbuffer_format))) + if (FAILED(wined3d_check_device_format(wined3d, output->adapter->ordinal, device_type, + display_format, 0, WINED3D_BIND_RENDER_TARGET, WINED3D_RTYPE_TEXTURE_2D, + backbuffer_format))) { TRACE("Format %s not allowed for render targets.\n", debug_d3dformat(backbuffer_format)); return WINED3DERR_NOTAVAILABLE; diff --git a/dlls/wined3d/wined3d.spec b/dlls/wined3d/wined3d.spec index d043b91cc4e..d8ffdee9ac2 100644 --- a/dlls/wined3d/wined3d.spec +++ b/dlls/wined3d/wined3d.spec @@ -6,7 +6,7 @@ @ cdecl wined3d_check_device_format(ptr long long long long long long long) @ cdecl wined3d_check_device_format_conversion(ptr long long long) @ cdecl wined3d_check_device_multisample_type(ptr long long long long long ptr) -@ cdecl wined3d_check_device_type(ptr long long long long long) +@ cdecl wined3d_check_device_type(ptr ptr long long long long) @ cdecl wined3d_create(long) @ cdecl wined3d_decref(ptr) @ cdecl wined3d_get_adapter(ptr long) diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h index 6e4d0a2defb..92a35e537e0 100644 --- a/include/wine/wined3d.h +++ b/include/wine/wined3d.h @@ -2256,9 +2256,10 @@ HRESULT __cdecl wined3d_check_device_format_conversion(const struct wined3d_outp HRESULT __cdecl wined3d_check_device_multisample_type(const struct wined3d *wined3d, UINT adapter_idx, enum wined3d_device_type device_type, enum wined3d_format_id surface_format_id, BOOL windowed, enum wined3d_multisample_type multisample_type, DWORD *quality_levels); -HRESULT __cdecl wined3d_check_device_type(const struct wined3d *wined3d, UINT adapter_idx, - enum wined3d_device_type device_type, enum wined3d_format_id display_format_id, - enum wined3d_format_id backbuffer_format_id, BOOL windowed); +HRESULT __cdecl wined3d_check_device_type(const struct wined3d *wined3d, + const struct wined3d_output *output, enum wined3d_device_type device_type, + enum wined3d_format_id display_format_id, enum wined3d_format_id backbuffer_format_id, + BOOL windowed); struct wined3d * __cdecl wined3d_create(DWORD flags); ULONG __cdecl wined3d_decref(struct wined3d *wined3d); struct wined3d_adapter * __cdecl wined3d_get_adapter(const struct wined3d *wined3d,