Signed-off-by: Zhiyi Zhang <zzhang(a)codeweavers.com>
---
dlls/d3d11/device.c | 4 +++-
dlls/d3d8/directx.c | 19 +++++++++++++++++--
dlls/d3d9/directx.c | 19 +++++++++++++++++--
dlls/wined3d/directx.c | 10 +++-------
dlls/wined3d/wined3d.spec | 2 +-
include/wine/wined3d.h | 2 +-
6 files changed, 42 insertions(+), 14 deletions(-)
diff --git a/dlls/d3d11/device.c b/dlls/d3d11/device.c
index 555d998da22..92d0c33faf6 100644
--- a/dlls/d3d11/device.c
+++ b/dlls/d3d11/device.c
@@ -3436,6 +3436,7 @@ static HRESULT STDMETHODCALLTYPE d3d11_device_CheckMultisampleQualityLevels(ID3D
{
struct d3d_device *device = impl_from_ID3D11Device2(iface);
struct wined3d_device_creation_parameters params;
+ struct wined3d_adapter *wined3d_adapter;
struct wined3d *wined3d;
HRESULT hr;
@@ -3460,7 +3461,8 @@ static HRESULT STDMETHODCALLTYPE d3d11_device_CheckMultisampleQualityLevels(ID3D
wined3d_mutex_lock();
wined3d = wined3d_device_get_wined3d(device->wined3d_device);
wined3d_device_get_creation_parameters(device->wined3d_device, ¶ms);
- hr = wined3d_check_device_multisample_type(wined3d, params.adapter_idx, params.device_type,
+ wined3d_adapter = wined3d_get_adapter(wined3d, params.adapter_idx);
+ hr = wined3d_check_device_multisample_type(wined3d_adapter, params.device_type,
wined3dformat_from_dxgi_format(format), TRUE, sample_count, quality_level_count);
wined3d_mutex_unlock();
diff --git a/dlls/d3d8/directx.c b/dlls/d3d8/directx.c
index d60088f2a3c..de35ad55983 100644
--- a/dlls/d3d8/directx.c
+++ b/dlls/d3d8/directx.c
@@ -247,12 +247,18 @@ static HRESULT WINAPI d3d8_CheckDeviceFormat(IDirect3D8 *iface, UINT adapter, D3
{
struct d3d8 *d3d8 = impl_from_IDirect3D8(iface);
enum wined3d_resource_type wined3d_rtype;
+ struct wined3d_adapter *wined3d_adapter;
unsigned int bind_flags;
+ unsigned int output_idx;
HRESULT hr;
TRACE("iface %p, adapter %u, device_type %#x, adapter_format %#x, usage %#x, resource_type %#x, format %#x.\n",
iface, adapter, device_type, adapter_format, usage, resource_type, format);
+ output_idx = adapter;
+ if (output_idx >= d3d8->wined3d_output_count)
+ return D3DERR_INVALIDCALL;
+
if (adapter_format != D3DFMT_X8R8G8B8 && adapter_format != D3DFMT_R5G6B5
&& adapter_format != D3DFMT_X1R5G5B5)
{
@@ -292,7 +298,9 @@ static HRESULT WINAPI d3d8_CheckDeviceFormat(IDirect3D8 *iface, UINT adapter, D3
if (format == D3DFMT_RESZ && resource_type == D3DRTYPE_SURFACE && usage == D3DUSAGE_RENDERTARGET)
{
DWORD levels;
- hr = wined3d_check_device_multisample_type(d3d8->wined3d, adapter, device_type,
+
+ wined3d_adapter = wined3d_output_get_adapter(d3d8->wined3d_outputs[output_idx]);
+ hr = wined3d_check_device_multisample_type(wined3d_adapter, device_type,
WINED3DFMT_D24_UNORM_S8_UINT, FALSE, WINED3D_MULTISAMPLE_NON_MASKABLE, &levels);
if (SUCCEEDED(hr) && !levels)
hr = D3DERR_NOTAVAILABLE;
@@ -309,16 +317,23 @@ static HRESULT WINAPI d3d8_CheckDeviceMultiSampleType(IDirect3D8 *iface, UINT ad
D3DFORMAT format, BOOL windowed, D3DMULTISAMPLE_TYPE multisample_type)
{
struct d3d8 *d3d8 = impl_from_IDirect3D8(iface);
+ struct wined3d_adapter *wined3d_adapter;
+ unsigned int output_idx;
HRESULT hr;
TRACE("iface %p, adapter %u, device_type %#x, format %#x, windowed %#x, multisample_type %#x.\n",
iface, adapter, device_type, format, windowed, multisample_type);
+ output_idx = adapter;
+ if (output_idx >= d3d8->wined3d_output_count)
+ return D3DERR_INVALIDCALL;
+
if (multisample_type > D3DMULTISAMPLE_16_SAMPLES)
return D3DERR_INVALIDCALL;
wined3d_mutex_lock();
- hr = wined3d_check_device_multisample_type(d3d8->wined3d, adapter, device_type,
+ wined3d_adapter = wined3d_output_get_adapter(d3d8->wined3d_outputs[output_idx]);
+ hr = wined3d_check_device_multisample_type(wined3d_adapter, device_type,
wined3dformat_from_d3dformat(format), windowed,
(enum wined3d_multisample_type)multisample_type, NULL);
wined3d_mutex_unlock();
diff --git a/dlls/d3d9/directx.c b/dlls/d3d9/directx.c
index 501ae45877b..8d596550a6a 100644
--- a/dlls/d3d9/directx.c
+++ b/dlls/d3d9/directx.c
@@ -271,12 +271,18 @@ static HRESULT WINAPI d3d9_CheckDeviceFormat(IDirect3D9Ex *iface, UINT adapter,
{
struct d3d9 *d3d9 = impl_from_IDirect3D9Ex(iface);
enum wined3d_resource_type wined3d_rtype;
+ struct wined3d_adapter *wined3d_adapter;
unsigned int bind_flags;
+ unsigned int output_idx;
HRESULT hr;
TRACE("iface %p, adapter %u, device_type %#x, adapter_format %#x, usage %#x, resource_type %#x, format %#x.\n",
iface, adapter, device_type, adapter_format, usage, resource_type, format);
+ output_idx = adapter;
+ if (output_idx >= d3d9->wined3d_output_count)
+ return D3DERR_INVALIDCALL;
+
if (adapter_format != D3DFMT_X8R8G8B8 && adapter_format != D3DFMT_R5G6B5
&& adapter_format != D3DFMT_X1R5G5B5)
{
@@ -316,7 +322,9 @@ static HRESULT WINAPI d3d9_CheckDeviceFormat(IDirect3D9Ex *iface, UINT adapter,
if (format == D3DFMT_RESZ && resource_type == D3DRTYPE_SURFACE && usage == D3DUSAGE_RENDERTARGET)
{
DWORD levels;
- hr = wined3d_check_device_multisample_type(d3d9->wined3d, adapter, device_type,
+
+ wined3d_adapter = wined3d_output_get_adapter(d3d9->wined3d_outputs[output_idx]);
+ hr = wined3d_check_device_multisample_type(wined3d_adapter, device_type,
WINED3DFMT_D24_UNORM_S8_UINT, FALSE, WINED3D_MULTISAMPLE_NON_MASKABLE, &levels);
if (SUCCEEDED(hr) && !levels)
hr = D3DERR_NOTAVAILABLE;
@@ -334,16 +342,23 @@ static HRESULT WINAPI d3d9_CheckDeviceMultiSampleType(IDirect3D9Ex *iface, UINT
D3DFORMAT format, BOOL windowed, D3DMULTISAMPLE_TYPE multisample_type, DWORD *levels)
{
struct d3d9 *d3d9 = impl_from_IDirect3D9Ex(iface);
+ struct wined3d_adapter *wined3d_adapter;
+ unsigned int output_idx;
HRESULT hr;
TRACE("iface %p, adapter %u, device_type %#x, format %#x, windowed %#x, multisample_type %#x, levels %p.\n",
iface, adapter, device_type, format, windowed, multisample_type, levels);
+ output_idx = adapter;
+ if (output_idx >= d3d9->wined3d_output_count)
+ return D3DERR_INVALIDCALL;
+
if (multisample_type > D3DMULTISAMPLE_16_SAMPLES)
return D3DERR_INVALIDCALL;
wined3d_mutex_lock();
- hr = wined3d_check_device_multisample_type(d3d9->wined3d, adapter, device_type,
+ wined3d_adapter = wined3d_output_get_adapter(d3d9->wined3d_outputs[output_idx]);
+ hr = wined3d_check_device_multisample_type(wined3d_adapter, device_type,
wined3dformat_from_d3dformat(format), windowed, multisample_type, levels);
wined3d_mutex_unlock();
if (hr == WINED3DERR_NOTAVAILABLE && levels)
diff --git a/dlls/wined3d/directx.c b/dlls/wined3d/directx.c
index 722b12f0a30..fcfeaa73481 100644
--- a/dlls/wined3d/directx.c
+++ b/dlls/wined3d/directx.c
@@ -1475,21 +1475,18 @@ HRESULT CDECL wined3d_check_depth_stencil_match(const struct wined3d_adapter *ad
return WINED3DERR_NOTAVAILABLE;
}
-HRESULT CDECL wined3d_check_device_multisample_type(const struct wined3d *wined3d, UINT adapter_idx,
+HRESULT CDECL wined3d_check_device_multisample_type(const struct wined3d_adapter *adapter,
enum wined3d_device_type device_type, enum wined3d_format_id surface_format_id, BOOL windowed,
enum wined3d_multisample_type multisample_type, DWORD *quality_levels)
{
- const struct wined3d_adapter *adapter;
const struct wined3d_format *format;
HRESULT hr = WINED3D_OK;
- TRACE("wined3d %p, adapter_idx %u, device_type %s, surface_format %s, "
+ TRACE("adapter %p, device_type %s, surface_format %s, "
"windowed %#x, multisample_type %#x, quality_levels %p.\n",
- wined3d, adapter_idx, debug_d3ddevicetype(device_type), debug_d3dformat(surface_format_id),
+ adapter, debug_d3ddevicetype(device_type), debug_d3dformat(surface_format_id),
windowed, multisample_type, quality_levels);
- if (adapter_idx >= wined3d->adapter_count)
- return WINED3DERR_INVALIDCALL;
if (surface_format_id == WINED3DFMT_UNKNOWN)
return WINED3DERR_INVALIDCALL;
if (multisample_type < WINED3D_MULTISAMPLE_NONE)
@@ -1500,7 +1497,6 @@ HRESULT CDECL wined3d_check_device_multisample_type(const struct wined3d *wined3
return WINED3DERR_NOTAVAILABLE;
}
- adapter = wined3d->adapters[adapter_idx];
format = wined3d_get_format(adapter, surface_format_id, 0);
if (multisample_type && !(format->multisample_types & 1u << (multisample_type - 1)))
diff --git a/dlls/wined3d/wined3d.spec b/dlls/wined3d/wined3d.spec
index 076386ac64a..7000259d0b6 100644
--- a/dlls/wined3d/wined3d.spec
+++ b/dlls/wined3d/wined3d.spec
@@ -5,7 +5,7 @@
@ cdecl wined3d_check_depth_stencil_match(ptr long long long long)
@ 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_multisample_type(ptr long long long long ptr)
@ cdecl wined3d_check_device_type(ptr ptr long long long long)
@ cdecl wined3d_create(long)
@ cdecl wined3d_decref(ptr)
diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h
index 752c98261de..30d1da2ce25 100644
--- a/include/wine/wined3d.h
+++ b/include/wine/wined3d.h
@@ -2256,7 +2256,7 @@ HRESULT __cdecl wined3d_check_device_format(const struct wined3d *wined3d, UINT
HRESULT __cdecl wined3d_check_device_format_conversion(const struct wined3d_output *output,
enum wined3d_device_type device_type, enum wined3d_format_id source_format_id,
enum wined3d_format_id target_format_id);
-HRESULT __cdecl wined3d_check_device_multisample_type(const struct wined3d *wined3d, UINT adapter_idx,
+HRESULT __cdecl wined3d_check_device_multisample_type(const struct wined3d_adapter *adapter,
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,
--
2.20.1