volumetexture.c 14.1 KB
Newer Older
1 2 3
/*
 * IDirect3DVolumeTexture9 implementation
 *
4
 * Copyright 2002-2005 Jason Edmeades
5 6 7 8 9 10 11 12 13 14 15 16 17 18
 *                     Raphael Junqueira
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * 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 24
 */

#include "config.h"
#include "d3d9_private.h"

25
WINE_DEFAULT_DEBUG_CHANNEL(d3d9);
26 27

/* IDirect3DVolumeTexture9 IUnknown parts follow: */
28
static HRESULT WINAPI IDirect3DVolumeTexture9Impl_QueryInterface(LPDIRECT3DVOLUMETEXTURE9 iface, REFIID riid, LPVOID* ppobj) {
29
    IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
30

Henri Verbeet's avatar
Henri Verbeet committed
31 32
    TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), ppobj);

33
    if (IsEqualGUID(riid, &IID_IUnknown)
34 35 36
    || IsEqualGUID(riid, &IID_IDirect3DResource9)
    || IsEqualGUID(riid, &IID_IDirect3DBaseTexture9)
    || IsEqualGUID(riid, &IID_IDirect3DVolumeTexture9)) {
37
        IDirect3DVolumeTexture9_AddRef(iface);
38
        *ppobj = This;
H. Verbeet's avatar
H. Verbeet committed
39
        return S_OK;
40 41 42
    }

    WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
H. Verbeet's avatar
H. Verbeet committed
43
    *ppobj = NULL;
44 45 46
    return E_NOINTERFACE;
}

47
static ULONG WINAPI IDirect3DVolumeTexture9Impl_AddRef(LPDIRECT3DVOLUMETEXTURE9 iface) {
48
    IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
49 50
    ULONG ref = InterlockedIncrement(&This->ref);

Henri Verbeet's avatar
Henri Verbeet committed
51
    TRACE("%p increasing refcount to %u.\n", iface, ref);
52

53 54 55 56 57 58 59 60
    if (ref == 1)
    {
        IDirect3DDevice9Ex_AddRef(This->parentDevice);
        wined3d_mutex_lock();
        IWineD3DVolumeTexture_AddRef(This->wineD3DVolumeTexture);
        wined3d_mutex_unlock();
    }

61
    return ref;
62 63
}

64
static ULONG WINAPI IDirect3DVolumeTexture9Impl_Release(LPDIRECT3DVOLUMETEXTURE9 iface) {
65
    IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
66
    ULONG ref = InterlockedDecrement(&This->ref);
67

Henri Verbeet's avatar
Henri Verbeet committed
68
    TRACE("%p decreasing refcount to %u.\n", iface, ref);
69

70
    if (ref == 0) {
71 72
        IDirect3DDevice9Ex *parentDevice = This->parentDevice;

73
        wined3d_mutex_lock();
74
        IWineD3DVolumeTexture_Release(This->wineD3DVolumeTexture);
75
        wined3d_mutex_unlock();
76 77 78

        /* Release the device last, as it may cause the device to be destroyed. */
        IDirect3DDevice9Ex_Release(parentDevice);
79 80 81 82 83
    }
    return ref;
}

/* IDirect3DVolumeTexture9 IDirect3DResource9 Interface follow: */
84 85
static HRESULT WINAPI IDirect3DVolumeTexture9Impl_GetDevice(IDirect3DVolumeTexture9 *iface, IDirect3DDevice9 **device)
{
86
    IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
87

88
    TRACE("iface %p, device %p.\n", iface, device);
89

90 91
    *device = (IDirect3DDevice9 *)This->parentDevice;
    IDirect3DDevice9_AddRef(*device);
92

93 94 95
    TRACE("Returning device %p.\n", *device);

    return D3D_OK;
96 97
}

