VirtualBox

source: vbox/trunk/src/VBox/Additions/WINNT/Graphics/Wine/d3d9/volumetexture.c@ 33252

Last change on this file since 33252 was 25949, checked in by vboxsync, 15 years ago

crOpenGL: update to wine 1.1.36 and disable unnecessary fbo state poll

  • Property svn:eol-style set to native
File size: 14.6 KB
Line 
1/*
2 * IDirect3DVolumeTexture9 implementation
3 *
4 * Copyright 2002-2005 Jason Edmeades
5 * Raphael Junqueira
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/*
23 * Sun LGPL Disclaimer: For the avoidance of doubt, except that if any license choice
24 * other than GPL or LGPL is available it will apply instead, Sun elects to use only
25 * the Lesser General Public License version 2.1 (LGPLv2) at this time for any software where
26 * a choice of LGPL license versions is made available with the language indicating
27 * that LGPLv2 or any later version may be used, or where a choice of which version
28 * of the LGPL is applied is otherwise unspecified.
29 */
30
31#include "config.h"
32#include "d3d9_private.h"
33
34WINE_DEFAULT_DEBUG_CHANNEL(d3d9);
35
36/* IDirect3DVolumeTexture9 IUnknown parts follow: */
37static HRESULT WINAPI IDirect3DVolumeTexture9Impl_QueryInterface(LPDIRECT3DVOLUMETEXTURE9 iface, REFIID riid, LPVOID* ppobj) {
38 IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
39
40 TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), ppobj);
41
42 if (IsEqualGUID(riid, &IID_IUnknown)
43 || IsEqualGUID(riid, &IID_IDirect3DResource9)
44 || IsEqualGUID(riid, &IID_IDirect3DBaseTexture9)
45 || IsEqualGUID(riid, &IID_IDirect3DVolumeTexture9)) {
46 IDirect3DVolumeTexture9_AddRef(iface);
47 *ppobj = This;
48 return S_OK;
49 }
50
51 WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
52 *ppobj = NULL;
53 return E_NOINTERFACE;
54}
55
56static ULONG WINAPI IDirect3DVolumeTexture9Impl_AddRef(LPDIRECT3DVOLUMETEXTURE9 iface) {
57 IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
58 ULONG ref = InterlockedIncrement(&This->ref);
59
60 TRACE("%p increasing refcount to %u.\n", iface, ref);
61
62 if (ref == 1)
63 {
64 IDirect3DDevice9Ex_AddRef(This->parentDevice);
65 wined3d_mutex_lock();
66 IWineD3DVolumeTexture_AddRef(This->wineD3DVolumeTexture);
67 wined3d_mutex_unlock();
68 }
69
70 return ref;
71}
72
73static ULONG WINAPI IDirect3DVolumeTexture9Impl_Release(LPDIRECT3DVOLUMETEXTURE9 iface) {
74 IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
75 ULONG ref = InterlockedDecrement(&This->ref);
76
77 TRACE("%p decreasing refcount to %u.\n", iface, ref);
78
79 if (ref == 0) {
80 IDirect3DDevice9Ex *parentDevice = This->parentDevice;
81
82 wined3d_mutex_lock();
83 IWineD3DVolumeTexture_Release(This->wineD3DVolumeTexture);
84 wined3d_mutex_unlock();
85
86 /* Release the device last, as it may cause the device to be destroyed. */
87 IDirect3DDevice9Ex_Release(parentDevice);
88 }
89 return ref;
90}
91
92/* IDirect3DVolumeTexture9 IDirect3DResource9 Interface follow: */
93static HRESULT WINAPI IDirect3DVolumeTexture9Impl_GetDevice(IDirect3DVolumeTexture9 *iface, IDirect3DDevice9 **device)
94{
95 IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
96
97 TRACE("iface %p, device %p.\n", iface, device);
98
99 *device = (IDirect3DDevice9 *)This->parentDevice;
100 IDirect3DDevice9_AddRef(*device);
101
102 TRACE("Returning device %p.\n", *device);
103
104 return D3D_OK;
105}
106
107static HRESULT WINAPI IDirect3DVolumeTexture9Impl_SetPrivateData(LPDIRECT3DVOLUMETEXTURE9 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
108 IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
109 HRESULT hr;
110
111 TRACE("iface %p, guid %s, data %p, data_size %u, flags %#x.\n",
112 iface, debugstr_guid(refguid), pData, SizeOfData, Flags);
113
114 wined3d_mutex_lock();
115
116 hr = IWineD3DVolumeTexture_SetPrivateData(This->wineD3DVolumeTexture, refguid, pData, SizeOfData, Flags);
117
118 wined3d_mutex_unlock();
119
120 return hr;
121}
122
123static HRESULT WINAPI IDirect3DVolumeTexture9Impl_GetPrivateData(LPDIRECT3DVOLUMETEXTURE9 iface, REFGUID refguid, void* pData, DWORD* pSizeOfData) {
124 IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
125 HRESULT hr;
126
127 TRACE("iface %p, guid %s, data %p, data_size %p.\n",
128 iface, debugstr_guid(refguid), pData, pSizeOfData);
129
130 wined3d_mutex_lock();
131
132 hr = IWineD3DVolumeTexture_GetPrivateData(This->wineD3DVolumeTexture, refguid, pData, pSizeOfData);
133
134 wined3d_mutex_unlock();
135
136 return hr;
137}
138
139static HRESULT WINAPI IDirect3DVolumeTexture9Impl_FreePrivateData(LPDIRECT3DVOLUMETEXTURE9 iface, REFGUID refguid) {
140 IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
141 HRESULT hr;
142
143 TRACE("iface %p, guid %s.\n", iface, debugstr_guid(refguid));
144
145 wined3d_mutex_lock();
146
147 hr = IWineD3DVolumeTexture_FreePrivateData(This->wineD3DVolumeTexture, refguid);
148
149 wined3d_mutex_unlock();
150
151 return hr;
152}
153
154static DWORD WINAPI IDirect3DVolumeTexture9Impl_SetPriority(LPDIRECT3DVOLUMETEXTURE9 iface, DWORD PriorityNew) {
155 IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
156 DWORD priority;
157
158 TRACE("iface %p, priority %u.\n", iface, PriorityNew);
159
160 wined3d_mutex_lock();
161
162 priority = IWineD3DVolumeTexture_SetPriority(This->wineD3DVolumeTexture, PriorityNew);
163
164 wined3d_mutex_unlock();
165
166 return priority;
167}
168
169static DWORD WINAPI IDirect3DVolumeTexture9Impl_GetPriority(LPDIRECT3DVOLUMETEXTURE9 iface) {
170 IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
171 DWORD priority;
172
173 TRACE("iface %p.\n", iface);
174
175 wined3d_mutex_lock();
176
177 priority = IWineD3DVolumeTexture_GetPriority(This->wineD3DVolumeTexture);
178
179 wined3d_mutex_unlock();
180
181 return priority;
182}
183
184static void WINAPI IDirect3DVolumeTexture9Impl_PreLoad(LPDIRECT3DVOLUMETEXTURE9 iface) {
185 IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
186
187 TRACE("iface %p.\n", iface);
188
189 wined3d_mutex_lock();
190
191 IWineD3DVolumeTexture_PreLoad(This->wineD3DVolumeTexture);
192
193 wined3d_mutex_unlock();
194}
195
196static D3DRESOURCETYPE WINAPI IDirect3DVolumeTexture9Impl_GetType(LPDIRECT3DVOLUMETEXTURE9 iface) {
197 IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
198 D3DRESOURCETYPE type;
199
200 TRACE("iface %p.\n", iface);
201
202 wined3d_mutex_lock();
203
204 type = IWineD3DVolumeTexture_GetType(This->wineD3DVolumeTexture);
205
206 wined3d_mutex_unlock();
207
208 return type;
209}
210
211/* IDirect3DVolumeTexture9 IDirect3DBaseTexture9 Interface follow: */
212static DWORD WINAPI IDirect3DVolumeTexture9Impl_SetLOD(LPDIRECT3DVOLUMETEXTURE9 iface, DWORD LODNew) {
213 IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
214 DWORD lod;
215
216 TRACE("iface %p, lod %u.\n", iface, LODNew);
217
218 wined3d_mutex_lock();
219
220 lod = IWineD3DVolumeTexture_SetLOD(This->wineD3DVolumeTexture, LODNew);
221
222 wined3d_mutex_unlock();
223
224 return lod;
225}
226
227static DWORD WINAPI IDirect3DVolumeTexture9Impl_GetLOD(LPDIRECT3DVOLUMETEXTURE9 iface) {
228 IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
229 DWORD lod;
230
231 TRACE("iface %p.\n", iface);
232
233 wined3d_mutex_lock();
234
235 lod = IWineD3DVolumeTexture_GetLOD(This->wineD3DVolumeTexture);
236
237 wined3d_mutex_unlock();
238
239 return lod;
240}
241
242static DWORD WINAPI IDirect3DVolumeTexture9Impl_GetLevelCount(LPDIRECT3DVOLUMETEXTURE9 iface) {
243 IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
244 DWORD level_count;
245
246 TRACE("iface %p.\n", iface);
247
248 wined3d_mutex_lock();
249
250 level_count = IWineD3DVolumeTexture_GetLevelCount(This->wineD3DVolumeTexture);
251
252 wined3d_mutex_unlock();
253
254 return level_count;
255}
256
257static HRESULT WINAPI IDirect3DVolumeTexture9Impl_SetAutoGenFilterType(LPDIRECT3DVOLUMETEXTURE9 iface, D3DTEXTUREFILTERTYPE FilterType) {
258 IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
259 HRESULT hr;
260
261 TRACE("iface %p, filter_type %#x.\n", iface, FilterType);
262
263 wined3d_mutex_lock();
264
265 hr = IWineD3DVolumeTexture_SetAutoGenFilterType(This->wineD3DVolumeTexture, (WINED3DTEXTUREFILTERTYPE) FilterType);
266
267 wined3d_mutex_unlock();
268
269 return hr;
270}
271
272static D3DTEXTUREFILTERTYPE WINAPI IDirect3DVolumeTexture9Impl_GetAutoGenFilterType(LPDIRECT3DVOLUMETEXTURE9 iface) {
273 IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
274 D3DTEXTUREFILTERTYPE filter_type;
275
276 TRACE("iface %p.\n", iface);
277
278 wined3d_mutex_lock();
279
280 filter_type = (D3DTEXTUREFILTERTYPE)IWineD3DVolumeTexture_GetAutoGenFilterType(This->wineD3DVolumeTexture);
281
282 wined3d_mutex_unlock();
283
284 return filter_type;
285}
286
287static void WINAPI IDirect3DVolumeTexture9Impl_GenerateMipSubLevels(LPDIRECT3DVOLUMETEXTURE9 iface) {
288 IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
289
290 TRACE("iface %p.\n", iface);
291
292 wined3d_mutex_lock();
293
294 IWineD3DVolumeTexture_GenerateMipSubLevels(This->wineD3DVolumeTexture);
295
296 wined3d_mutex_unlock();
297}
298
299/* IDirect3DVolumeTexture9 Interface follow: */
300static HRESULT WINAPI IDirect3DVolumeTexture9Impl_GetLevelDesc(LPDIRECT3DVOLUMETEXTURE9 iface, UINT Level, D3DVOLUME_DESC* pDesc) {
301 IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
302 WINED3DVOLUME_DESC wined3ddesc;
303 HRESULT hr;
304
305 TRACE("iface %p, level %u, desc %p.\n", iface, Level, pDesc);
306
307 wined3d_mutex_lock();
308
309 hr = IWineD3DVolumeTexture_GetLevelDesc(This->wineD3DVolumeTexture, Level, &wined3ddesc);
310
311 wined3d_mutex_unlock();
312
313 if (SUCCEEDED(hr))
314 {
315 pDesc->Format = d3dformat_from_wined3dformat(wined3ddesc.Format);
316 pDesc->Type = wined3ddesc.Type;
317 pDesc->Usage = wined3ddesc.Usage;
318 pDesc->Pool = wined3ddesc.Pool;
319 pDesc->Width = wined3ddesc.Width;
320 pDesc->Height = wined3ddesc.Height;
321 pDesc->Depth = wined3ddesc.Depth;
322 }
323
324 return hr;
325}
326
327static HRESULT WINAPI IDirect3DVolumeTexture9Impl_GetVolumeLevel(LPDIRECT3DVOLUMETEXTURE9 iface, UINT Level, IDirect3DVolume9** ppVolumeLevel) {
328 IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
329 HRESULT hrc = D3D_OK;
330 IWineD3DVolume *myVolume = NULL;
331
332 TRACE("iface %p, level %u, volume %p.\n", iface, Level, ppVolumeLevel);
333
334 wined3d_mutex_lock();
335
336 hrc = IWineD3DVolumeTexture_GetVolumeLevel(This->wineD3DVolumeTexture, Level, &myVolume);
337 if (hrc == D3D_OK && NULL != ppVolumeLevel) {
338 IWineD3DVolumeTexture_GetParent(myVolume, (IUnknown **)ppVolumeLevel);
339 IWineD3DVolumeTexture_Release(myVolume);
340 }
341
342 wined3d_mutex_unlock();
343
344 return hrc;
345}
346
347static HRESULT WINAPI IDirect3DVolumeTexture9Impl_LockBox(LPDIRECT3DVOLUMETEXTURE9 iface, UINT Level, D3DLOCKED_BOX* pLockedVolume, CONST D3DBOX* pBox, DWORD Flags) {
348 IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
349 HRESULT hr;
350
351 TRACE("iface %p, level %u, locked_box %p, box %p, flags %#x.\n",
352 iface, Level, pLockedVolume, pBox, Flags);
353
354 wined3d_mutex_lock();
355
356 hr = IWineD3DVolumeTexture_LockBox(This->wineD3DVolumeTexture, Level, (WINED3DLOCKED_BOX *)pLockedVolume,
357 (const WINED3DBOX *)pBox, Flags);
358
359 wined3d_mutex_unlock();
360
361 return hr;
362}
363
364static HRESULT WINAPI IDirect3DVolumeTexture9Impl_UnlockBox(LPDIRECT3DVOLUMETEXTURE9 iface, UINT Level) {
365 IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
366 HRESULT hr;
367
368 TRACE("iface %p, level %u.\n", iface, Level);
369
370 wined3d_mutex_lock();
371
372 hr = IWineD3DVolumeTexture_UnlockBox(This->wineD3DVolumeTexture, Level);
373
374 wined3d_mutex_unlock();
375
376 return hr;
377}
378
379static HRESULT WINAPI IDirect3DVolumeTexture9Impl_AddDirtyBox(LPDIRECT3DVOLUMETEXTURE9 iface, CONST D3DBOX* pDirtyBox) {
380 IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
381 HRESULT hr;
382
383 TRACE("iface %p, dirty_box %p.\n", iface, pDirtyBox);
384
385 wined3d_mutex_lock();
386
387 hr = IWineD3DVolumeTexture_AddDirtyBox(This->wineD3DVolumeTexture, (CONST WINED3DBOX *)pDirtyBox);
388
389 wined3d_mutex_unlock();
390
391 return hr;
392}
393
394
395static const IDirect3DVolumeTexture9Vtbl Direct3DVolumeTexture9_Vtbl =
396{
397 /* IUnknown */
398 IDirect3DVolumeTexture9Impl_QueryInterface,
399 IDirect3DVolumeTexture9Impl_AddRef,
400 IDirect3DVolumeTexture9Impl_Release,
401 /* IDirect3DResource9 */
402 IDirect3DVolumeTexture9Impl_GetDevice,
403 IDirect3DVolumeTexture9Impl_SetPrivateData,
404 IDirect3DVolumeTexture9Impl_GetPrivateData,
405 IDirect3DVolumeTexture9Impl_FreePrivateData,
406 IDirect3DVolumeTexture9Impl_SetPriority,
407 IDirect3DVolumeTexture9Impl_GetPriority,
408 IDirect3DVolumeTexture9Impl_PreLoad,
409 IDirect3DVolumeTexture9Impl_GetType,
410 /* IDirect3DBaseTexture9 */
411 IDirect3DVolumeTexture9Impl_SetLOD,
412 IDirect3DVolumeTexture9Impl_GetLOD,
413 IDirect3DVolumeTexture9Impl_GetLevelCount,
414 IDirect3DVolumeTexture9Impl_SetAutoGenFilterType,
415 IDirect3DVolumeTexture9Impl_GetAutoGenFilterType,
416 IDirect3DVolumeTexture9Impl_GenerateMipSubLevels,
417 /* IDirect3DVolumeTexture9 */
418 IDirect3DVolumeTexture9Impl_GetLevelDesc,
419 IDirect3DVolumeTexture9Impl_GetVolumeLevel,
420 IDirect3DVolumeTexture9Impl_LockBox,
421 IDirect3DVolumeTexture9Impl_UnlockBox,
422 IDirect3DVolumeTexture9Impl_AddDirtyBox
423};
424
425static void STDMETHODCALLTYPE volumetexture_wined3d_object_destroyed(void *parent)
426{
427 HeapFree(GetProcessHeap(), 0, parent);
428}
429
430static const struct wined3d_parent_ops d3d9_volumetexture_wined3d_parent_ops =
431{
432 volumetexture_wined3d_object_destroyed,
433};
434
435HRESULT volumetexture_init(IDirect3DVolumeTexture9Impl *texture, IDirect3DDevice9Impl *device,
436 UINT width, UINT height, UINT depth, UINT levels, DWORD usage, D3DFORMAT format, D3DPOOL pool)
437{
438 HRESULT hr;
439
440 texture->lpVtbl = &Direct3DVolumeTexture9_Vtbl;
441 texture->ref = 1;
442
443 wined3d_mutex_lock();
444 hr = IWineD3DDevice_CreateVolumeTexture(device->WineD3DDevice, width, height, depth, levels,
445 usage & WINED3DUSAGE_MASK, wined3dformat_from_d3dformat(format), pool,
446 &texture->wineD3DVolumeTexture, (IUnknown *)texture, &d3d9_volumetexture_wined3d_parent_ops);
447 wined3d_mutex_unlock();
448 if (FAILED(hr))
449 {
450 WARN("Failed to create wined3d volume texture, hr %#x.\n", hr);
451 return hr;
452 }
453
454 texture->parentDevice = (IDirect3DDevice9Ex *)device;
455 IDirect3DDevice9Ex_AddRef(texture->parentDevice);
456
457 return D3D_OK;
458}
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette