2 * IDirect3DVolumeTexture8 implementation
4 * Copyright 2005 Oliver Stieber
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.
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.
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
22 #include "d3d8_private.h"
24 WINE_DEFAULT_DEBUG_CHANNEL(d3d8);
26 /* IDirect3DVolumeTexture8 IUnknown parts follow: */
27 static HRESULT WINAPI IDirect3DVolumeTexture8Impl_QueryInterface(LPDIRECT3DVOLUMETEXTURE8 iface, REFIID riid, LPVOID *ppobj) {
28 IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
30 TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), ppobj);
32 if (IsEqualGUID(riid, &IID_IUnknown)
33 || IsEqualGUID(riid, &IID_IDirect3DResource8)
34 || IsEqualGUID(riid, &IID_IDirect3DBaseTexture8)
35 || IsEqualGUID(riid, &IID_IDirect3DVolumeTexture8)) {
36 IUnknown_AddRef(iface);
41 WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
46 static ULONG WINAPI IDirect3DVolumeTexture8Impl_AddRef(LPDIRECT3DVOLUMETEXTURE8 iface) {
47 IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
48 ULONG ref = InterlockedIncrement(&This->ref);
50 TRACE("%p increasing refcount to %u.\n", iface, ref);
54 IDirect3DDevice8_AddRef(This->parentDevice);
56 IWineD3DVolumeTexture_AddRef(This->wineD3DVolumeTexture);
57 wined3d_mutex_unlock();
63 static ULONG WINAPI IDirect3DVolumeTexture8Impl_Release(LPDIRECT3DVOLUMETEXTURE8 iface) {
64 IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
65 ULONG ref = InterlockedDecrement(&This->ref);
67 TRACE("%p decreasing refcount to %u.\n", iface, ref);
70 IDirect3DDevice8 *parentDevice = This->parentDevice;
73 IWineD3DVolumeTexture_Release(This->wineD3DVolumeTexture);
74 wined3d_mutex_unlock();
76 /* Release the device last, as it may cause the device to be destroyed. */
77 IDirect3DDevice8_Release(parentDevice);
82 /* IDirect3DVolumeTexture8 IDirect3DResource8 Interface follow: */
83 static HRESULT WINAPI IDirect3DVolumeTexture8Impl_GetDevice(LPDIRECT3DVOLUMETEXTURE8 iface, IDirect3DDevice8 **ppDevice) {
84 IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
85 IWineD3DDevice *wined3d_device;
88 TRACE("iface %p, device %p.\n", iface, ppDevice);
91 hr = IWineD3DVolumeTexture_GetDevice(This->wineD3DVolumeTexture, &wined3d_device);
94 IWineD3DDevice_GetParent(wined3d_device, (IUnknown **)ppDevice);
95 IWineD3DDevice_Release(wined3d_device);
97 wined3d_mutex_unlock();
102 static HRESULT WINAPI IDirect3DVolumeTexture8Impl_SetPrivateData(LPDIRECT3DVOLUMETEXTURE8 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
103 IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
106 TRACE("iface %p, guid %s, data %p, data_size %u, flags %#x.\n",
107 iface, debugstr_guid(refguid), pData, SizeOfData, Flags);
109 wined3d_mutex_lock();
110 hr = IWineD3DVolumeTexture_SetPrivateData(This->wineD3DVolumeTexture, refguid, pData, SizeOfData, Flags);
111 wined3d_mutex_unlock();
116 static HRESULT WINAPI IDirect3DVolumeTexture8Impl_GetPrivateData(LPDIRECT3DVOLUMETEXTURE8 iface, REFGUID refguid, void *pData, DWORD *pSizeOfData) {
117 IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
120 TRACE("iface %p, guid %s, data %p, data_size %p.\n",
121 iface, debugstr_guid(refguid), pData, pSizeOfData);
123 wined3d_mutex_lock();
124 hr = IWineD3DVolumeTexture_GetPrivateData(This->wineD3DVolumeTexture, refguid, pData, pSizeOfData);
125 wined3d_mutex_unlock();
130 static HRESULT WINAPI IDirect3DVolumeTexture8Impl_FreePrivateData(LPDIRECT3DVOLUMETEXTURE8 iface, REFGUID refguid) {
131 IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
134 TRACE("iface %p, guid %s.\n", iface, debugstr_guid(refguid));
136 wined3d_mutex_lock();
137 hr = IWineD3DVolumeTexture_FreePrivateData(This->wineD3DVolumeTexture, refguid);
138 wined3d_mutex_unlock();
143 static DWORD WINAPI IDirect3DVolumeTexture8Impl_SetPriority(LPDIRECT3DVOLUMETEXTURE8 iface, DWORD PriorityNew) {
144 IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
147 TRACE("iface %p, priority %u.\n", iface, PriorityNew);
149 wined3d_mutex_lock();
150 ret = IWineD3DVolumeTexture_SetPriority(This->wineD3DVolumeTexture, PriorityNew);
151 wined3d_mutex_unlock();
156 static DWORD WINAPI IDirect3DVolumeTexture8Impl_GetPriority(LPDIRECT3DVOLUMETEXTURE8 iface) {
157 IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
160 TRACE("iface %p.\n", iface);
162 wined3d_mutex_lock();
163 ret = IWineD3DVolumeTexture_GetPriority(This->wineD3DVolumeTexture);
164 wined3d_mutex_unlock();
169 static void WINAPI IDirect3DVolumeTexture8Impl_PreLoad(LPDIRECT3DVOLUMETEXTURE8 iface) {
170 IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
172 TRACE("iface %p.\n", iface);
174 wined3d_mutex_lock();
175 IWineD3DVolumeTexture_PreLoad(This->wineD3DVolumeTexture);
176 wined3d_mutex_unlock();
179 static D3DRESOURCETYPE WINAPI IDirect3DVolumeTexture8Impl_GetType(LPDIRECT3DVOLUMETEXTURE8 iface) {
180 IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
181 D3DRESOURCETYPE type;
183 TRACE("iface %p.\n", iface);
185 wined3d_mutex_lock();
186 type = IWineD3DVolumeTexture_GetType(This->wineD3DVolumeTexture);
187 wined3d_mutex_unlock();
192 /* IDirect3DVolumeTexture8 IDirect3DBaseTexture8 Interface follow: */
193 static DWORD WINAPI IDirect3DVolumeTexture8Impl_SetLOD(LPDIRECT3DVOLUMETEXTURE8 iface, DWORD LODNew) {
194 IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
197 TRACE("iface %p, lod %u.\n", iface, LODNew);
199 wined3d_mutex_lock();
200 ret = IWineD3DVolumeTexture_SetLOD(This->wineD3DVolumeTexture, LODNew);
201 wined3d_mutex_unlock();
206 static DWORD WINAPI IDirect3DVolumeTexture8Impl_GetLOD(LPDIRECT3DVOLUMETEXTURE8 iface) {
207 IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
210 TRACE("iface %p.\n", iface);
212 wined3d_mutex_lock();
213 ret = IWineD3DVolumeTexture_GetLOD(This->wineD3DVolumeTexture);
214 wined3d_mutex_unlock();
219 static DWORD WINAPI IDirect3DVolumeTexture8Impl_GetLevelCount(LPDIRECT3DVOLUMETEXTURE8 iface) {
220 IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
223 TRACE("iface %p.\n", iface);
225 wined3d_mutex_lock();
226 ret = IWineD3DVolumeTexture_GetLevelCount(This->wineD3DVolumeTexture);
227 wined3d_mutex_unlock();
232 /* IDirect3DVolumeTexture8 Interface follow: */
233 static HRESULT WINAPI IDirect3DVolumeTexture8Impl_GetLevelDesc(LPDIRECT3DVOLUMETEXTURE8 iface, UINT Level, D3DVOLUME_DESC* pDesc) {
234 IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
235 WINED3DVOLUME_DESC wined3ddesc;
238 TRACE("iface %p, level %u, desc %p.\n", iface, Level, pDesc);
240 wined3d_mutex_lock();
241 hr = IWineD3DVolumeTexture_GetLevelDesc(This->wineD3DVolumeTexture, Level, &wined3ddesc);
242 wined3d_mutex_unlock();
246 pDesc->Format = d3dformat_from_wined3dformat(wined3ddesc.Format);
247 pDesc->Type = wined3ddesc.Type;
248 pDesc->Usage = wined3ddesc.Usage;
249 pDesc->Pool = wined3ddesc.Pool;
250 pDesc->Size = wined3ddesc.Size;
251 pDesc->Width = wined3ddesc.Width;
252 pDesc->Height = wined3ddesc.Height;
253 pDesc->Depth = wined3ddesc.Depth;
259 static HRESULT WINAPI IDirect3DVolumeTexture8Impl_GetVolumeLevel(LPDIRECT3DVOLUMETEXTURE8 iface, UINT Level, IDirect3DVolume8 **ppVolumeLevel) {
260 IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
261 HRESULT hrc = D3D_OK;
262 IWineD3DVolume *myVolume = NULL;
264 TRACE("iface %p, level %u, volume %p.\n", iface, Level, ppVolumeLevel);
266 wined3d_mutex_lock();
267 hrc = IWineD3DVolumeTexture_GetVolumeLevel(This->wineD3DVolumeTexture, Level, &myVolume);
268 if (hrc == D3D_OK && NULL != ppVolumeLevel) {
269 IWineD3DVolumeTexture_GetParent(myVolume, (IUnknown **)ppVolumeLevel);
270 IWineD3DVolumeTexture_Release(myVolume);
272 wined3d_mutex_unlock();
277 static HRESULT WINAPI IDirect3DVolumeTexture8Impl_LockBox(LPDIRECT3DVOLUMETEXTURE8 iface, UINT Level, D3DLOCKED_BOX *pLockedVolume, CONST D3DBOX *pBox, DWORD Flags) {
278 IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
281 TRACE("iface %p, level %u, locked_box %p, box %p, flags %#x.\n",
282 iface, Level, pLockedVolume, pBox, Flags);
284 wined3d_mutex_lock();
285 hr = IWineD3DVolumeTexture_LockBox(This->wineD3DVolumeTexture, Level, (WINED3DLOCKED_BOX *) pLockedVolume, (CONST WINED3DBOX *) pBox, Flags);
286 wined3d_mutex_unlock();
291 static HRESULT WINAPI IDirect3DVolumeTexture8Impl_UnlockBox(LPDIRECT3DVOLUMETEXTURE8 iface, UINT Level) {
292 IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
295 TRACE("iface %p, level %u.\n", iface, Level);
297 wined3d_mutex_lock();
298 hr = IWineD3DVolumeTexture_UnlockBox(This->wineD3DVolumeTexture, Level);
299 wined3d_mutex_unlock();
304 static HRESULT WINAPI IDirect3DVolumeTexture8Impl_AddDirtyBox(LPDIRECT3DVOLUMETEXTURE8 iface, CONST D3DBOX *pDirtyBox) {
305 IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
308 TRACE("iface %p, dirty_box %p.\n", iface, pDirtyBox);
310 wined3d_mutex_lock();
311 hr = IWineD3DVolumeTexture_AddDirtyBox(This->wineD3DVolumeTexture, (CONST WINED3DBOX *) pDirtyBox);
312 wined3d_mutex_unlock();
317 static const IDirect3DVolumeTexture8Vtbl Direct3DVolumeTexture8_Vtbl =
320 IDirect3DVolumeTexture8Impl_QueryInterface,
321 IDirect3DVolumeTexture8Impl_AddRef,
322 IDirect3DVolumeTexture8Impl_Release,
323 /* IDirect3DResource8 */
324 IDirect3DVolumeTexture8Impl_GetDevice,
325 IDirect3DVolumeTexture8Impl_SetPrivateData,
326 IDirect3DVolumeTexture8Impl_GetPrivateData,
327 IDirect3DVolumeTexture8Impl_FreePrivateData,
328 IDirect3DVolumeTexture8Impl_SetPriority,
329 IDirect3DVolumeTexture8Impl_GetPriority,
330 IDirect3DVolumeTexture8Impl_PreLoad,
331 IDirect3DVolumeTexture8Impl_GetType,
332 /* IDirect3DBaseTexture8 */
333 IDirect3DVolumeTexture8Impl_SetLOD,
334 IDirect3DVolumeTexture8Impl_GetLOD,
335 IDirect3DVolumeTexture8Impl_GetLevelCount,
336 /* IDirect3DVolumeTexture8 */
337 IDirect3DVolumeTexture8Impl_GetLevelDesc,
338 IDirect3DVolumeTexture8Impl_GetVolumeLevel,
339 IDirect3DVolumeTexture8Impl_LockBox,
340 IDirect3DVolumeTexture8Impl_UnlockBox,
341 IDirect3DVolumeTexture8Impl_AddDirtyBox
344 static void STDMETHODCALLTYPE volumetexture_wined3d_object_destroyed(void *parent)
346 HeapFree(GetProcessHeap(), 0, parent);
349 static const struct wined3d_parent_ops d3d8_volumetexture_wined3d_parent_ops =
351 volumetexture_wined3d_object_destroyed,
354 HRESULT volumetexture_init(IDirect3DVolumeTexture8Impl *texture, IDirect3DDevice8Impl *device,
355 UINT width, UINT height, UINT depth, UINT levels, DWORD usage, D3DFORMAT format, D3DPOOL pool)
359 texture->lpVtbl = &Direct3DVolumeTexture8_Vtbl;
362 wined3d_mutex_lock();
363 hr = IWineD3DDevice_CreateVolumeTexture(device->WineD3DDevice, width, height, depth, levels,
364 usage & WINED3DUSAGE_MASK, wined3dformat_from_d3dformat(format), pool,
365 &texture->wineD3DVolumeTexture, (IUnknown *)texture, &d3d8_volumetexture_wined3d_parent_ops);
366 wined3d_mutex_unlock();
369 WARN("Failed to create wined3d volume texture, hr %#x.\n", hr);
373 texture->parentDevice = (IDirect3DDevice8 *)device;
374 IDirect3DDevice8_AddRef(texture->parentDevice);