~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Wine Cross Reference
wine/dlls/d3d9/directx.c

Version: ~ [ wine-1.5.30 ] ~ [ wine-1.5.29 ] ~ [ wine-1.5.28 ] ~ [ wine-1.5.27 ] ~ [ wine-1.5.26 ] ~ [ wine-1.5.25 ] ~ [ wine-1.5.24 ] ~ [ wine-1.5.23 ] ~ [ wine-1.5.22 ] ~ [ wine-1.5.21 ] ~ [ wine-1.5.20 ] ~ [ wine-1.5.19 ] ~ [ wine-1.5.18 ] ~ [ wine-1.5.17 ] ~ [ wine-1.5.16 ] ~ [ wine-1.5.15 ] ~ [ wine-1.5.14 ] ~ [ wine-1.5.13 ] ~ [ wine-1.5.12 ] ~ [ wine-1.5.11 ] ~ [ wine-1.5.10 ] ~ [ wine-1.5.9 ] ~ [ wine-1.5.8 ] ~ [ wine-1.5.7 ] ~ [ wine-1.4.1 ] ~ [ wine-1.5.6 ] ~ [ wine-1.5.5 ] ~ [ wine-1.5.4 ] ~ [ wine-1.5.3 ] ~ [ wine-1.5.2 ] ~ [ wine-1.5.1 ] ~ [ wine-1.5.0 ] ~ [ wine-1.4 ] ~ [ wine-1.4-rc6 ] ~ [ wine-1.4-rc5 ] ~ [ wine-1.4-rc4 ] ~ [ wine-1.4-rc3 ] ~ [ wine-1.4-rc2 ] ~ [ wine-1.4-rc1 ] ~ [ wine-1.3.37 ] ~ [ wine-1.3.36 ] ~ [ wine-1.3.35 ] ~ [ wine-1.3.34 ] ~ [ wine-1.3.33 ] ~ [ wine-1.3.32 ] ~ [ wine-1.3.31 ] ~ [ wine-1.3.30 ] ~ [ wine-1.3.29 ] ~ [ wine-1.3.28 ] ~ [ wine-1.3.27 ] ~ [ wine-1.3.26 ] ~ [ wine-1.3.25 ] ~ [ wine-1.3.24 ] ~ [ wine-1.3.23 ] ~ [ wine-1.3.22 ] ~ [ wine-1.3.21 ] ~ [ wine-1.3.20 ] ~ [ wine-1.3.19 ] ~ [ wine-1.3.18 ] ~ [ wine-1.2.3 ] ~ [ wine-1.3.17 ] ~ [ wine-1.3.16 ] ~ [ wine-1.3.15 ] ~ [ wine-1.3.14 ] ~ [ wine-1.3.13 ] ~ [ wine-1.3.12 ] ~ [ wine-1.3.11 ] ~ [ wine-1.3.10 ] ~ [ wine-1.3.9 ] ~ [ wine-1.2.2 ] ~ [ wine-1.3.8 ] ~ [ wine-1.3.7 ] ~ [ wine-1.3.6 ] ~ [ wine-1.3.5 ] ~ [ wine-1.2.1 ] ~ [ wine-1.3.4 ] ~ [ wine-1.3.3 ] ~ [ wine-1.3.2 ] ~ [ wine-1.3.1 ] ~ [ wine-1.3.0 ] ~ [ wine-1.2 ] ~ [ wine-1.2-rc7 ] ~ [ wine-1.2-rc6 ] ~ [ wine-1.2-rc5 ] ~ [ wine-1.2-rc4 ] ~ [ wine-1.2-rc3 ] ~ [ wine-1.2-rc2 ] ~ [ wine-1.2-rc1 ] ~ [ wine-1.1.44 ] ~ [ wine-1.1.43 ] ~ [ wine-1.1.42 ] ~ [ wine-1.1.41 ] ~ [ wine-1.1.40 ] ~ [ wine-1.1.39 ] ~ [ wine-1.1.38 ] ~ [ wine-1.1.37 ] ~ [ wine-1.1.36 ] ~ [ wine-1.1.35 ] ~ [ wine-1.1.34 ] ~ [ wine-1.1.33 ] ~ [ wine-1.1.32 ] ~ [ wine-1.1.31 ] ~ [ wine-1.1.30 ] ~ [ wine-1.1.29 ] ~ [ wine-1.1.28 ] ~ [ wine-1.1.27 ] ~ [ wine-1.1.26 ] ~ [ wine-1.1.25 ] ~ [ wine-1.1.24 ] ~ [ wine-1.1.23 ] ~ [ wine-1.1.22 ] ~ [ wine-1.1.21 ] ~ [ wine-1.1.20 ] ~ [ wine-1.1.19 ] ~ [ wine-1.1.18 ] ~ [ wine-1.1.17 ] ~ [ wine-1.1.16 ] ~ [ wine-1.1.15 ] ~ [ wine-1.1.14 ] ~ [ wine-1.1.13 ] ~ [ wine-1.1.12 ] ~ [ wine-1.1.11 ] ~ [ wine-1.1.10 ] ~ [ wine-1.1.9 ] ~ [ wine-1.1.8 ] ~ [ wine-1.1.7 ] ~ [ wine-1.0.1 ] ~ [ wine-1.1.6 ] ~ [ wine-1.1.5 ] ~ [ wine-1.1.4 ] ~ [ wine-1.1.3 ] ~ [ wine-1.1.2 ] ~ [ wine-1.1.1 ] ~ [ wine-1.1.0 ] ~ [ wine-1.0 ] ~

  1 /*
  2  * IDirect3D9 implementation
  3  *
  4  * Copyright 2002 Jason Edmeades
  5  * Copyright 2005 Oliver Stieber
  6  *
  7  * This library is free software; you can redistribute it and/or
  8  * modify it under the terms of the GNU Lesser General Public
  9  * License as published by the Free Software Foundation; either
 10  * version 2.1 of the License, or (at your option) any later version.
 11  *
 12  * This library is distributed in the hope that it will be useful,
 13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 15  * Lesser General Public License for more details.
 16  *
 17  * You should have received a copy of the GNU Lesser General Public
 18  * License along with this library; if not, write to the Free Software
 19  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
 20  */
 21 
 22 #include "config.h"
 23 #include "d3d9_private.h"
 24 
 25 WINE_DEFAULT_DEBUG_CHANNEL(d3d9);
 26 
 27 /* IDirect3D9 IUnknown parts follow: */
 28 static HRESULT WINAPI IDirect3D9Impl_QueryInterface(LPDIRECT3D9EX iface, REFIID riid, LPVOID* ppobj)
 29 {
 30     IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
 31 
 32     if (IsEqualGUID(riid, &IID_IUnknown)
 33         || IsEqualGUID(riid, &IID_IDirect3D9)) {
 34         IDirect3D9Ex_AddRef(iface);
 35         *ppobj = This;
 36         TRACE("Returning IDirect3D9 interface at %p\n", *ppobj);
 37         return S_OK;
 38     } else if(IsEqualGUID(riid, &IID_IDirect3D9Ex)) {
 39         if(This->extended) {
 40             *ppobj = This;
 41             TRACE("Returning IDirect3D9Ex interface at %p\n", *ppobj);
 42             IDirect3D9Ex_AddRef((IDirect3D9Ex *)*ppobj);
 43         } else {
 44             WARN("Application asks for IDirect3D9Ex, but this instance wasn't created with Direct3DCreate9Ex\n");
 45             WARN("Returning E_NOINTERFACE\n");
 46             *ppobj = NULL;
 47             return E_NOINTERFACE;
 48         }
 49     }
 50 
 51     WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
 52     *ppobj = NULL;
 53     return E_NOINTERFACE;
 54 }
 55 
 56 static ULONG WINAPI IDirect3D9Impl_AddRef(LPDIRECT3D9EX iface) {
 57     IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
 58     ULONG ref = InterlockedIncrement(&This->ref);
 59 
 60     TRACE("(%p) : AddRef from %d\n", This, ref - 1);
 61 
 62     return ref;
 63 }
 64 
 65 static ULONG WINAPI IDirect3D9Impl_Release(LPDIRECT3D9EX iface) {
 66     IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
 67     ULONG ref = InterlockedDecrement(&This->ref);
 68 
 69     TRACE("(%p) : ReleaseRef to %d\n", This, ref);
 70 
 71     if (ref == 0) {
 72         EnterCriticalSection(&d3d9_cs);
 73         IWineD3D_Release(This->WineD3D);
 74         LeaveCriticalSection(&d3d9_cs);
 75         HeapFree(GetProcessHeap(), 0, This);
 76     }
 77 
 78     return ref;
 79 }
 80 
 81 /* IDirect3D9 Interface follow: */
 82 static HRESULT  WINAPI  IDirect3D9Impl_RegisterSoftwareDevice(LPDIRECT3D9EX iface, void* pInitializeFunction) {
 83     IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
 84     HRESULT hr;
 85     TRACE("(%p)->(%p)\n", This, pInitializeFunction);
 86 
 87     EnterCriticalSection(&d3d9_cs);
 88     hr = IWineD3D_RegisterSoftwareDevice(This->WineD3D, pInitializeFunction);
 89     LeaveCriticalSection(&d3d9_cs);
 90     return hr;
 91 }
 92 
 93 static UINT     WINAPI  IDirect3D9Impl_GetAdapterCount(LPDIRECT3D9EX iface) {
 94     IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
 95     HRESULT hr;
 96     TRACE("%p\n", This);
 97 
 98     EnterCriticalSection(&d3d9_cs);
 99     hr = IWineD3D_GetAdapterCount(This->WineD3D);
100     LeaveCriticalSection(&d3d9_cs);
101     return hr;
102 }
103 
104 static HRESULT WINAPI IDirect3D9Impl_GetAdapterIdentifier(LPDIRECT3D9EX iface, UINT Adapter, DWORD Flags, D3DADAPTER_IDENTIFIER9* pIdentifier) {
105     IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
106     WINED3DADAPTER_IDENTIFIER adapter_id;
107     HRESULT hr;
108 
109     /* dx8 and dx9 have different structures to be filled in, with incompatible 
110        layouts so pass in pointers to the places to be filled via an internal 
111        structure                                                                */
112     adapter_id.Driver           = pIdentifier->Driver;          
113     adapter_id.Description      = pIdentifier->Description;     
114     adapter_id.DeviceName       = pIdentifier->DeviceName;      
115     adapter_id.DriverVersion    = &pIdentifier->DriverVersion;   
116     adapter_id.VendorId         = &pIdentifier->VendorId;        
117     adapter_id.DeviceId         = &pIdentifier->DeviceId;        
118     adapter_id.SubSysId         = &pIdentifier->SubSysId;        
119     adapter_id.Revision         = &pIdentifier->Revision;        
120     adapter_id.DeviceIdentifier = &pIdentifier->DeviceIdentifier;
121     adapter_id.WHQLLevel        = &pIdentifier->WHQLLevel;       
122 
123     EnterCriticalSection(&d3d9_cs);
124     hr = IWineD3D_GetAdapterIdentifier(This->WineD3D, Adapter, Flags, &adapter_id);
125     LeaveCriticalSection(&d3d9_cs);
126     return hr;
127 }
128 
129 static UINT WINAPI IDirect3D9Impl_GetAdapterModeCount(LPDIRECT3D9EX iface, UINT Adapter, D3DFORMAT Format) {
130     IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
131     HRESULT hr;
132     TRACE("(%p)->(%d, %d\n", This, Adapter, Format);
133 
134     /* Others than that not supported by d3d9, but reported by wined3d for ddraw. Filter them out */
135     if(Format != D3DFMT_X8R8G8B8 && Format != D3DFMT_R5G6B5) {
136         return 0;
137     }
138 
139     EnterCriticalSection(&d3d9_cs);
140     hr = IWineD3D_GetAdapterModeCount(This->WineD3D, Adapter, wined3dformat_from_d3dformat(Format));
141     LeaveCriticalSection(&d3d9_cs);
142     return hr;
143 }
144 
145 static HRESULT WINAPI IDirect3D9Impl_EnumAdapterModes(LPDIRECT3D9EX iface, UINT Adapter, D3DFORMAT Format, UINT Mode, D3DDISPLAYMODE* pMode) {
146     IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
147     HRESULT hr;
148     TRACE("(%p)->(%d, %d, %d, %p)\n", This, Adapter, Format, Mode, pMode);
149     /* We can't pass this to WineD3D, otherwise it'll think it came from D3D8 or DDraw.
150        It's supposed to fail anyway, so no harm returning failure. */
151     if(Format != D3DFMT_X8R8G8B8 && Format != D3DFMT_R5G6B5)
152         return D3DERR_INVALIDCALL;
153 
154     EnterCriticalSection(&d3d9_cs);
155     hr = IWineD3D_EnumAdapterModes(This->WineD3D, Adapter, wined3dformat_from_d3dformat(Format),
156             Mode, (WINED3DDISPLAYMODE *) pMode);
157     LeaveCriticalSection(&d3d9_cs);
158 
159     if (SUCCEEDED(hr)) pMode->Format = d3dformat_from_wined3dformat(pMode->Format);
160 
161     return hr;
162 }
163 
164 static HRESULT WINAPI IDirect3D9Impl_GetAdapterDisplayMode(LPDIRECT3D9EX iface, UINT Adapter, D3DDISPLAYMODE* pMode) {
165     IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
166     HRESULT hr;
167 
168     EnterCriticalSection(&d3d9_cs);
169     hr = IWineD3D_GetAdapterDisplayMode(This->WineD3D, Adapter, (WINED3DDISPLAYMODE *) pMode);
170     LeaveCriticalSection(&d3d9_cs);
171 
172     if (SUCCEEDED(hr)) pMode->Format = d3dformat_from_wined3dformat(pMode->Format);
173 
174     return hr;
175 }
176 
177 static HRESULT WINAPI IDirect3D9Impl_CheckDeviceType(LPDIRECT3D9EX iface,
178                                               UINT Adapter, D3DDEVTYPE CheckType, D3DFORMAT DisplayFormat,
179                                               D3DFORMAT BackBufferFormat, BOOL Windowed) {
180     IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
181     HRESULT hr;
182     TRACE("(%p)->(%d, %d, %d, %d, %s\n", This, Adapter, CheckType, DisplayFormat,
183           BackBufferFormat, Windowed ? "true" : "false");
184 
185     EnterCriticalSection(&d3d9_cs);
186     hr = IWineD3D_CheckDeviceType(This->WineD3D, Adapter, CheckType, wined3dformat_from_d3dformat(DisplayFormat),
187             wined3dformat_from_d3dformat(BackBufferFormat), Windowed);
188     LeaveCriticalSection(&d3d9_cs);
189     return hr;
190 }
191 
192 static HRESULT WINAPI IDirect3D9Impl_CheckDeviceFormat(LPDIRECT3D9EX iface,
193                                                   UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat,
194                                                   DWORD Usage, D3DRESOURCETYPE RType, D3DFORMAT CheckFormat) {
195     IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
196     HRESULT hr;
197     TRACE("%p\n", This);
198 
199     EnterCriticalSection(&d3d9_cs);
200     hr = IWineD3D_CheckDeviceFormat(This->WineD3D, Adapter, DeviceType, wined3dformat_from_d3dformat(AdapterFormat),
201             Usage, RType, wined3dformat_from_d3dformat(CheckFormat), SURFACE_OPENGL);
202     LeaveCriticalSection(&d3d9_cs);
203     return hr;
204 }
205 
206 static HRESULT WINAPI IDirect3D9Impl_CheckDeviceMultiSampleType(LPDIRECT3D9EX iface,
207                                                            UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT SurfaceFormat,
208                                                            BOOL Windowed, D3DMULTISAMPLE_TYPE MultiSampleType, DWORD* pQualityLevels) {
209     IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
210     HRESULT hr;
211     TRACE("%p\n", This);
212 
213     EnterCriticalSection(&d3d9_cs);
214     hr = IWineD3D_CheckDeviceMultiSampleType(This->WineD3D, Adapter, DeviceType,
215             wined3dformat_from_d3dformat(SurfaceFormat), Windowed, MultiSampleType, pQualityLevels);
216     LeaveCriticalSection(&d3d9_cs);
217     return hr;
218 }
219 
220 static HRESULT WINAPI IDirect3D9Impl_CheckDepthStencilMatch(LPDIRECT3D9EX iface,
221                                                        UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat,
222                                                        D3DFORMAT RenderTargetFormat, D3DFORMAT DepthStencilFormat) {
223     IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
224     HRESULT hr;
225     TRACE("%p\n", This);
226 
227     EnterCriticalSection(&d3d9_cs);
228     hr = IWineD3D_CheckDepthStencilMatch(This->WineD3D, Adapter, DeviceType,
229             wined3dformat_from_d3dformat(AdapterFormat), wined3dformat_from_d3dformat(RenderTargetFormat),
230             wined3dformat_from_d3dformat(DepthStencilFormat));
231     LeaveCriticalSection(&d3d9_cs);
232     return hr;
233 }
234 
235 static HRESULT WINAPI IDirect3D9Impl_CheckDeviceFormatConversion(LPDIRECT3D9EX iface, UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT SourceFormat, D3DFORMAT TargetFormat) {
236     IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
237     HRESULT hr;
238     TRACE("%p\n", This);
239 
240     EnterCriticalSection(&d3d9_cs);
241     hr = IWineD3D_CheckDeviceFormatConversion(This->WineD3D, Adapter, DeviceType,
242             wined3dformat_from_d3dformat(SourceFormat), wined3dformat_from_d3dformat(TargetFormat));
243     LeaveCriticalSection(&d3d9_cs);
244     return hr;
245 }
246 
247 void filter_caps(D3DCAPS9* pCaps)
248 {
249 
250     DWORD textureFilterCaps =
251         D3DPTFILTERCAPS_MINFPOINT      | D3DPTFILTERCAPS_MINFLINEAR    | D3DPTFILTERCAPS_MINFANISOTROPIC |
252         D3DPTFILTERCAPS_MINFPYRAMIDALQUAD                              | D3DPTFILTERCAPS_MINFGAUSSIANQUAD|
253         D3DPTFILTERCAPS_MIPFPOINT      | D3DPTFILTERCAPS_MIPFLINEAR    | D3DPTFILTERCAPS_MAGFPOINT       |
254         D3DPTFILTERCAPS_MAGFLINEAR     |D3DPTFILTERCAPS_MAGFANISOTROPIC|D3DPTFILTERCAPS_MAGFPYRAMIDALQUAD|
255         D3DPTFILTERCAPS_MAGFGAUSSIANQUAD;
256     pCaps->TextureFilterCaps &= textureFilterCaps;
257     pCaps->CubeTextureFilterCaps &= textureFilterCaps;
258     pCaps->VolumeTextureFilterCaps &= textureFilterCaps;
259 
260     pCaps->DevCaps &=
261         D3DDEVCAPS_EXECUTESYSTEMMEMORY | D3DDEVCAPS_EXECUTEVIDEOMEMORY | D3DDEVCAPS_TLVERTEXSYSTEMMEMORY |
262         D3DDEVCAPS_TLVERTEXVIDEOMEMORY | D3DDEVCAPS_TEXTURESYSTEMMEMORY| D3DDEVCAPS_TEXTUREVIDEOMEMORY   |
263         D3DDEVCAPS_DRAWPRIMTLVERTEX    | D3DDEVCAPS_CANRENDERAFTERFLIP | D3DDEVCAPS_TEXTURENONLOCALVIDMEM|
264         D3DDEVCAPS_DRAWPRIMITIVES2     | D3DDEVCAPS_SEPARATETEXTUREMEMORIES                              |
265         D3DDEVCAPS_DRAWPRIMITIVES2EX   | D3DDEVCAPS_HWTRANSFORMANDLIGHT| D3DDEVCAPS_CANBLTSYSTONONLOCAL  |
266         D3DDEVCAPS_HWRASTERIZATION     | D3DDEVCAPS_PUREDEVICE         | D3DDEVCAPS_QUINTICRTPATCHES     |
267         D3DDEVCAPS_RTPATCHES           | D3DDEVCAPS_RTPATCHHANDLEZERO  | D3DDEVCAPS_NPATCHES;
268 
269     pCaps->ShadeCaps &=
270         D3DPSHADECAPS_COLORGOURAUDRGB  | D3DPSHADECAPS_SPECULARGOURAUDRGB |
271         D3DPSHADECAPS_ALPHAGOURAUDBLEND | D3DPSHADECAPS_FOGGOURAUD;
272 
273     pCaps->RasterCaps &=
274         D3DPRASTERCAPS_DITHER          | D3DPRASTERCAPS_ZTEST          | D3DPRASTERCAPS_FOGVERTEX        |
275         D3DPRASTERCAPS_FOGTABLE        | D3DPRASTERCAPS_MIPMAPLODBIAS  | D3DPRASTERCAPS_ZBUFFERLESSHSR   |
276         D3DPRASTERCAPS_FOGRANGE        | D3DPRASTERCAPS_ANISOTROPY     | D3DPRASTERCAPS_WBUFFER          |
277         D3DPRASTERCAPS_WFOG            | D3DPRASTERCAPS_ZFOG           | D3DPRASTERCAPS_COLORPERSPECTIVE |
278         D3DPRASTERCAPS_SCISSORTEST     | D3DPRASTERCAPS_SLOPESCALEDEPTHBIAS                              |
279         D3DPRASTERCAPS_DEPTHBIAS       | D3DPRASTERCAPS_MULTISAMPLE_TOGGLE;
280 
281     pCaps->DevCaps2 &=
282         D3DDEVCAPS2_STREAMOFFSET       | D3DDEVCAPS2_DMAPNPATCH        | D3DDEVCAPS2_ADAPTIVETESSRTPATCH |
283         D3DDEVCAPS2_ADAPTIVETESSNPATCH | D3DDEVCAPS2_CAN_STRETCHRECT_FROM_TEXTURES                       |
284         D3DDEVCAPS2_PRESAMPLEDDMAPNPATCH| D3DDEVCAPS2_VERTEXELEMENTSCANSHARESTREAMOFFSET;
285 
286     pCaps->Caps2 &=
287         D3DCAPS2_FULLSCREENGAMMA       | D3DCAPS2_CANCALIBRATEGAMMA    | D3DCAPS2_RESERVED               |
288         D3DCAPS2_CANMANAGERESOURCE     | D3DCAPS2_DYNAMICTEXTURES      | D3DCAPS2_CANAUTOGENMIPMAP;
289 
290     pCaps->VertexProcessingCaps &=
291         D3DVTXPCAPS_TEXGEN             | D3DVTXPCAPS_MATERIALSOURCE7   | D3DVTXPCAPS_DIRECTIONALLIGHTS   |
292         D3DVTXPCAPS_POSITIONALLIGHTS   | D3DVTXPCAPS_LOCALVIEWER       | D3DVTXPCAPS_TWEENING            |
293         D3DVTXPCAPS_TEXGEN_SPHEREMAP   | D3DVTXPCAPS_NO_TEXGEN_NONLOCALVIEWER;
294 
295     pCaps->TextureCaps &=
296         D3DPTEXTURECAPS_PERSPECTIVE    | D3DPTEXTURECAPS_POW2          | D3DPTEXTURECAPS_ALPHA           |
297         D3DPTEXTURECAPS_SQUAREONLY     | D3DPTEXTURECAPS_TEXREPEATNOTSCALEDBYSIZE                        |
298         D3DPTEXTURECAPS_ALPHAPALETTE   | D3DPTEXTURECAPS_NONPOW2CONDITIONAL                              |
299         D3DPTEXTURECAPS_PROJECTED      | D3DPTEXTURECAPS_CUBEMAP       | D3DPTEXTURECAPS_VOLUMEMAP       |
300         D3DPTEXTURECAPS_MIPMAP         | D3DPTEXTURECAPS_MIPVOLUMEMAP  | D3DPTEXTURECAPS_MIPCUBEMAP      |
301         D3DPTEXTURECAPS_CUBEMAP_POW2   | D3DPTEXTURECAPS_VOLUMEMAP_POW2| D3DPTEXTURECAPS_NOPROJECTEDBUMPENV;
302 }
303 
304 static HRESULT WINAPI IDirect3D9Impl_GetDeviceCaps(LPDIRECT3D9EX iface, UINT Adapter, D3DDEVTYPE DeviceType, D3DCAPS9* pCaps) {
305     IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
306     HRESULT hrc = D3D_OK;
307     WINED3DCAPS *pWineCaps;
308 
309     TRACE("(%p) Relay %d %u %p\n", This, Adapter, DeviceType, pCaps);
310 
311     if(NULL == pCaps){
312         return D3DERR_INVALIDCALL;
313     }
314     pWineCaps = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(WINED3DCAPS));
315     if(pWineCaps == NULL){
316         return D3DERR_INVALIDCALL; /*well this is what MSDN says to return*/
317     }
318     memset(pCaps, 0, sizeof(*pCaps));
319     EnterCriticalSection(&d3d9_cs);
320     hrc = IWineD3D_GetDeviceCaps(This->WineD3D, Adapter, DeviceType, pWineCaps);
321     LeaveCriticalSection(&d3d9_cs);
322     WINECAPSTOD3D9CAPS(pCaps, pWineCaps)
323     HeapFree(GetProcessHeap(), 0, pWineCaps);
324 
325     /* Some functionality is implemented in d3d9.dll, not wined3d.dll. Add the needed caps */
326     pCaps->DevCaps2 |= D3DDEVCAPS2_CAN_STRETCHRECT_FROM_TEXTURES;
327 
328     filter_caps(pCaps);
329 
330     TRACE("(%p) returning %p\n", This, pCaps);
331     return hrc;
332 }
333 
334 static HMONITOR WINAPI IDirect3D9Impl_GetAdapterMonitor(LPDIRECT3D9EX iface, UINT Adapter) {
335     IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
336     HMONITOR ret;
337     TRACE("%p\n", This);
338 
339     EnterCriticalSection(&d3d9_cs);
340     ret = IWineD3D_GetAdapterMonitor(This->WineD3D, Adapter);
341     LeaveCriticalSection(&d3d9_cs);
342     return ret;
343 }
344 
345 ULONG WINAPI D3D9CB_DestroyRenderTarget(IWineD3DSurface *pSurface) {
346     IDirect3DSurface9Impl* surfaceParent;
347     TRACE("(%p) call back\n", pSurface);
348 
349     IWineD3DSurface_GetParent(pSurface, (IUnknown **) &surfaceParent);
350     surfaceParent->isImplicit = FALSE;
351     /* Surface had refcount of 0 GetParent addrefed to 1, so 1 Release is enough */
352     return IDirect3DSurface9_Release((IDirect3DSurface9*) surfaceParent);
353 }
354 
355 ULONG WINAPI D3D9CB_DestroySwapChain(IWineD3DSwapChain *pSwapChain) {
356     IDirect3DSwapChain9Impl* swapChainParent;
357     TRACE("(%p) call back\n", pSwapChain);
358 
359     IWineD3DSwapChain_GetParent(pSwapChain,(IUnknown **) &swapChainParent);
360     swapChainParent->isImplicit = FALSE;
361     /* Swap chain had refcount of 0 GetParent addrefed to 1, so 1 Release is enough */
362     return IDirect3DSwapChain9_Release((IDirect3DSwapChain9*) swapChainParent);
363 }
364 
365 ULONG WINAPI D3D9CB_DestroyDepthStencilSurface(IWineD3DSurface *pSurface) {
366     IDirect3DSurface9Impl* surfaceParent;
367     TRACE("(%p) call back\n", pSurface);
368 
369     IWineD3DSurface_GetParent(pSurface, (IUnknown **) &surfaceParent);
370     surfaceParent->isImplicit = FALSE;
371     /* Surface had refcount of 0 GetParent addrefed to 1, so 1 Release is enough */
372     return IDirect3DSurface9_Release((IDirect3DSurface9*) surfaceParent);
373 }
374 
375 static HRESULT WINAPI IDirect3D9Impl_CreateDevice(LPDIRECT3D9EX iface, UINT Adapter, D3DDEVTYPE DeviceType,
376                                                   HWND hFocusWindow, DWORD BehaviourFlags,
377                                                   D3DPRESENT_PARAMETERS* pPresentationParameters,
378                                                   IDirect3DDevice9** ppReturnedDeviceInterface) {
379 
380     IDirect3D9Impl       *This   = (IDirect3D9Impl *)iface;
381     IDirect3DDevice9Impl *object = NULL;
382     WINED3DPRESENT_PARAMETERS *localParameters;
383     UINT i, count = 1;
384     HRESULT hr;
385     TRACE("(%p) Relay\n", This);
386 
387     /* Check the validity range of the adapter parameter */
388     if (Adapter >= IDirect3D9Impl_GetAdapterCount(iface)) {
389         *ppReturnedDeviceInterface = NULL;
390         return D3DERR_INVALIDCALL;
391     }
392 
393     /* Allocate the storage for the device object */
394     object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DDevice9Impl));
395     if (NULL == object) {
396         FIXME("Allocation of memory failed\n");
397         *ppReturnedDeviceInterface = NULL;
398         return D3DERR_OUTOFVIDEOMEMORY;
399     }
400 
401     object->lpVtbl = &Direct3DDevice9_Vtbl;
402     object->device_parent_vtbl = &d3d9_wined3d_device_parent_vtbl;
403     object->ref = 1;
404     *ppReturnedDeviceInterface = (IDirect3DDevice9 *)object;
405 
406     /* Allocate an associated WineD3DDevice object */
407     EnterCriticalSection(&d3d9_cs);
408     hr = IWineD3D_CreateDevice(This->WineD3D, Adapter, DeviceType, hFocusWindow, BehaviourFlags,
409             (IUnknown *)object, (IWineD3DDeviceParent *)&object->device_parent_vtbl, &object->WineD3DDevice);
410     if (hr != D3D_OK) {
411         HeapFree(GetProcessHeap(), 0, object);
412         *ppReturnedDeviceInterface = NULL;
413         LeaveCriticalSection(&d3d9_cs);
414         return hr;
415     }
416 
417     TRACE("(%p) : Created Device %p\n", This, object);
418 
419     if (BehaviourFlags & D3DCREATE_ADAPTERGROUP_DEVICE)
420     {
421         WINED3DCAPS caps;
422 
423         IWineD3D_GetDeviceCaps(This->WineD3D, Adapter, DeviceType, &caps);
424         count = caps.NumberOfAdaptersInGroup;
425     }
426 
427     if(BehaviourFlags & D3DCREATE_MULTITHREADED) {
428         IWineD3DDevice_SetMultithreaded(object->WineD3DDevice);
429     }
430 
431     localParameters = HeapAlloc(GetProcessHeap(), 0, sizeof(*localParameters) * count);
432     for (i = 0; i < count; ++i)
433     {
434         localParameters[i].BackBufferWidth = pPresentationParameters[i].BackBufferWidth;
435         localParameters[i].BackBufferHeight = pPresentationParameters[i].BackBufferHeight;
436         localParameters[i].BackBufferFormat = wined3dformat_from_d3dformat(pPresentationParameters[i].BackBufferFormat);
437         localParameters[i].BackBufferCount = pPresentationParameters[i].BackBufferCount;
438         localParameters[i].MultiSampleType = pPresentationParameters[i].MultiSampleType;
439         localParameters[i].MultiSampleQuality = pPresentationParameters[i].MultiSampleQuality;
440         localParameters[i].SwapEffect = pPresentationParameters[i].SwapEffect;
441         localParameters[i].hDeviceWindow = pPresentationParameters[i].hDeviceWindow;
442         localParameters[i].Windowed = pPresentationParameters[i].Windowed;
443         localParameters[i].EnableAutoDepthStencil = pPresentationParameters[i].EnableAutoDepthStencil;
444         localParameters[i].AutoDepthStencilFormat = wined3dformat_from_d3dformat(pPresentationParameters[i].AutoDepthStencilFormat);
445         localParameters[i].Flags = pPresentationParameters[i].Flags;
446         localParameters[i].FullScreen_RefreshRateInHz = pPresentationParameters[i].FullScreen_RefreshRateInHz;
447         localParameters[i].PresentationInterval = pPresentationParameters[i].PresentationInterval;
448         localParameters[i].AutoRestoreDisplayMode = TRUE;
449     }
450 
451     hr = IWineD3DDevice_Init3D(object->WineD3DDevice, localParameters);
452     if (hr != D3D_OK) {
453         FIXME("(%p) D3D Initialization failed for WineD3DDevice %p\n", This, object->WineD3DDevice);
454         HeapFree(GetProcessHeap(), 0, object);
455         *ppReturnedDeviceInterface = NULL;
456     }
457 
458     for (i = 0; i < count; ++i)
459     {
460         pPresentationParameters[i].BackBufferWidth = localParameters[i].BackBufferWidth;
461         pPresentationParameters[i].BackBufferHeight = localParameters[i].BackBufferHeight;
462         pPresentationParameters[i].BackBufferFormat = d3dformat_from_wined3dformat(localParameters[i].BackBufferFormat);
463         pPresentationParameters[i].BackBufferCount = localParameters[i].BackBufferCount;
464         pPresentationParameters[i].MultiSampleType = localParameters[i].MultiSampleType;
465         pPresentationParameters[i].MultiSampleQuality = localParameters[i].MultiSampleQuality;
466         pPresentationParameters[i].SwapEffect = localParameters[i].SwapEffect;
467         pPresentationParameters[i].hDeviceWindow = localParameters[i].hDeviceWindow;
468         pPresentationParameters[i].Windowed = localParameters[i].Windowed;
469         pPresentationParameters[i].EnableAutoDepthStencil = localParameters[i].EnableAutoDepthStencil;
470         pPresentationParameters[i].AutoDepthStencilFormat = d3dformat_from_wined3dformat(localParameters[i].AutoDepthStencilFormat);
471         pPresentationParameters[i].Flags = localParameters[i].Flags;
472         pPresentationParameters[i].FullScreen_RefreshRateInHz = localParameters[i].FullScreen_RefreshRateInHz;
473         pPresentationParameters[i].PresentationInterval = localParameters[i].PresentationInterval;
474     }
475     HeapFree(GetProcessHeap(), 0, localParameters);
476 
477     /* Initialize the converted declaration array. This creates a valid pointer and when adding decls HeapReAlloc
478      * can be used without further checking
479      */
480     object->convertedDecls = HeapAlloc(GetProcessHeap(), 0, 0);
481     LeaveCriticalSection(&d3d9_cs);
482 
483     return hr;
484 }
485 
486 static UINT WINAPI IDirect3D9ExImpl_GetAdapterModeCountEx(IDirect3D9Ex *iface, UINT Adapter, CONST D3DDISPLAYMODEFILTER *pFilter) {
487     IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
488     FIXME("(%p)->(%d, %p): Stub!\n", This, Adapter, pFilter);
489     return D3DERR_DRIVERINTERNALERROR;
490 }
491 
492 static HRESULT WINAPI IDirect3D9ExImpl_EnumAdapterModesEx(IDirect3D9Ex *iface, UINT Adapter, CONST D3DDISPLAYMODEFILTER *pFilter, UINT Mode, D3DDISPLAYMODEEX* pMode) {
493     IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
494     FIXME("(%p)->(%d, %p, %p): Stub!\n", This, Adapter, pFilter, pMode);
495     return D3DERR_DRIVERINTERNALERROR;
496 }
497 
498 static HRESULT WINAPI IDirect3D9ExImpl_GetAdapterDisplayModeEx(IDirect3D9Ex *iface, UINT Adapter, D3DDISPLAYMODEEX *pMode, D3DDISPLAYROTATION *pRotation) {
499     IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
500     FIXME("(%p)->(%d, %p, %p): Stub!\n", This, Adapter, pMode, pRotation);
501     return D3DERR_DRIVERINTERNALERROR;
502 }
503 
504 static HRESULT WINAPI IDirect3D9ExImpl_CreateDeviceEx(IDirect3D9Ex *iface, UINT Adapter, D3DDEVTYPE DeviceType, HWND hFocusWindow, DWORD BehaviorFlags, D3DPRESENT_PARAMETERS* pPresentationParameters, D3DDISPLAYMODEEX* pFullscreenDisplayMode, struct IDirect3DDevice9Ex **ppReturnedDeviceInterface) {
505     IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
506     FIXME("(%p)->(%d, %d, %p, 0x%08x, %p, %p, %p): Stub!\n", This, Adapter, DeviceType, hFocusWindow, BehaviorFlags, pPresentationParameters, pFullscreenDisplayMode, ppReturnedDeviceInterface);
507     *ppReturnedDeviceInterface = NULL;
508     return D3DERR_DRIVERINTERNALERROR;
509 }
510 
511 static HRESULT WINAPI IDirect3D9ExImpl_GetAdapterLUID(IDirect3D9Ex *iface, UINT Adapter, LUID *pLUID) {
512     IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
513     FIXME("(%p)->(%d, %p)\n", This, Adapter, pLUID);
514     return D3DERR_DRIVERINTERNALERROR;
515 }
516 
517 
518 const IDirect3D9ExVtbl Direct3D9_Vtbl =
519 {
520     /* IUnknown */
521     IDirect3D9Impl_QueryInterface,
522     IDirect3D9Impl_AddRef,
523     IDirect3D9Impl_Release,
524     /* IDirect3D9 */
525     IDirect3D9Impl_RegisterSoftwareDevice,
526     IDirect3D9Impl_GetAdapterCount,
527     IDirect3D9Impl_GetAdapterIdentifier,
528     IDirect3D9Impl_GetAdapterModeCount,
529     IDirect3D9Impl_EnumAdapterModes,
530     IDirect3D9Impl_GetAdapterDisplayMode,
531     IDirect3D9Impl_CheckDeviceType,
532     IDirect3D9Impl_CheckDeviceFormat,
533     IDirect3D9Impl_CheckDeviceMultiSampleType,
534     IDirect3D9Impl_CheckDepthStencilMatch,
535     IDirect3D9Impl_CheckDeviceFormatConversion,
536     IDirect3D9Impl_GetDeviceCaps,
537     IDirect3D9Impl_GetAdapterMonitor,
538     IDirect3D9Impl_CreateDevice,
539     /* IDirect3D9Ex */
540     IDirect3D9ExImpl_GetAdapterModeCountEx,
541     IDirect3D9ExImpl_EnumAdapterModesEx,
542     IDirect3D9ExImpl_GetAdapterDisplayModeEx,
543     IDirect3D9ExImpl_CreateDeviceEx,
544     IDirect3D9ExImpl_GetAdapterLUID
545 
546 };
547 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.