Signed-off-by: Zhiyi Zhang <zzhang(a)codeweavers.com>
---
dlls/d3d11/device.c | 4 +++-
dlls/d3d8/directx.c | 7 ++++---
dlls/d3d9/d3d9_private.h | 1 +
dlls/d3d9/device.c | 1 +
dlls/d3d9/directx.c | 4 ++--
dlls/d3d9/texture.c | 6 +++++-
dlls/ddraw/ddraw.c | 6 +++---
dlls/ddraw/device.c | 12 +++++++-----
dlls/ddraw/surface.c | 2 +-
dlls/wined3d/directx.c | 18 +++++++-----------
dlls/wined3d/wined3d.spec | 2 +-
include/wine/wined3d.h | 7 ++++---
12 files changed, 39 insertions(+), 31 deletions(-)
diff --git a/dlls/d3d11/device.c b/dlls/d3d11/device.c
index 92d0c33faf6..05b12504ce9 100644
--- a/dlls/d3d11/device.c
+++ b/dlls/d3d11/device.c
@@ -3355,6 +3355,7 @@ static HRESULT STDMETHODCALLTYPE d3d11_device_CheckFormatSupport(ID3D11Device2 *
{
struct d3d_device *device = impl_from_ID3D11Device2(iface);
struct wined3d_device_creation_parameters params;
+ struct wined3d_adapter *wined3d_adapter;
enum wined3d_format_id wined3d_format;
D3D_FEATURE_LEVEL feature_level;
struct wined3d *wined3d;
@@ -3392,9 +3393,10 @@ static HRESULT STDMETHODCALLTYPE d3d11_device_CheckFormatSupport(ID3D11Device2 *
feature_level = device->feature_level;
wined3d = wined3d_device_get_wined3d(device->wined3d_device);
wined3d_device_get_creation_parameters(device->wined3d_device, ¶ms);
+ wined3d_adapter = wined3d_get_adapter(wined3d, params.adapter_idx);
for (i = 0; i < ARRAY_SIZE(flag_mapping); ++i)
{
- hr = wined3d_check_device_format(wined3d, params.adapter_idx, params.device_type,
+ hr = wined3d_check_device_format(wined3d, wined3d_adapter, params.device_type,
WINED3DFMT_UNKNOWN, 0, flag_mapping[i].bind_flags, flag_mapping[i].rtype, wined3d_format);
if (hr == WINED3DERR_NOTAVAILABLE || hr == WINED3DOK_NOMIPGEN)
continue;
diff --git a/dlls/d3d8/directx.c b/dlls/d3d8/directx.c
index de35ad55983..cbb638f014d 100644
--- a/dlls/d3d8/directx.c
+++ b/dlls/d3d8/directx.c
@@ -295,19 +295,20 @@ static HRESULT WINAPI d3d8_CheckDeviceFormat(IDirect3D8 *iface, UINT adapter, D3
}
wined3d_mutex_lock();
+ wined3d_adapter = wined3d_output_get_adapter(d3d8->wined3d_outputs[output_idx]);
if (format == D3DFMT_RESZ && resource_type == D3DRTYPE_SURFACE && usage == D3DUSAGE_RENDERTARGET)
{
DWORD levels;
- 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;
}
else
- hr = wined3d_check_device_format(d3d8->wined3d, adapter, device_type, wined3dformat_from_d3dformat(adapter_format),
- usage, bind_flags, wined3d_rtype, wined3dformat_from_d3dformat(format));
+ hr = wined3d_check_device_format(d3d8->wined3d, wined3d_adapter, device_type,
+ wined3dformat_from_d3dformat(adapter_format), usage, bind_flags, wined3d_rtype,
+ wined3dformat_from_d3dformat(format));
wined3d_mutex_unlock();
return hr;
diff --git a/dlls/d3d9/d3d9_private.h b/dlls/d3d9/d3d9_private.h
index a21582d6e1e..a0daaf42880 100644
--- a/dlls/d3d9/d3d9_private.h
+++ b/dlls/d3d9/d3d9_private.h
@@ -92,6 +92,7 @@ struct d3d9_device
struct wined3d_device_parent device_parent;
LONG refcount;
struct wined3d_device *wined3d_device;
+ unsigned int adapter_ordinal;
struct d3d9 *d3d_parent;
struct fvf_declaration *fvf_decls;
diff --git a/dlls/d3d9/device.c b/dlls/d3d9/device.c
index 84c119d3e0d..ec1d18a79fe 100644
--- a/dlls/d3d9/device.c
+++ b/dlls/d3d9/device.c
@@ -4617,6 +4617,7 @@ HRESULT device_init(struct d3d9_device *device, struct d3d9 *parent, struct wine
device->IDirect3DDevice9Ex_iface.lpVtbl = &d3d9_device_vtbl;
device->device_parent.ops = &d3d9_wined3d_device_parent_ops;
+ device->adapter_ordinal = adapter;
device->refcount = 1;
if (!(flags & D3DCREATE_FPU_PRESERVE)) setup_fpu();
diff --git a/dlls/d3d9/directx.c b/dlls/d3d9/directx.c
index 8d596550a6a..6c8ca1c3d3d 100644
--- a/dlls/d3d9/directx.c
+++ b/dlls/d3d9/directx.c
@@ -319,18 +319,18 @@ static HRESULT WINAPI d3d9_CheckDeviceFormat(IDirect3D9Ex *iface, UINT adapter,
}
wined3d_mutex_lock();
+ wined3d_adapter = wined3d_output_get_adapter(d3d9->wined3d_outputs[output_idx]);
if (format == D3DFMT_RESZ && resource_type == D3DRTYPE_SURFACE && usage == D3DUSAGE_RENDERTARGET)
{
DWORD levels;
- 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;
}
else
- hr = wined3d_check_device_format(d3d9->wined3d, adapter, device_type,
+ hr = wined3d_check_device_format(d3d9->wined3d, wined3d_adapter, device_type,
wined3dformat_from_d3dformat(adapter_format), usage, bind_flags,
wined3d_rtype, wined3dformat_from_d3dformat(format));
wined3d_mutex_unlock();
diff --git a/dlls/d3d9/texture.c b/dlls/d3d9/texture.c
index 2ef27a6de3d..0d36c02aaa6 100644
--- a/dlls/d3d9/texture.c
+++ b/dlls/d3d9/texture.c
@@ -1296,7 +1296,9 @@ static const struct wined3d_parent_ops d3d9_texture_wined3d_parent_ops =
HRESULT texture_init(struct d3d9_texture *texture, struct d3d9_device *device,
UINT width, UINT height, UINT levels, DWORD usage, D3DFORMAT format, D3DPOOL pool)
{
+ struct wined3d_adapter *wined3d_adapter;
struct wined3d_resource_desc desc;
+ unsigned int output_idx;
DWORD flags = 0;
HRESULT hr;
@@ -1346,7 +1348,9 @@ HRESULT texture_init(struct d3d9_texture *texture, struct d3d9_device *device,
return D3DERR_INVALIDCALL;
}
wined3d_mutex_lock();
- hr = wined3d_check_device_format(device->d3d_parent->wined3d, WINED3DADAPTER_DEFAULT,
+ output_idx = device->adapter_ordinal;
+ wined3d_adapter = wined3d_output_get_adapter(device->d3d_parent->wined3d_outputs[output_idx]);
+ hr = wined3d_check_device_format(device->d3d_parent->wined3d, wined3d_adapter,
WINED3D_DEVICE_TYPE_HAL, WINED3DFMT_B8G8R8A8_UNORM, WINED3DUSAGE_QUERY_GENMIPMAP,
WINED3D_BIND_SHADER_RESOURCE, WINED3D_RTYPE_TEXTURE_2D, wined3dformat_from_d3dformat(format));
wined3d_mutex_unlock();
diff --git a/dlls/ddraw/ddraw.c b/dlls/ddraw/ddraw.c
index 5487855be67..7c13d4abd4b 100644
--- a/dlls/ddraw/ddraw.c
+++ b/dlls/ddraw/ddraw.c
@@ -1720,7 +1720,7 @@ static HRESULT WINAPI ddraw7_GetFourCCCodes(IDirectDraw7 *iface, DWORD *NumCodes
for (i = 0; i < ARRAY_SIZE(formats); ++i)
{
- if (SUCCEEDED(wined3d_check_device_format(ddraw->wined3d, WINED3DADAPTER_DEFAULT, WINED3D_DEVICE_TYPE_HAL,
+ if (SUCCEEDED(wined3d_check_device_format(ddraw->wined3d, ddraw->wined3d_adapter, WINED3D_DEVICE_TYPE_HAL,
mode.format_id, 0, 0, WINED3D_RTYPE_TEXTURE_2D, formats[i])))
{
if (count < outsize)
@@ -4441,7 +4441,7 @@ static HRESULT WINAPI d3d7_EnumZBufferFormats(IDirect3D7 *iface, REFCLSID device
for (i = 0; i < ARRAY_SIZE(formats); ++i)
{
- if (SUCCEEDED(wined3d_check_device_format(ddraw->wined3d, WINED3DADAPTER_DEFAULT, type,
+ if (SUCCEEDED(wined3d_check_device_format(ddraw->wined3d, ddraw->wined3d_adapter, type,
mode.format_id, 0, WINED3D_BIND_DEPTH_STENCIL, WINED3D_RTYPE_TEXTURE_2D, formats[i])))
{
DDPIXELFORMAT pformat;
@@ -4465,7 +4465,7 @@ static HRESULT WINAPI d3d7_EnumZBufferFormats(IDirect3D7 *iface, REFCLSID device
* while others used dwZBufferBitDepth=32. In either case the pitch matches a 32 bits per
* pixel format, so we use dwZBufferBitDepth=32. Some games expect 24. Windows Vista and
* newer enumerate both versions, so we do the same(bug 22434) */
- if (SUCCEEDED(wined3d_check_device_format(ddraw->wined3d, WINED3DADAPTER_DEFAULT, type, mode.format_id,
+ if (SUCCEEDED(wined3d_check_device_format(ddraw->wined3d, ddraw->wined3d_adapter, type, mode.format_id,
0, WINED3D_BIND_DEPTH_STENCIL, WINED3D_RTYPE_TEXTURE_2D, WINED3DFMT_X8D24_UNORM)))
{
DDPIXELFORMAT x8d24 =
diff --git a/dlls/ddraw/device.c b/dlls/ddraw/device.c
index ab3584b8fea..3c0ae71196d 100644
--- a/dlls/ddraw/device.c
+++ b/dlls/ddraw/device.c
@@ -1095,8 +1095,9 @@ static HRESULT d3d_device7_EnumTextureFormats(IDirect3DDevice7 *iface,
for (i = 0; i < ARRAY_SIZE(FormatList); ++i)
{
- if (wined3d_check_device_format(device->ddraw->wined3d, WINED3DADAPTER_DEFAULT, WINED3D_DEVICE_TYPE_HAL,
- mode.format_id, 0, WINED3D_BIND_SHADER_RESOURCE, WINED3D_RTYPE_TEXTURE_2D, FormatList[i]) == D3D_OK)
+ if (wined3d_check_device_format(device->ddraw->wined3d, device->ddraw->wined3d_adapter,
+ WINED3D_DEVICE_TYPE_HAL, mode.format_id, 0, WINED3D_BIND_SHADER_RESOURCE,
+ WINED3D_RTYPE_TEXTURE_2D, FormatList[i]) == D3D_OK)
{
DDPIXELFORMAT pformat;
@@ -1117,7 +1118,7 @@ static HRESULT d3d_device7_EnumTextureFormats(IDirect3DDevice7 *iface,
for (i = 0; i < ARRAY_SIZE(BumpFormatList); ++i)
{
- if (wined3d_check_device_format(device->ddraw->wined3d, WINED3DADAPTER_DEFAULT,
+ if (wined3d_check_device_format(device->ddraw->wined3d, device->ddraw->wined3d_adapter,
WINED3D_DEVICE_TYPE_HAL, mode.format_id, WINED3DUSAGE_QUERY_LEGACYBUMPMAP,
WINED3D_BIND_SHADER_RESOURCE, WINED3D_RTYPE_TEXTURE_2D, BumpFormatList[i]) == D3D_OK)
{
@@ -1223,8 +1224,9 @@ static HRESULT WINAPI d3d_device2_EnumTextureFormats(IDirect3DDevice2 *iface,
for (i = 0; i < ARRAY_SIZE(FormatList); ++i)
{
- if (wined3d_check_device_format(device->ddraw->wined3d, WINED3DADAPTER_DEFAULT, WINED3D_DEVICE_TYPE_HAL,
- mode.format_id, 0, WINED3D_BIND_SHADER_RESOURCE, WINED3D_RTYPE_TEXTURE_2D, FormatList[i]) == D3D_OK)
+ if (wined3d_check_device_format(device->ddraw->wined3d, device->ddraw->wined3d_adapter,
+ WINED3D_DEVICE_TYPE_HAL, mode.format_id, 0, WINED3D_BIND_SHADER_RESOURCE,
+ WINED3D_RTYPE_TEXTURE_2D, FormatList[i]) == D3D_OK)
{
DDSURFACEDESC sdesc;
diff --git a/dlls/ddraw/surface.c b/dlls/ddraw/surface.c
index a803324c450..627963232e4 100644
--- a/dlls/ddraw/surface.c
+++ b/dlls/ddraw/surface.c
@@ -6168,7 +6168,7 @@ HRESULT ddraw_surface_create(struct ddraw *ddraw, const DDSURFACEDESC2 *surface_
bind_flags |= WINED3D_BIND_RENDER_TARGET;
if (!(ddraw->flags & DDRAW_NO3D) && SUCCEEDED(hr = wined3d_check_device_format(ddraw->wined3d,
- WINED3DADAPTER_DEFAULT, WINED3D_DEVICE_TYPE_HAL, mode.format_id,
+ ddraw->wined3d_adapter, WINED3D_DEVICE_TYPE_HAL, mode.format_id,
usage, bind_flags, WINED3D_RTYPE_TEXTURE_2D, wined3d_desc.format)))
desc->ddsCaps.dwCaps |= DDSCAPS_VIDEOMEMORY;
else
diff --git a/dlls/wined3d/directx.c b/dlls/wined3d/directx.c
index fcfeaa73481..d026c6a49ef 100644
--- a/dlls/wined3d/directx.c
+++ b/dlls/wined3d/directx.c
@@ -1558,28 +1558,24 @@ static BOOL wined3d_check_surface_format(const struct wined3d_format *format)
*
* For now lets report this on all formats, but in the future we may want to
* restrict it to some should applications need that. */
-HRESULT CDECL wined3d_check_device_format(const struct wined3d *wined3d, UINT adapter_idx,
- enum wined3d_device_type device_type, enum wined3d_format_id adapter_format_id, DWORD usage,
- unsigned int bind_flags, enum wined3d_resource_type resource_type, enum wined3d_format_id check_format_id)
+HRESULT CDECL wined3d_check_device_format(const struct wined3d *wined3d,
+ const struct wined3d_adapter *adapter, enum wined3d_device_type device_type,
+ enum wined3d_format_id adapter_format_id, DWORD usage, unsigned int bind_flags,
+ enum wined3d_resource_type resource_type, enum wined3d_format_id check_format_id)
{
const struct wined3d_format *adapter_format, *format;
enum wined3d_gl_resource_type gl_type, gl_type_end;
- const struct wined3d_adapter *adapter;
BOOL mipmap_gen_supported = TRUE;
unsigned int allowed_bind_flags;
DWORD format_flags = 0;
DWORD allowed_usage;
- TRACE("wined3d %p, adapter_idx %u, device_type %s, adapter_format %s, usage %s, %s, "
+ TRACE("wined3d %p, adapter %p, device_type %s, adapter_format %s, usage %s, %s, "
"bind_flags %s, resource_type %s, check_format %s.\n",
- wined3d, adapter_idx, debug_d3ddevicetype(device_type), debug_d3dformat(adapter_format_id),
+ wined3d, adapter, debug_d3ddevicetype(device_type), debug_d3dformat(adapter_format_id),
debug_d3dusage(usage), debug_d3dusagequery(usage), wined3d_debug_bind_flags(bind_flags),
debug_d3dresourcetype(resource_type), debug_d3dformat(check_format_id));
- if (adapter_idx >= wined3d->adapter_count)
- return WINED3DERR_INVALIDCALL;
-
- adapter = wined3d->adapters[adapter_idx];
adapter_format = wined3d_get_format(adapter, adapter_format_id, WINED3D_BIND_RENDER_TARGET);
format = wined3d_get_format(adapter, check_format_id, bind_flags);
@@ -1873,7 +1869,7 @@ HRESULT CDECL wined3d_check_device_type(const struct wined3d *wined3d,
}
/* Validate that the back buffer format is usable for render targets. */
- if (FAILED(wined3d_check_device_format(wined3d, output->adapter->ordinal, device_type,
+ if (FAILED(wined3d_check_device_format(wined3d, output->adapter, device_type,
display_format, 0, WINED3D_BIND_RENDER_TARGET, WINED3D_RTYPE_TEXTURE_2D,
backbuffer_format)))
{
diff --git a/dlls/wined3d/wined3d.spec b/dlls/wined3d/wined3d.spec
index 7000259d0b6..3e511c6c2e1 100644
--- a/dlls/wined3d/wined3d.spec
+++ b/dlls/wined3d/wined3d.spec
@@ -3,7 +3,7 @@
@ cdecl wined3d_calculate_format_pitch(ptr long long long)
@ 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(ptr ptr 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 ptr)
@ cdecl wined3d_check_device_type(ptr ptr long long long long)
diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h
index 30d1da2ce25..8f2829d21d0 100644
--- a/include/wine/wined3d.h
+++ b/include/wine/wined3d.h
@@ -2250,9 +2250,10 @@ UINT __cdecl wined3d_calculate_format_pitch(const struct wined3d *wined3d, UINT
HRESULT __cdecl wined3d_check_depth_stencil_match(const struct wined3d_adapter *adapter,
enum wined3d_device_type device_type, enum wined3d_format_id adapter_format_id,
enum wined3d_format_id render_target_format_id, enum wined3d_format_id depth_stencil_format_id);
-HRESULT __cdecl wined3d_check_device_format(const struct wined3d *wined3d, UINT adaper_idx,
- enum wined3d_device_type device_type, enum wined3d_format_id adapter_format_id, DWORD usage,
- unsigned int bind_flags, enum wined3d_resource_type resource_type, enum wined3d_format_id check_format_id);
+HRESULT __cdecl wined3d_check_device_format(const struct wined3d *wined3d,
+ const struct wined3d_adapter *adapter, enum wined3d_device_type device_type,
+ enum wined3d_format_id adapter_format_id, DWORD usage, unsigned int bind_flags,
+ enum wined3d_resource_type resource_type, enum wined3d_format_id check_format_id);
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);
--
2.20.1