2002-09-27 22:46:16 +00:00
|
|
|
/*
|
|
|
|
* IDirect3D8 implementation
|
|
|
|
*
|
2004-04-15 23:58:15 +00:00
|
|
|
* Copyright 2002-2004 Jason Edmeades
|
2004-04-19 23:04:58 +00:00
|
|
|
* Copyright 2003-2004 Raphael Junqueira
|
2004-04-15 23:58:15 +00:00
|
|
|
* Copyright 2004 Christian Costa
|
2002-09-27 22:46:16 +00:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 12:49:52 +00:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2002-09-27 22:46:16 +00:00
|
|
|
*/
|
|
|
|
|
2003-04-22 04:05:08 +00:00
|
|
|
#include "config.h"
|
|
|
|
|
2003-09-05 23:08:26 +00:00
|
|
|
#include <stdarg.h>
|
|
|
|
|
2003-01-07 20:36:20 +00:00
|
|
|
#define NONAMELESSUNION
|
|
|
|
#define NONAMELESSSTRUCT
|
2002-09-27 22:46:16 +00:00
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "wingdi.h"
|
2003-09-16 20:24:49 +00:00
|
|
|
#include "winuser.h"
|
2002-09-27 22:46:16 +00:00
|
|
|
#include "wine/debug.h"
|
2003-06-04 22:55:19 +00:00
|
|
|
#include "wine/unicode.h"
|
2002-09-27 22:46:16 +00:00
|
|
|
|
|
|
|
#include "d3d8_private.h"
|
|
|
|
|
2006-02-25 12:15:08 +00:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(d3d8);
|
2002-09-27 22:46:16 +00:00
|
|
|
|
2011-01-23 20:49:42 +00:00
|
|
|
static inline IDirect3D8Impl *impl_from_IDirect3D8(IDirect3D8 *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, IDirect3D8Impl, IDirect3D8_iface);
|
|
|
|
}
|
|
|
|
|
2006-06-10 09:48:24 +00:00
|
|
|
static HRESULT WINAPI IDirect3D8Impl_QueryInterface(LPDIRECT3D8 iface, REFIID riid,LPVOID *ppobj)
|
2002-09-27 22:46:16 +00:00
|
|
|
{
|
2011-01-23 20:49:42 +00:00
|
|
|
IDirect3D8Impl *This = impl_from_IDirect3D8(iface);
|
2002-09-27 22:46:16 +00:00
|
|
|
|
2009-10-19 08:12:20 +00:00
|
|
|
TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), ppobj);
|
|
|
|
|
2002-09-27 22:46:16 +00:00
|
|
|
if (IsEqualGUID(riid, &IID_IUnknown)
|
2002-12-17 01:15:15 +00:00
|
|
|
|| IsEqualGUID(riid, &IID_IDirect3D8)) {
|
2006-02-25 12:15:08 +00:00
|
|
|
IUnknown_AddRef(iface);
|
2002-09-27 22:46:16 +00:00
|
|
|
*ppobj = This;
|
2006-06-07 13:13:29 +00:00
|
|
|
return S_OK;
|
2002-09-27 22:46:16 +00:00
|
|
|
}
|
|
|
|
|
2006-02-25 12:15:08 +00:00
|
|
|
WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid),ppobj);
|
2006-06-07 13:13:29 +00:00
|
|
|
*ppobj = NULL;
|
2002-09-27 22:46:16 +00:00
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
2011-01-23 20:49:42 +00:00
|
|
|
static ULONG WINAPI IDirect3D8Impl_AddRef(LPDIRECT3D8 iface)
|
|
|
|
{
|
|
|
|
IDirect3D8Impl *This = impl_from_IDirect3D8(iface);
|
2005-01-24 11:31:45 +00:00
|
|
|
ULONG ref = InterlockedIncrement(&This->ref);
|
|
|
|
|
2009-10-19 08:12:20 +00:00
|
|
|
TRACE("%p increasing refcount to %u.\n", iface, ref);
|
2005-01-24 11:31:45 +00:00
|
|
|
|
|
|
|
return ref;
|
2002-09-27 22:46:16 +00:00
|
|
|
}
|
|
|
|
|
2011-01-23 20:49:42 +00:00
|
|
|
static ULONG WINAPI IDirect3D8Impl_Release(LPDIRECT3D8 iface)
|
|
|
|
{
|
|
|
|
IDirect3D8Impl *This = impl_from_IDirect3D8(iface);
|
2005-01-24 11:31:45 +00:00
|
|
|
ULONG ref = InterlockedDecrement(&This->ref);
|
|
|
|
|
2009-10-19 08:12:20 +00:00
|
|
|
TRACE("%p decreasing refcount to %u.\n", iface, ref);
|
2005-01-24 11:31:45 +00:00
|
|
|
|
2004-09-28 02:12:12 +00:00
|
|
|
if (ref == 0) {
|
2006-02-25 12:15:08 +00:00
|
|
|
TRACE("Releasing wined3d %p\n", This->WineD3D);
|
2009-08-25 06:17:14 +00:00
|
|
|
|
|
|
|
wined3d_mutex_lock();
|
2011-02-01 18:39:53 +00:00
|
|
|
wined3d_decref(This->WineD3D);
|
2009-08-25 06:17:14 +00:00
|
|
|
wined3d_mutex_unlock();
|
|
|
|
|
2002-09-27 22:46:16 +00:00
|
|
|
HeapFree(GetProcessHeap(), 0, This);
|
2004-09-28 02:12:12 +00:00
|
|
|
}
|
2006-02-25 12:15:08 +00:00
|
|
|
|
2002-09-27 22:46:16 +00:00
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
2011-01-23 20:49:42 +00:00
|
|
|
static HRESULT WINAPI IDirect3D8Impl_RegisterSoftwareDevice(LPDIRECT3D8 iface,
|
|
|
|
void* pInitializeFunction)
|
|
|
|
{
|
|
|
|
IDirect3D8Impl *This = impl_from_IDirect3D8(iface);
|
2007-05-22 22:33:42 +00:00
|
|
|
HRESULT hr;
|
2009-10-19 08:12:20 +00:00
|
|
|
|
|
|
|
TRACE("iface %p, init_function %p.\n", iface, pInitializeFunction);
|
2007-05-22 22:33:42 +00:00
|
|
|
|
2009-08-25 06:17:14 +00:00
|
|
|
wined3d_mutex_lock();
|
2011-02-01 18:39:53 +00:00
|
|
|
hr = wined3d_register_software_device(This->WineD3D, pInitializeFunction);
|
2009-08-25 06:17:14 +00:00
|
|
|
wined3d_mutex_unlock();
|
|
|
|
|
2007-05-22 22:33:42 +00:00
|
|
|
return hr;
|
2002-09-27 22:46:16 +00:00
|
|
|
}
|
|
|
|
|
2011-01-23 20:49:42 +00:00
|
|
|
static UINT WINAPI IDirect3D8Impl_GetAdapterCount(LPDIRECT3D8 iface)
|
|
|
|
{
|
|
|
|
IDirect3D8Impl *This = impl_from_IDirect3D8(iface);
|
2007-05-22 22:33:42 +00:00
|
|
|
HRESULT hr;
|
2009-10-19 08:12:20 +00:00
|
|
|
|
|
|
|
TRACE("iface %p.\n", iface);
|
2007-05-22 22:33:42 +00:00
|
|
|
|
2009-08-25 06:17:14 +00:00
|
|
|
wined3d_mutex_lock();
|
2011-02-01 18:39:53 +00:00
|
|
|
hr = wined3d_get_adapter_count(This->WineD3D);
|
2009-08-25 06:17:14 +00:00
|
|
|
wined3d_mutex_unlock();
|
|
|
|
|
2007-05-22 22:33:42 +00:00
|
|
|
return hr;
|
2002-09-27 22:46:16 +00:00
|
|
|
}
|
|
|
|
|
2011-01-23 20:49:42 +00:00
|
|
|
static HRESULT WINAPI IDirect3D8Impl_GetAdapterIdentifier(LPDIRECT3D8 iface, UINT Adapter,
|
|
|
|
DWORD Flags, D3DADAPTER_IDENTIFIER8 *pIdentifier)
|
2009-07-07 09:08:03 +00:00
|
|
|
{
|
2011-01-23 20:49:42 +00:00
|
|
|
IDirect3D8Impl *This = impl_from_IDirect3D8(iface);
|
2011-11-23 20:14:57 +00:00
|
|
|
struct wined3d_adapter_identifier adapter_id;
|
2007-05-22 22:33:42 +00:00
|
|
|
HRESULT hr;
|
2004-09-29 21:26:47 +00:00
|
|
|
|
2009-10-19 08:12:20 +00:00
|
|
|
TRACE("iface %p, adapter %u, flags %#x, identifier %p.\n",
|
|
|
|
iface, Adapter, Flags, pIdentifier);
|
2004-09-29 21:26:47 +00:00
|
|
|
|
2009-07-07 09:08:03 +00:00
|
|
|
adapter_id.driver = pIdentifier->Driver;
|
|
|
|
adapter_id.driver_size = sizeof(pIdentifier->Driver);
|
|
|
|
adapter_id.description = pIdentifier->Description;
|
|
|
|
adapter_id.description_size = sizeof(pIdentifier->Description);
|
|
|
|
adapter_id.device_name = NULL; /* d3d9 only */
|
|
|
|
adapter_id.device_name_size = 0; /* d3d9 only */
|
|
|
|
|
2009-08-25 06:17:14 +00:00
|
|
|
wined3d_mutex_lock();
|
2011-02-01 18:39:53 +00:00
|
|
|
hr = wined3d_get_adapter_identifier(This->WineD3D, Adapter, Flags, &adapter_id);
|
2009-08-25 06:17:14 +00:00
|
|
|
wined3d_mutex_unlock();
|
2009-07-07 09:08:03 +00:00
|
|
|
|
|
|
|
pIdentifier->DriverVersion = adapter_id.driver_version;
|
|
|
|
pIdentifier->VendorId = adapter_id.vendor_id;
|
|
|
|
pIdentifier->DeviceId = adapter_id.device_id;
|
|
|
|
pIdentifier->SubSysId = adapter_id.subsystem_id;
|
|
|
|
pIdentifier->Revision = adapter_id.revision;
|
|
|
|
memcpy(&pIdentifier->DeviceIdentifier, &adapter_id.device_identifier, sizeof(pIdentifier->DeviceIdentifier));
|
|
|
|
pIdentifier->WHQLLevel = adapter_id.whql_level;
|
|
|
|
|
2007-05-22 22:33:42 +00:00
|
|
|
return hr;
|
2002-09-27 22:46:16 +00:00
|
|
|
}
|
|
|
|
|
2011-01-23 20:49:42 +00:00
|
|
|
static UINT WINAPI IDirect3D8Impl_GetAdapterModeCount(LPDIRECT3D8 iface,UINT Adapter)
|
|
|
|
{
|
|
|
|
IDirect3D8Impl *This = impl_from_IDirect3D8(iface);
|
2007-05-22 22:33:42 +00:00
|
|
|
HRESULT hr;
|
2009-10-19 08:12:20 +00:00
|
|
|
|
|
|
|
TRACE("iface %p, adapter %u.\n", iface, Adapter);
|
2007-05-22 22:33:42 +00:00
|
|
|
|
2009-08-25 06:17:14 +00:00
|
|
|
wined3d_mutex_lock();
|
2011-02-01 18:39:53 +00:00
|
|
|
hr = wined3d_get_adapter_mode_count(This->WineD3D, Adapter, 0);
|
2009-08-25 06:17:14 +00:00
|
|
|
wined3d_mutex_unlock();
|
|
|
|
|
2007-05-22 22:33:42 +00:00
|
|
|
return hr;
|
2002-09-27 22:46:16 +00:00
|
|
|
}
|
|
|
|
|
2011-01-23 20:49:42 +00:00
|
|
|
static HRESULT WINAPI IDirect3D8Impl_EnumAdapterModes(LPDIRECT3D8 iface, UINT Adapter, UINT Mode,
|
|
|
|
D3DDISPLAYMODE* pMode)
|
|
|
|
{
|
|
|
|
IDirect3D8Impl *This = impl_from_IDirect3D8(iface);
|
2007-05-22 22:33:42 +00:00
|
|
|
HRESULT hr;
|
2009-10-19 08:12:20 +00:00
|
|
|
|
|
|
|
TRACE("iface %p, adapter %u, mode_idx %u, mode %p.\n",
|
|
|
|
iface, Adapter, Mode, pMode);
|
2007-05-22 22:33:42 +00:00
|
|
|
|
2009-08-25 06:17:14 +00:00
|
|
|
wined3d_mutex_lock();
|
2011-11-16 19:08:06 +00:00
|
|
|
hr = wined3d_enum_adapter_modes(This->WineD3D, Adapter, WINED3DFMT_UNKNOWN,
|
|
|
|
Mode, (struct wined3d_display_mode *)pMode);
|
2009-08-25 06:17:14 +00:00
|
|
|
wined3d_mutex_unlock();
|
2009-02-19 15:59:41 +00:00
|
|
|
|
|
|
|
if (SUCCEEDED(hr)) pMode->Format = d3dformat_from_wined3dformat(pMode->Format);
|
|
|
|
|
2007-05-22 22:33:42 +00:00
|
|
|
return hr;
|
2002-09-27 22:46:16 +00:00
|
|
|
}
|
|
|
|
|
2011-01-23 20:49:42 +00:00
|
|
|
static HRESULT WINAPI IDirect3D8Impl_GetAdapterDisplayMode(LPDIRECT3D8 iface, UINT Adapter,
|
|
|
|
D3DDISPLAYMODE* pMode)
|
|
|
|
{
|
|
|
|
IDirect3D8Impl *This = impl_from_IDirect3D8(iface);
|
2007-05-22 22:33:42 +00:00
|
|
|
HRESULT hr;
|
2009-10-19 08:12:20 +00:00
|
|
|
|
|
|
|
TRACE("iface %p, adapter %u, mode %p.\n",
|
|
|
|
iface, Adapter, pMode);
|
2007-05-22 22:33:42 +00:00
|
|
|
|
2009-08-25 06:17:14 +00:00
|
|
|
wined3d_mutex_lock();
|
2011-11-16 19:08:06 +00:00
|
|
|
hr = wined3d_get_adapter_display_mode(This->WineD3D, Adapter, (struct wined3d_display_mode *)pMode);
|
2009-08-25 06:17:14 +00:00
|
|
|
wined3d_mutex_unlock();
|
2009-02-19 15:59:41 +00:00
|
|
|
|
|
|
|
if (SUCCEEDED(hr)) pMode->Format = d3dformat_from_wined3dformat(pMode->Format);
|
|
|
|
|
2007-05-22 22:33:42 +00:00
|
|
|
return hr;
|
2002-09-27 22:46:16 +00:00
|
|
|
}
|
|
|
|
|
2011-01-23 20:49:42 +00:00
|
|
|
static HRESULT WINAPI IDirect3D8Impl_CheckDeviceType(LPDIRECT3D8 iface, UINT Adapter,
|
|
|
|
D3DDEVTYPE CheckType, D3DFORMAT DisplayFormat, D3DFORMAT BackBufferFormat, BOOL Windowed)
|
|
|
|
{
|
|
|
|
IDirect3D8Impl *This = impl_from_IDirect3D8(iface);
|
2007-05-22 22:33:42 +00:00
|
|
|
HRESULT hr;
|
2009-10-19 08:12:20 +00:00
|
|
|
|
|
|
|
TRACE("iface %p, adapter %u, device_type %#x, display_format %#x, backbuffer_format %#x, windowed %#x.\n",
|
|
|
|
iface, Adapter, CheckType, DisplayFormat, BackBufferFormat, Windowed);
|
2007-05-22 22:33:42 +00:00
|
|
|
|
2009-08-25 06:17:14 +00:00
|
|
|
wined3d_mutex_lock();
|
2011-02-01 18:39:53 +00:00
|
|
|
hr = wined3d_check_device_type(This->WineD3D, Adapter, CheckType, wined3dformat_from_d3dformat(DisplayFormat),
|
2009-02-19 15:59:41 +00:00
|
|
|
wined3dformat_from_d3dformat(BackBufferFormat), Windowed);
|
2009-08-25 06:17:14 +00:00
|
|
|
wined3d_mutex_unlock();
|
|
|
|
|
2007-05-22 22:33:42 +00:00
|
|
|
return hr;
|
2002-09-27 22:46:16 +00:00
|
|
|
}
|
|
|
|
|
2011-01-23 20:49:42 +00:00
|
|
|
static HRESULT WINAPI IDirect3D8Impl_CheckDeviceFormat(LPDIRECT3D8 iface, UINT Adapter,
|
|
|
|
D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat, DWORD Usage, D3DRESOURCETYPE RType,
|
|
|
|
D3DFORMAT CheckFormat)
|
|
|
|
{
|
|
|
|
IDirect3D8Impl *This = impl_from_IDirect3D8(iface);
|
2012-01-17 20:13:36 +00:00
|
|
|
enum wined3d_resource_type wined3d_rtype;
|
2007-05-22 22:33:42 +00:00
|
|
|
HRESULT hr;
|
2009-10-19 08:12:20 +00:00
|
|
|
|
|
|
|
TRACE("iface %p, adapter %u, device_type %#x, adapter_format %#x, usage %#x, resource_type %#x, format %#x.\n",
|
|
|
|
iface, Adapter, DeviceType, AdapterFormat, Usage, RType, CheckFormat);
|
2007-05-22 22:33:42 +00:00
|
|
|
|
2009-04-06 14:44:00 +00:00
|
|
|
switch(RType) {
|
|
|
|
case D3DRTYPE_VERTEXBUFFER:
|
|
|
|
case D3DRTYPE_INDEXBUFFER:
|
2012-01-17 20:13:36 +00:00
|
|
|
wined3d_rtype = WINED3D_RTYPE_BUFFER;
|
2009-04-06 14:44:00 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2012-01-17 20:13:36 +00:00
|
|
|
wined3d_rtype = RType;
|
2009-04-06 14:44:00 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2009-08-25 06:17:14 +00:00
|
|
|
wined3d_mutex_lock();
|
2011-02-01 18:39:53 +00:00
|
|
|
hr = wined3d_check_device_format(This->WineD3D, Adapter, DeviceType, wined3dformat_from_d3dformat(AdapterFormat),
|
2012-01-19 23:36:28 +00:00
|
|
|
Usage, wined3d_rtype, wined3dformat_from_d3dformat(CheckFormat), WINED3D_SURFACE_TYPE_OPENGL);
|
2009-08-25 06:17:14 +00:00
|
|
|
wined3d_mutex_unlock();
|
|
|
|
|
2007-05-22 22:33:42 +00:00
|
|
|
return hr;
|
2002-09-27 22:46:16 +00:00
|
|
|
}
|
|
|
|
|
2009-08-25 06:17:13 +00:00
|
|
|
static HRESULT WINAPI IDirect3D8Impl_CheckDeviceMultiSampleType(IDirect3D8 *iface, UINT Adapter,
|
2011-01-23 20:49:42 +00:00
|
|
|
D3DDEVTYPE DeviceType, D3DFORMAT SurfaceFormat, BOOL Windowed,
|
|
|
|
D3DMULTISAMPLE_TYPE MultiSampleType)
|
2009-08-25 06:17:13 +00:00
|
|
|
{
|
2011-01-23 20:49:42 +00:00
|
|
|
IDirect3D8Impl *This = impl_from_IDirect3D8(iface);
|
2007-05-22 22:33:42 +00:00
|
|
|
HRESULT hr;
|
2009-10-19 08:12:20 +00:00
|
|
|
|
|
|
|
TRACE("iface %p, adapter %u, device_type %#x, format %#x, windowed %#x, multisample_type %#x.\n",
|
|
|
|
iface, Adapter, DeviceType, SurfaceFormat, Windowed, MultiSampleType);
|
2007-05-22 22:33:42 +00:00
|
|
|
|
2009-08-25 06:17:14 +00:00
|
|
|
wined3d_mutex_lock();
|
2011-02-01 18:39:53 +00:00
|
|
|
hr = wined3d_check_device_multisample_type(This->WineD3D, Adapter, DeviceType,
|
2012-01-08 20:15:00 +00:00
|
|
|
wined3dformat_from_d3dformat(SurfaceFormat), Windowed,
|
|
|
|
(enum wined3d_multisample_type)MultiSampleType, NULL);
|
2009-08-25 06:17:14 +00:00
|
|
|
wined3d_mutex_unlock();
|
|
|
|
|
2007-05-22 22:33:42 +00:00
|
|
|
return hr;
|
2002-09-27 22:46:16 +00:00
|
|
|
}
|
|
|
|
|
2011-01-23 20:49:42 +00:00
|
|
|
static HRESULT WINAPI IDirect3D8Impl_CheckDepthStencilMatch(IDirect3D8 *iface, UINT Adapter,
|
|
|
|
D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat, D3DFORMAT RenderTargetFormat,
|
|
|
|
D3DFORMAT DepthStencilFormat)
|
2009-08-25 06:17:13 +00:00
|
|
|
{
|
2011-01-23 20:49:42 +00:00
|
|
|
IDirect3D8Impl *This = impl_from_IDirect3D8(iface);
|
2007-05-22 22:33:42 +00:00
|
|
|
HRESULT hr;
|
2009-10-19 08:12:20 +00:00
|
|
|
|
|
|
|
TRACE("iface %p, adapter %u, device_type %#x, adapter_format %#x, rt_format %#x, ds_format %#x.\n",
|
|
|
|
iface, Adapter, DeviceType, AdapterFormat, RenderTargetFormat, DepthStencilFormat);
|
2007-05-22 22:33:42 +00:00
|
|
|
|
2009-08-25 06:17:14 +00:00
|
|
|
wined3d_mutex_lock();
|
2011-02-01 18:39:53 +00:00
|
|
|
hr = wined3d_check_depth_stencil_match(This->WineD3D, Adapter, DeviceType,
|
2009-02-19 15:59:41 +00:00
|
|
|
wined3dformat_from_d3dformat(AdapterFormat), wined3dformat_from_d3dformat(RenderTargetFormat),
|
|
|
|
wined3dformat_from_d3dformat(DepthStencilFormat));
|
2009-08-25 06:17:14 +00:00
|
|
|
wined3d_mutex_unlock();
|
|
|
|
|
2007-05-22 22:33:42 +00:00
|
|
|
return hr;
|
2002-09-27 22:46:16 +00:00
|
|
|
}
|
|
|
|
|
2009-08-07 10:17:41 +00:00
|
|
|
void fixup_caps(WINED3DCAPS *caps)
|
|
|
|
{
|
|
|
|
/* D3D8 doesn't support SM 2.0 or higher, so clamp to 1.x */
|
2011-10-25 14:58:44 +00:00
|
|
|
if (caps->PixelShaderVersion)
|
2009-08-07 10:17:41 +00:00
|
|
|
caps->PixelShaderVersion = D3DPS_VERSION(1,4);
|
2011-10-25 14:58:44 +00:00
|
|
|
else
|
|
|
|
caps->PixelShaderVersion = D3DPS_VERSION(0,0);
|
|
|
|
if (caps->VertexShaderVersion)
|
2009-08-07 10:17:41 +00:00
|
|
|
caps->VertexShaderVersion = D3DVS_VERSION(1,1);
|
2011-10-25 14:58:44 +00:00
|
|
|
else
|
|
|
|
caps->VertexShaderVersion = D3DVS_VERSION(0,0);
|
2009-08-07 10:17:41 +00:00
|
|
|
caps->MaxVertexShaderConst = min(D3D8_MAX_VERTEX_SHADER_CONSTANTF, caps->MaxVertexShaderConst);
|
|
|
|
|
|
|
|
caps->StencilCaps &= ~WINED3DSTENCILCAPS_TWOSIDED;
|
|
|
|
}
|
|
|
|
|
2011-01-23 20:49:42 +00:00
|
|
|
static HRESULT WINAPI IDirect3D8Impl_GetDeviceCaps(LPDIRECT3D8 iface, UINT Adapter,
|
|
|
|
D3DDEVTYPE DeviceType, D3DCAPS8* pCaps)
|
|
|
|
{
|
|
|
|
IDirect3D8Impl *This = impl_from_IDirect3D8(iface);
|
2005-06-17 09:59:03 +00:00
|
|
|
HRESULT hrc = D3D_OK;
|
|
|
|
WINED3DCAPS *pWineCaps;
|
|
|
|
|
2009-10-19 08:12:20 +00:00
|
|
|
TRACE("iface %p, adapter %u, device_type %#x, caps %p.\n", iface, Adapter, DeviceType, pCaps);
|
2005-06-17 09:59:03 +00:00
|
|
|
|
|
|
|
if(NULL == pCaps){
|
|
|
|
return D3DERR_INVALIDCALL;
|
|
|
|
}
|
|
|
|
pWineCaps = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(WINED3DCAPS));
|
|
|
|
if(pWineCaps == NULL){
|
|
|
|
return D3DERR_INVALIDCALL; /*well this is what MSDN says to return*/
|
|
|
|
}
|
2009-08-25 06:17:14 +00:00
|
|
|
|
|
|
|
wined3d_mutex_lock();
|
2011-02-01 18:39:53 +00:00
|
|
|
hrc = wined3d_get_device_caps(This->WineD3D, Adapter, DeviceType, pWineCaps);
|
2009-08-25 06:17:14 +00:00
|
|
|
wined3d_mutex_unlock();
|
|
|
|
|
2009-08-07 10:17:41 +00:00
|
|
|
fixup_caps(pWineCaps);
|
2008-03-18 18:26:00 +00:00
|
|
|
WINECAPSTOD3D8CAPS(pCaps, pWineCaps)
|
2005-06-17 09:59:03 +00:00
|
|
|
HeapFree(GetProcessHeap(), 0, pWineCaps);
|
2006-12-23 13:41:53 +00:00
|
|
|
|
2005-06-17 09:59:03 +00:00
|
|
|
TRACE("(%p) returning %p\n", This, pCaps);
|
|
|
|
return hrc;
|
2002-09-27 22:46:16 +00:00
|
|
|
}
|
|
|
|
|
2011-01-23 20:49:42 +00:00
|
|
|
static HMONITOR WINAPI IDirect3D8Impl_GetAdapterMonitor(LPDIRECT3D8 iface, UINT Adapter)
|
|
|
|
{
|
|
|
|
IDirect3D8Impl *This = impl_from_IDirect3D8(iface);
|
2007-05-22 22:33:42 +00:00
|
|
|
HMONITOR ret;
|
2009-10-19 08:12:20 +00:00
|
|
|
|
|
|
|
TRACE("iface %p, adapter %u.\n", iface, Adapter);
|
2007-05-22 22:33:42 +00:00
|
|
|
|
2009-08-25 06:17:14 +00:00
|
|
|
wined3d_mutex_lock();
|
2011-02-01 18:39:53 +00:00
|
|
|
ret = wined3d_get_adapter_monitor(This->WineD3D, Adapter);
|
2009-08-25 06:17:14 +00:00
|
|
|
wined3d_mutex_unlock();
|
|
|
|
|
2007-05-22 22:33:42 +00:00
|
|
|
return ret;
|
2002-09-27 22:46:16 +00:00
|
|
|
}
|
|
|
|
|
2011-01-23 20:49:42 +00:00
|
|
|
static HRESULT WINAPI IDirect3D8Impl_CreateDevice(IDirect3D8 *iface, UINT adapter,
|
|
|
|
D3DDEVTYPE device_type, HWND focus_window, DWORD flags, D3DPRESENT_PARAMETERS *parameters,
|
|
|
|
IDirect3DDevice8 **device)
|
2009-11-17 08:43:14 +00:00
|
|
|
{
|
2011-01-23 20:49:42 +00:00
|
|
|
IDirect3D8Impl *This = impl_from_IDirect3D8(iface);
|
2009-11-17 08:43:14 +00:00
|
|
|
IDirect3DDevice8Impl *object;
|
2006-02-25 12:15:08 +00:00
|
|
|
HRESULT hr;
|
2009-10-19 08:12:20 +00:00
|
|
|
|
|
|
|
TRACE("iface %p, adapter %u, device_type %#x, focus_window %p, flags %#x, parameters %p, device %p.\n",
|
2009-11-17 08:43:14 +00:00
|
|
|
iface, adapter, device_type, focus_window, flags, parameters, device);
|
2006-02-25 12:15:08 +00:00
|
|
|
|
2009-11-17 08:43:14 +00:00
|
|
|
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
|
|
|
|
if (!object)
|
|
|
|
{
|
|
|
|
ERR("Failed to allocate device memory.\n");
|
|
|
|
return E_OUTOFMEMORY;
|
2002-12-18 05:05:41 +00:00
|
|
|
}
|
2006-02-25 12:15:08 +00:00
|
|
|
|
2011-06-03 12:23:21 +00:00
|
|
|
hr = device_init(object, This, This->WineD3D, adapter, device_type, focus_window, flags, parameters);
|
2009-11-17 08:43:14 +00:00
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
WARN("Failed to initialize device, hr %#x.\n", hr);
|
2006-04-12 19:08:57 +00:00
|
|
|
HeapFree(GetProcessHeap(), 0, object);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2009-11-17 08:43:14 +00:00
|
|
|
TRACE("Created device %p.\n", object);
|
2011-01-28 00:17:54 +00:00
|
|
|
*device = &object->IDirect3DDevice8_iface;
|
2007-02-15 21:36:50 +00:00
|
|
|
|
2009-10-20 08:20:18 +00:00
|
|
|
return D3D_OK;
|
2002-09-27 22:46:16 +00:00
|
|
|
}
|
|
|
|
|
2005-05-27 20:17:35 +00:00
|
|
|
const IDirect3D8Vtbl Direct3D8_Vtbl =
|
2002-09-27 22:46:16 +00:00
|
|
|
{
|
2006-02-25 12:15:08 +00:00
|
|
|
/* IUnknown */
|
2002-09-27 22:46:16 +00:00
|
|
|
IDirect3D8Impl_QueryInterface,
|
|
|
|
IDirect3D8Impl_AddRef,
|
|
|
|
IDirect3D8Impl_Release,
|
2006-02-25 12:15:08 +00:00
|
|
|
/* IDirect3D8 */
|
2002-09-27 22:46:16 +00:00
|
|
|
IDirect3D8Impl_RegisterSoftwareDevice,
|
|
|
|
IDirect3D8Impl_GetAdapterCount,
|
|
|
|
IDirect3D8Impl_GetAdapterIdentifier,
|
|
|
|
IDirect3D8Impl_GetAdapterModeCount,
|
|
|
|
IDirect3D8Impl_EnumAdapterModes,
|
|
|
|
IDirect3D8Impl_GetAdapterDisplayMode,
|
|
|
|
IDirect3D8Impl_CheckDeviceType,
|
|
|
|
IDirect3D8Impl_CheckDeviceFormat,
|
|
|
|
IDirect3D8Impl_CheckDeviceMultiSampleType,
|
|
|
|
IDirect3D8Impl_CheckDepthStencilMatch,
|
|
|
|
IDirect3D8Impl_GetDeviceCaps,
|
|
|
|
IDirect3D8Impl_GetAdapterMonitor,
|
|
|
|
IDirect3D8Impl_CreateDevice
|
|
|
|
};
|