98
static HRESULT WINAPI IDirect3DVolumeTexture9Impl_SetPrivateData(LPDIRECT3DVOLUMETEXTURE9 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
99
    IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
Henri Verbeet's avatar
Henri Verbeet committed
100 101
    HRESULT hr;

Henri Verbeet's avatar
Henri Verbeet committed
102 103
    TRACE("iface %p, guid %s, data %p, data_size %u, flags %#x.\n",
            iface, debugstr_guid(refguid), pData, SizeOfData, Flags);
Henri Verbeet's avatar
Henri Verbeet committed
104

105
    wined3d_mutex_lock();
Henri Verbeet's avatar
Henri Verbeet committed
106 107 108

    hr = IWineD3DVolumeTexture_SetPrivateData(This->wineD3DVolumeTexture, refguid, pData, SizeOfData, Flags);

109
    wined3d_mutex_unlock();
Henri Verbeet's avatar
Henri Verbeet committed
110 111

    return hr;
112 113
}

114
static HRESULT WINAPI IDirect3DVolumeTexture9Impl_GetPrivateData(LPDIRECT3DVOLUMETEXTURE9 iface, REFGUID refguid, void* pData, DWORD* pSizeOfData) {
115
    IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
Henri Verbeet's avatar
Henri Verbeet committed
116 117
    HRESULT hr;

Henri Verbeet's avatar
Henri Verbeet committed
118 119
    TRACE("iface %p, guid %s, data %p, data_size %p.\n",
            iface, debugstr_guid(refguid), pData, pSizeOfData);
Henri Verbeet's avatar
Henri Verbeet committed
120

121
    wined3d_mutex_lock();
Henri Verbeet's avatar
Henri Verbeet committed
122 123 124

    hr = IWineD3DVolumeTexture_GetPrivateData(This->wineD3DVolumeTexture, refguid, pData, pSizeOfData);

125
    wined3d_mutex_unlock();
Henri Verbeet's avatar
Henri Verbeet committed
126 127

    return hr;
128 129
}

130
static HRESULT WINAPI IDirect3DVolumeTexture9Impl_FreePrivateData(LPDIRECT3DVOLUMETEXTURE9 iface, REFGUID refguid) {
131
    IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
Henri Verbeet's avatar
Henri Verbeet committed
132 133
    HRESULT hr;

Henri Verbeet's avatar
Henri Verbeet committed
134
    TRACE("iface %p, guid %s.\n", iface, debugstr_guid(refguid));
Henri Verbeet's avatar
Henri Verbeet committed
135

136
    wined3d_mutex_lock();
Henri Verbeet's avatar
Henri Verbeet committed
137 138 139

    hr = IWineD3DVolumeTexture_FreePrivateData(This->wineD3DVolumeTexture, refguid);

140
    wined3d_mutex_unlock();
Henri Verbeet's avatar
Henri Verbeet committed
141 142

    return hr;
143 144
}

145
static DWORD WINAPI IDirect3DVolumeTexture9Impl_SetPriority(LPDIRECT3DVOLUMETEXTURE9 iface, DWORD PriorityNew) {
146
    IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
Henri Verbeet's avatar
Henri Verbeet committed
147 148
    DWORD priority;

Henri Verbeet's avatar
Henri Verbeet committed
149
    TRACE("iface %p, priority %u.\n", iface, PriorityNew);
Henri Verbeet's avatar
Henri Verbeet committed
150

151
    wined3d_mutex_lock();
Henri Verbeet's avatar
Henri Verbeet committed
152 153 154

    priority = IWineD3DVolumeTexture_SetPriority(This->wineD3DVolumeTexture, PriorityNew);

155
    wined3d_mutex_unlock();
Henri Verbeet's avatar
Henri Verbeet committed
156 157

    return priority;
158 159
}

160
static DWORD WINAPI IDirect3DVolumeTexture9Impl_GetPriority(LPDIRECT3DVOLUMETEXTURE9 iface) {
161
    IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
Henri Verbeet's avatar
Henri Verbeet committed
162 163
    DWORD priority;

Henri Verbeet's avatar
Henri Verbeet committed
164
    TRACE("iface %p.\n", iface);
Henri Verbeet's avatar
Henri Verbeet committed
165

166
    wined3d_mutex_lock();
Henri Verbeet's avatar
Henri Verbeet committed
167 168 169

    priority = IWineD3DVolumeTexture_GetPriority(This->wineD3DVolumeTexture);

170
    wined3d_mutex_unlock();
Henri Verbeet's avatar
Henri Verbeet committed
171 172

    return priority;
173 174
}

