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 | if (IsEqualGUID(riid, &IID_IUnknown)
|
---|
40 | || IsEqualGUID(riid, &IID_IDirect3DResource8)
|
---|
41 | || IsEqualGUID(riid, &IID_IDirect3DBaseTexture8)
|
---|
42 | || IsEqualGUID(riid, &IID_IDirect3DVolumeTexture8)) {
|
---|
43 | IUnknown_AddRef(iface);
|
---|
44 | *ppobj = This;
|
---|
45 | return S_OK;
|
---|
46 | }
|
---|
47 |
|
---|
48 | WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
|
---|
49 | *ppobj = NULL;
|
---|
50 | return E_NOINTERFACE;
|
---|
51 | }
|
---|
52 |
|
---|
53 | static ULONG WINAPI IDirect3DVolumeTexture8Impl_AddRef(LPDIRECT3DVOLUMETEXTURE8 iface) {
|
---|
54 | IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
|
---|
55 | ULONG ref = InterlockedIncrement(&This->ref);
|
---|
56 |
|
---|
57 | TRACE("(%p) : AddRef from %d\n", This, ref - 1);
|
---|
58 |
|
---|
59 | if (ref == 1)
|
---|
60 | {
|
---|
61 | IDirect3DDevice8_AddRef(This->parentDevice);
|
---|
62 | wined3d_mutex_lock();
|
---|
63 | IWineD3DVolumeTexture_AddRef(This->wineD3DVolumeTexture);
|
---|
64 | wined3d_mutex_unlock();
|
---|
65 | }
|
---|
66 |
|
---|
67 | return ref;
|
---|
68 | }
|
---|
69 |
|
---|
70 | static ULONG WINAPI IDirect3DVolumeTexture8Impl_Release(LPDIRECT3DVOLUMETEXTURE8 iface) {
|
---|
71 | IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
|
---|
72 | ULONG ref = InterlockedDecrement(&This->ref);
|
---|
73 |
|
---|
74 | TRACE("(%p) : ReleaseRef to %d\n", This, ref);
|
---|
75 |
|
---|
76 | if (ref == 0) {
|
---|
77 | IUnknown_Release(This->parentDevice);
|
---|
78 | wined3d_mutex_lock();
|
---|
79 | IWineD3DVolumeTexture_Release(This->wineD3DVolumeTexture);
|
---|
80 | wined3d_mutex_unlock();
|
---|
81 | }
|
---|
82 | return ref;
|
---|
83 | }
|
---|
84 |
|
---|
85 | /* IDirect3DVolumeTexture8 IDirect3DResource8 Interface follow: */
|
---|
86 | static HRESULT WINAPI IDirect3DVolumeTexture8Impl_GetDevice(LPDIRECT3DVOLUMETEXTURE8 iface, IDirect3DDevice8 **ppDevice) {
|
---|
87 | IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
|
---|
88 | IWineD3DDevice *wined3d_device;
|
---|
89 | HRESULT hr;
|
---|
90 | TRACE("(%p) Relay\n", This);
|
---|
91 |
|
---|
92 | wined3d_mutex_lock();
|
---|
93 | hr = IWineD3DVolumeTexture_GetDevice(This->wineD3DVolumeTexture, &wined3d_device);
|
---|
94 | if (SUCCEEDED(hr))
|
---|
95 | {
|
---|
96 | IWineD3DDevice_GetParent(wined3d_device, (IUnknown **)ppDevice);
|
---|
97 | IWineD3DDevice_Release(wined3d_device);
|
---|
98 | }
|
---|
99 | wined3d_mutex_unlock();
|
---|
100 |
|
---|
101 | return hr;
|
---|
102 | }
|
---|
103 |
|
---|
104 | static HRESULT WINAPI IDirect3DVolumeTexture8Impl_SetPrivateData(LPDIRECT3DVOLUMETEXTURE8 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
|
---|
105 | IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
|
---|
106 | HRESULT hr;
|
---|
107 | TRACE("(%p) Relay\n", This);
|
---|
108 |
|
---|
109 | wined3d_mutex_lock();
|
---|
110 | hr = IWineD3DVolumeTexture_SetPrivateData(This->wineD3DVolumeTexture, refguid, pData, SizeOfData, Flags);
|
---|
111 | wined3d_mutex_unlock();
|
---|
112 |
|
---|
113 | return hr;
|
---|
114 | }
|
---|
115 |
|
---|
116 | static HRESULT WINAPI IDirect3DVolumeTexture8Impl_GetPrivateData(LPDIRECT3DVOLUMETEXTURE8 iface, REFGUID refguid, void *pData, DWORD *pSizeOfData) {
|
---|
117 | IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
|
---|
118 | HRESULT hr;
|
---|
119 | TRACE("(%p) Relay\n", This);
|
---|
120 |
|
---|
121 | wined3d_mutex_lock();
|
---|
122 | hr = IWineD3DVolumeTexture_GetPrivateData(This->wineD3DVolumeTexture, refguid, pData, pSizeOfData);
|
---|
123 | wined3d_mutex_unlock();
|
---|
124 |
|
---|
125 | return hr;
|
---|
126 | }
|
---|
127 |
|
---|
128 | static HRESULT WINAPI IDirect3DVolumeTexture8Impl_FreePrivateData(LPDIRECT3DVOLUMETEXTURE8 iface, REFGUID refguid) {
|
---|
129 | IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
|
---|
130 | HRESULT hr;
|
---|
131 | TRACE("(%p) Relay\n", This);
|
---|
132 |
|
---|
133 | wined3d_mutex_lock();
|
---|
134 | hr = IWineD3DVolumeTexture_FreePrivateData(This->wineD3DVolumeTexture, refguid);
|
---|
135 | wined3d_mutex_unlock();
|
---|
136 |
|
---|
137 | return hr;
|
---|
138 | }
|
---|
139 |
|
---|
140 | static DWORD WINAPI IDirect3DVolumeTexture8Impl_SetPriority(LPDIRECT3DVOLUMETEXTURE8 iface, DWORD PriorityNew) {
|
---|
141 | IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
|
---|
142 | DWORD ret;
|
---|
143 | TRACE("(%p) Relay\n", This);
|
---|
144 |
|
---|
145 | wined3d_mutex_lock();
|
---|
146 | ret = IWineD3DVolumeTexture_SetPriority(This->wineD3DVolumeTexture, PriorityNew);
|
---|
147 | wined3d_mutex_unlock();
|
---|
148 |
|
---|
149 | return ret;
|
---|
150 | }
|
---|
151 |
|
---|
152 | static DWORD WINAPI IDirect3DVolumeTexture8Impl_GetPriority(LPDIRECT3DVOLUMETEXTURE8 iface) {
|
---|
153 | IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
|
---|
154 | DWORD ret;
|
---|
155 | TRACE("(%p) Relay\n", This);
|
---|
156 |
|
---|
157 | wined3d_mutex_lock();
|
---|
158 | ret = IWineD3DVolumeTexture_GetPriority(This->wineD3DVolumeTexture);
|
---|
159 | wined3d_mutex_unlock();
|
---|
160 |
|
---|
161 | return ret;
|
---|
162 | }
|
---|
163 |
|
---|
164 | static void WINAPI IDirect3DVolumeTexture8Impl_PreLoad(LPDIRECT3DVOLUMETEXTURE8 iface) {
|
---|
165 | IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
|
---|
166 | TRACE("(%p) Relay\n", This);
|
---|
167 |
|
---|
168 | wined3d_mutex_lock();
|
---|
169 | IWineD3DVolumeTexture_PreLoad(This->wineD3DVolumeTexture);
|
---|
170 | wined3d_mutex_unlock();
|
---|
171 | }
|
---|
172 |
|
---|
173 | static D3DRESOURCETYPE WINAPI IDirect3DVolumeTexture8Impl_GetType(LPDIRECT3DVOLUMETEXTURE8 iface) {
|
---|
174 | IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
|
---|
175 | D3DRESOURCETYPE type;
|
---|
176 | TRACE("(%p) Relay\n", This);
|
---|
177 |
|
---|
178 | wined3d_mutex_lock();
|
---|
179 | type = IWineD3DVolumeTexture_GetType(This->wineD3DVolumeTexture);
|
---|
180 | wined3d_mutex_unlock();
|
---|
181 |
|
---|
182 | return type;
|
---|
183 | }
|
---|
184 |
|
---|
185 | /* IDirect3DVolumeTexture8 IDirect3DBaseTexture8 Interface follow: */
|
---|
186 | static DWORD WINAPI IDirect3DVolumeTexture8Impl_SetLOD(LPDIRECT3DVOLUMETEXTURE8 iface, DWORD LODNew) {
|
---|
187 | IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
|
---|
188 | DWORD ret;
|
---|
189 | TRACE("(%p) Relay\n", This);
|
---|
190 |
|
---|
191 | wined3d_mutex_lock();
|
---|
192 | ret = IWineD3DVolumeTexture_SetLOD(This->wineD3DVolumeTexture, LODNew);
|
---|
193 | wined3d_mutex_unlock();
|
---|
194 |
|
---|
195 | return ret;
|
---|
196 | }
|
---|
197 |
|
---|
198 | static DWORD WINAPI IDirect3DVolumeTexture8Impl_GetLOD(LPDIRECT3DVOLUMETEXTURE8 iface) {
|
---|
199 | IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
|
---|
200 | DWORD ret;
|
---|
201 | TRACE("(%p) Relay\n", This);
|
---|
202 |
|
---|
203 | wined3d_mutex_lock();
|
---|
204 | ret = IWineD3DVolumeTexture_GetLOD(This->wineD3DVolumeTexture);
|
---|
205 | wined3d_mutex_unlock();
|
---|
206 |
|
---|
207 | return ret;
|
---|
208 | }
|
---|
209 |
|
---|
210 | static DWORD WINAPI IDirect3DVolumeTexture8Impl_GetLevelCount(LPDIRECT3DVOLUMETEXTURE8 iface) {
|
---|
211 | IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
|
---|
212 | DWORD ret;
|
---|
213 | TRACE("(%p) Relay\n", This);
|
---|
214 |
|
---|
215 | wined3d_mutex_lock();
|
---|
216 | ret = IWineD3DVolumeTexture_GetLevelCount(This->wineD3DVolumeTexture);
|
---|
217 | wined3d_mutex_unlock();
|
---|
218 |
|
---|
219 | return ret;
|
---|
220 | }
|
---|
221 |
|
---|
222 | /* IDirect3DVolumeTexture8 Interface follow: */
|
---|
223 | static HRESULT WINAPI IDirect3DVolumeTexture8Impl_GetLevelDesc(LPDIRECT3DVOLUMETEXTURE8 iface, UINT Level, D3DVOLUME_DESC* pDesc) {
|
---|
224 | IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
|
---|
225 | WINED3DVOLUME_DESC wined3ddesc;
|
---|
226 | HRESULT hr;
|
---|
227 |
|
---|
228 | TRACE("(%p) Relay\n", This);
|
---|
229 |
|
---|
230 | wined3d_mutex_lock();
|
---|
231 | hr = IWineD3DVolumeTexture_GetLevelDesc(This->wineD3DVolumeTexture, Level, &wined3ddesc);
|
---|
232 | wined3d_mutex_unlock();
|
---|
233 |
|
---|
234 | if (SUCCEEDED(hr))
|
---|
235 | {
|
---|
236 | pDesc->Format = d3dformat_from_wined3dformat(wined3ddesc.Format);
|
---|
237 | pDesc->Type = wined3ddesc.Type;
|
---|
238 | pDesc->Usage = wined3ddesc.Usage;
|
---|
239 | pDesc->Pool = wined3ddesc.Pool;
|
---|
240 | pDesc->Size = wined3ddesc.Size;
|
---|
241 | pDesc->Width = wined3ddesc.Width;
|
---|
242 | pDesc->Height = wined3ddesc.Height;
|
---|
243 | pDesc->Depth = wined3ddesc.Depth;
|
---|
244 | }
|
---|
245 |
|
---|
246 | return hr;
|
---|
247 | }
|
---|
248 |
|
---|
249 | static HRESULT WINAPI IDirect3DVolumeTexture8Impl_GetVolumeLevel(LPDIRECT3DVOLUMETEXTURE8 iface, UINT Level, IDirect3DVolume8 **ppVolumeLevel) {
|
---|
250 | IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
|
---|
251 | HRESULT hrc = D3D_OK;
|
---|
252 | IWineD3DVolume *myVolume = NULL;
|
---|
253 |
|
---|
254 | TRACE("(%p) Relay\n", This);
|
---|
255 |
|
---|
256 | wined3d_mutex_lock();
|
---|
257 | hrc = IWineD3DVolumeTexture_GetVolumeLevel(This->wineD3DVolumeTexture, Level, &myVolume);
|
---|
258 | if (hrc == D3D_OK && NULL != ppVolumeLevel) {
|
---|
259 | IWineD3DVolumeTexture_GetParent(myVolume, (IUnknown **)ppVolumeLevel);
|
---|
260 | IWineD3DVolumeTexture_Release(myVolume);
|
---|
261 | }
|
---|
262 | wined3d_mutex_unlock();
|
---|
263 |
|
---|
264 | return hrc;
|
---|
265 | }
|
---|
266 |
|
---|
267 | static HRESULT WINAPI IDirect3DVolumeTexture8Impl_LockBox(LPDIRECT3DVOLUMETEXTURE8 iface, UINT Level, D3DLOCKED_BOX *pLockedVolume, CONST D3DBOX *pBox, DWORD Flags) {
|
---|
268 | IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
|
---|
269 | HRESULT hr;
|
---|
270 | TRACE("(%p) Relay %p %p %p %d\n", This, This->wineD3DVolumeTexture, pLockedVolume, pBox,Flags);
|
---|
271 |
|
---|
272 | wined3d_mutex_lock();
|
---|
273 | hr = IWineD3DVolumeTexture_LockBox(This->wineD3DVolumeTexture, Level, (WINED3DLOCKED_BOX *) pLockedVolume, (CONST WINED3DBOX *) pBox, Flags);
|
---|
274 | wined3d_mutex_unlock();
|
---|
275 |
|
---|
276 | return hr;
|
---|
277 | }
|
---|
278 |
|
---|
279 | static HRESULT WINAPI IDirect3DVolumeTexture8Impl_UnlockBox(LPDIRECT3DVOLUMETEXTURE8 iface, UINT Level) {
|
---|
280 | IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
|
---|
281 | HRESULT hr;
|
---|
282 | TRACE("(%p) Relay %p %d\n", This, This->wineD3DVolumeTexture, Level);
|
---|
283 |
|
---|
284 | wined3d_mutex_lock();
|
---|
285 | hr = IWineD3DVolumeTexture_UnlockBox(This->wineD3DVolumeTexture, Level);
|
---|
286 | wined3d_mutex_unlock();
|
---|
287 |
|
---|
288 | return hr;
|
---|
289 | }
|
---|
290 |
|
---|
291 | static HRESULT WINAPI IDirect3DVolumeTexture8Impl_AddDirtyBox(LPDIRECT3DVOLUMETEXTURE8 iface, CONST D3DBOX *pDirtyBox) {
|
---|
292 | IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
|
---|
293 | HRESULT hr;
|
---|
294 | TRACE("(%p) Relay\n", This);
|
---|
295 |
|
---|
296 | wined3d_mutex_lock();
|
---|
297 | hr = IWineD3DVolumeTexture_AddDirtyBox(This->wineD3DVolumeTexture, (CONST WINED3DBOX *) pDirtyBox);
|
---|
298 | wined3d_mutex_unlock();
|
---|
299 |
|
---|
300 | return hr;
|
---|
301 | }
|
---|
302 |
|
---|
303 | static const IDirect3DVolumeTexture8Vtbl Direct3DVolumeTexture8_Vtbl =
|
---|
304 | {
|
---|
305 | /* IUnknown */
|
---|
306 | IDirect3DVolumeTexture8Impl_QueryInterface,
|
---|
307 | IDirect3DVolumeTexture8Impl_AddRef,
|
---|
308 | IDirect3DVolumeTexture8Impl_Release,
|
---|
309 | /* IDirect3DResource8 */
|
---|
310 | IDirect3DVolumeTexture8Impl_GetDevice,
|
---|
311 | IDirect3DVolumeTexture8Impl_SetPrivateData,
|
---|
312 | IDirect3DVolumeTexture8Impl_GetPrivateData,
|
---|
313 | IDirect3DVolumeTexture8Impl_FreePrivateData,
|
---|
314 | IDirect3DVolumeTexture8Impl_SetPriority,
|
---|
315 | IDirect3DVolumeTexture8Impl_GetPriority,
|
---|
316 | IDirect3DVolumeTexture8Impl_PreLoad,
|
---|
317 | IDirect3DVolumeTexture8Impl_GetType,
|
---|
318 | /* IDirect3DBaseTexture8 */
|
---|
319 | IDirect3DVolumeTexture8Impl_SetLOD,
|
---|
320 | IDirect3DVolumeTexture8Impl_GetLOD,
|
---|
321 | IDirect3DVolumeTexture8Impl_GetLevelCount,
|
---|
322 | /* IDirect3DVolumeTexture8 */
|
---|
323 | IDirect3DVolumeTexture8Impl_GetLevelDesc,
|
---|
324 | IDirect3DVolumeTexture8Impl_GetVolumeLevel,
|
---|
325 | IDirect3DVolumeTexture8Impl_LockBox,
|
---|
326 | IDirect3DVolumeTexture8Impl_UnlockBox,
|
---|
327 | IDirect3DVolumeTexture8Impl_AddDirtyBox
|
---|
328 | };
|
---|
329 |
|
---|
330 | static void STDMETHODCALLTYPE volumetexture_wined3d_object_destroyed(void *parent)
|
---|
331 | {
|
---|
332 | HeapFree(GetProcessHeap(), 0, parent);
|
---|
333 | }
|
---|
334 |
|
---|
335 | static const struct wined3d_parent_ops d3d8_volumetexture_wined3d_parent_ops =
|
---|
336 | {
|
---|
337 | volumetexture_wined3d_object_destroyed,
|
---|
338 | };
|
---|
339 |
|
---|
340 | HRESULT volumetexture_init(IDirect3DVolumeTexture8Impl *texture, IDirect3DDevice8Impl *device,
|
---|
341 | UINT width, UINT height, UINT depth, UINT levels, DWORD usage, D3DFORMAT format, D3DPOOL pool)
|
---|
342 | {
|
---|
343 | HRESULT hr;
|
---|
344 |
|
---|
345 | texture->lpVtbl = &Direct3DVolumeTexture8_Vtbl;
|
---|
346 | texture->ref = 1;
|
---|
347 |
|
---|
348 | wined3d_mutex_lock();
|
---|
349 | hr = IWineD3DDevice_CreateVolumeTexture(device->WineD3DDevice, width, height, depth, levels,
|
---|
350 | usage & WINED3DUSAGE_MASK, wined3dformat_from_d3dformat(format), pool,
|
---|
351 | &texture->wineD3DVolumeTexture, (IUnknown *)texture, &d3d8_volumetexture_wined3d_parent_ops);
|
---|
352 | wined3d_mutex_unlock();
|
---|
353 | if (FAILED(hr))
|
---|
354 | {
|
---|
355 | WARN("Failed to create wined3d volume texture, hr %#x.\n", hr);
|
---|
356 | return hr;
|
---|
357 | }
|
---|
358 |
|
---|
359 | texture->parentDevice = (IDirect3DDevice8 *)device;
|
---|
360 | IDirect3DDevice8_AddRef(texture->parentDevice);
|
---|
361 |
|
---|
362 | return D3D_OK;
|
---|
363 | }
|
---|