058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync/*
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync * IDirect3D9 implementation
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync *
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync * Copyright 2002 Jason Edmeades
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync * Copyright 2005 Oliver Stieber
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync *
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync * This library is free software; you can redistribute it and/or
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync * modify it under the terms of the GNU Lesser General Public
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync * License as published by the Free Software Foundation; either
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync * version 2.1 of the License, or (at your option) any later version.
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync *
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync * This library is distributed in the hope that it will be useful,
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync * but WITHOUT ANY WARRANTY; without even the implied warranty of
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync * Lesser General Public License for more details.
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync *
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync * You should have received a copy of the GNU Lesser General Public
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync * License along with this library; if not, write to the Free Software
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync */
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
4237d5a79f48789aacc67dc43378d2d7813a39f4vboxsync/*
4237d5a79f48789aacc67dc43378d2d7813a39f4vboxsync * Oracle LGPL Disclaimer: For the avoidance of doubt, except that if any license choice
4237d5a79f48789aacc67dc43378d2d7813a39f4vboxsync * other than GPL or LGPL is available it will apply instead, Oracle elects to use only
4237d5a79f48789aacc67dc43378d2d7813a39f4vboxsync * the Lesser General Public License version 2.1 (LGPLv2) at this time for any software where
4237d5a79f48789aacc67dc43378d2d7813a39f4vboxsync * a choice of LGPL license versions is made available with the language indicating
4237d5a79f48789aacc67dc43378d2d7813a39f4vboxsync * that LGPLv2 or any later version may be used, or where a choice of which version
4237d5a79f48789aacc67dc43378d2d7813a39f4vboxsync * of the LGPL is applied is otherwise unspecified.
4237d5a79f48789aacc67dc43378d2d7813a39f4vboxsync */
4237d5a79f48789aacc67dc43378d2d7813a39f4vboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync#include "config.h"
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync#include "d3d9_private.h"
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsyncWINE_DEFAULT_DEBUG_CHANNEL(d3d9);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsyncstatic inline struct d3d9 *impl_from_IDirect3D9Ex(IDirect3D9Ex *iface)
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync{
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync return CONTAINING_RECORD(iface, struct d3d9, IDirect3D9Ex_iface);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync}
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsyncstatic HRESULT WINAPI d3d9_QueryInterface(IDirect3D9Ex *iface, REFIID riid, void **out)
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync{
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync struct d3d9 *d3d9 = impl_from_IDirect3D9Ex(iface);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync if (IsEqualGUID(riid, &IID_IDirect3D9)
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync || IsEqualGUID(riid, &IID_IUnknown))
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync {
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync IDirect3D9Ex_AddRef(&d3d9->IDirect3D9Ex_iface);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync *out = &d3d9->IDirect3D9Ex_iface;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync return S_OK;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync }
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync if (IsEqualGUID(riid, &IID_IDirect3D9Ex))
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync {
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync if (!d3d9->extended)
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync {
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync WARN("Application asks for IDirect3D9Ex, but this instance wasn't created with Direct3DCreate9Ex.\n");
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync *out = NULL;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync return E_NOINTERFACE;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync }
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync IDirect3D9Ex_AddRef(&d3d9->IDirect3D9Ex_iface);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync *out = &d3d9->IDirect3D9Ex_iface;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync return S_OK;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync }
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync *out = NULL;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync return E_NOINTERFACE;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync}
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsyncstatic ULONG WINAPI d3d9_AddRef(IDirect3D9Ex *iface)
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync{
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync struct d3d9 *d3d9 = impl_from_IDirect3D9Ex(iface);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync ULONG refcount = InterlockedIncrement(&d3d9->refcount);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync TRACE("%p increasing refcount to %u.\n", iface, refcount);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync return refcount;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync}
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsyncstatic ULONG WINAPI d3d9_Release(IDirect3D9Ex *iface)
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync{
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync struct d3d9 *d3d9 = impl_from_IDirect3D9Ex(iface);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync ULONG refcount = InterlockedDecrement(&d3d9->refcount);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync TRACE("%p decreasing refcount to %u.\n", iface, refcount);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync if (!refcount)
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync {
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync wined3d_mutex_lock();
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync wined3d_decref(d3d9->wined3d);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync wined3d_mutex_unlock();
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync HeapFree(GetProcessHeap(), 0, d3d9);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync }
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync return refcount;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync}
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsyncstatic HRESULT WINAPI d3d9_RegisterSoftwareDevice(IDirect3D9Ex *iface, void *init_function)
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync{
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync struct d3d9 *d3d9 = impl_from_IDirect3D9Ex(iface);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync HRESULT hr;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync TRACE("iface %p, init_function %p.\n", iface, init_function);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync wined3d_mutex_lock();
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync hr = wined3d_register_software_device(d3d9->wined3d, init_function);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync wined3d_mutex_unlock();
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync return hr;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync}
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsyncstatic UINT WINAPI d3d9_GetAdapterCount(IDirect3D9Ex *iface)
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync{
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync struct d3d9 *d3d9 = impl_from_IDirect3D9Ex(iface);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync UINT ret;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync TRACE("iface %p.\n", iface);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync wined3d_mutex_lock();
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync ret = wined3d_get_adapter_count(d3d9->wined3d);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync wined3d_mutex_unlock();
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync return ret;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync}
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsyncstatic HRESULT WINAPI d3d9_GetAdapterIdentifier(IDirect3D9Ex *iface, UINT adapter,
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync DWORD flags, D3DADAPTER_IDENTIFIER9 *identifier)
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync{
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync struct d3d9 *d3d9 = impl_from_IDirect3D9Ex(iface);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync struct wined3d_adapter_identifier adapter_id;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync HRESULT hr;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync TRACE("iface %p, adapter %u, flags %#x, identifier %p.\n",
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync iface, adapter, flags, identifier);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync adapter_id.driver = identifier->Driver;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync adapter_id.driver_size = sizeof(identifier->Driver);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync adapter_id.description = identifier->Description;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync adapter_id.description_size = sizeof(identifier->Description);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync adapter_id.device_name = identifier->DeviceName;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync adapter_id.device_name_size = sizeof(identifier->DeviceName);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync wined3d_mutex_lock();
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync hr = wined3d_get_adapter_identifier(d3d9->wined3d, adapter, flags, &adapter_id);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync wined3d_mutex_unlock();
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync identifier->DriverVersion = adapter_id.driver_version;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync identifier->VendorId = adapter_id.vendor_id;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync identifier->DeviceId = adapter_id.device_id;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync identifier->SubSysId = adapter_id.subsystem_id;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync identifier->Revision = adapter_id.revision;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync memcpy(&identifier->DeviceIdentifier, &adapter_id.device_identifier, sizeof(identifier->DeviceIdentifier));
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync identifier->WHQLLevel = adapter_id.whql_level;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync return hr;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync}
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsyncstatic UINT WINAPI d3d9_GetAdapterModeCount(IDirect3D9Ex *iface, UINT adapter, D3DFORMAT format)
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync{
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync struct d3d9 *d3d9 = impl_from_IDirect3D9Ex(iface);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync UINT ret;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync TRACE("iface %p, adapter %u, format %#x.\n", iface, adapter, format);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync /* Others than that not supported by d3d9, but reported by wined3d for ddraw. Filter them out. */
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync if (format != D3DFMT_X8R8G8B8 && format != D3DFMT_R5G6B5)
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync return 0;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync wined3d_mutex_lock();
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync ret = wined3d_get_adapter_mode_count(d3d9->wined3d, adapter,
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync wined3dformat_from_d3dformat(format), WINED3D_SCANLINE_ORDERING_UNKNOWN);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync wined3d_mutex_unlock();
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync return ret;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync}
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsyncstatic HRESULT WINAPI d3d9_EnumAdapterModes(IDirect3D9Ex *iface, UINT adapter,
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync D3DFORMAT format, UINT mode_idx, D3DDISPLAYMODE *mode)
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync{
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync struct d3d9 *d3d9 = impl_from_IDirect3D9Ex(iface);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync struct wined3d_display_mode wined3d_mode;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync HRESULT hr;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync TRACE("iface %p, adapter %u, format %#x, mode_idx %u, mode %p.\n",
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync iface, adapter, format, mode_idx, mode);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync if (format != D3DFMT_X8R8G8B8 && format != D3DFMT_R5G6B5)
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync return D3DERR_INVALIDCALL;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync wined3d_mutex_lock();
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync hr = wined3d_enum_adapter_modes(d3d9->wined3d, adapter, wined3dformat_from_d3dformat(format),
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync WINED3D_SCANLINE_ORDERING_UNKNOWN, mode_idx, &wined3d_mode);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync wined3d_mutex_unlock();
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync if (SUCCEEDED(hr))
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync {
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync mode->Width = wined3d_mode.width;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync mode->Height = wined3d_mode.height;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync mode->RefreshRate = wined3d_mode.refresh_rate;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync mode->Format = d3dformat_from_wined3dformat(wined3d_mode.format_id);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync }
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync return hr;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync}
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsyncstatic HRESULT WINAPI d3d9_GetAdapterDisplayMode(IDirect3D9Ex *iface, UINT adapter, D3DDISPLAYMODE *mode)
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync{
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync struct d3d9 *d3d9 = impl_from_IDirect3D9Ex(iface);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync struct wined3d_display_mode wined3d_mode;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync HRESULT hr;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync TRACE("iface %p, adapter %u, mode %p.\n", iface, adapter, mode);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync wined3d_mutex_lock();
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync hr = wined3d_get_adapter_display_mode(d3d9->wined3d, adapter, &wined3d_mode, NULL);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync wined3d_mutex_unlock();
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync if (SUCCEEDED(hr))
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync {
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync mode->Width = wined3d_mode.width;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync mode->Height = wined3d_mode.height;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync mode->RefreshRate = wined3d_mode.refresh_rate;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync mode->Format = d3dformat_from_wined3dformat(wined3d_mode.format_id);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync }
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync return hr;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync}
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsyncstatic HRESULT WINAPI d3d9_CheckDeviceType(IDirect3D9Ex *iface, UINT adapter, D3DDEVTYPE device_type,
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync D3DFORMAT display_format, D3DFORMAT backbuffer_format, BOOL windowed)
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync{
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync struct d3d9 *d3d9 = impl_from_IDirect3D9Ex(iface);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync HRESULT hr;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync TRACE("iface %p, adapter %u, device_type %#x, display_format %#x, backbuffer_format %#x, windowed %#x.\n",
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync iface, adapter, device_type, display_format, backbuffer_format, windowed);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync wined3d_mutex_lock();
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync hr = wined3d_check_device_type(d3d9->wined3d, adapter, device_type, wined3dformat_from_d3dformat(display_format),
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync wined3dformat_from_d3dformat(backbuffer_format), windowed);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync wined3d_mutex_unlock();
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync return hr;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync}
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsyncstatic HRESULT WINAPI d3d9_CheckDeviceFormat(IDirect3D9Ex *iface, UINT adapter, D3DDEVTYPE device_type,
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync D3DFORMAT adapter_format, DWORD usage, D3DRESOURCETYPE resource_type, D3DFORMAT format)
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync{
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync struct d3d9 *d3d9 = impl_from_IDirect3D9Ex(iface);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync enum wined3d_resource_type wined3d_rtype;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync HRESULT hr;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync TRACE("iface %p, adapter %u, device_type %#x, adapter_format %#x, usage %#x, resource_type %#x, format %#x.\n",
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync iface, adapter, device_type, adapter_format, usage, resource_type, format);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync switch (resource_type)
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync {
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync case D3DRTYPE_VERTEXBUFFER:
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync case D3DRTYPE_INDEXBUFFER:
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync wined3d_rtype = WINED3D_RTYPE_BUFFER;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync break;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync default:
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync wined3d_rtype = resource_type;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync break;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync }
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync wined3d_mutex_lock();
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync hr = wined3d_check_device_format(d3d9->wined3d, adapter, device_type, wined3dformat_from_d3dformat(adapter_format),
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync usage, wined3d_rtype, wined3dformat_from_d3dformat(format));
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync wined3d_mutex_unlock();
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync return hr;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync}
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsyncstatic HRESULT WINAPI d3d9_CheckDeviceMultiSampleType(IDirect3D9Ex *iface, UINT adapter, D3DDEVTYPE device_type,
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync D3DFORMAT format, BOOL windowed, D3DMULTISAMPLE_TYPE multisample_type, DWORD *levels)
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync{
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync struct d3d9 *d3d9 = impl_from_IDirect3D9Ex(iface);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync HRESULT hr;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync TRACE("iface %p, adapter %u, device_type %#x, format %#x, windowed %#x, multisample_type %#x, levels %p.\n",
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync iface, adapter, device_type, format, windowed, multisample_type, levels);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync wined3d_mutex_lock();
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync hr = wined3d_check_device_multisample_type(d3d9->wined3d, adapter, device_type,
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync wined3dformat_from_d3dformat(format), windowed, multisample_type, levels);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync wined3d_mutex_unlock();
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync return hr;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync}
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsyncstatic HRESULT WINAPI d3d9_CheckDepthStencilMatch(IDirect3D9Ex *iface, UINT adapter, D3DDEVTYPE device_type,
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync D3DFORMAT adapter_format, D3DFORMAT rt_format, D3DFORMAT ds_format)
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync{
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync struct d3d9 *d3d9 = impl_from_IDirect3D9Ex(iface);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync HRESULT hr;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync TRACE("iface %p, adapter %u, device_type %#x, adapter_format %#x, rt_format %#x, ds_format %#x.\n",
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync iface, adapter, device_type, adapter_format, rt_format, ds_format);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync wined3d_mutex_lock();
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync hr = wined3d_check_depth_stencil_match(d3d9->wined3d, adapter, device_type,
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync wined3dformat_from_d3dformat(adapter_format), wined3dformat_from_d3dformat(rt_format),
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync wined3dformat_from_d3dformat(ds_format));
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync wined3d_mutex_unlock();
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync return hr;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync}
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsyncstatic HRESULT WINAPI d3d9_CheckDeviceFormatConversion(IDirect3D9Ex *iface, UINT adapter,
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync D3DDEVTYPE device_type, D3DFORMAT src_format, D3DFORMAT dst_format)
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync{
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync struct d3d9 *d3d9 = impl_from_IDirect3D9Ex(iface);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync HRESULT hr;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync TRACE("iface %p, adapter %u, device_type %#x, src_format %#x, dst_format %#x.\n",
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync iface, adapter, device_type, src_format, dst_format);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync wined3d_mutex_lock();
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync hr = wined3d_check_device_format_conversion(d3d9->wined3d, adapter, device_type,
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync wined3dformat_from_d3dformat(src_format), wined3dformat_from_d3dformat(dst_format));
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync wined3d_mutex_unlock();
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync return hr;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync}
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsyncvoid filter_caps(D3DCAPS9* pCaps)
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync{
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync DWORD ps_minor_version[] = {0, 4, 0, 0};
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync DWORD vs_minor_version[] = {0, 1, 0, 0};
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync DWORD textureFilterCaps =
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync D3DPTFILTERCAPS_MINFPOINT | D3DPTFILTERCAPS_MINFLINEAR | D3DPTFILTERCAPS_MINFANISOTROPIC |
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync D3DPTFILTERCAPS_MINFPYRAMIDALQUAD | D3DPTFILTERCAPS_MINFGAUSSIANQUAD|
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync D3DPTFILTERCAPS_MIPFPOINT | D3DPTFILTERCAPS_MIPFLINEAR | D3DPTFILTERCAPS_MAGFPOINT |
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync D3DPTFILTERCAPS_MAGFLINEAR |D3DPTFILTERCAPS_MAGFANISOTROPIC|D3DPTFILTERCAPS_MAGFPYRAMIDALQUAD|
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync D3DPTFILTERCAPS_MAGFGAUSSIANQUAD;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync pCaps->TextureFilterCaps &= textureFilterCaps;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync pCaps->CubeTextureFilterCaps &= textureFilterCaps;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync pCaps->VolumeTextureFilterCaps &= textureFilterCaps;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync pCaps->DevCaps &=
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync D3DDEVCAPS_EXECUTESYSTEMMEMORY | D3DDEVCAPS_EXECUTEVIDEOMEMORY | D3DDEVCAPS_TLVERTEXSYSTEMMEMORY |
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync D3DDEVCAPS_TLVERTEXVIDEOMEMORY | D3DDEVCAPS_TEXTURESYSTEMMEMORY| D3DDEVCAPS_TEXTUREVIDEOMEMORY |
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync D3DDEVCAPS_DRAWPRIMTLVERTEX | D3DDEVCAPS_CANRENDERAFTERFLIP | D3DDEVCAPS_TEXTURENONLOCALVIDMEM|
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync D3DDEVCAPS_DRAWPRIMITIVES2 | D3DDEVCAPS_SEPARATETEXTUREMEMORIES |
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync D3DDEVCAPS_DRAWPRIMITIVES2EX | D3DDEVCAPS_HWTRANSFORMANDLIGHT| D3DDEVCAPS_CANBLTSYSTONONLOCAL |
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync D3DDEVCAPS_HWRASTERIZATION | D3DDEVCAPS_PUREDEVICE | D3DDEVCAPS_QUINTICRTPATCHES |
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync D3DDEVCAPS_RTPATCHES | D3DDEVCAPS_RTPATCHHANDLEZERO | D3DDEVCAPS_NPATCHES;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync pCaps->ShadeCaps &=
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync D3DPSHADECAPS_COLORGOURAUDRGB | D3DPSHADECAPS_SPECULARGOURAUDRGB |
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync D3DPSHADECAPS_ALPHAGOURAUDBLEND | D3DPSHADECAPS_FOGGOURAUD;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync pCaps->RasterCaps &=
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync D3DPRASTERCAPS_DITHER | D3DPRASTERCAPS_ZTEST | D3DPRASTERCAPS_FOGVERTEX |
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync D3DPRASTERCAPS_FOGTABLE | D3DPRASTERCAPS_MIPMAPLODBIAS | D3DPRASTERCAPS_ZBUFFERLESSHSR |
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync D3DPRASTERCAPS_FOGRANGE | D3DPRASTERCAPS_ANISOTROPY | D3DPRASTERCAPS_WBUFFER |
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync D3DPRASTERCAPS_WFOG | D3DPRASTERCAPS_ZFOG | D3DPRASTERCAPS_COLORPERSPECTIVE |
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync D3DPRASTERCAPS_SCISSORTEST | D3DPRASTERCAPS_SLOPESCALEDEPTHBIAS |
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync D3DPRASTERCAPS_DEPTHBIAS | D3DPRASTERCAPS_MULTISAMPLE_TOGGLE;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync pCaps->DevCaps2 &=
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync D3DDEVCAPS2_STREAMOFFSET | D3DDEVCAPS2_DMAPNPATCH | D3DDEVCAPS2_ADAPTIVETESSRTPATCH |
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync D3DDEVCAPS2_ADAPTIVETESSNPATCH | D3DDEVCAPS2_CAN_STRETCHRECT_FROM_TEXTURES |
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync D3DDEVCAPS2_PRESAMPLEDDMAPNPATCH| D3DDEVCAPS2_VERTEXELEMENTSCANSHARESTREAMOFFSET;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync pCaps->Caps2 &=
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync D3DCAPS2_FULLSCREENGAMMA | D3DCAPS2_CANCALIBRATEGAMMA | D3DCAPS2_RESERVED |
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync D3DCAPS2_CANMANAGERESOURCE | D3DCAPS2_DYNAMICTEXTURES | D3DCAPS2_CANAUTOGENMIPMAP;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync pCaps->VertexProcessingCaps &=
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync D3DVTXPCAPS_TEXGEN | D3DVTXPCAPS_MATERIALSOURCE7 | D3DVTXPCAPS_DIRECTIONALLIGHTS |
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync D3DVTXPCAPS_POSITIONALLIGHTS | D3DVTXPCAPS_LOCALVIEWER | D3DVTXPCAPS_TWEENING |
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync D3DVTXPCAPS_TEXGEN_SPHEREMAP | D3DVTXPCAPS_NO_TEXGEN_NONLOCALVIEWER;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync pCaps->TextureCaps &=
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync D3DPTEXTURECAPS_PERSPECTIVE | D3DPTEXTURECAPS_POW2 | D3DPTEXTURECAPS_ALPHA |
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync D3DPTEXTURECAPS_SQUAREONLY | D3DPTEXTURECAPS_TEXREPEATNOTSCALEDBYSIZE |
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync D3DPTEXTURECAPS_ALPHAPALETTE | D3DPTEXTURECAPS_NONPOW2CONDITIONAL |
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync D3DPTEXTURECAPS_PROJECTED | D3DPTEXTURECAPS_CUBEMAP | D3DPTEXTURECAPS_VOLUMEMAP |
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync D3DPTEXTURECAPS_MIPMAP | D3DPTEXTURECAPS_MIPVOLUMEMAP | D3DPTEXTURECAPS_MIPCUBEMAP |
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync D3DPTEXTURECAPS_CUBEMAP_POW2 | D3DPTEXTURECAPS_VOLUMEMAP_POW2| D3DPTEXTURECAPS_NOPROJECTEDBUMPENV;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync pCaps->MaxVertexShaderConst = min(D3D9_MAX_VERTEX_SHADER_CONSTANTF, pCaps->MaxVertexShaderConst);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync pCaps->NumSimultaneousRTs = min(D3D9_MAX_SIMULTANEOUS_RENDERTARGETS, pCaps->NumSimultaneousRTs);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync if (pCaps->PixelShaderVersion > 3)
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync pCaps->PixelShaderVersion = D3DPS_VERSION(3,0);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync else
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync {
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync DWORD major = pCaps->PixelShaderVersion;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync pCaps->PixelShaderVersion = D3DPS_VERSION(major,ps_minor_version[major]);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync }
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync if (pCaps->VertexShaderVersion > 3)
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync pCaps->VertexShaderVersion = D3DVS_VERSION(3,0);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync else
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync {
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync DWORD major = pCaps->VertexShaderVersion;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync pCaps->VertexShaderVersion = D3DVS_VERSION(major,vs_minor_version[major]);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync }
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync}
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsyncstatic HRESULT WINAPI d3d9_GetDeviceCaps(IDirect3D9Ex *iface, UINT adapter, D3DDEVTYPE device_type, D3DCAPS9 *caps)
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync{
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync struct d3d9 *d3d9 = impl_from_IDirect3D9Ex(iface);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync WINED3DCAPS *wined3d_caps;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync HRESULT hr;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync TRACE("iface %p, adapter %u, device_type %#x, caps %p.\n", iface, adapter, device_type, caps);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync if (!caps)
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync return D3DERR_INVALIDCALL;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync if (!(wined3d_caps = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(WINED3DCAPS))))
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync return D3DERR_INVALIDCALL; /*well this is what MSDN says to return*/
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync memset(caps, 0, sizeof(*caps));
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync wined3d_mutex_lock();
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync hr = wined3d_get_device_caps(d3d9->wined3d, adapter, device_type, wined3d_caps);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync wined3d_mutex_unlock();
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync WINECAPSTOD3D9CAPS(caps, wined3d_caps)
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync HeapFree(GetProcessHeap(), 0, wined3d_caps);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync /* Some functionality is implemented in d3d9.dll, not wined3d.dll. Add the needed caps */
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync caps->DevCaps2 |= D3DDEVCAPS2_CAN_STRETCHRECT_FROM_TEXTURES;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync filter_caps(caps);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync return hr;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync}
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsyncstatic HMONITOR WINAPI d3d9_GetAdapterMonitor(IDirect3D9Ex *iface, UINT adapter)
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync{
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync struct d3d9 *d3d9 = impl_from_IDirect3D9Ex(iface);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync HMONITOR ret;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync TRACE("iface %p, adapter %u.\n", iface, adapter);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync wined3d_mutex_lock();
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync ret = wined3d_get_adapter_monitor(d3d9->wined3d, adapter);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync wined3d_mutex_unlock();
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync return ret;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync}
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsyncstatic HRESULT WINAPI DECLSPEC_HOTPATCH d3d9_CreateDevice(IDirect3D9Ex *iface, UINT adapter,
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync D3DDEVTYPE device_type, HWND focus_window, DWORD flags, D3DPRESENT_PARAMETERS *parameters,
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync IDirect3DDevice9 **device)
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync{
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync struct d3d9 *d3d9 = impl_from_IDirect3D9Ex(iface);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync struct d3d9_device *object;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync HRESULT hr;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync TRACE("iface %p, adapter %u, device_type %#x, focus_window %p, flags %#x, parameters %p, device %p.\n",
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync iface, adapter, device_type, focus_window, flags, parameters, device);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync if (!object)
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync return E_OUTOFMEMORY;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync hr = device_init(object, d3d9, d3d9->wined3d, adapter, device_type, focus_window, flags,
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync#ifdef VBOX_WITH_WDDM
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync (VBOXWINEEX_D3DPRESENT_PARAMETERS *)
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync#endif
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync parameters, NULL);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync if (FAILED(hr))
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync {
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync WARN("Failed to initialize device, hr %#x.\n", hr);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync HeapFree(GetProcessHeap(), 0, object);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync return hr;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync }
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync TRACE("Created device %p.\n", object);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync *device = (IDirect3DDevice9 *)object;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync return D3D_OK;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync}
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsyncstatic UINT WINAPI d3d9_GetAdapterModeCountEx(IDirect3D9Ex *iface,
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync UINT adapter, const D3DDISPLAYMODEFILTER *filter)
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync{
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync struct d3d9 *d3d9 = impl_from_IDirect3D9Ex(iface);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync UINT ret;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync TRACE("iface %p, adapter %u, filter %p.\n", iface, adapter, filter);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync if (filter->Format != D3DFMT_X8R8G8B8 && filter->Format != D3DFMT_R5G6B5)
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync return 0;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync wined3d_mutex_lock();
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync ret = wined3d_get_adapter_mode_count(d3d9->wined3d, adapter,
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync wined3dformat_from_d3dformat(filter->Format), filter->ScanLineOrdering);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync wined3d_mutex_unlock();
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync return ret;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync}
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsyncstatic HRESULT WINAPI d3d9_EnumAdapterModesEx(IDirect3D9Ex *iface,
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync UINT adapter, const D3DDISPLAYMODEFILTER *filter, UINT mode_idx, D3DDISPLAYMODEEX *mode)
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync{
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync struct d3d9 *d3d9 = impl_from_IDirect3D9Ex(iface);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync struct wined3d_display_mode wined3d_mode;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync HRESULT hr;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync TRACE("iface %p, adapter %u, filter %p, mode_idx %u, mode %p.\n",
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync iface, adapter, filter, mode_idx, mode);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync if (filter->Format != D3DFMT_X8R8G8B8 && filter->Format != D3DFMT_R5G6B5)
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync return D3DERR_INVALIDCALL;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync wined3d_mutex_lock();
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync hr = wined3d_enum_adapter_modes(d3d9->wined3d, adapter, wined3dformat_from_d3dformat(filter->Format),
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync filter->ScanLineOrdering, mode_idx, &wined3d_mode);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync wined3d_mutex_unlock();
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync if (SUCCEEDED(hr))
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync {
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync mode->Width = wined3d_mode.width;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync mode->Height = wined3d_mode.height;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync mode->RefreshRate = wined3d_mode.refresh_rate;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync mode->Format = d3dformat_from_wined3dformat(wined3d_mode.format_id);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync mode->ScanLineOrdering = wined3d_mode.scanline_ordering;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync }
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync return hr;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync}
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsyncstatic HRESULT WINAPI d3d9_GetAdapterDisplayModeEx(IDirect3D9Ex *iface,
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync UINT adapter, D3DDISPLAYMODEEX *mode, D3DDISPLAYROTATION *rotation)
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync{
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync struct d3d9 *d3d9 = impl_from_IDirect3D9Ex(iface);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync struct wined3d_display_mode wined3d_mode;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync HRESULT hr;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync TRACE("iface %p, adapter %u, mode %p, rotation %p.\n",
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync iface, adapter, mode, rotation);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync if (mode->Size != sizeof(*mode))
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync return D3DERR_INVALIDCALL;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync wined3d_mutex_lock();
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync hr = wined3d_get_adapter_display_mode(d3d9->wined3d, adapter, &wined3d_mode,
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync (enum wined3d_display_rotation *)rotation);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync wined3d_mutex_unlock();
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync if (SUCCEEDED(hr))
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync {
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync mode->Width = wined3d_mode.width;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync mode->Height = wined3d_mode.height;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync mode->RefreshRate = wined3d_mode.refresh_rate;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync mode->Format = d3dformat_from_wined3dformat(wined3d_mode.format_id);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync mode->ScanLineOrdering = wined3d_mode.scanline_ordering;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync }
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync return hr;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync}
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsyncstatic HRESULT WINAPI DECLSPEC_HOTPATCH d3d9_CreateDeviceEx(IDirect3D9Ex *iface,
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync UINT adapter, D3DDEVTYPE device_type, HWND focus_window, DWORD flags,
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync D3DPRESENT_PARAMETERS *parameters, D3DDISPLAYMODEEX *mode, IDirect3DDevice9Ex **device)
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync{
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync struct d3d9 *d3d9 = impl_from_IDirect3D9Ex(iface);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync struct d3d9_device *object;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync HRESULT hr;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync TRACE("iface %p, adapter %u, device_type %#x, focus_window %p, flags %#x, parameters %p, mode %p, device %p.\n",
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync iface, adapter, device_type, focus_window, flags, parameters, mode, device);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync if (!object)
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync return E_OUTOFMEMORY;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync hr = device_init(object, d3d9, d3d9->wined3d, adapter, device_type, focus_window, flags,
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync#ifdef VBOX_WITH_WDDM
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync (VBOXWINEEX_D3DPRESENT_PARAMETERS *)
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync#endif
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync parameters, mode);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync if (FAILED(hr))
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync {
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync WARN("Failed to initialize device, hr %#x.\n", hr);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync HeapFree(GetProcessHeap(), 0, object);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync return hr;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync }
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync TRACE("Created device %p.\n", object);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync *device = &object->IDirect3DDevice9Ex_iface;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync return D3D_OK;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync}
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsyncstatic HRESULT WINAPI d3d9_GetAdapterLUID(IDirect3D9Ex *iface, UINT adapter, LUID *luid)
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync{
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync struct d3d9 *d3d9 = impl_from_IDirect3D9Ex(iface);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync struct wined3d_adapter_identifier adapter_id;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync HRESULT hr;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync TRACE("iface %p, adapter %u, luid %p.\n", iface, adapter, luid);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync adapter_id.driver_size = 0;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync adapter_id.description_size = 0;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync adapter_id.device_name_size = 0;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync wined3d_mutex_lock();
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync hr = wined3d_get_adapter_identifier(d3d9->wined3d, adapter, 0, &adapter_id);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync wined3d_mutex_unlock();
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync memcpy(luid, &adapter_id.adapter_luid, sizeof(*luid));
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync return hr;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync}
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsyncstatic const struct IDirect3D9ExVtbl d3d9_vtbl =
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync{
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync /* IUnknown */
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync d3d9_QueryInterface,
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync d3d9_AddRef,
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync d3d9_Release,
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync /* IDirect3D9 */
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync d3d9_RegisterSoftwareDevice,
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync d3d9_GetAdapterCount,
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync d3d9_GetAdapterIdentifier,
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync d3d9_GetAdapterModeCount,
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync d3d9_EnumAdapterModes,
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync d3d9_GetAdapterDisplayMode,
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync d3d9_CheckDeviceType,
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync d3d9_CheckDeviceFormat,
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync d3d9_CheckDeviceMultiSampleType,
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync d3d9_CheckDepthStencilMatch,
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync d3d9_CheckDeviceFormatConversion,
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync d3d9_GetDeviceCaps,
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync d3d9_GetAdapterMonitor,
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync d3d9_CreateDevice,
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync /* IDirect3D9Ex */
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync d3d9_GetAdapterModeCountEx,
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync d3d9_EnumAdapterModesEx,
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync d3d9_GetAdapterDisplayModeEx,
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync d3d9_CreateDeviceEx,
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync d3d9_GetAdapterLUID,
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync};
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsyncBOOL d3d9_init(struct d3d9 *d3d9, BOOL extended)
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync{
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync DWORD flags = extended ? 0 : WINED3D_VIDMEM_ACCOUNTING;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync d3d9->IDirect3D9Ex_iface.lpVtbl = &d3d9_vtbl;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync d3d9->refcount = 1;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync wined3d_mutex_lock();
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync d3d9->wined3d = wined3d_create(9, flags);
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync wined3d_mutex_unlock();
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync if (!d3d9->wined3d)
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync return FALSE;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync d3d9->extended = extended;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync return TRUE;
058c0c53c37f5cb271aeb3c385c10766f84f4aefvboxsync}