175
static void WINAPI IDirect3DVolumeTexture9Impl_PreLoad(LPDIRECT3DVOLUMETEXTURE9 iface) {
176
    IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
Henri Verbeet's avatar
Henri Verbeet committed
177

Henri Verbeet's avatar
Henri Verbeet committed
178
    TRACE("iface %p.\n", iface);
Henri Verbeet's avatar
Henri Verbeet committed
179

180
    wined3d_mutex_lock();
Henri Verbeet's avatar
Henri Verbeet committed
181

182
    IWineD3DVolumeTexture_PreLoad(This->wineD3DVolumeTexture);
Henri Verbeet's avatar
Henri Verbeet committed
183

184
    wined3d_mutex_unlock();
185 186
}

187
static D3DRESOURCETYPE WINAPI IDirect3DVolumeTexture9Impl_GetType(LPDIRECT3DVOLUMETEXTURE9 iface) {
188
    IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
Henri Verbeet's avatar
Henri Verbeet committed
189 190
    D3DRESOURCETYPE type;

Henri Verbeet's avatar
Henri Verbeet committed
191
    TRACE("iface %p.\n", iface);
Henri Verbeet's avatar
Henri Verbeet committed
192

193
    wined3d_mutex_lock();
Henri Verbeet's avatar
Henri Verbeet committed
194 195 196

    type = IWineD3DVolumeTexture_GetType(This->wineD3DVolumeTexture);

197
    wined3d_mutex_unlock();
Henri Verbeet's avatar
Henri Verbeet committed
198 199

    return type;
200 201 202
}

/* IDirect3DVolumeTexture9 IDirect3DBaseTexture9 Interface follow: */
203
static DWORD WINAPI IDirect3DVolumeTexture9Impl_SetLOD(LPDIRECT3DVOLUMETEXTURE9 iface, DWORD LODNew) {
204
    IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
Henri Verbeet's avatar
Henri Verbeet committed
205 206
    DWORD lod;

Henri Verbeet's avatar
Henri Verbeet committed
207
    TRACE("iface %p, lod %u.\n", iface, LODNew);
Henri Verbeet's avatar
Henri Verbeet committed
208

209
    wined3d_mutex_lock();
Henri Verbeet's avatar
Henri Verbeet committed
210 211 212

    lod = IWineD3DVolumeTexture_SetLOD(This->wineD3DVolumeTexture, LODNew);

213
    wined3d_mutex_unlock();
Henri Verbeet's avatar
Henri Verbeet committed
214 215

    return lod;
216 217
}

218
static DWORD WINAPI IDirect3DVolumeTexture9Impl_GetLOD(LPDIRECT3DVOLUMETEXTURE9 iface) {
219
    IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
Henri Verbeet's avatar
Henri Verbeet committed
220 221
    DWORD lod;

Henri Verbeet's avatar
Henri Verbeet committed
222
    TRACE("iface %p.\n", iface);
Henri Verbeet's avatar
Henri Verbeet committed
223

224
    wined3d_mutex_lock();
Henri Verbeet's avatar
Henri Verbeet committed
225 226 227

    lod = IWineD3DVolumeTexture_GetLOD(This->wineD3DVolumeTexture);

228
    wined3d_mutex_unlock();
Henri Verbeet's avatar
Henri Verbeet committed
229 230

    return lod;
231 232
}

233
static DWORD WINAPI IDirect3DVolumeTexture9Impl_GetLevelCount(LPDIRECT3DVOLUMETEXTURE9 iface) {
234
    IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
Henri Verbeet's avatar
Henri Verbeet committed
235 236
    DWORD level_count;

Henri Verbeet's avatar
Henri Verbeet committed
237
    TRACE("iface %p.\n", iface);
Henri Verbeet's avatar
Henri Verbeet committed
238

239
    wined3d_mutex_lock();
Henri Verbeet's avatar
Henri Verbeet committed
240 241 242

    level_count = IWineD3DVolumeTexture_GetLevelCount(This->wineD3DVolumeTexture);

243
    wined3d_mutex_unlock();
Henri Verbeet's avatar
Henri Verbeet committed
244 245

    return level_count;
246 247
}

