1 | /*
|
---|
2 | * IDirect3D8 implementation
|
---|
3 | *
|
---|
4 | * Copyright 2002-2004 Jason Edmeades
|
---|
5 | * Copyright 2003-2004 Raphael Junqueira
|
---|
6 | * Copyright 2004 Christian Costa
|
---|
7 | *
|
---|
8 | * This library is free software; you can redistribute it and/or
|
---|
9 | * modify it under the terms of the GNU Lesser General Public
|
---|
10 | * License as published by the Free Software Foundation; either
|
---|
11 | * version 2.1 of the License, or (at your option) any later version.
|
---|
12 | *
|
---|
13 | * This library is distributed in the hope that it will be useful,
|
---|
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
16 | * Lesser General Public License for more details.
|
---|
17 | *
|
---|
18 | * You should have received a copy of the GNU Lesser General Public
|
---|
19 | * License along with this library; if not, write to the Free Software
|
---|
20 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
---|
21 | */
|
---|
22 |
|
---|
23 | /*
|
---|
24 | * Sun LGPL Disclaimer: For the avoidance of doubt, except that if any license choice
|
---|
25 | * other than GPL or LGPL is available it will apply instead, Sun elects to use only
|
---|
26 | * the Lesser General Public License version 2.1 (LGPLv2) at this time for any software where
|
---|
27 | * a choice of LGPL license versions is made available with the language indicating
|
---|
28 | * that LGPLv2 or any later version may be used, or where a choice of which version
|
---|
29 | * of the LGPL is applied is otherwise unspecified.
|
---|
30 | */
|
---|
31 |
|
---|
32 | #include "config.h"
|
---|
33 |
|
---|
34 | #include <stdarg.h>
|
---|
35 |
|
---|
36 | #define NONAMELESSUNION
|
---|
37 | #define NONAMELESSSTRUCT
|
---|
38 | #include "windef.h"
|
---|
39 | #include "winbase.h"
|
---|
40 | #include "wingdi.h"
|
---|
41 | #include "winuser.h"
|
---|
42 | #include "wine/debug.h"
|
---|
43 | #include "wine/unicode.h"
|
---|
44 |
|
---|
45 | #include "d3d8_private.h"
|
---|
46 |
|
---|
47 | WINE_DEFAULT_DEBUG_CHANNEL(d3d8);
|
---|
48 |
|
---|
49 | /* IDirect3D IUnknown parts follow: */
|
---|
50 | static HRESULT WINAPI IDirect3D8Impl_QueryInterface(LPDIRECT3D8 iface, REFIID riid,LPVOID *ppobj)
|
---|
51 | {
|
---|
52 | IDirect3D8Impl *This = (IDirect3D8Impl *)iface;
|
---|
53 |
|
---|
54 | if (IsEqualGUID(riid, &IID_IUnknown)
|
---|
55 | || IsEqualGUID(riid, &IID_IDirect3D8)) {
|
---|
56 | IUnknown_AddRef(iface);
|
---|
57 | *ppobj = This;
|
---|
58 | return S_OK;
|
---|
59 | }
|
---|
60 |
|
---|
61 | WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid),ppobj);
|
---|
62 | *ppobj = NULL;
|
---|
63 | return E_NOINTERFACE;
|
---|
64 | }
|
---|
65 |
|
---|
66 | static ULONG WINAPI IDirect3D8Impl_AddRef(LPDIRECT3D8 iface) {
|
---|
67 | IDirect3D8Impl *This = (IDirect3D8Impl *)iface;
|
---|
68 | ULONG ref = InterlockedIncrement(&This->ref);
|
---|
69 |
|
---|
70 | TRACE("(%p) : AddRef from %d\n", This, ref - 1);
|
---|
71 |
|
---|
72 | return ref;
|
---|
73 | }
|
---|
74 |
|
---|
75 | static ULONG WINAPI IDirect3D8Impl_Release(LPDIRECT3D8 iface) {
|
---|
76 | IDirect3D8Impl *This = (IDirect3D8Impl *)iface;
|
---|
77 | ULONG ref = InterlockedDecrement(&This->ref);
|
---|
78 |
|
---|
79 | TRACE("(%p) : ReleaseRef to %d\n", This, ref);
|
---|
80 |
|
---|
81 | if (ref == 0) {
|
---|
82 | TRACE("Releasing wined3d %p\n", This->WineD3D);
|
---|
83 | EnterCriticalSection(&d3d8_cs);
|
---|
84 | IWineD3D_Release(This->WineD3D);
|
---|
85 | LeaveCriticalSection(&d3d8_cs);
|
---|
86 | HeapFree(GetProcessHeap(), 0, This);
|
---|
87 | }
|
---|
88 |
|
---|
89 | return ref;
|
---|
90 | }
|
---|
91 |
|
---|
92 | /* IDirect3D8 Interface follow: */
|
---|
93 | static HRESULT WINAPI IDirect3D8Impl_RegisterSoftwareDevice (LPDIRECT3D8 iface, void* pInitializeFunction) {
|
---|
94 | IDirect3D8Impl *This = (IDirect3D8Impl *)iface;
|
---|
95 | HRESULT hr;
|
---|
96 | TRACE("(%p)->(%p)\n", This, pInitializeFunction);
|
---|
97 |
|
---|
98 | EnterCriticalSection(&d3d8_cs);
|
---|
99 | hr = IWineD3D_RegisterSoftwareDevice(This->WineD3D, pInitializeFunction);
|
---|
100 | LeaveCriticalSection(&d3d8_cs);
|
---|
101 | return hr;
|
---|
102 | }
|
---|
103 |
|
---|
104 | static UINT WINAPI IDirect3D8Impl_GetAdapterCount (LPDIRECT3D8 iface) {
|
---|
105 | IDirect3D8Impl *This = (IDirect3D8Impl *)iface;
|
---|
106 | HRESULT hr;
|
---|
107 | TRACE("(%p)\n", This);
|
---|
108 |
|
---|
109 | EnterCriticalSection(&d3d8_cs);
|
---|
110 | hr = IWineD3D_GetAdapterCount(This->WineD3D);
|
---|
111 | LeaveCriticalSection(&d3d8_cs);
|
---|
112 | return hr;
|
---|
113 | }
|
---|
114 |
|
---|
115 | static HRESULT WINAPI IDirect3D8Impl_GetAdapterIdentifier (LPDIRECT3D8 iface,
|
---|
116 | UINT Adapter, DWORD Flags, D3DADAPTER_IDENTIFIER8* pIdentifier) {
|
---|
117 | IDirect3D8Impl *This = (IDirect3D8Impl *)iface;
|
---|
118 | WINED3DADAPTER_IDENTIFIER adapter_id;
|
---|
119 | HRESULT hr;
|
---|
120 |
|
---|
121 | TRACE("(%p)->(%d,%08x, %p\n", This, Adapter, Flags, pIdentifier);
|
---|
122 | EnterCriticalSection(&d3d8_cs);
|
---|
123 | /* dx8 and dx9 have different structures to be filled in, with incompatible
|
---|
124 | layouts so pass in pointers to the places to be filled via an internal
|
---|
125 | structure */
|
---|
126 | adapter_id.Driver = pIdentifier->Driver;
|
---|
127 | adapter_id.Description = pIdentifier->Description;
|
---|
128 | adapter_id.DeviceName = NULL; /* d3d9 only */
|
---|
129 | adapter_id.DriverVersion = &pIdentifier->DriverVersion;
|
---|
130 | adapter_id.VendorId = &pIdentifier->VendorId;
|
---|
131 | adapter_id.DeviceId = &pIdentifier->DeviceId;
|
---|
132 | adapter_id.SubSysId = &pIdentifier->SubSysId;
|
---|
133 | adapter_id.Revision = &pIdentifier->Revision;
|
---|
134 | adapter_id.DeviceIdentifier = &pIdentifier->DeviceIdentifier;
|
---|
135 | adapter_id.WHQLLevel = &pIdentifier->WHQLLevel;
|
---|
136 |
|
---|
137 | hr = IWineD3D_GetAdapterIdentifier(This->WineD3D, Adapter, Flags, &adapter_id);
|
---|
138 | LeaveCriticalSection(&d3d8_cs);
|
---|
139 | return hr;
|
---|
140 | }
|
---|
141 |
|
---|
142 | static UINT WINAPI IDirect3D8Impl_GetAdapterModeCount (LPDIRECT3D8 iface,UINT Adapter) {
|
---|
143 | IDirect3D8Impl *This = (IDirect3D8Impl *)iface;
|
---|
144 | HRESULT hr;
|
---|
145 | TRACE("(%p)->(%d)\n", This, Adapter);
|
---|
146 |
|
---|
147 | EnterCriticalSection(&d3d8_cs);
|
---|
148 | hr = IWineD3D_GetAdapterModeCount(This->WineD3D, Adapter, 0 /* format */);
|
---|
149 | LeaveCriticalSection(&d3d8_cs);
|
---|
150 | return hr;
|
---|
151 | }
|
---|
152 |
|
---|
153 | static HRESULT WINAPI IDirect3D8Impl_EnumAdapterModes (LPDIRECT3D8 iface, UINT Adapter, UINT Mode, D3DDISPLAYMODE* pMode) {
|
---|
154 | IDirect3D8Impl *This = (IDirect3D8Impl *)iface;
|
---|
155 | HRESULT hr;
|
---|
156 | TRACE("(%p)->(%d, %d, %p)\n", This, Adapter, Mode, pMode);
|
---|
157 |
|
---|
158 | EnterCriticalSection(&d3d8_cs);
|
---|
159 | hr = IWineD3D_EnumAdapterModes(This->WineD3D, Adapter, WINED3DFMT_UNKNOWN, Mode, (WINED3DDISPLAYMODE *) pMode);
|
---|
160 | LeaveCriticalSection(&d3d8_cs);
|
---|
161 |
|
---|
162 | if (SUCCEEDED(hr)) pMode->Format = d3dformat_from_wined3dformat(pMode->Format);
|
---|
163 |
|
---|
164 | return hr;
|
---|
165 | }
|
---|
166 |
|
---|
167 | static HRESULT WINAPI IDirect3D8Impl_GetAdapterDisplayMode (LPDIRECT3D8 iface, UINT Adapter, D3DDISPLAYMODE* pMode) {
|
---|
168 | IDirect3D8Impl *This = (IDirect3D8Impl *)iface;
|
---|
169 | HRESULT hr;
|
---|
170 | TRACE("(%p)->(%d,%p)\n", This, Adapter, pMode);
|
---|
171 |
|
---|
172 | EnterCriticalSection(&d3d8_cs);
|
---|
173 | hr = IWineD3D_GetAdapterDisplayMode(This->WineD3D, Adapter, (WINED3DDISPLAYMODE *) pMode);
|
---|
174 | LeaveCriticalSection(&d3d8_cs);
|
---|
175 |
|
---|
176 | if (SUCCEEDED(hr)) pMode->Format = d3dformat_from_wined3dformat(pMode->Format);
|
---|
177 |
|
---|
178 | return hr;
|
---|
179 | }
|
---|
180 |
|
---|
181 | static HRESULT WINAPI IDirect3D8Impl_CheckDeviceType (LPDIRECT3D8 iface,
|
---|
182 | UINT Adapter, D3DDEVTYPE CheckType, D3DFORMAT DisplayFormat,
|
---|
183 | D3DFORMAT BackBufferFormat, BOOL Windowed) {
|
---|
184 | IDirect3D8Impl *This = (IDirect3D8Impl *)iface;
|
---|
185 | HRESULT hr;
|
---|
186 | TRACE("(%p)->(%d, %d, %d, %d, %s)\n", This, Adapter, CheckType, DisplayFormat, BackBufferFormat, Windowed ? "true" : "false");
|
---|
187 |
|
---|
188 | EnterCriticalSection(&d3d8_cs);
|
---|
189 | hr = IWineD3D_CheckDeviceType(This->WineD3D, Adapter, CheckType, wined3dformat_from_d3dformat(DisplayFormat),
|
---|
190 | wined3dformat_from_d3dformat(BackBufferFormat), Windowed);
|
---|
191 | LeaveCriticalSection(&d3d8_cs);
|
---|
192 | return hr;
|
---|
193 | }
|
---|
194 |
|
---|
195 | static HRESULT WINAPI IDirect3D8Impl_CheckDeviceFormat (LPDIRECT3D8 iface,
|
---|
196 | UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat,
|
---|
197 | DWORD Usage, D3DRESOURCETYPE RType, D3DFORMAT CheckFormat) {
|
---|
198 | IDirect3D8Impl *This = (IDirect3D8Impl *)iface;
|
---|
199 | HRESULT hr;
|
---|
200 | WINED3DRESOURCETYPE WineD3DRType;
|
---|
201 | TRACE("(%p)->(%d, %d, %d, %08x, %d, %d)\n", This, Adapter, DeviceType, AdapterFormat, Usage, RType, CheckFormat);
|
---|
202 |
|
---|
203 | switch(RType) {
|
---|
204 | case D3DRTYPE_VERTEXBUFFER:
|
---|
205 | case D3DRTYPE_INDEXBUFFER:
|
---|
206 | WineD3DRType = WINED3DRTYPE_BUFFER;
|
---|
207 | break;
|
---|
208 |
|
---|
209 | default:
|
---|
210 | WineD3DRType = RType;
|
---|
211 | break;
|
---|
212 | }
|
---|
213 |
|
---|
214 | EnterCriticalSection(&d3d8_cs);
|
---|
215 | hr = IWineD3D_CheckDeviceFormat(This->WineD3D, Adapter, DeviceType, wined3dformat_from_d3dformat(AdapterFormat),
|
---|
216 | Usage, WineD3DRType, wined3dformat_from_d3dformat(CheckFormat), SURFACE_OPENGL);
|
---|
217 | LeaveCriticalSection(&d3d8_cs);
|
---|
218 | return hr;
|
---|
219 | }
|
---|
220 |
|
---|
221 | static HRESULT WINAPI IDirect3D8Impl_CheckDeviceMultiSampleType(LPDIRECT3D8 iface,
|
---|
222 | UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT SurfaceFormat,
|
---|
223 | BOOL Windowed, D3DMULTISAMPLE_TYPE MultiSampleType) {
|
---|
224 | IDirect3D8Impl *This = (IDirect3D8Impl *)iface;
|
---|
225 | HRESULT hr;
|
---|
226 | TRACE("(%p)-<(%d, %d, %d, %s, %d)\n", This, Adapter, DeviceType, SurfaceFormat, Windowed ? "true" : "false", MultiSampleType);
|
---|
227 |
|
---|
228 | EnterCriticalSection(&d3d8_cs);
|
---|
229 | hr = IWineD3D_CheckDeviceMultiSampleType(This->WineD3D, Adapter, DeviceType,
|
---|
230 | wined3dformat_from_d3dformat(SurfaceFormat), Windowed, (WINED3DMULTISAMPLE_TYPE) MultiSampleType, NULL);
|
---|
231 | LeaveCriticalSection(&d3d8_cs);
|
---|
232 | return hr;
|
---|
233 | }
|
---|
234 |
|
---|
235 | static HRESULT WINAPI IDirect3D8Impl_CheckDepthStencilMatch(LPDIRECT3D8 iface,
|
---|
236 | UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat,
|
---|
237 | D3DFORMAT RenderTargetFormat, D3DFORMAT DepthStencilFormat) {
|
---|
238 | IDirect3D8Impl *This = (IDirect3D8Impl *)iface;
|
---|
239 | HRESULT hr;
|
---|
240 | TRACE("(%p)-<(%d, %d, %d, %d, %d)\n", This, Adapter, DeviceType, AdapterFormat, RenderTargetFormat, DepthStencilFormat);
|
---|
241 |
|
---|
242 | EnterCriticalSection(&d3d8_cs);
|
---|
243 | hr = IWineD3D_CheckDepthStencilMatch(This->WineD3D, Adapter, DeviceType,
|
---|
244 | wined3dformat_from_d3dformat(AdapterFormat), wined3dformat_from_d3dformat(RenderTargetFormat),
|
---|
245 | wined3dformat_from_d3dformat(DepthStencilFormat));
|
---|
246 | LeaveCriticalSection(&d3d8_cs);
|
---|
247 | return hr;
|
---|
248 | }
|
---|
249 |
|
---|
250 | static HRESULT WINAPI IDirect3D8Impl_GetDeviceCaps(LPDIRECT3D8 iface, UINT Adapter, D3DDEVTYPE DeviceType, D3DCAPS8* pCaps) {
|
---|
251 | IDirect3D8Impl *This = (IDirect3D8Impl *)iface;
|
---|
252 | HRESULT hrc = D3D_OK;
|
---|
253 | WINED3DCAPS *pWineCaps;
|
---|
254 |
|
---|
255 | TRACE("(%p) Relay %d %u %p\n", This, Adapter, DeviceType, pCaps);
|
---|
256 |
|
---|
257 | if(NULL == pCaps){
|
---|
258 | return D3DERR_INVALIDCALL;
|
---|
259 | }
|
---|
260 | pWineCaps = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(WINED3DCAPS));
|
---|
261 | if(pWineCaps == NULL){
|
---|
262 | return D3DERR_INVALIDCALL; /*well this is what MSDN says to return*/
|
---|
263 | }
|
---|
264 | EnterCriticalSection(&d3d8_cs);
|
---|
265 | hrc = IWineD3D_GetDeviceCaps(This->WineD3D, Adapter, DeviceType, pWineCaps);
|
---|
266 | LeaveCriticalSection(&d3d8_cs);
|
---|
267 | WINECAPSTOD3D8CAPS(pCaps, pWineCaps)
|
---|
268 | HeapFree(GetProcessHeap(), 0, pWineCaps);
|
---|
269 |
|
---|
270 | /* D3D8 doesn't support SM 2.0 or higher, so clamp to 1.x */
|
---|
271 | if(pCaps->PixelShaderVersion > D3DPS_VERSION(1,4)){
|
---|
272 | pCaps->PixelShaderVersion = D3DPS_VERSION(1,4);
|
---|
273 | }
|
---|
274 | if(pCaps->VertexShaderVersion > D3DVS_VERSION(1,1)){
|
---|
275 | pCaps->VertexShaderVersion = D3DVS_VERSION(1,1);
|
---|
276 | }
|
---|
277 | pCaps->MaxVertexShaderConst = min(D3D8_MAX_VERTEX_SHADER_CONSTANTF, pCaps->MaxVertexShaderConst);
|
---|
278 |
|
---|
279 | TRACE("(%p) returning %p\n", This, pCaps);
|
---|
280 | return hrc;
|
---|
281 | }
|
---|
282 |
|
---|
283 | static HMONITOR WINAPI IDirect3D8Impl_GetAdapterMonitor(LPDIRECT3D8 iface, UINT Adapter) {
|
---|
284 | IDirect3D8Impl *This = (IDirect3D8Impl *)iface;
|
---|
285 | HMONITOR ret;
|
---|
286 | TRACE("(%p)->(%d)\n", This, Adapter);
|
---|
287 |
|
---|
288 | EnterCriticalSection(&d3d8_cs);
|
---|
289 | ret = IWineD3D_GetAdapterMonitor(This->WineD3D, Adapter);
|
---|
290 | LeaveCriticalSection(&d3d8_cs);
|
---|
291 | return ret;
|
---|
292 | }
|
---|
293 |
|
---|
294 | ULONG WINAPI D3D8CB_DestroyRenderTarget(IWineD3DSurface *pSurface) {
|
---|
295 | IDirect3DSurface8Impl* surfaceParent;
|
---|
296 | TRACE("(%p) call back\n", pSurface);
|
---|
297 |
|
---|
298 | IWineD3DSurface_GetParent(pSurface, (IUnknown **) &surfaceParent);
|
---|
299 | surfaceParent->isImplicit = FALSE;
|
---|
300 | /* Surface had refcount of 0 GetParent addrefed to 1, so 1 Release is enough */
|
---|
301 | return IDirect3DSurface8_Release((IDirect3DSurface8*) surfaceParent);
|
---|
302 | }
|
---|
303 |
|
---|
304 | ULONG WINAPI D3D8CB_DestroySwapChain(IWineD3DSwapChain *pSwapChain) {
|
---|
305 | IUnknown* swapChainParent;
|
---|
306 | TRACE("(%p) call back\n", pSwapChain);
|
---|
307 |
|
---|
308 | IWineD3DSwapChain_GetParent(pSwapChain, &swapChainParent);
|
---|
309 | IUnknown_Release(swapChainParent);
|
---|
310 | return IUnknown_Release(swapChainParent);
|
---|
311 | }
|
---|
312 |
|
---|
313 | ULONG WINAPI D3D8CB_DestroyDepthStencilSurface(IWineD3DSurface *pSurface) {
|
---|
314 | IDirect3DSurface8Impl* surfaceParent;
|
---|
315 | TRACE("(%p) call back\n", pSurface);
|
---|
316 |
|
---|
317 | IWineD3DSurface_GetParent(pSurface, (IUnknown **) &surfaceParent);
|
---|
318 | surfaceParent->isImplicit = FALSE;
|
---|
319 | /* Surface had refcount of 0 GetParent addrefed to 1, so 1 Release is enough */
|
---|
320 | return IDirect3DSurface8_Release((IDirect3DSurface8*) surfaceParent);
|
---|
321 | }
|
---|
322 |
|
---|
323 | static HRESULT WINAPI IDirect3D8Impl_CreateDevice(LPDIRECT3D8 iface, UINT Adapter, D3DDEVTYPE DeviceType, HWND hFocusWindow,
|
---|
324 | DWORD BehaviourFlags, D3DPRESENT_PARAMETERS* pPresentationParameters,
|
---|
325 | IDirect3DDevice8** ppReturnedDeviceInterface) {
|
---|
326 |
|
---|
327 | IDirect3D8Impl *This = (IDirect3D8Impl *)iface;
|
---|
328 | IDirect3DDevice8Impl *object = NULL;
|
---|
329 | WINED3DPRESENT_PARAMETERS localParameters;
|
---|
330 | HRESULT hr;
|
---|
331 | TRACE("(%p) Relay\n", This);
|
---|
332 |
|
---|
333 | /* Check the validity range of the adapter parameter */
|
---|
334 | if (Adapter >= IDirect3D8Impl_GetAdapterCount(iface)) {
|
---|
335 | *ppReturnedDeviceInterface = NULL;
|
---|
336 | return D3DERR_INVALIDCALL;
|
---|
337 | }
|
---|
338 |
|
---|
339 | /* Allocate the storage for the device object */
|
---|
340 | object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DDevice8Impl));
|
---|
341 | if (NULL == object) {
|
---|
342 | FIXME("Allocation of memory failed\n");
|
---|
343 | *ppReturnedDeviceInterface = NULL;
|
---|
344 | return D3DERR_OUTOFVIDEOMEMORY;
|
---|
345 | }
|
---|
346 |
|
---|
347 | object->lpVtbl = &Direct3DDevice8_Vtbl;
|
---|
348 | object->device_parent_vtbl = &d3d8_wined3d_device_parent_vtbl;
|
---|
349 | object->ref = 1;
|
---|
350 | object->handle_table.entries = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
|
---|
351 | D3D8_INITIAL_HANDLE_TABLE_SIZE * sizeof(*object->handle_table.entries));
|
---|
352 | object->handle_table.table_size = D3D8_INITIAL_HANDLE_TABLE_SIZE;
|
---|
353 | *ppReturnedDeviceInterface = (IDirect3DDevice8 *)object;
|
---|
354 |
|
---|
355 | /* Allocate an associated WineD3DDevice object */
|
---|
356 | EnterCriticalSection(&d3d8_cs);
|
---|
357 | hr = IWineD3D_CreateDevice(This->WineD3D, Adapter, DeviceType, hFocusWindow, BehaviourFlags,
|
---|
358 | (IUnknown *)object, (IWineD3DDeviceParent *)&object->device_parent_vtbl, &object->WineD3DDevice);
|
---|
359 |
|
---|
360 | if (hr != D3D_OK) {
|
---|
361 | HeapFree(GetProcessHeap(), 0, object);
|
---|
362 | *ppReturnedDeviceInterface = NULL;
|
---|
363 | LeaveCriticalSection(&d3d8_cs);
|
---|
364 | return hr;
|
---|
365 | }
|
---|
366 |
|
---|
367 | TRACE("(%p) : Created Device %p\n", This, object);
|
---|
368 |
|
---|
369 | localParameters.BackBufferWidth = pPresentationParameters->BackBufferWidth;
|
---|
370 | localParameters.BackBufferHeight = pPresentationParameters->BackBufferHeight;
|
---|
371 | localParameters.BackBufferFormat = wined3dformat_from_d3dformat(pPresentationParameters->BackBufferFormat);
|
---|
372 | localParameters.BackBufferCount = pPresentationParameters->BackBufferCount;
|
---|
373 | localParameters.MultiSampleType = pPresentationParameters->MultiSampleType;
|
---|
374 | localParameters.MultiSampleQuality = 0; /* d3d9 only */
|
---|
375 | localParameters.SwapEffect = pPresentationParameters->SwapEffect;
|
---|
376 | localParameters.hDeviceWindow = pPresentationParameters->hDeviceWindow;
|
---|
377 | localParameters.Windowed = pPresentationParameters->Windowed;
|
---|
378 | localParameters.EnableAutoDepthStencil = pPresentationParameters->EnableAutoDepthStencil;
|
---|
379 | localParameters.AutoDepthStencilFormat = wined3dformat_from_d3dformat(pPresentationParameters->AutoDepthStencilFormat);
|
---|
380 | localParameters.Flags = pPresentationParameters->Flags;
|
---|
381 | localParameters.FullScreen_RefreshRateInHz = pPresentationParameters->FullScreen_RefreshRateInHz;
|
---|
382 | localParameters.PresentationInterval = pPresentationParameters->FullScreen_PresentationInterval;
|
---|
383 | localParameters.AutoRestoreDisplayMode = TRUE;
|
---|
384 |
|
---|
385 | if(BehaviourFlags & D3DCREATE_MULTITHREADED) {
|
---|
386 | IWineD3DDevice_SetMultithreaded(object->WineD3DDevice);
|
---|
387 | }
|
---|
388 |
|
---|
389 | hr = IWineD3DDevice_Init3D(object->WineD3DDevice, &localParameters);
|
---|
390 | LeaveCriticalSection(&d3d8_cs);
|
---|
391 |
|
---|
392 | pPresentationParameters->BackBufferWidth = localParameters.BackBufferWidth;
|
---|
393 | pPresentationParameters->BackBufferHeight = localParameters.BackBufferHeight;
|
---|
394 | pPresentationParameters->BackBufferFormat = d3dformat_from_wined3dformat(localParameters.BackBufferFormat);
|
---|
395 | pPresentationParameters->BackBufferCount = localParameters.BackBufferCount;
|
---|
396 | pPresentationParameters->MultiSampleType = localParameters.MultiSampleType;
|
---|
397 | pPresentationParameters->SwapEffect = localParameters.SwapEffect;
|
---|
398 | pPresentationParameters->hDeviceWindow = localParameters.hDeviceWindow;
|
---|
399 | pPresentationParameters->Windowed = localParameters.Windowed;
|
---|
400 | pPresentationParameters->EnableAutoDepthStencil = localParameters.EnableAutoDepthStencil;
|
---|
401 | pPresentationParameters->AutoDepthStencilFormat = d3dformat_from_wined3dformat(localParameters.AutoDepthStencilFormat);
|
---|
402 | pPresentationParameters->Flags = localParameters.Flags;
|
---|
403 | pPresentationParameters->FullScreen_RefreshRateInHz = localParameters.FullScreen_RefreshRateInHz;
|
---|
404 | pPresentationParameters->FullScreen_PresentationInterval = localParameters.PresentationInterval;
|
---|
405 |
|
---|
406 | if (hr != D3D_OK) {
|
---|
407 | FIXME("(%p) D3D Initialization failed for WineD3DDevice %p\n", This, object->WineD3DDevice);
|
---|
408 | HeapFree(GetProcessHeap(), 0, object);
|
---|
409 | *ppReturnedDeviceInterface = NULL;
|
---|
410 | }
|
---|
411 |
|
---|
412 | object->declArraySize = 16;
|
---|
413 | object->decls = HeapAlloc(GetProcessHeap(), 0, object->declArraySize * sizeof(*object->decls));
|
---|
414 | if(!object->decls) {
|
---|
415 | ERR("Out of memory\n");
|
---|
416 | EnterCriticalSection(&d3d8_cs);
|
---|
417 | IWineD3DDevice_Release(object->WineD3DDevice);
|
---|
418 | LeaveCriticalSection(&d3d8_cs);
|
---|
419 | HeapFree(GetProcessHeap(), 0, object);
|
---|
420 | *ppReturnedDeviceInterface = NULL;
|
---|
421 | hr = E_OUTOFMEMORY;
|
---|
422 | }
|
---|
423 | return hr;
|
---|
424 | }
|
---|
425 |
|
---|
426 | const IDirect3D8Vtbl Direct3D8_Vtbl =
|
---|
427 | {
|
---|
428 | /* IUnknown */
|
---|
429 | IDirect3D8Impl_QueryInterface,
|
---|
430 | IDirect3D8Impl_AddRef,
|
---|
431 | IDirect3D8Impl_Release,
|
---|
432 | /* IDirect3D8 */
|
---|
433 | IDirect3D8Impl_RegisterSoftwareDevice,
|
---|
434 | IDirect3D8Impl_GetAdapterCount,
|
---|
435 | IDirect3D8Impl_GetAdapterIdentifier,
|
---|
436 | IDirect3D8Impl_GetAdapterModeCount,
|
---|
437 | IDirect3D8Impl_EnumAdapterModes,
|
---|
438 | IDirect3D8Impl_GetAdapterDisplayMode,
|
---|
439 | IDirect3D8Impl_CheckDeviceType,
|
---|
440 | IDirect3D8Impl_CheckDeviceFormat,
|
---|
441 | IDirect3D8Impl_CheckDeviceMultiSampleType,
|
---|
442 | IDirect3D8Impl_CheckDepthStencilMatch,
|
---|
443 | IDirect3D8Impl_GetDeviceCaps,
|
---|
444 | IDirect3D8Impl_GetAdapterMonitor,
|
---|
445 | IDirect3D8Impl_CreateDevice
|
---|
446 | };
|
---|