af062818b47340eef15700d2f0211576ba3506eevboxsync * IDirect3D8 implementation
af062818b47340eef15700d2f0211576ba3506eevboxsync * Copyright 2002-2004 Jason Edmeades
af062818b47340eef15700d2f0211576ba3506eevboxsync * Copyright 2003-2004 Raphael Junqueira
af062818b47340eef15700d2f0211576ba3506eevboxsync * Copyright 2004 Christian Costa
af062818b47340eef15700d2f0211576ba3506eevboxsync * This library is free software; you can redistribute it and/or
af062818b47340eef15700d2f0211576ba3506eevboxsync * modify it under the terms of the GNU Lesser General Public
af062818b47340eef15700d2f0211576ba3506eevboxsync * License as published by the Free Software Foundation; either
af062818b47340eef15700d2f0211576ba3506eevboxsync * version 2.1 of the License, or (at your option) any later version.
af062818b47340eef15700d2f0211576ba3506eevboxsync * This library is distributed in the hope that it will be useful,
af062818b47340eef15700d2f0211576ba3506eevboxsync * but WITHOUT ANY WARRANTY; without even the implied warranty of
af062818b47340eef15700d2f0211576ba3506eevboxsync * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
af062818b47340eef15700d2f0211576ba3506eevboxsync * Lesser General Public License for more details.
af062818b47340eef15700d2f0211576ba3506eevboxsync * You should have received a copy of the GNU Lesser General Public
af062818b47340eef15700d2f0211576ba3506eevboxsync * License along with this library; if not, write to the Free Software
af062818b47340eef15700d2f0211576ba3506eevboxsync * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
4b9d6701570cb98fd36e209314239d104ec584d3vboxsync * Oracle LGPL Disclaimer: For the avoidance of doubt, except that if any license choice
4b9d6701570cb98fd36e209314239d104ec584d3vboxsync * other than GPL or LGPL is available it will apply instead, Oracle elects to use only
b955672b950093ff7416d1269dd4d3b69983bd8fvboxsync * the Lesser General Public License version 2.1 (LGPLv2) at this time for any software where
b955672b950093ff7416d1269dd4d3b69983bd8fvboxsync * a choice of LGPL license versions is made available with the language indicating
b955672b950093ff7416d1269dd4d3b69983bd8fvboxsync * that LGPLv2 or any later version may be used, or where a choice of which version
b955672b950093ff7416d1269dd4d3b69983bd8fvboxsync * of the LGPL is applied is otherwise unspecified.
af062818b47340eef15700d2f0211576ba3506eevboxsync/* IDirect3D IUnknown parts follow: */
af062818b47340eef15700d2f0211576ba3506eevboxsyncstatic HRESULT WINAPI IDirect3D8Impl_QueryInterface(LPDIRECT3D8 iface, REFIID riid,LPVOID *ppobj)
5112e32d7072e280613921c982a6672f2c859cf3vboxsync TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), ppobj);
af062818b47340eef15700d2f0211576ba3506eevboxsync WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid),ppobj);
af062818b47340eef15700d2f0211576ba3506eevboxsyncstatic ULONG WINAPI IDirect3D8Impl_AddRef(LPDIRECT3D8 iface) {
5112e32d7072e280613921c982a6672f2c859cf3vboxsync TRACE("%p increasing refcount to %u.\n", iface, ref);
af062818b47340eef15700d2f0211576ba3506eevboxsyncstatic ULONG WINAPI IDirect3D8Impl_Release(LPDIRECT3D8 iface) {
5112e32d7072e280613921c982a6672f2c859cf3vboxsync TRACE("%p decreasing refcount to %u.\n", iface, ref);
af062818b47340eef15700d2f0211576ba3506eevboxsync if (ref == 0) {
af062818b47340eef15700d2f0211576ba3506eevboxsync/* IDirect3D8 Interface follow: */
af062818b47340eef15700d2f0211576ba3506eevboxsyncstatic HRESULT WINAPI IDirect3D8Impl_RegisterSoftwareDevice (LPDIRECT3D8 iface, void* pInitializeFunction) {
5112e32d7072e280613921c982a6672f2c859cf3vboxsync TRACE("iface %p, init_function %p.\n", iface, pInitializeFunction);
af062818b47340eef15700d2f0211576ba3506eevboxsync hr = IWineD3D_RegisterSoftwareDevice(This->WineD3D, pInitializeFunction);
af062818b47340eef15700d2f0211576ba3506eevboxsyncstatic UINT WINAPI IDirect3D8Impl_GetAdapterCount (LPDIRECT3D8 iface) {
040b4a09341f574825386333398110f4db3e1e51vboxsyncstatic HRESULT WINAPI IDirect3D8Impl_GetAdapterIdentifier(LPDIRECT3D8 iface,
040b4a09341f574825386333398110f4db3e1e51vboxsync UINT Adapter, DWORD Flags, D3DADAPTER_IDENTIFIER8 *pIdentifier)
5112e32d7072e280613921c982a6672f2c859cf3vboxsync TRACE("iface %p, adapter %u, flags %#x, identifier %p.\n",
040b4a09341f574825386333398110f4db3e1e51vboxsync adapter_id.driver_size = sizeof(pIdentifier->Driver);
040b4a09341f574825386333398110f4db3e1e51vboxsync adapter_id.description_size = sizeof(pIdentifier->Description);
af062818b47340eef15700d2f0211576ba3506eevboxsync hr = IWineD3D_GetAdapterIdentifier(This->WineD3D, Adapter, Flags, &adapter_id);
040b4a09341f574825386333398110f4db3e1e51vboxsync pIdentifier->DriverVersion = adapter_id.driver_version;
040b4a09341f574825386333398110f4db3e1e51vboxsync memcpy(&pIdentifier->DeviceIdentifier, &adapter_id.device_identifier, sizeof(pIdentifier->DeviceIdentifier));
af062818b47340eef15700d2f0211576ba3506eevboxsyncstatic UINT WINAPI IDirect3D8Impl_GetAdapterModeCount (LPDIRECT3D8 iface,UINT Adapter) {
af062818b47340eef15700d2f0211576ba3506eevboxsync hr = IWineD3D_GetAdapterModeCount(This->WineD3D, Adapter, 0 /* format */);
af062818b47340eef15700d2f0211576ba3506eevboxsyncstatic HRESULT WINAPI IDirect3D8Impl_EnumAdapterModes (LPDIRECT3D8 iface, UINT Adapter, UINT Mode, D3DDISPLAYMODE* pMode) {
5112e32d7072e280613921c982a6672f2c859cf3vboxsync TRACE("iface %p, adapter %u, mode_idx %u, mode %p.\n",
af062818b47340eef15700d2f0211576ba3506eevboxsync hr = IWineD3D_EnumAdapterModes(This->WineD3D, Adapter, WINED3DFMT_UNKNOWN, Mode, (WINED3DDISPLAYMODE *) pMode);
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync if (SUCCEEDED(hr)) pMode->Format = d3dformat_from_wined3dformat(pMode->Format);
af062818b47340eef15700d2f0211576ba3506eevboxsyncstatic HRESULT WINAPI IDirect3D8Impl_GetAdapterDisplayMode (LPDIRECT3D8 iface, UINT Adapter, D3DDISPLAYMODE* pMode) {
af062818b47340eef15700d2f0211576ba3506eevboxsync hr = IWineD3D_GetAdapterDisplayMode(This->WineD3D, Adapter, (WINED3DDISPLAYMODE *) pMode);
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync if (SUCCEEDED(hr)) pMode->Format = d3dformat_from_wined3dformat(pMode->Format);
af062818b47340eef15700d2f0211576ba3506eevboxsyncstatic HRESULT WINAPI IDirect3D8Impl_CheckDeviceType (LPDIRECT3D8 iface,
af062818b47340eef15700d2f0211576ba3506eevboxsync UINT Adapter, D3DDEVTYPE CheckType, D3DFORMAT DisplayFormat,
5112e32d7072e280613921c982a6672f2c859cf3vboxsync TRACE("iface %p, adapter %u, device_type %#x, display_format %#x, backbuffer_format %#x, windowed %#x.\n",
5112e32d7072e280613921c982a6672f2c859cf3vboxsync iface, Adapter, CheckType, DisplayFormat, BackBufferFormat, Windowed);
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync hr = IWineD3D_CheckDeviceType(This->WineD3D, Adapter, CheckType, wined3dformat_from_d3dformat(DisplayFormat),
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync wined3dformat_from_d3dformat(BackBufferFormat), Windowed);
af062818b47340eef15700d2f0211576ba3506eevboxsyncstatic HRESULT WINAPI IDirect3D8Impl_CheckDeviceFormat (LPDIRECT3D8 iface,
af062818b47340eef15700d2f0211576ba3506eevboxsync UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat,
af062818b47340eef15700d2f0211576ba3506eevboxsync DWORD Usage, D3DRESOURCETYPE RType, D3DFORMAT CheckFormat) {
5112e32d7072e280613921c982a6672f2c859cf3vboxsync TRACE("iface %p, adapter %u, device_type %#x, adapter_format %#x, usage %#x, resource_type %#x, format %#x.\n",
5112e32d7072e280613921c982a6672f2c859cf3vboxsync iface, Adapter, DeviceType, AdapterFormat, Usage, RType, CheckFormat);
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync /* See comment in dlls/d3d9/directx.c, IDirect3D9Impl_CheckDeviceFormat for details */
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync WARN("D3DFMT_R8G8B8 is not available on windows, returning D3DERR_NOTAVAILABLE\n");
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync hr = IWineD3D_CheckDeviceFormat(This->WineD3D, Adapter, DeviceType, wined3dformat_from_d3dformat(AdapterFormat),
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync Usage, WineD3DRType, wined3dformat_from_d3dformat(CheckFormat), SURFACE_OPENGL);
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsyncstatic HRESULT WINAPI IDirect3D8Impl_CheckDeviceMultiSampleType(IDirect3D8 *iface, UINT Adapter,
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync D3DDEVTYPE DeviceType, D3DFORMAT SurfaceFormat, BOOL Windowed, D3DMULTISAMPLE_TYPE MultiSampleType)
5112e32d7072e280613921c982a6672f2c859cf3vboxsync TRACE("iface %p, adapter %u, device_type %#x, format %#x, windowed %#x, multisample_type %#x.\n",
5112e32d7072e280613921c982a6672f2c859cf3vboxsync iface, Adapter, DeviceType, SurfaceFormat, Windowed, MultiSampleType);
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync hr = IWineD3D_CheckDeviceMultiSampleType(This->WineD3D, Adapter, DeviceType,
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync wined3dformat_from_d3dformat(SurfaceFormat), Windowed, (WINED3DMULTISAMPLE_TYPE) MultiSampleType, NULL);
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsyncstatic HRESULT WINAPI IDirect3D8Impl_CheckDepthStencilMatch(IDirect3D8 *iface, UINT Adapter, D3DDEVTYPE DeviceType,
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync D3DFORMAT AdapterFormat, D3DFORMAT RenderTargetFormat, D3DFORMAT DepthStencilFormat)
5112e32d7072e280613921c982a6672f2c859cf3vboxsync TRACE("iface %p, adapter %u, device_type %#x, adapter_format %#x, rt_format %#x, ds_format %#x.\n",
5112e32d7072e280613921c982a6672f2c859cf3vboxsync iface, Adapter, DeviceType, AdapterFormat, RenderTargetFormat, DepthStencilFormat);
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync hr = IWineD3D_CheckDepthStencilMatch(This->WineD3D, Adapter, DeviceType,
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync wined3dformat_from_d3dformat(AdapterFormat), wined3dformat_from_d3dformat(RenderTargetFormat),
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync /* D3D8 doesn't support SM 2.0 or higher, so clamp to 1.x */
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync if (caps->PixelShaderVersion > D3DPS_VERSION(1,4)) {
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync if (caps->VertexShaderVersion > D3DVS_VERSION(1,1)) {
114410893548b9522c46fdcbd8f63385eb8bfb68vboxsync caps->MaxVertexShaderConst = min(D3D8_MAX_VERTEX_SHADER_CONSTANTF, caps->MaxVertexShaderConst);
af062818b47340eef15700d2f0211576ba3506eevboxsyncstatic HRESULT WINAPI IDirect3D8Impl_GetDeviceCaps(LPDIRECT3D8 iface, UINT Adapter, D3DDEVTYPE DeviceType, D3DCAPS8* pCaps) {
5112e32d7072e280613921c982a6672f2c859cf3vboxsync TRACE("iface %p, adapter %u, device_type %#x, caps %p.\n", iface, Adapter, DeviceType, pCaps);
af062818b47340eef15700d2f0211576ba3506eevboxsync pWineCaps = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(WINED3DCAPS));
af062818b47340eef15700d2f0211576ba3506eevboxsync return D3DERR_INVALIDCALL; /*well this is what MSDN says to return*/
af062818b47340eef15700d2f0211576ba3506eevboxsync hrc = IWineD3D_GetDeviceCaps(This->WineD3D, Adapter, DeviceType, pWineCaps);
af062818b47340eef15700d2f0211576ba3506eevboxsyncstatic HMONITOR WINAPI IDirect3D8Impl_GetAdapterMonitor(LPDIRECT3D8 iface, UINT Adapter) {
af062818b47340eef15700d2f0211576ba3506eevboxsync ret = IWineD3D_GetAdapterMonitor(This->WineD3D, Adapter);
5112e32d7072e280613921c982a6672f2c859cf3vboxsyncstatic HRESULT WINAPI IDirect3D8Impl_CreateDevice(IDirect3D8 *iface, UINT adapter, D3DDEVTYPE device_type,
5112e32d7072e280613921c982a6672f2c859cf3vboxsync HWND focus_window, DWORD flags, D3DPRESENT_PARAMETERS *parameters, IDirect3DDevice8 **device)
5112e32d7072e280613921c982a6672f2c859cf3vboxsync TRACE("iface %p, adapter %u, device_type %#x, focus_window %p, flags %#x, parameters %p, device %p.\n",
5112e32d7072e280613921c982a6672f2c859cf3vboxsync iface, adapter, device_type, focus_window, flags, parameters, device);
5112e32d7072e280613921c982a6672f2c859cf3vboxsync object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
5112e32d7072e280613921c982a6672f2c859cf3vboxsync hr = device_init(object, This->WineD3D, adapter, device_type, focus_window, flags, parameters);
5112e32d7072e280613921c982a6672f2c859cf3vboxsync WARN("Failed to initialize device, hr %#x.\n", hr);
af062818b47340eef15700d2f0211576ba3506eevboxsync /* IUnknown */
af062818b47340eef15700d2f0211576ba3506eevboxsync /* IDirect3D8 */