248
static HRESULT WINAPI IDirect3DVolumeTexture9Impl_SetAutoGenFilterType(LPDIRECT3DVOLUMETEXTURE9 iface, D3DTEXTUREFILTERTYPE FilterType) {
249
    IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
Henri Verbeet's avatar
Henri Verbeet committed
250 251
    HRESULT hr;

Henri Verbeet's avatar
Henri Verbeet committed
252
    TRACE("iface %p, filter_type %#x.\n", iface, FilterType);
Henri Verbeet's avatar
Henri Verbeet committed
253

254
    wined3d_mutex_lock();
Henri Verbeet's avatar
Henri Verbeet committed
255 256 257

    hr = IWineD3DVolumeTexture_SetAutoGenFilterType(This->wineD3DVolumeTexture, (WINED3DTEXTUREFILTERTYPE) FilterType);

258
    wined3d_mutex_unlock();
Henri Verbeet's avatar
Henri Verbeet committed
259 260

    return hr;
261 262
}

263
static D3DTEXTUREFILTERTYPE WINAPI IDirect3DVolumeTexture9Impl_GetAutoGenFilterType(LPDIRECT3DVOLUMETEXTURE9 iface) {
264
    IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
Henri Verbeet's avatar
Henri Verbeet committed
265 266
    D3DTEXTUREFILTERTYPE filter_type;

Henri Verbeet's avatar
Henri Verbeet committed
267
    TRACE("iface %p.\n", iface);
Henri Verbeet's avatar
Henri Verbeet committed
268

269
    wined3d_mutex_lock();
Henri Verbeet's avatar
Henri Verbeet committed
270 271 272

    filter_type = (D3DTEXTUREFILTERTYPE)IWineD3DVolumeTexture_GetAutoGenFilterType(This->wineD3DVolumeTexture);

273
    wined3d_mutex_unlock();
Henri Verbeet's avatar
Henri Verbeet committed
274 275

    return filter_type;
276 277
}

278
static void WINAPI IDirect3DVolumeTexture9Impl_GenerateMipSubLevels(LPDIRECT3DVOLUMETEXTURE9 iface) {
279
    IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
Henri Verbeet's avatar
Henri Verbeet committed
280

Henri Verbeet's avatar
Henri Verbeet committed
281
    TRACE("iface %p.\n", iface);
Henri Verbeet's avatar
Henri Verbeet committed
282

283
    wined3d_mutex_lock();
Henri Verbeet's avatar
Henri Verbeet committed
284

285
    IWineD3DVolumeTexture_GenerateMipSubLevels(This->wineD3DVolumeTexture);
Henri Verbeet's avatar
Henri Verbeet committed
286

287
    wined3d_mutex_unlock();
288 289 290
}

/* IDirect3DVolumeTexture9 Interface follow: */
291
static HRESULT WINAPI IDirect3DVolumeTexture9Impl_GetLevelDesc(LPDIRECT3DVOLUMETEXTURE9 iface, UINT Level, D3DVOLUME_DESC* pDesc) {
292
    IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
293
    WINED3DVOLUME_DESC     wined3ddesc;
294
    HRESULT hr;
295

Henri Verbeet's avatar
Henri Verbeet committed
296
    TRACE("iface %p, level %u, desc %p.\n", iface, Level, pDesc);
297

298
    wined3d_mutex_lock();
Henri Verbeet's avatar
Henri Verbeet committed
299

300 301
    hr = IWineD3DVolumeTexture_GetLevelDesc(This->wineD3DVolumeTexture, Level, &wined3ddesc);

302
    wined3d_mutex_unlock();
Henri Verbeet's avatar
Henri Verbeet committed
303

304 305 306 307 308 309 310 311 312 313
    if (SUCCEEDED(hr))
    {
        pDesc->Format = d3dformat_from_wined3dformat(wined3ddesc.Format);
        pDesc->Type = wined3ddesc.Type;
        pDesc->Usage = wined3ddesc.Usage;
        pDesc->Pool = wined3ddesc.Pool;
        pDesc->Width = wined3ddesc.Width;
        pDesc->Height = wined3ddesc.Height;
        pDesc->Depth = wined3ddesc.Depth;
    }
314 315

    return hr;
316 317
}

