ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

directx.c
Go to the documentation of this file.
00001 /*
00002  * IDirect3D9 implementation
00003  *
00004  * Copyright 2002 Jason Edmeades
00005  * Copyright 2005 Oliver Stieber
00006  *
00007  * This library is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU Lesser General Public
00009  * License as published by the Free Software Foundation; either
00010  * version 2.1 of the License, or (at your option) any later version.
00011  *
00012  * This library is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015  * Lesser General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU Lesser General Public
00018  * License along with this library; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
00020  */
00021 
00022 #include "config.h"
00023 #include "d3d9_private.h"
00024 
00025 WINE_DEFAULT_DEBUG_CHANNEL(d3d9);
00026 
00027 static inline IDirect3D9Impl *impl_from_IDirect3D9Ex(IDirect3D9Ex *iface)
00028 {
00029     return CONTAINING_RECORD(iface, IDirect3D9Impl, IDirect3D9Ex_iface);
00030 }
00031 
00032 static HRESULT WINAPI IDirect3D9Impl_QueryInterface(IDirect3D9Ex *iface, REFIID riid, void **ppobj)
00033 {
00034     IDirect3D9Impl *This = impl_from_IDirect3D9Ex(iface);
00035 
00036     TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), ppobj);
00037 
00038     if (IsEqualGUID(riid, &IID_IUnknown)
00039         || IsEqualGUID(riid, &IID_IDirect3D9)) {
00040         IDirect3D9Ex_AddRef(iface);
00041         *ppobj = This;
00042         TRACE("Returning IDirect3D9 interface at %p\n", *ppobj);
00043         return S_OK;
00044     } else if(IsEqualGUID(riid, &IID_IDirect3D9Ex)) {
00045         if(This->extended) {
00046             *ppobj = This;
00047             TRACE("Returning IDirect3D9Ex interface at %p\n", *ppobj);
00048             IDirect3D9Ex_AddRef((IDirect3D9Ex *)*ppobj);
00049         } else {
00050             WARN("Application asks for IDirect3D9Ex, but this instance wasn't created with Direct3DCreate9Ex\n");
00051             WARN("Returning E_NOINTERFACE\n");
00052             *ppobj = NULL;
00053             return E_NOINTERFACE;
00054         }
00055     }
00056 
00057     WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
00058     *ppobj = NULL;
00059     return E_NOINTERFACE;
00060 }
00061 
00062 static ULONG WINAPI IDirect3D9Impl_AddRef(IDirect3D9Ex *iface)
00063 {
00064     IDirect3D9Impl *This = impl_from_IDirect3D9Ex(iface);
00065     ULONG ref = InterlockedIncrement(&This->ref);
00066 
00067     TRACE("%p increasing refcount to %u.\n", iface, ref);
00068 
00069     return ref;
00070 }
00071 
00072 static ULONG WINAPI IDirect3D9Impl_Release(IDirect3D9Ex *iface)
00073 {
00074     IDirect3D9Impl *This = impl_from_IDirect3D9Ex(iface);
00075     ULONG ref = InterlockedDecrement(&This->ref);
00076 
00077     TRACE("%p decreasing refcount to %u.\n", iface, ref);
00078 
00079     if (ref == 0) {
00080         wined3d_mutex_lock();
00081         wined3d_decref(This->WineD3D);
00082         wined3d_mutex_unlock();
00083 
00084         HeapFree(GetProcessHeap(), 0, This);
00085     }
00086 
00087     return ref;
00088 }
00089 
00090 /* IDirect3D9 Interface follow: */
00091 static HRESULT  WINAPI  IDirect3D9Impl_RegisterSoftwareDevice(IDirect3D9Ex *iface,
00092         void *pInitializeFunction)
00093 {
00094     IDirect3D9Impl *This = impl_from_IDirect3D9Ex(iface);
00095     HRESULT hr;
00096 
00097     TRACE("iface %p, init_function %p.\n", iface, pInitializeFunction);
00098 
00099     wined3d_mutex_lock();
00100     hr = wined3d_register_software_device(This->WineD3D, pInitializeFunction);
00101     wined3d_mutex_unlock();
00102 
00103     return hr;
00104 }
00105 
00106 static UINT WINAPI IDirect3D9Impl_GetAdapterCount(IDirect3D9Ex *iface)
00107 {
00108     IDirect3D9Impl *This = impl_from_IDirect3D9Ex(iface);
00109     UINT ret;
00110 
00111     TRACE("iface %p.\n", iface);
00112 
00113     wined3d_mutex_lock();
00114     ret = wined3d_get_adapter_count(This->WineD3D);
00115     wined3d_mutex_unlock();
00116 
00117     return ret;
00118 }
00119 
00120 static HRESULT WINAPI IDirect3D9Impl_GetAdapterIdentifier(IDirect3D9Ex *iface, UINT Adapter,
00121         DWORD Flags, D3DADAPTER_IDENTIFIER9 *pIdentifier)
00122 {
00123     IDirect3D9Impl *This = impl_from_IDirect3D9Ex(iface);
00124     struct wined3d_adapter_identifier adapter_id;
00125     HRESULT hr;
00126 
00127     TRACE("iface %p, adapter %u, flags %#x, identifier %p.\n",
00128             iface, Adapter, Flags, pIdentifier);
00129 
00130     adapter_id.driver = pIdentifier->Driver;
00131     adapter_id.driver_size = sizeof(pIdentifier->Driver);
00132     adapter_id.description = pIdentifier->Description;
00133     adapter_id.description_size = sizeof(pIdentifier->Description);
00134     adapter_id.device_name = pIdentifier->DeviceName;
00135     adapter_id.device_name_size = sizeof(pIdentifier->DeviceName);
00136 
00137     wined3d_mutex_lock();
00138     hr = wined3d_get_adapter_identifier(This->WineD3D, Adapter, Flags, &adapter_id);
00139     wined3d_mutex_unlock();
00140 
00141     pIdentifier->DriverVersion = adapter_id.driver_version;
00142     pIdentifier->VendorId = adapter_id.vendor_id;
00143     pIdentifier->DeviceId = adapter_id.device_id;
00144     pIdentifier->SubSysId = adapter_id.subsystem_id;
00145     pIdentifier->Revision = adapter_id.revision;
00146     memcpy(&pIdentifier->DeviceIdentifier, &adapter_id.device_identifier, sizeof(pIdentifier->DeviceIdentifier));
00147     pIdentifier->WHQLLevel = adapter_id.whql_level;
00148 
00149     return hr;
00150 }
00151 
00152 static UINT WINAPI IDirect3D9Impl_GetAdapterModeCount(IDirect3D9Ex *iface, UINT Adapter,
00153         D3DFORMAT Format)
00154 {
00155     IDirect3D9Impl *This = impl_from_IDirect3D9Ex(iface);
00156     UINT ret;
00157 
00158     TRACE("iface %p, adapter %u, format %#x.\n", iface, Adapter, Format);
00159 
00160     /* Others than that not supported by d3d9, but reported by wined3d for ddraw. Filter them out */
00161     if(Format != D3DFMT_X8R8G8B8 && Format != D3DFMT_R5G6B5) {
00162         return 0;
00163     }
00164 
00165     wined3d_mutex_lock();
00166     ret = wined3d_get_adapter_mode_count(This->WineD3D, Adapter, wined3dformat_from_d3dformat(Format));
00167     wined3d_mutex_unlock();
00168 
00169     return ret;
00170 }
00171 
00172 static HRESULT WINAPI IDirect3D9Impl_EnumAdapterModes(IDirect3D9Ex *iface, UINT Adapter,
00173         D3DFORMAT Format, UINT Mode, D3DDISPLAYMODE *pMode)
00174 {
00175     IDirect3D9Impl *This = impl_from_IDirect3D9Ex(iface);
00176     HRESULT hr;
00177 
00178     TRACE("iface %p, adapter %u, format %#x, mode_idx %u, mode %p.\n",
00179             iface, Adapter, Format, Mode, pMode);
00180 
00181     /* We can't pass this to WineD3D, otherwise it'll think it came from D3D8 or DDraw.
00182        It's supposed to fail anyway, so no harm returning failure. */
00183     if(Format != D3DFMT_X8R8G8B8 && Format != D3DFMT_R5G6B5)
00184         return D3DERR_INVALIDCALL;
00185 
00186     wined3d_mutex_lock();
00187     hr = wined3d_enum_adapter_modes(This->WineD3D, Adapter, wined3dformat_from_d3dformat(Format),
00188             Mode, (struct wined3d_display_mode *)pMode);
00189     wined3d_mutex_unlock();
00190 
00191     if (SUCCEEDED(hr)) pMode->Format = d3dformat_from_wined3dformat(pMode->Format);
00192 
00193     return hr;
00194 }
00195 
00196 static HRESULT WINAPI IDirect3D9Impl_GetAdapterDisplayMode(IDirect3D9Ex *iface, UINT Adapter,
00197         D3DDISPLAYMODE *pMode)
00198 {
00199     IDirect3D9Impl *This = impl_from_IDirect3D9Ex(iface);
00200     HRESULT hr;
00201 
00202     TRACE("iface %p, adapter %u, mode %p.\n", iface, Adapter, pMode);
00203 
00204     wined3d_mutex_lock();
00205     hr = wined3d_get_adapter_display_mode(This->WineD3D, Adapter, (struct wined3d_display_mode *)pMode);
00206     wined3d_mutex_unlock();
00207 
00208     if (SUCCEEDED(hr)) pMode->Format = d3dformat_from_wined3dformat(pMode->Format);
00209 
00210     return hr;
00211 }
00212 
00213 static HRESULT WINAPI IDirect3D9Impl_CheckDeviceType(IDirect3D9Ex *iface, UINT Adapter,
00214         D3DDEVTYPE CheckType, D3DFORMAT DisplayFormat, D3DFORMAT BackBufferFormat, BOOL Windowed)
00215 {
00216     IDirect3D9Impl *This = impl_from_IDirect3D9Ex(iface);
00217     HRESULT hr;
00218 
00219     TRACE("iface %p, adapter %u, device_type %#x, display_format %#x, backbuffer_format %#x, windowed %#x.\n",
00220             iface, Adapter, CheckType, DisplayFormat, BackBufferFormat, Windowed);
00221 
00222     wined3d_mutex_lock();
00223     hr = wined3d_check_device_type(This->WineD3D, Adapter, CheckType, wined3dformat_from_d3dformat(DisplayFormat),
00224             wined3dformat_from_d3dformat(BackBufferFormat), Windowed);
00225     wined3d_mutex_unlock();
00226 
00227     return hr;
00228 }
00229 
00230 static HRESULT WINAPI IDirect3D9Impl_CheckDeviceFormat(IDirect3D9Ex *iface, UINT Adapter,
00231         D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat, DWORD Usage, D3DRESOURCETYPE RType,
00232         D3DFORMAT CheckFormat)
00233 {
00234     IDirect3D9Impl *This = impl_from_IDirect3D9Ex(iface);
00235     enum wined3d_resource_type wined3d_rtype;
00236     HRESULT hr;
00237 
00238     TRACE("iface %p, adapter %u, device_type %#x, adapter_format %#x, usage %#x, resource_type %#x, format %#x.\n",
00239             iface, Adapter, DeviceType, AdapterFormat, Usage, RType, CheckFormat);
00240 
00241     switch(RType) {
00242         case D3DRTYPE_VERTEXBUFFER:
00243         case D3DRTYPE_INDEXBUFFER:
00244             wined3d_rtype = WINED3D_RTYPE_BUFFER;
00245             break;
00246 
00247         default:
00248             wined3d_rtype = RType;
00249             break;
00250     }
00251 
00252     wined3d_mutex_lock();
00253     hr = wined3d_check_device_format(This->WineD3D, Adapter, DeviceType, wined3dformat_from_d3dformat(AdapterFormat),
00254             Usage, wined3d_rtype, wined3dformat_from_d3dformat(CheckFormat), SURFACE_OPENGL);
00255     wined3d_mutex_unlock();
00256 
00257     return hr;
00258 }
00259 
00260 static HRESULT WINAPI IDirect3D9Impl_CheckDeviceMultiSampleType(IDirect3D9Ex *iface, UINT Adapter,
00261         D3DDEVTYPE DeviceType, D3DFORMAT SurfaceFormat, BOOL Windowed,
00262         D3DMULTISAMPLE_TYPE MultiSampleType, DWORD *pQualityLevels)
00263 {
00264     IDirect3D9Impl *This = impl_from_IDirect3D9Ex(iface);
00265     HRESULT hr;
00266 
00267     TRACE("iface %p, adapter %u, device_type %#x, format %#x, windowed %#x, multisample_type %#x, levels %p.\n",
00268             iface, Adapter, DeviceType, SurfaceFormat, Windowed, MultiSampleType, pQualityLevels);
00269 
00270     wined3d_mutex_lock();
00271     hr = wined3d_check_device_multisample_type(This->WineD3D, Adapter, DeviceType,
00272             wined3dformat_from_d3dformat(SurfaceFormat), Windowed, MultiSampleType, pQualityLevels);
00273     wined3d_mutex_unlock();
00274 
00275     return hr;
00276 }
00277 
00278 static HRESULT WINAPI IDirect3D9Impl_CheckDepthStencilMatch(IDirect3D9Ex *iface, UINT Adapter,
00279         D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat, D3DFORMAT RenderTargetFormat,
00280         D3DFORMAT DepthStencilFormat)
00281 {
00282     IDirect3D9Impl *This = impl_from_IDirect3D9Ex(iface);
00283     HRESULT hr;
00284 
00285     TRACE("iface %p, adapter %u, device_type %#x, adapter_format %#x, rt_format %#x, ds_format %#x.\n",
00286             iface, Adapter, DeviceType, AdapterFormat, RenderTargetFormat, DepthStencilFormat);
00287 
00288     wined3d_mutex_lock();
00289     hr = wined3d_check_depth_stencil_match(This->WineD3D, Adapter, DeviceType,
00290             wined3dformat_from_d3dformat(AdapterFormat), wined3dformat_from_d3dformat(RenderTargetFormat),
00291             wined3dformat_from_d3dformat(DepthStencilFormat));
00292     wined3d_mutex_unlock();
00293 
00294     return hr;
00295 }
00296 
00297 static HRESULT WINAPI IDirect3D9Impl_CheckDeviceFormatConversion(IDirect3D9Ex *iface, UINT Adapter,
00298         D3DDEVTYPE DeviceType, D3DFORMAT SourceFormat, D3DFORMAT TargetFormat)
00299 {
00300     IDirect3D9Impl *This = impl_from_IDirect3D9Ex(iface);
00301     HRESULT hr;
00302 
00303     TRACE("iface %p, adapter %u, device_type %#x, src_format %#x, dst_format %#x.\n",
00304             iface, Adapter, DeviceType, SourceFormat, TargetFormat);
00305 
00306     wined3d_mutex_lock();
00307     hr = wined3d_check_device_format_conversion(This->WineD3D, Adapter, DeviceType,
00308             wined3dformat_from_d3dformat(SourceFormat), wined3dformat_from_d3dformat(TargetFormat));
00309     wined3d_mutex_unlock();
00310 
00311     return hr;
00312 }
00313 
00314 void filter_caps(D3DCAPS9* pCaps)
00315 {
00316     DWORD ps_minor_version[] = {0, 4, 0, 0};
00317     DWORD vs_minor_version[] = {0, 1, 0, 0};
00318     DWORD textureFilterCaps =
00319         D3DPTFILTERCAPS_MINFPOINT      | D3DPTFILTERCAPS_MINFLINEAR    | D3DPTFILTERCAPS_MINFANISOTROPIC |
00320         D3DPTFILTERCAPS_MINFPYRAMIDALQUAD                              | D3DPTFILTERCAPS_MINFGAUSSIANQUAD|
00321         D3DPTFILTERCAPS_MIPFPOINT      | D3DPTFILTERCAPS_MIPFLINEAR    | D3DPTFILTERCAPS_MAGFPOINT       |
00322         D3DPTFILTERCAPS_MAGFLINEAR     |D3DPTFILTERCAPS_MAGFANISOTROPIC|D3DPTFILTERCAPS_MAGFPYRAMIDALQUAD|
00323         D3DPTFILTERCAPS_MAGFGAUSSIANQUAD;
00324     pCaps->TextureFilterCaps &= textureFilterCaps;
00325     pCaps->CubeTextureFilterCaps &= textureFilterCaps;
00326     pCaps->VolumeTextureFilterCaps &= textureFilterCaps;
00327 
00328     pCaps->DevCaps &=
00329         D3DDEVCAPS_EXECUTESYSTEMMEMORY | D3DDEVCAPS_EXECUTEVIDEOMEMORY | D3DDEVCAPS_TLVERTEXSYSTEMMEMORY |
00330         D3DDEVCAPS_TLVERTEXVIDEOMEMORY | D3DDEVCAPS_TEXTURESYSTEMMEMORY| D3DDEVCAPS_TEXTUREVIDEOMEMORY   |
00331         D3DDEVCAPS_DRAWPRIMTLVERTEX    | D3DDEVCAPS_CANRENDERAFTERFLIP | D3DDEVCAPS_TEXTURENONLOCALVIDMEM|
00332         D3DDEVCAPS_DRAWPRIMITIVES2     | D3DDEVCAPS_SEPARATETEXTUREMEMORIES                              |
00333         D3DDEVCAPS_DRAWPRIMITIVES2EX   | D3DDEVCAPS_HWTRANSFORMANDLIGHT| D3DDEVCAPS_CANBLTSYSTONONLOCAL  |
00334         D3DDEVCAPS_HWRASTERIZATION     | D3DDEVCAPS_PUREDEVICE         | D3DDEVCAPS_QUINTICRTPATCHES     |
00335         D3DDEVCAPS_RTPATCHES           | D3DDEVCAPS_RTPATCHHANDLEZERO  | D3DDEVCAPS_NPATCHES;
00336 
00337     pCaps->ShadeCaps &=
00338         D3DPSHADECAPS_COLORGOURAUDRGB  | D3DPSHADECAPS_SPECULARGOURAUDRGB |
00339         D3DPSHADECAPS_ALPHAGOURAUDBLEND | D3DPSHADECAPS_FOGGOURAUD;
00340 
00341     pCaps->RasterCaps &=
00342         D3DPRASTERCAPS_DITHER          | D3DPRASTERCAPS_ZTEST          | D3DPRASTERCAPS_FOGVERTEX        |
00343         D3DPRASTERCAPS_FOGTABLE        | D3DPRASTERCAPS_MIPMAPLODBIAS  | D3DPRASTERCAPS_ZBUFFERLESSHSR   |
00344         D3DPRASTERCAPS_FOGRANGE        | D3DPRASTERCAPS_ANISOTROPY     | D3DPRASTERCAPS_WBUFFER          |
00345         D3DPRASTERCAPS_WFOG            | D3DPRASTERCAPS_ZFOG           | D3DPRASTERCAPS_COLORPERSPECTIVE |
00346         D3DPRASTERCAPS_SCISSORTEST     | D3DPRASTERCAPS_SLOPESCALEDEPTHBIAS                              |
00347         D3DPRASTERCAPS_DEPTHBIAS       | D3DPRASTERCAPS_MULTISAMPLE_TOGGLE;
00348 
00349     pCaps->DevCaps2 &=
00350         D3DDEVCAPS2_STREAMOFFSET       | D3DDEVCAPS2_DMAPNPATCH        | D3DDEVCAPS2_ADAPTIVETESSRTPATCH |
00351         D3DDEVCAPS2_ADAPTIVETESSNPATCH | D3DDEVCAPS2_CAN_STRETCHRECT_FROM_TEXTURES                       |
00352         D3DDEVCAPS2_PRESAMPLEDDMAPNPATCH| D3DDEVCAPS2_VERTEXELEMENTSCANSHARESTREAMOFFSET;
00353 
00354     pCaps->Caps2 &=
00355         D3DCAPS2_FULLSCREENGAMMA       | D3DCAPS2_CANCALIBRATEGAMMA    | D3DCAPS2_RESERVED               |
00356         D3DCAPS2_CANMANAGERESOURCE     | D3DCAPS2_DYNAMICTEXTURES      | D3DCAPS2_CANAUTOGENMIPMAP;
00357 
00358     pCaps->VertexProcessingCaps &=
00359         D3DVTXPCAPS_TEXGEN             | D3DVTXPCAPS_MATERIALSOURCE7   | D3DVTXPCAPS_DIRECTIONALLIGHTS   |
00360         D3DVTXPCAPS_POSITIONALLIGHTS   | D3DVTXPCAPS_LOCALVIEWER       | D3DVTXPCAPS_TWEENING            |
00361         D3DVTXPCAPS_TEXGEN_SPHEREMAP   | D3DVTXPCAPS_NO_TEXGEN_NONLOCALVIEWER;
00362 
00363     pCaps->TextureCaps &=
00364         D3DPTEXTURECAPS_PERSPECTIVE    | D3DPTEXTURECAPS_POW2          | D3DPTEXTURECAPS_ALPHA           |
00365         D3DPTEXTURECAPS_SQUAREONLY     | D3DPTEXTURECAPS_TEXREPEATNOTSCALEDBYSIZE                        |
00366         D3DPTEXTURECAPS_ALPHAPALETTE   | D3DPTEXTURECAPS_NONPOW2CONDITIONAL                              |
00367         D3DPTEXTURECAPS_PROJECTED      | D3DPTEXTURECAPS_CUBEMAP       | D3DPTEXTURECAPS_VOLUMEMAP       |
00368         D3DPTEXTURECAPS_MIPMAP         | D3DPTEXTURECAPS_MIPVOLUMEMAP  | D3DPTEXTURECAPS_MIPCUBEMAP      |
00369         D3DPTEXTURECAPS_CUBEMAP_POW2   | D3DPTEXTURECAPS_VOLUMEMAP_POW2| D3DPTEXTURECAPS_NOPROJECTEDBUMPENV;
00370 
00371     pCaps->MaxVertexShaderConst = min(D3D9_MAX_VERTEX_SHADER_CONSTANTF, pCaps->MaxVertexShaderConst);
00372     pCaps->NumSimultaneousRTs = min(D3D9_MAX_SIMULTANEOUS_RENDERTARGETS, pCaps->NumSimultaneousRTs);
00373 
00374     if (pCaps->PixelShaderVersion > 3)
00375         pCaps->PixelShaderVersion = D3DPS_VERSION(3,0);
00376     else
00377     {
00378         DWORD major = pCaps->PixelShaderVersion;
00379         pCaps->PixelShaderVersion = D3DPS_VERSION(major,ps_minor_version[major]);
00380     }
00381 
00382     if (pCaps->VertexShaderVersion > 3)
00383         pCaps->VertexShaderVersion = D3DVS_VERSION(3,0);
00384     else
00385     {
00386         DWORD major = pCaps->VertexShaderVersion;
00387         pCaps->VertexShaderVersion = D3DVS_VERSION(major,vs_minor_version[major]);
00388     }
00389 }
00390 
00391 static HRESULT WINAPI IDirect3D9Impl_GetDeviceCaps(IDirect3D9Ex *iface, UINT Adapter,
00392         D3DDEVTYPE DeviceType, D3DCAPS9 *pCaps)
00393 {
00394     IDirect3D9Impl *This = impl_from_IDirect3D9Ex(iface);
00395     HRESULT hrc = D3D_OK;
00396     WINED3DCAPS *pWineCaps;
00397 
00398     TRACE("iface %p, adapter %u, device_type %#x, caps %p.\n", iface, Adapter, DeviceType, pCaps);
00399 
00400     if(NULL == pCaps){
00401         return D3DERR_INVALIDCALL;
00402     }
00403     pWineCaps = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(WINED3DCAPS));
00404     if(pWineCaps == NULL){
00405         return D3DERR_INVALIDCALL; /*well this is what MSDN says to return*/
00406     }
00407     memset(pCaps, 0, sizeof(*pCaps));
00408 
00409     wined3d_mutex_lock();
00410     hrc = wined3d_get_device_caps(This->WineD3D, Adapter, DeviceType, pWineCaps);
00411     wined3d_mutex_unlock();
00412 
00413     WINECAPSTOD3D9CAPS(pCaps, pWineCaps)
00414     HeapFree(GetProcessHeap(), 0, pWineCaps);
00415 
00416     /* Some functionality is implemented in d3d9.dll, not wined3d.dll. Add the needed caps */
00417     pCaps->DevCaps2 |= D3DDEVCAPS2_CAN_STRETCHRECT_FROM_TEXTURES;
00418 
00419     filter_caps(pCaps);
00420 
00421     TRACE("(%p) returning %p\n", This, pCaps);
00422     return hrc;
00423 }
00424 
00425 static HMONITOR WINAPI IDirect3D9Impl_GetAdapterMonitor(IDirect3D9Ex *iface, UINT Adapter)
00426 {
00427     IDirect3D9Impl *This = impl_from_IDirect3D9Ex(iface);
00428     HMONITOR ret;
00429 
00430     TRACE("iface %p, adapter %u.\n", iface, Adapter);
00431 
00432     wined3d_mutex_lock();
00433     ret = wined3d_get_adapter_monitor(This->WineD3D, Adapter);
00434     wined3d_mutex_unlock();
00435 
00436     return ret;
00437 }
00438 
00439 static HRESULT WINAPI DECLSPEC_HOTPATCH IDirect3D9Impl_CreateDevice(IDirect3D9Ex *iface, UINT adapter,
00440         D3DDEVTYPE device_type, HWND focus_window, DWORD flags, D3DPRESENT_PARAMETERS *parameters,
00441         IDirect3DDevice9 **device)
00442 {
00443     IDirect3D9Impl *This = impl_from_IDirect3D9Ex(iface);
00444     IDirect3DDevice9Impl *object;
00445     HRESULT hr;
00446 
00447     TRACE("iface %p, adapter %u, device_type %#x, focus_window %p, flags %#x, parameters %p, device %p.\n",
00448             iface, adapter, device_type, focus_window, flags, parameters, device);
00449 
00450     object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
00451     if (!object)
00452     {
00453         ERR("Failed to allocate device memory.\n");
00454         return E_OUTOFMEMORY;
00455     }
00456 
00457     hr = device_init(object, This, This->WineD3D, adapter, device_type, focus_window, flags, parameters, NULL);
00458     if (FAILED(hr))
00459     {
00460         WARN("Failed to initialize device, hr %#x.\n", hr);
00461         HeapFree(GetProcessHeap(), 0, object);
00462         return hr;
00463     }
00464 
00465     TRACE("Created device %p.\n", object);
00466     *device = (IDirect3DDevice9 *)object;
00467 
00468     return D3D_OK;
00469 }
00470 
00471 static UINT WINAPI IDirect3D9ExImpl_GetAdapterModeCountEx(IDirect3D9Ex *iface,
00472         UINT adapter, const D3DDISPLAYMODEFILTER *filter)
00473 {
00474     FIXME("iface %p, adapter %u, filter %p stub!\n", iface, adapter, filter);
00475 
00476     return 0;
00477 }
00478 
00479 static HRESULT WINAPI IDirect3D9ExImpl_EnumAdapterModesEx(IDirect3D9Ex *iface,
00480         UINT adapter, const D3DDISPLAYMODEFILTER *filter, UINT mode_idx, D3DDISPLAYMODEEX *mode)
00481 {
00482     FIXME("iface %p, adapter %u, filter %p, mode_idx %u, mode %p stub!\n",
00483             iface, adapter, filter, mode_idx, mode);
00484 
00485     return E_NOTIMPL;
00486 }
00487 
00488 static HRESULT WINAPI IDirect3D9ExImpl_GetAdapterDisplayModeEx(IDirect3D9Ex *iface,
00489         UINT adapter, D3DDISPLAYMODEEX *mode, D3DDISPLAYROTATION *rotation)
00490 {
00491     FIXME("iface %p, adapter %u, mode %p, rotation %p stub!\n",
00492             iface, adapter, mode, rotation);
00493 
00494     return E_NOTIMPL;
00495 }
00496 
00497 static HRESULT WINAPI DECLSPEC_HOTPATCH IDirect3D9ExImpl_CreateDeviceEx(IDirect3D9Ex *iface,
00498         UINT adapter, D3DDEVTYPE device_type, HWND focus_window, DWORD flags,
00499         D3DPRESENT_PARAMETERS *parameters, D3DDISPLAYMODEEX *mode, IDirect3DDevice9Ex **device)
00500 {
00501     IDirect3D9Impl *d3d9 = impl_from_IDirect3D9Ex(iface);
00502     IDirect3DDevice9Impl *object;
00503     HRESULT hr;
00504 
00505     TRACE("iface %p, adapter %u, device_type %#x, focus_window %p, flags %#x, parameters %p, mode %p, device %p.\n",
00506             iface, adapter, device_type, focus_window, flags, parameters, mode, device);
00507 
00508     object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
00509     if (!object)
00510     {
00511         ERR("Failed to allocate device memory.\n");
00512         return E_OUTOFMEMORY;
00513     }
00514 
00515     hr = device_init(object, d3d9, d3d9->WineD3D, adapter, device_type, focus_window, flags, parameters, mode);
00516     if (FAILED(hr))
00517     {
00518         WARN("Failed to initialize device, hr %#x.\n", hr);
00519         HeapFree(GetProcessHeap(), 0, object);
00520         return hr;
00521     }
00522 
00523     TRACE("Created device %p.\n", object);
00524     *device = &object->IDirect3DDevice9Ex_iface;
00525 
00526     return D3D_OK;
00527 }
00528 
00529 static HRESULT WINAPI IDirect3D9ExImpl_GetAdapterLUID(IDirect3D9Ex *iface, UINT adapter, LUID *luid)
00530 {
00531     IDirect3D9Impl *This = impl_from_IDirect3D9Ex(iface);
00532     struct wined3d_adapter_identifier adapter_id;
00533     HRESULT hr;
00534 
00535     TRACE("iface %p, adapter %u, luid %p.\n", iface, adapter, luid);
00536 
00537     adapter_id.driver_size = 0;
00538     adapter_id.description_size = 0;
00539     adapter_id.device_name_size = 0;
00540 
00541     wined3d_mutex_lock();
00542     hr = wined3d_get_adapter_identifier(This->WineD3D, adapter, 0, &adapter_id);
00543     wined3d_mutex_unlock();
00544 
00545     memcpy(luid, &adapter_id.adapter_luid, sizeof(*luid));
00546 
00547     return hr;
00548 }
00549 
00550 
00551 const IDirect3D9ExVtbl Direct3D9_Vtbl =
00552 {
00553     /* IUnknown */
00554     IDirect3D9Impl_QueryInterface,
00555     IDirect3D9Impl_AddRef,
00556     IDirect3D9Impl_Release,
00557     /* IDirect3D9 */
00558     IDirect3D9Impl_RegisterSoftwareDevice,
00559     IDirect3D9Impl_GetAdapterCount,
00560     IDirect3D9Impl_GetAdapterIdentifier,
00561     IDirect3D9Impl_GetAdapterModeCount,
00562     IDirect3D9Impl_EnumAdapterModes,
00563     IDirect3D9Impl_GetAdapterDisplayMode,
00564     IDirect3D9Impl_CheckDeviceType,
00565     IDirect3D9Impl_CheckDeviceFormat,
00566     IDirect3D9Impl_CheckDeviceMultiSampleType,
00567     IDirect3D9Impl_CheckDepthStencilMatch,
00568     IDirect3D9Impl_CheckDeviceFormatConversion,
00569     IDirect3D9Impl_GetDeviceCaps,
00570     IDirect3D9Impl_GetAdapterMonitor,
00571     IDirect3D9Impl_CreateDevice,
00572     /* IDirect3D9Ex */
00573     IDirect3D9ExImpl_GetAdapterModeCountEx,
00574     IDirect3D9ExImpl_EnumAdapterModesEx,
00575     IDirect3D9ExImpl_GetAdapterDisplayModeEx,
00576     IDirect3D9ExImpl_CreateDeviceEx,
00577     IDirect3D9ExImpl_GetAdapterLUID
00578 
00579 };

Generated on Fri May 25 2012 04:19:52 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.