1 | /*
|
---|
2 | * IDirect3DVolumeTexture8 implementation
|
---|
3 | *
|
---|
4 | * Copyright 2005 Oliver Stieber
|
---|
5 | *
|
---|
6 | * This library is free software; you can redistribute it and/or
|
---|
7 | * modify it under the terms of the GNU Lesser General Public
|
---|
8 | * License as published by the Free Software Foundation; either
|
---|
9 | * version 2.1 of the License, or (at your option) any later version.
|
---|
10 | *
|
---|
11 | * This library is distributed in the hope that it will be useful,
|
---|
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
14 | * Lesser General Public License for more details.
|
---|
15 | *
|
---|
16 | * You should have received a copy of the GNU Lesser General Public
|
---|
17 | * License along with this library; if not, write to the Free Software
|
---|
18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
---|
19 | */
|
---|
20 |
|
---|
21 | /*
|
---|
22 | * Sun LGPL Disclaimer: For the avoidance of doubt, except that if any license choice
|
---|
23 | * other than GPL or LGPL is available it will apply instead, Sun elects to use only
|
---|
24 | * the Lesser General Public License version 2.1 (LGPLv2) at this time for any software where
|
---|
25 | * a choice of LGPL license versions is made available with the language indicating
|
---|
26 | * that LGPLv2 or any later version may be used, or where a choice of which version
|
---|
27 | * of the LGPL is applied is otherwise unspecified.
|
---|
28 | */
|
---|
29 |
|
---|
30 | #include "config.h"
|
---|
31 | #include "d3d8_private.h"
|
---|
32 |
|
---|
33 | WINE_DEFAULT_DEBUG_CHANNEL(d3d8);
|
---|
34 |
|
---|
35 | /* IDirect3DVolumeTexture8 IUnknown parts follow: */
|
---|
36 | static HRESULT WINAPI IDirect3DVolumeTexture8Impl_QueryInterface(LPDIRECT3DVOLUMETEXTURE8 iface, REFIID riid, LPVOID *ppobj) {
|
---|
37 | IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
|
---|
38 |
|
---|
39 | TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), ppobj);
|
---|
40 |
|
---|
41 | if (IsEqualGUID(riid, &IID_IUnknown)
|
---|
42 | || IsEqualGUID(riid, &IID_IDirect3DResource8)
|
---|
43 | || IsEqualGUID(riid, &IID_IDirect3DBaseTexture8)
|
---|
44 | || IsEqualGUID(riid, &IID_IDirect3DVolumeTexture8)) {
|
---|
45 | IUnknown_AddRef(iface);
|
---|
46 | *ppobj = This;
|
---|
47 | return S_OK;
|
---|
48 | }
|
---|
49 |
|
---|
50 | WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
|
---|
51 | *ppobj = NULL;
|
---|
52 | return E_NOINTERFACE;
|
---|
53 | }
|
---|
54 |
|
---|
55 | static ULONG WINAPI IDirect3DVolumeTexture8Impl_AddRef(LPDIRECT3DVOLUMETEXTURE8 iface) {
|
---|
56 | IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
|
---|
57 | ULONG ref = InterlockedIncrement(&This->ref);
|
---|
58 |
|
---|
59 | TRACE("%p increasing refcount to %u.\n", iface, ref);
|
---|
60 |
|
---|
61 | if (ref == 1)
|
---|
62 | {
|
---|
63 | IDirect3DDevice8_AddRef(This->parentDevice);
|
---|
64 | wined3d_mutex_lock();
|
---|
65 | IWineD3DVolumeTexture_AddRef(This->wineD3DVolumeTexture);
|
---|
66 | wined3d_mutex_unlock();
|
---|
67 | }
|
---|
68 |
|
---|
69 | return ref;
|
---|
70 | }
|
---|
71 |
|
---|
72 | static ULONG WINAPI IDirect3DVolumeTexture8Impl_Release(LPDIRECT3DVOLUMETEXTURE8 iface) {
|
---|
73 | IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
|
---|
74 | ULONG ref = InterlockedDecrement(&This->ref);
|
---|
75 |
|
---|
76 | TRACE("%p decreasing refcount to %u.\n", iface, ref);
|
---|
77 |
|
---|
78 | if (ref == 0) {
|
---|
79 | IDirect3DDevice8 *parentDevice = This->parentDevice;
|
---|
80 |
|
---|
81 | wined3d_mutex_lock();
|
---|
82 | IWineD3DVolumeTexture_Release(This->wineD3DVolumeTexture);
|
---|
83 | wined3d_mutex_unlock();
|
---|
84 |
|
---|
85 | /* Release the device last, as it may cause the device to be destroyed. */
|
---|
86 | IDirect3DDevice8_Release(parentDevice);
|
---|
87 | }
|
---|
88 | return ref;
|
---|
89 | }
|
---|
90 |
|
---|
91 | /* IDirect3DVolumeTexture8 IDirect3DResource8 Interface follow: */
|
---|
92 | static HRESULT WINAPI IDirect3DVolumeTexture8Impl_GetDevice(IDirect3DVolumeTexture8 *iface, IDirect3DDevice8 **device)
|
---|
93 | {
|
---|
94 | IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
|
---|
95 |
|
---|
96 | TRACE("iface %p, device %p.\n", iface, device);
|
---|
97 |
|
---|
98 | *device = (IDirect3DDevice8 *)This->parentDevice;
|
---|
99 | IDirect3DDevice8_AddRef(*device);
|
---|
100 |
|
---|
101 | TRACE("Returning device %p.\n", *device);
|
---|
102 |
|
---|
103 | return D3D_OK;
|
---|
104 | }
|
---|
105 |
|
---|
106 | static HRESULT WINAPI IDirect3DVolumeTexture8Impl_SetPrivateData(LPDIRECT3DVOLUMETEXTURE8 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
|
---|
107 | IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
|
---|
108 | HRESULT hr;
|
---|
109 |
|
---|
110 | TRACE("iface %p, guid %s, data %p, data_size %u, flags %#x.\n",
|
---|
111 | iface, debugstr_guid(refguid), pData, SizeOfData, Flags);
|
---|
112 |
|
---|
113 | wined3d_mutex_lock();
|
---|
114 | hr = IWineD3DVolumeTexture_SetPrivateData(This->wineD3DVolumeTexture, refguid, pData, SizeOfData, Flags);
|
---|
115 | wined3d_mutex_unlock();
|
---|
116 |
|
---|
117 | return hr;
|
---|
118 | }
|
---|
119 |
|
---|
120 | static HRESULT WINAPI IDirect3DVolumeTexture8Impl_GetPrivateData(LPDIRECT3DVOLUMETEXTURE8 iface, REFGUID refguid, void *pData, DWORD *pSizeOfData) {
|
---|
121 | IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
|
---|
122 | HRESULT hr;
|
---|
123 |
|
---|
124 | TRACE("iface %p, guid %s, data %p, data_size %p.\n",
|
---|
125 | iface, debugstr_guid(refguid), pData, pSizeOfData);
|
---|
126 |
|
---|
127 | wined3d_mutex_lock();
|
---|
128 | hr = IWineD3DVolumeTexture_GetPrivateData(This->wineD3DVolumeTexture, refguid, pData, pSizeOfData);
|
---|
129 | wined3d_mutex_unlock();
|
---|
130 |
|
---|
131 | return hr;
|
---|
132 | }
|
---|
133 |
|
---|
134 | static HRESULT WINAPI IDirect3DVolumeTexture8Impl_FreePrivateData(LPDIRECT3DVOLUMETEXTURE8 iface, REFGUID refguid) {
|
---|
135 | IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
|
---|
136 | HRESULT hr;
|
---|
137 |
|
---|
138 | TRACE("iface %p, guid %s.\n", iface, debugstr_guid(refguid));
|
---|
139 |
|
---|
140 | wined3d_mutex_lock();
|
---|
141 | hr = IWineD3DVolumeTexture_FreePrivateData(This->wineD3DVolumeTexture, refguid);
|
---|
142 | wined3d_mutex_unlock();
|
---|
143 |
|
---|
144 | return hr;
|
---|
145 | }
|
---|
146 |
|
---|
147 | static DWORD WINAPI IDirect3DVolumeTexture8Impl_SetPriority(LPDIRECT3DVOLUMETEXTURE8 iface, DWORD PriorityNew) {
|
---|
148 | IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
|
---|
149 | DWORD ret;
|
---|
150 |
|
---|
151 | TRACE("iface %p, priority %u.\n", iface, PriorityNew);
|
---|
152 |
|
---|
153 | wined3d_mutex_lock();
|
---|
154 | ret = IWineD3DVolumeTexture_SetPriority(This->wineD3DVolumeTexture, PriorityNew);
|
---|
155 | wined3d_mutex_unlock();
|
---|
156 |
|
---|
157 | return ret;
|
---|
158 | }
|
---|
159 |
|
---|
160 | static DWORD WINAPI IDirect3DVolumeTexture8Impl_GetPriority(LPDIRECT3DVOLUMETEXTURE8 iface) {
|
---|
161 | IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
|
---|
162 | DWORD ret;
|
---|
163 |
|
---|
164 | TRACE("iface %p.\n", iface);
|
---|
165 |
|
---|
166 | wined3d_mutex_lock();
|
---|
167 | ret = IWineD3DVolumeTexture_GetPriority(This->wineD3DVolumeTexture);
|
---|
168 | wined3d_mutex_unlock();
|
---|
169 |
|
---|
170 | return ret;
|
---|
171 | }
|
---|
172 |
|
---|
173 | static void WINAPI IDirect3DVolumeTexture8Impl_PreLoad(LPDIRECT3DVOLUMETEXTURE8 iface) {
|
---|
174 | IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
|
---|
175 |
|
---|
176 | TRACE("iface %p.\n", iface);
|
---|
177 |
|
---|
178 | wined3d_mutex_lock();
|
---|
179 | IWineD3DVolumeTexture_PreLoad(This->wineD3DVolumeTexture);
|
---|
180 | wined3d_mutex_unlock();
|
---|
181 | }
|
---|
182 |
|
---|
183 | static D3DRESOURCETYPE WINAPI IDirect3DVolumeTexture8Impl_GetType(LPDIRECT3DVOLUMETEXTURE8 iface) {
|
---|
184 | IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
|
---|
185 | D3DRESOURCETYPE type;
|
---|
186 |
|
---|
187 | TRACE("iface %p.\n", iface);
|
---|
188 |
|
---|
189 | wined3d_mutex_lock();
|
---|
190 | type = IWineD3DVolumeTexture_GetType(This->wineD3DVolumeTexture);
|
---|
191 | wined3d_mutex_unlock();
|
---|
192 |
|
---|
193 | return type;
|
---|
194 | }
|
---|
195 |
|
---|
196 | /* IDirect3DVolumeTexture8 IDirect3DBaseTexture8 Interface follow: */
|
---|
197 | static DWORD WINAPI IDirect3DVolumeTexture8Impl_SetLOD(LPDIRECT3DVOLUMETEXTURE8 iface, DWORD LODNew) {
|
---|
198 | IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
|
---|
199 | DWORD ret;
|
---|
200 |
|
---|
201 | TRACE("iface %p, lod %u.\n", iface, LODNew);
|
---|
202 |
|
---|
203 | wined3d_mutex_lock();
|
---|
204 | ret = IWineD3DVolumeTexture_SetLOD(This->wineD3DVolumeTexture, LODNew);
|
---|
205 | wined3d_mutex_unlock();
|
---|
206 |
|
---|
207 | return ret;
|
---|
208 | }
|
---|
209 |
|
---|
210 | static DWORD WINAPI IDirect3DVolumeTexture8Impl_GetLOD(LPDIRECT3DVOLUMETEXTURE8 iface) {
|
---|
211 | IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
|
---|
212 | DWORD ret;
|
---|
213 |
|
---|
214 | TRACE("iface %p.\n", iface);
|
---|
215 |
|
---|
216 | wined3d_mutex_lock();
|
---|
217 | ret = IWineD3DVolumeTexture_GetLOD(This->wineD3DVolumeTexture);
|
---|
218 | wined3d_mutex_unlock();
|
---|
219 |
|
---|
220 | return ret;
|
---|
221 | }
|
---|
222 |
|
---|
223 | static DWORD WINAPI IDirect3DVolumeTexture8Impl_GetLevelCount(LPDIRECT3DVOLUMETEXTURE8 iface) {
|
---|
224 | IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
|
---|
225 | DWORD ret;
|
---|
226 |
|
---|
227 | TRACE("iface %p.\n", iface);
|
---|
228 |
|
---|
229 | wined3d_mutex_lock();
|
---|
230 | ret = IWineD3DVolumeTexture_GetLevelCount(This->wineD3DVolumeTexture);
|
---|
231 | wined3d_mutex_unlock();
|
---|
232 |
|
---|
233 | return ret;
|
---|
234 | }
|
---|
235 |
|
---|
236 | /* IDirect3DVolumeTexture8 Interface follow: */
|
---|
237 | static HRESULT WINAPI IDirect3DVolumeTexture8Impl_GetLevelDesc(LPDIRECT3DVOLUMETEXTURE8 iface, UINT Level, D3DVOLUME_DESC* pDesc) {
|
---|
238 | IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
|
---|
239 | WINED3DVOLUME_DESC wined3ddesc;
|
---|
240 | HRESULT hr;
|
---|
241 |
|
---|
242 | TRACE("iface %p, level %u, desc %p.\n", iface, Level, pDesc);
|
---|
243 |
|
---|
244 | wined3d_mutex_lock();
|
---|
245 | hr = IWineD3DVolumeTexture_GetLevelDesc(This->wineD3DVolumeTexture, Level, &wined3ddesc);
|
---|
246 | wined3d_mutex_unlock();
|
---|
247 |
|
---|
248 | if (SUCCEEDED(hr))
|
---|
249 | {
|
---|
250 | pDesc->Format = d3dformat_from_wined3dformat(wined3ddesc.Format);
|
---|
251 | pDesc->Type = wined3ddesc.Type;
|
---|
252 | pDesc->Usage = wined3ddesc.Usage;
|
---|
253 | pDesc->Pool = wined3ddesc.Pool;
|
---|
254 | pDesc->Size = wined3ddesc.Size;
|
---|
255 | pDesc->Width = wined3ddesc.Width;
|
---|
256 | pDesc->Height = wined3ddesc.Height;
|
---|
257 | pDesc->Depth = wined3ddesc.Depth;
|
---|
258 | }
|
---|
259 |
|
---|
260 | return hr;
|
---|
261 | }
|
---|
262 |
|
---|
263 | static HRESULT WINAPI IDirect3DVolumeTexture8Impl_GetVolumeLevel(LPDIRECT3DVOLUMETEXTURE8 iface, UINT Level, IDirect3DVolume8 **ppVolumeLevel) {
|
---|
264 | IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
|
---|
265 | HRESULT hrc = D3D_OK;
|
---|
266 | IWineD3DVolume *myVolume = NULL;
|
---|
267 |
|
---|
268 | TRACE("iface %p, level %u, volume %p.\n", iface, Level, ppVolumeLevel);
|
---|
269 |
|
---|
270 | wined3d_mutex_lock();
|
---|
271 | hrc = IWineD3DVolumeTexture_GetVolumeLevel(This->wineD3DVolumeTexture, Level, &myVolume);
|
---|
272 | if (hrc == D3D_OK && NULL != ppVolumeLevel) {
|
---|
273 | IWineD3DVolumeTexture_GetParent(myVolume, (IUnknown **)ppVolumeLevel);
|
---|
274 | IWineD3DVolumeTexture_Release(myVolume);
|
---|
275 | }
|
---|
276 | wined3d_mutex_unlock();
|
---|
277 |
|
---|
278 | return hrc;
|
---|
279 | }
|
---|
280 |
|
---|
281 | static HRESULT WINAPI IDirect3DVolumeTexture8Impl_LockBox(LPDIRECT3DVOLUMETEXTURE8 iface, UINT Level, D3DLOCKED_BOX *pLockedVolume, CONST D3DBOX *pBox, DWORD Flags) {
|
---|
282 | IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
|
---|
283 | HRESULT hr;
|
---|
284 |
|
---|
285 | TRACE("iface %p, level %u, locked_box %p, box %p, flags %#x.\n",
|
---|
286 | iface, Level, pLockedVolume, pBox, Flags);
|
---|
287 |
|
---|
288 | wined3d_mutex_lock();
|
---|
289 | hr = IWineD3DVolumeTexture_LockBox(This->wineD3DVolumeTexture, Level, (WINED3DLOCKED_BOX *) pLockedVolume, (CONST WINED3DBOX *) pBox, Flags);
|
---|
290 | wined3d_mutex_unlock();
|
---|
291 |
|
---|
292 | return hr;
|
---|
293 | }
|
---|
294 |
|
---|
295 | static HRESULT WINAPI IDirect3DVolumeTexture8Impl_UnlockBox(LPDIRECT3DVOLUMETEXTURE8 iface, UINT Level) {
|
---|
296 | IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
|
---|
297 | HRESULT hr;
|
---|
298 |
|
---|
299 | TRACE("iface %p, level %u.\n", iface, Level);
|
---|
300 |
|
---|
301 | wined3d_mutex_lock();
|
---|
302 | hr = IWineD3DVolumeTexture_UnlockBox(This->wineD3DVolumeTexture, Level);
|
---|
303 | wined3d_mutex_unlock();
|
---|
304 |
|
---|
305 | return hr;
|
---|
306 | }
|
---|
307 |
|
---|
308 | static HRESULT WINAPI IDirect3DVolumeTexture8Impl_AddDirtyBox(LPDIRECT3DVOLUMETEXTURE8 iface, CONST D3DBOX *pDirtyBox) {
|
---|
309 | IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
|
---|
310 | HRESULT hr;
|
---|
311 |
|
---|
312 | TRACE("iface %p, dirty_box %p.\n", iface, pDirtyBox);
|
---|
313 |
|
---|
314 | wined3d_mutex_lock();
|
---|
315 | hr = IWineD3DVolumeTexture_AddDirtyBox(This->wineD3DVolumeTexture, (CONST WINED3DBOX *) pDirtyBox);
|
---|
316 | wined3d_mutex_unlock();
|
---|
317 |
|
---|
318 | return hr;
|
---|
319 | }
|
---|
320 |
|
---|
321 | static const IDirect3DVolumeTexture8Vtbl Direct3DVolumeTexture8_Vtbl =
|
---|
322 | {
|
---|
323 | /* IUnknown */
|
---|
324 | IDirect3DVolumeTexture8Impl_QueryInterface,
|
---|
325 | IDirect3DVolumeTexture8Impl_AddRef,
|
---|
326 | IDirect3DVolumeTexture8Impl_Release,
|
---|
327 | /* IDirect3DResource8 */
|
---|
328 | IDirect3DVolumeTexture8Impl_GetDevice,
|
---|
329 | IDirect3DVolumeTexture8Impl_SetPrivateData,
|
---|
330 | IDirect3DVolumeTexture8Impl_GetPrivateData,
|
---|
331 | IDirect3DVolumeTexture8Impl_FreePrivateData,
|
---|
332 | IDirect3DVolumeTexture8Impl_SetPriority,
|
---|
333 | IDirect3DVolumeTexture8Impl_GetPriority,
|
---|
334 | IDirect3DVolumeTexture8Impl_PreLoad,
|
---|
335 | IDirect3DVolumeTexture8Impl_GetType,
|
---|
336 | /* IDirect3DBaseTexture8 */
|
---|
337 | IDirect3DVolumeTexture8Impl_SetLOD,
|
---|
338 | IDirect3DVolumeTexture8Impl_GetLOD,
|
---|
339 | IDirect3DVolumeTexture8Impl_GetLevelCount,
|
---|
340 | /* IDirect3DVolumeTexture8 */
|
---|
341 | IDirect3DVolumeTexture8Impl_GetLevelDesc,
|
---|
342 | IDirect3DVolumeTexture8Impl_GetVolumeLevel,
|
---|
343 | IDirect3DVolumeTexture8Impl_LockBox,
|
---|
344 | IDirect3DVolumeTexture8Impl_UnlockBox,
|
---|
345 | IDirect3DVolumeTexture8Impl_AddDirtyBox
|
---|
346 | };
|
---|
347 |
|
---|
348 | static void STDMETHODCALLTYPE volumetexture_wined3d_object_destroyed(void *parent)
|
---|
349 | {
|
---|
350 | HeapFree(GetProcessHeap(), 0, parent);
|
---|
351 | }
|
---|
352 |
|
---|
353 | static const struct wined3d_parent_ops d3d8_volumetexture_wined3d_parent_ops =
|
---|
354 | {
|
---|
355 | volumetexture_wined3d_object_destroyed,
|
---|
356 | };
|
---|
357 |
|
---|
358 | HRESULT volumetexture_init(IDirect3DVolumeTexture8Impl *texture, IDirect3DDevice8Impl *device,
|
---|
359 | UINT width, UINT height, UINT depth, UINT levels, DWORD usage, D3DFORMAT format, D3DPOOL pool)
|
---|
360 | {
|
---|
361 | HRESULT hr;
|
---|
362 |
|
---|
363 | texture->lpVtbl = &Direct3DVolumeTexture8_Vtbl;
|
---|
364 | texture->ref = 1;
|
---|
365 |
|
---|
366 | wined3d_mutex_lock();
|
---|
367 | hr = IWineD3DDevice_CreateVolumeTexture(device->WineD3DDevice, width, height, depth, levels,
|
---|
368 | usage & WINED3DUSAGE_MASK, wined3dformat_from_d3dformat(format), pool,
|
---|
369 | &texture->wineD3DVolumeTexture, (IUnknown *)texture, &d3d8_volumetexture_wined3d_parent_ops);
|
---|
370 | wined3d_mutex_unlock();
|
---|
371 | if (FAILED(hr))
|
---|
372 | {
|
---|
373 | WARN("Failed to create wined3d volume texture, hr %#x.\n", hr);
|
---|
374 | return hr;
|
---|
375 | }
|
---|
376 |
|
---|
377 | texture->parentDevice = (IDirect3DDevice8 *)device;
|
---|
378 | IDirect3DDevice8_AddRef(texture->parentDevice);
|
---|
379 |
|
---|
380 | return D3D_OK;
|
---|
381 | }
|
---|