318 319 320
static HRESULT WINAPI IDirect3DVolumeTexture9Impl_GetVolumeLevel(IDirect3DVolumeTexture9 *iface,
        UINT Level, IDirect3DVolume9 **ppVolumeLevel)
{
321
    IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
322
    IWineD3DVolume *myVolume = NULL;
323
    HRESULT hr;
324

Henri Verbeet's avatar
Henri Verbeet committed
325
    TRACE("iface %p, level %u, volume %p.\n", iface, Level, ppVolumeLevel);
326

327
    wined3d_mutex_lock();
Henri Verbeet's avatar
Henri Verbeet committed
328

329 330 331 332 333
    hr = IWineD3DVolumeTexture_GetVolumeLevel(This->wineD3DVolumeTexture, Level, &myVolume);
    if (SUCCEEDED(hr) && ppVolumeLevel)
    {
       *ppVolumeLevel = IWineD3DVolumeTexture_GetParent(myVolume);
       IDirect3DVolumeTexture9_AddRef(*ppVolumeLevel);
334
       IWineD3DVolumeTexture_Release(myVolume);
335
    }
Henri Verbeet's avatar
Henri Verbeet committed
336

337
    wined3d_mutex_unlock();
Henri Verbeet's avatar
Henri Verbeet committed
338

339
    return hr;
340
}
341

342
static HRESULT WINAPI IDirect3DVolumeTexture9Impl_LockBox(LPDIRECT3DVOLUMETEXTURE9 iface, UINT Level, D3DLOCKED_BOX* pLockedVolume, CONST D3DBOX* pBox, DWORD Flags) {
343
    IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
Henri Verbeet's avatar
Henri Verbeet committed
344 345
    HRESULT hr;

Henri Verbeet's avatar
Henri Verbeet committed
346 347
    TRACE("iface %p, level %u, locked_box %p, box %p, flags %#x.\n",
            iface, Level, pLockedVolume, pBox, Flags);
Henri Verbeet's avatar
Henri Verbeet committed
348

349
    wined3d_mutex_lock();
Henri Verbeet's avatar
Henri Verbeet committed
350 351 352 353

    hr = IWineD3DVolumeTexture_LockBox(This->wineD3DVolumeTexture, Level, (WINED3DLOCKED_BOX *)pLockedVolume,
            (const WINED3DBOX *)pBox, Flags);

354
    wined3d_mutex_unlock();
Henri Verbeet's avatar
Henri Verbeet committed
355 356

    return hr;
357 358
}

359
static HRESULT WINAPI IDirect3DVolumeTexture9Impl_UnlockBox(LPDIRECT3DVOLUMETEXTURE9 iface, UINT Level) {
360
    IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
Henri Verbeet's avatar
Henri Verbeet committed
361 362
    HRESULT hr;

Henri Verbeet's avatar
Henri Verbeet committed
363
    TRACE("iface %p, level %u.\n", iface, Level);
Henri Verbeet's avatar
Henri Verbeet committed
364

365
    wined3d_mutex_lock();
Henri Verbeet's avatar
Henri Verbeet committed
366 367 368

    hr = IWineD3DVolumeTexture_UnlockBox(This->wineD3DVolumeTexture, Level);

369
    wined3d_mutex_unlock();
Henri Verbeet's avatar
Henri Verbeet committed
370 371

    return hr;
372 373
}

374
static HRESULT WINAPI IDirect3DVolumeTexture9Impl_AddDirtyBox(LPDIRECT3DVOLUMETEXTURE9 iface, CONST D3DBOX* pDirtyBox) {
375
    IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
Henri Verbeet's avatar
Henri Verbeet committed
376 377
    HRESULT hr;

Henri Verbeet's avatar
Henri Verbeet committed
378
    TRACE("iface %p, dirty_box %p.\n", iface, pDirtyBox);
Henri Verbeet's avatar
Henri Verbeet committed
379

380
    wined3d_mutex_lock();
Henri Verbeet's avatar
Henri Verbeet committed
381 382 383

    hr = IWineD3DVolumeTexture_AddDirtyBox(This->wineD3DVolumeTexture, (CONST WINED3DBOX *)pDirtyBox);

384
    wined3d_mutex_unlock();
Henri Verbeet's avatar
Henri Verbeet committed
385 386

    return hr;
387 388 389
}


390
static const IDirect3DVolumeTexture9Vtbl Direct3DVolumeTexture9_Vtbl =
391
{
392
    /* IUnknown */
393 394 395
    IDirect3DVolumeTexture9Impl_QueryInterface,
    IDirect3DVolumeTexture9Impl_AddRef,
    IDirect3DVolumeTexture9Impl_Release,
396
    /* IDirect3DResource9 */
397 398 399 400 401 402 403 404
    IDirect3DVolumeTexture9Impl_GetDevice,
    IDirect3DVolumeTexture9Impl_SetPrivateData,
    IDirect3DVolumeTexture9Impl_GetPrivateData,
    IDirect3DVolumeTexture9Impl_FreePrivateData,
    IDirect3DVolumeTexture9Impl_SetPriority,
    IDirect3DVolumeTexture9Impl_GetPriority,
    IDirect3DVolumeTexture9Impl_PreLoad,
    IDirect3DVolumeTexture9Impl_GetType,
405
    /* IDirect3DBaseTexture9 */
406 407 408 409 410 411
    IDirect3DVolumeTexture9Impl_SetLOD,
    IDirect3DVolumeTexture9Impl_GetLOD,
    IDirect3DVolumeTexture9Impl_GetLevelCount,
    IDirect3DVolumeTexture9Impl_SetAutoGenFilterType,
    IDirect3DVolumeTexture9Impl_GetAutoGenFilterType,
    IDirect3DVolumeTexture9Impl_GenerateMipSubLevels,
412
    /* IDirect3DVolumeTexture9 */
413 414 415 416 417 418 419
    IDirect3DVolumeTexture9Impl_GetLevelDesc,
    IDirect3DVolumeTexture9Impl_GetVolumeLevel,
    IDirect3DVolumeTexture9Impl_LockBox,
    IDirect3DVolumeTexture9Impl_UnlockBox,
    IDirect3DVolumeTexture9Impl_AddDirtyBox
};

420 421 422 423 424 425 426 427 428 429
static void STDMETHODCALLTYPE volumetexture_wined3d_object_destroyed(void *parent)
{
    HeapFree(GetProcessHeap(), 0, parent);
}

static const struct wined3d_parent_ops d3d9_volumetexture_wined3d_parent_ops =
{
    volumetexture_wined3d_object_destroyed,
};

430 431
HRESULT volumetexture_init(IDirect3DVolumeTexture9Impl *texture, IDirect3DDevice9Impl *device,
        UINT width, UINT height, UINT depth, UINT levels, DWORD usage, D3DFORMAT format, D3DPOOL pool)
432
{
433
    HRESULT hr;
434

435 436
    texture->lpVtbl = &Direct3DVolumeTexture9_Vtbl;
    texture->ref = 1;
Henri Verbeet's avatar
Henri Verbeet committed
437

438
    wined3d_mutex_lock();
439
    hr = IWineD3DDevice_CreateVolumeTexture(device->WineD3DDevice, width, height, depth, levels,
440 441
            usage & WINED3DUSAGE_MASK, wined3dformat_from_d3dformat(format), pool, texture,
            &d3d9_volumetexture_wined3d_parent_ops, &texture->wineD3DVolumeTexture);
442
    wined3d_mutex_unlock();
443 444 445 446 447
    if (FAILED(hr))
    {
        WARN("Failed to create wined3d volume texture, hr %#x.\n", hr);
        return hr;
    }
Henri Verbeet's avatar
Henri Verbeet committed
448

449 450
    texture->parentDevice = (IDirect3DDevice9Ex *)device;
    IDirect3DDevice9Ex_AddRef(texture->parentDevice);
451

452
    return D3D_OK;
453
}