2 * Copyright 2005 Oliver Stieber
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 #include "d3d8_private.h"
22 WINE_DEFAULT_DEBUG_CHANNEL(d3d8
);
24 static inline struct d3d8_texture
*impl_from_IDirect3DTexture8(IDirect3DTexture8
*iface
)
26 return CONTAINING_RECORD(iface
, struct d3d8_texture
, IDirect3DBaseTexture8_iface
);
29 static inline struct d3d8_texture
*impl_from_IDirect3DCubeTexture8(IDirect3DCubeTexture8
*iface
)
31 return CONTAINING_RECORD(iface
, struct d3d8_texture
, IDirect3DBaseTexture8_iface
);
34 static inline struct d3d8_texture
*impl_from_IDirect3DVolumeTexture8(IDirect3DVolumeTexture8
*iface
)
36 return CONTAINING_RECORD(iface
, struct d3d8_texture
, IDirect3DBaseTexture8_iface
);
39 static HRESULT WINAPI
d3d8_texture_2d_QueryInterface(IDirect3DTexture8
*iface
, REFIID riid
, void **out
)
41 TRACE("iface %p, riid %s, out %p.\n", iface
, debugstr_guid(riid
), out
);
43 if (IsEqualGUID(riid
, &IID_IDirect3DTexture8
)
44 || IsEqualGUID(riid
, &IID_IDirect3DBaseTexture8
)
45 || IsEqualGUID(riid
, &IID_IDirect3DResource8
)
46 || IsEqualGUID(riid
, &IID_IUnknown
))
48 IDirect3DTexture8_AddRef(iface
);
53 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid
));
59 static ULONG WINAPI
d3d8_texture_2d_AddRef(IDirect3DTexture8
*iface
)
61 struct d3d8_texture
*texture
= impl_from_IDirect3DTexture8(iface
);
62 ULONG ref
= InterlockedIncrement(&texture
->resource
.refcount
);
64 TRACE("%p increasing refcount to %u.\n", iface
, ref
);
68 struct d3d8_surface
*surface
;
70 IDirect3DDevice8_AddRef(texture
->parent_device
);
72 LIST_FOR_EACH_ENTRY(surface
, &texture
->rtv_list
, struct d3d8_surface
, rtv_entry
)
74 wined3d_rendertarget_view_incref(surface
->wined3d_rtv
);
76 wined3d_texture_incref(texture
->wined3d_texture
);
77 wined3d_mutex_unlock();
83 static ULONG WINAPI
d3d8_texture_2d_Release(IDirect3DTexture8
*iface
)
85 struct d3d8_texture
*texture
= impl_from_IDirect3DTexture8(iface
);
86 ULONG ref
= InterlockedDecrement(&texture
->resource
.refcount
);
88 TRACE("%p decreasing refcount to %u.\n", iface
, ref
);
92 IDirect3DDevice8
*parent_device
= texture
->parent_device
;
93 struct d3d8_surface
*surface
;
96 LIST_FOR_EACH_ENTRY(surface
, &texture
->rtv_list
, struct d3d8_surface
, rtv_entry
)
98 wined3d_rendertarget_view_decref(surface
->wined3d_rtv
);
100 wined3d_texture_decref(texture
->wined3d_texture
);
101 wined3d_mutex_unlock();
103 /* Release the device last, as it may cause the device to be destroyed. */
104 IDirect3DDevice8_Release(parent_device
);
109 static HRESULT WINAPI
d3d8_texture_2d_GetDevice(IDirect3DTexture8
*iface
, IDirect3DDevice8
**device
)
111 struct d3d8_texture
*texture
= impl_from_IDirect3DTexture8(iface
);
113 TRACE("iface %p, device %p.\n", iface
, device
);
115 *device
= texture
->parent_device
;
116 IDirect3DDevice8_AddRef(*device
);
118 TRACE("Returning device %p.\n", *device
);
123 static HRESULT WINAPI
d3d8_texture_2d_SetPrivateData(IDirect3DTexture8
*iface
,
124 REFGUID guid
, const void *data
, DWORD data_size
, DWORD flags
)
126 struct d3d8_texture
*texture
= impl_from_IDirect3DTexture8(iface
);
127 TRACE("iface %p, guid %s, data %p, data_size %u, flags %#x.\n",
128 iface
, debugstr_guid(guid
), data
, data_size
, flags
);
130 return d3d8_resource_set_private_data(&texture
->resource
, guid
, data
, data_size
, flags
);
133 static HRESULT WINAPI
d3d8_texture_2d_GetPrivateData(IDirect3DTexture8
*iface
,
134 REFGUID guid
, void *data
, DWORD
*data_size
)
136 struct d3d8_texture
*texture
= impl_from_IDirect3DTexture8(iface
);
137 TRACE("iface %p, guid %s, data %p, data_size %p.\n",
138 iface
, debugstr_guid(guid
), data
, data_size
);
140 return d3d8_resource_get_private_data(&texture
->resource
, guid
, data
, data_size
);
143 static HRESULT WINAPI
d3d8_texture_2d_FreePrivateData(IDirect3DTexture8
*iface
, REFGUID guid
)
145 struct d3d8_texture
*texture
= impl_from_IDirect3DTexture8(iface
);
146 TRACE("iface %p, guid %s.\n", iface
, debugstr_guid(guid
));
148 return d3d8_resource_free_private_data(&texture
->resource
, guid
);
151 static DWORD WINAPI
d3d8_texture_2d_SetPriority(IDirect3DTexture8
*iface
, DWORD priority
)
153 struct d3d8_texture
*texture
= impl_from_IDirect3DTexture8(iface
);
154 struct wined3d_resource
*resource
;
157 TRACE("iface %p, priority %u.\n", iface
, priority
);
159 wined3d_mutex_lock();
160 resource
= wined3d_texture_get_resource(texture
->wined3d_texture
);
161 ret
= wined3d_resource_set_priority(resource
, priority
);
162 wined3d_mutex_unlock();
167 static DWORD WINAPI
d3d8_texture_2d_GetPriority(IDirect3DTexture8
*iface
)
169 struct d3d8_texture
*texture
= impl_from_IDirect3DTexture8(iface
);
170 const struct wined3d_resource
*resource
;
173 TRACE("iface %p.\n", iface
);
175 wined3d_mutex_lock();
176 resource
= wined3d_texture_get_resource(texture
->wined3d_texture
);
177 ret
= wined3d_resource_get_priority(resource
);
178 wined3d_mutex_unlock();
183 static void WINAPI
d3d8_texture_2d_PreLoad(IDirect3DTexture8
*iface
)
185 struct d3d8_texture
*texture
= impl_from_IDirect3DTexture8(iface
);
187 TRACE("iface %p.\n", iface
);
189 wined3d_mutex_lock();
190 wined3d_resource_preload(wined3d_texture_get_resource(texture
->wined3d_texture
));
191 wined3d_mutex_unlock();
194 static D3DRESOURCETYPE WINAPI
d3d8_texture_2d_GetType(IDirect3DTexture8
*iface
)
196 TRACE("iface %p.\n", iface
);
198 return D3DRTYPE_TEXTURE
;
201 static DWORD WINAPI
d3d8_texture_2d_SetLOD(IDirect3DTexture8
*iface
, DWORD lod
)
203 struct d3d8_texture
*texture
= impl_from_IDirect3DTexture8(iface
);
206 TRACE("iface %p, lod %u.\n", iface
, lod
);
208 wined3d_mutex_lock();
209 ret
= wined3d_texture_set_lod(texture
->wined3d_texture
, lod
);
210 wined3d_mutex_unlock();
215 static DWORD WINAPI
d3d8_texture_2d_GetLOD(IDirect3DTexture8
*iface
)
217 struct d3d8_texture
*texture
= impl_from_IDirect3DTexture8(iface
);
220 TRACE("iface %p.\n", iface
);
222 wined3d_mutex_lock();
223 ret
= wined3d_texture_get_lod(texture
->wined3d_texture
);
224 wined3d_mutex_unlock();
229 static DWORD WINAPI
d3d8_texture_2d_GetLevelCount(IDirect3DTexture8
*iface
)
231 struct d3d8_texture
*texture
= impl_from_IDirect3DTexture8(iface
);
234 TRACE("iface %p.\n", iface
);
236 wined3d_mutex_lock();
237 ret
= wined3d_texture_get_level_count(texture
->wined3d_texture
);
238 wined3d_mutex_unlock();
243 static HRESULT WINAPI
d3d8_texture_2d_GetLevelDesc(IDirect3DTexture8
*iface
, UINT level
, D3DSURFACE_DESC
*desc
)
245 struct d3d8_texture
*texture
= impl_from_IDirect3DTexture8(iface
);
246 struct wined3d_sub_resource_desc wined3d_desc
;
249 TRACE("iface %p, level %u, desc %p.\n", iface
, level
, desc
);
251 wined3d_mutex_lock();
252 if (SUCCEEDED(hr
= wined3d_texture_get_sub_resource_desc(texture
->wined3d_texture
, level
, &wined3d_desc
)))
254 desc
->Format
= d3dformat_from_wined3dformat(wined3d_desc
.format
);
255 desc
->Type
= D3DRTYPE_SURFACE
;
256 desc
->Usage
= d3dusage_from_wined3dusage(wined3d_desc
.usage
, wined3d_desc
.bind_flags
);
257 desc
->Pool
= d3dpool_from_wined3daccess(wined3d_desc
.access
, wined3d_desc
.usage
);
258 desc
->Size
= wined3d_desc
.size
;
259 desc
->MultiSampleType
= wined3d_desc
.multisample_type
;
260 desc
->Width
= wined3d_desc
.width
;
261 desc
->Height
= wined3d_desc
.height
;
263 wined3d_mutex_unlock();
268 static HRESULT WINAPI
d3d8_texture_2d_GetSurfaceLevel(IDirect3DTexture8
*iface
,
269 UINT level
, IDirect3DSurface8
**surface
)
271 struct d3d8_texture
*texture
= impl_from_IDirect3DTexture8(iface
);
272 struct d3d8_surface
*surface_impl
;
274 TRACE("iface %p, level %u, surface %p.\n", iface
, level
, surface
);
276 wined3d_mutex_lock();
277 if (!(surface_impl
= wined3d_texture_get_sub_resource_parent(texture
->wined3d_texture
, level
)))
279 wined3d_mutex_unlock();
280 return D3DERR_INVALIDCALL
;
283 *surface
= &surface_impl
->IDirect3DSurface8_iface
;
284 IDirect3DSurface8_AddRef(*surface
);
285 wined3d_mutex_unlock();
290 static HRESULT WINAPI
d3d8_texture_2d_LockRect(IDirect3DTexture8
*iface
, UINT level
,
291 D3DLOCKED_RECT
*locked_rect
, const RECT
*rect
, DWORD flags
)
293 struct d3d8_texture
*texture
= impl_from_IDirect3DTexture8(iface
);
294 struct d3d8_surface
*surface_impl
;
297 TRACE("iface %p, level %u, locked_rect %p, rect %p, flags %#x.\n",
298 iface
, level
, locked_rect
, rect
, flags
);
300 wined3d_mutex_lock();
301 if (!(surface_impl
= wined3d_texture_get_sub_resource_parent(texture
->wined3d_texture
, level
)))
302 hr
= D3DERR_INVALIDCALL
;
304 hr
= IDirect3DSurface8_LockRect(&surface_impl
->IDirect3DSurface8_iface
, locked_rect
, rect
, flags
);
305 wined3d_mutex_unlock();
310 static HRESULT WINAPI
d3d8_texture_2d_UnlockRect(IDirect3DTexture8
*iface
, UINT level
)
312 struct d3d8_texture
*texture
= impl_from_IDirect3DTexture8(iface
);
313 struct d3d8_surface
*surface_impl
;
316 TRACE("iface %p, level %u.\n", iface
, level
);
318 wined3d_mutex_lock();
319 if (!(surface_impl
= wined3d_texture_get_sub_resource_parent(texture
->wined3d_texture
, level
)))
320 hr
= D3DERR_INVALIDCALL
;
322 hr
= IDirect3DSurface8_UnlockRect(&surface_impl
->IDirect3DSurface8_iface
);
323 wined3d_mutex_unlock();
328 static HRESULT WINAPI
d3d8_texture_2d_AddDirtyRect(IDirect3DTexture8
*iface
, const RECT
*dirty_rect
)
330 struct d3d8_texture
*texture
= impl_from_IDirect3DTexture8(iface
);
333 TRACE("iface %p, dirty_rect %s.\n",
334 iface
, wine_dbgstr_rect(dirty_rect
));
336 wined3d_mutex_lock();
338 hr
= wined3d_texture_add_dirty_region(texture
->wined3d_texture
, 0, NULL
);
341 struct wined3d_box dirty_region
;
343 wined3d_box_set(&dirty_region
, dirty_rect
->left
, dirty_rect
->top
, dirty_rect
->right
, dirty_rect
->bottom
, 0, 1);
344 hr
= wined3d_texture_add_dirty_region(texture
->wined3d_texture
, 0, &dirty_region
);
346 wined3d_mutex_unlock();
351 static const IDirect3DTexture8Vtbl Direct3DTexture8_Vtbl
=
354 d3d8_texture_2d_QueryInterface
,
355 d3d8_texture_2d_AddRef
,
356 d3d8_texture_2d_Release
,
357 /* IDirect3DResource8 */
358 d3d8_texture_2d_GetDevice
,
359 d3d8_texture_2d_SetPrivateData
,
360 d3d8_texture_2d_GetPrivateData
,
361 d3d8_texture_2d_FreePrivateData
,
362 d3d8_texture_2d_SetPriority
,
363 d3d8_texture_2d_GetPriority
,
364 d3d8_texture_2d_PreLoad
,
365 d3d8_texture_2d_GetType
,
366 /* IDirect3dBaseTexture8 */
367 d3d8_texture_2d_SetLOD
,
368 d3d8_texture_2d_GetLOD
,
369 d3d8_texture_2d_GetLevelCount
,
370 /* IDirect3DTexture8 */
371 d3d8_texture_2d_GetLevelDesc
,
372 d3d8_texture_2d_GetSurfaceLevel
,
373 d3d8_texture_2d_LockRect
,
374 d3d8_texture_2d_UnlockRect
,
375 d3d8_texture_2d_AddDirtyRect
,
378 static HRESULT WINAPI
d3d8_texture_cube_QueryInterface(IDirect3DCubeTexture8
*iface
, REFIID riid
, void **out
)
380 TRACE("iface %p, riid %s, out %p.\n", iface
, debugstr_guid(riid
), out
);
382 if (IsEqualGUID(riid
, &IID_IDirect3DCubeTexture8
)
383 || IsEqualGUID(riid
, &IID_IDirect3DBaseTexture8
)
384 || IsEqualGUID(riid
, &IID_IDirect3DResource8
)
385 || IsEqualGUID(riid
, &IID_IUnknown
))
387 IDirect3DCubeTexture8_AddRef(iface
);
392 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid
));
395 return E_NOINTERFACE
;
398 static ULONG WINAPI
d3d8_texture_cube_AddRef(IDirect3DCubeTexture8
*iface
)
400 struct d3d8_texture
*texture
= impl_from_IDirect3DCubeTexture8(iface
);
401 ULONG ref
= InterlockedIncrement(&texture
->resource
.refcount
);
403 TRACE("%p increasing refcount to %u.\n", iface
, ref
);
407 struct d3d8_surface
*surface
;
409 IDirect3DDevice8_AddRef(texture
->parent_device
);
410 wined3d_mutex_lock();
411 LIST_FOR_EACH_ENTRY(surface
, &texture
->rtv_list
, struct d3d8_surface
, rtv_entry
)
413 wined3d_rendertarget_view_incref(surface
->wined3d_rtv
);
415 wined3d_texture_incref(texture
->wined3d_texture
);
416 wined3d_mutex_unlock();
422 static ULONG WINAPI
d3d8_texture_cube_Release(IDirect3DCubeTexture8
*iface
)
424 struct d3d8_texture
*texture
= impl_from_IDirect3DCubeTexture8(iface
);
425 ULONG ref
= InterlockedDecrement(&texture
->resource
.refcount
);
427 TRACE("%p decreasing refcount to %u.\n", iface
, ref
);
431 IDirect3DDevice8
*parent_device
= texture
->parent_device
;
432 struct d3d8_surface
*surface
;
434 TRACE("Releasing child %p.\n", texture
->wined3d_texture
);
436 wined3d_mutex_lock();
437 LIST_FOR_EACH_ENTRY(surface
, &texture
->rtv_list
, struct d3d8_surface
, rtv_entry
)
439 wined3d_rendertarget_view_decref(surface
->wined3d_rtv
);
441 wined3d_texture_decref(texture
->wined3d_texture
);
442 wined3d_mutex_unlock();
444 /* Release the device last, as it may cause the device to be destroyed. */
445 IDirect3DDevice8_Release(parent_device
);
450 static HRESULT WINAPI
d3d8_texture_cube_GetDevice(IDirect3DCubeTexture8
*iface
, IDirect3DDevice8
**device
)
452 struct d3d8_texture
*texture
= impl_from_IDirect3DCubeTexture8(iface
);
454 TRACE("iface %p, device %p.\n", iface
, device
);
456 *device
= texture
->parent_device
;
457 IDirect3DDevice8_AddRef(*device
);
459 TRACE("Returning device %p.\n", *device
);
464 static HRESULT WINAPI
d3d8_texture_cube_SetPrivateData(IDirect3DCubeTexture8
*iface
,
465 REFGUID guid
, const void *data
, DWORD data_size
, DWORD flags
)
467 struct d3d8_texture
*texture
= impl_from_IDirect3DCubeTexture8(iface
);
468 TRACE("iface %p, guid %s, data %p, data_size %u, flags %#x.\n",
469 iface
, debugstr_guid(guid
), data
, data_size
, flags
);
471 return d3d8_resource_set_private_data(&texture
->resource
, guid
, data
, data_size
, flags
);
474 static HRESULT WINAPI
d3d8_texture_cube_GetPrivateData(IDirect3DCubeTexture8
*iface
,
475 REFGUID guid
, void *data
, DWORD
*data_size
)
477 struct d3d8_texture
*texture
= impl_from_IDirect3DCubeTexture8(iface
);
478 TRACE("iface %p, guid %s, data %p, data_size %p.\n",
479 iface
, debugstr_guid(guid
), data
, data_size
);
481 return d3d8_resource_get_private_data(&texture
->resource
, guid
, data
, data_size
);
484 static HRESULT WINAPI
d3d8_texture_cube_FreePrivateData(IDirect3DCubeTexture8
*iface
, REFGUID guid
)
486 struct d3d8_texture
*texture
= impl_from_IDirect3DCubeTexture8(iface
);
487 TRACE("iface %p, guid %s.\n", iface
, debugstr_guid(guid
));
489 return d3d8_resource_free_private_data(&texture
->resource
, guid
);
492 static DWORD WINAPI
d3d8_texture_cube_SetPriority(IDirect3DCubeTexture8
*iface
, DWORD priority
)
494 struct d3d8_texture
*texture
= impl_from_IDirect3DCubeTexture8(iface
);
495 struct wined3d_resource
*resource
;
498 TRACE("iface %p, priority %u.\n", iface
, priority
);
500 wined3d_mutex_lock();
501 resource
= wined3d_texture_get_resource(texture
->wined3d_texture
);
502 ret
= wined3d_resource_set_priority(resource
, priority
);
503 wined3d_mutex_unlock();
508 static DWORD WINAPI
d3d8_texture_cube_GetPriority(IDirect3DCubeTexture8
*iface
)
510 struct d3d8_texture
*texture
= impl_from_IDirect3DCubeTexture8(iface
);
511 const struct wined3d_resource
*resource
;
514 TRACE("iface %p.\n", iface
);
516 wined3d_mutex_lock();
517 resource
= wined3d_texture_get_resource(texture
->wined3d_texture
);
518 ret
= wined3d_resource_get_priority(resource
);
519 wined3d_mutex_unlock();
524 static void WINAPI
d3d8_texture_cube_PreLoad(IDirect3DCubeTexture8
*iface
)
526 struct d3d8_texture
*texture
= impl_from_IDirect3DCubeTexture8(iface
);
528 TRACE("iface %p.\n", iface
);
530 wined3d_mutex_lock();
531 wined3d_resource_preload(wined3d_texture_get_resource(texture
->wined3d_texture
));
532 wined3d_mutex_unlock();
535 static D3DRESOURCETYPE WINAPI
d3d8_texture_cube_GetType(IDirect3DCubeTexture8
*iface
)
537 TRACE("iface %p.\n", iface
);
539 return D3DRTYPE_CUBETEXTURE
;
542 static DWORD WINAPI
d3d8_texture_cube_SetLOD(IDirect3DCubeTexture8
*iface
, DWORD lod
)
544 struct d3d8_texture
*texture
= impl_from_IDirect3DCubeTexture8(iface
);
547 TRACE("iface %p, lod %u.\n", iface
, lod
);
549 wined3d_mutex_lock();
550 ret
= wined3d_texture_set_lod(texture
->wined3d_texture
, lod
);
551 wined3d_mutex_unlock();
556 static DWORD WINAPI
d3d8_texture_cube_GetLOD(IDirect3DCubeTexture8
*iface
)
558 struct d3d8_texture
*texture
= impl_from_IDirect3DCubeTexture8(iface
);
561 TRACE("iface %p.\n", iface
);
563 wined3d_mutex_lock();
564 ret
= wined3d_texture_get_lod(texture
->wined3d_texture
);
565 wined3d_mutex_unlock();
570 static DWORD WINAPI
d3d8_texture_cube_GetLevelCount(IDirect3DCubeTexture8
*iface
)
572 struct d3d8_texture
*texture
= impl_from_IDirect3DCubeTexture8(iface
);
575 TRACE("iface %p.\n", iface
);
577 wined3d_mutex_lock();
578 ret
= wined3d_texture_get_level_count(texture
->wined3d_texture
);
579 wined3d_mutex_unlock();
584 static HRESULT WINAPI
d3d8_texture_cube_GetLevelDesc(IDirect3DCubeTexture8
*iface
, UINT level
, D3DSURFACE_DESC
*desc
)
586 struct d3d8_texture
*texture
= impl_from_IDirect3DCubeTexture8(iface
);
587 struct wined3d_sub_resource_desc wined3d_desc
;
590 TRACE("iface %p, level %u, desc %p.\n", iface
, level
, desc
);
592 wined3d_mutex_lock();
593 if (level
>= wined3d_texture_get_level_count(texture
->wined3d_texture
))
595 wined3d_mutex_unlock();
596 return D3DERR_INVALIDCALL
;
599 if (SUCCEEDED(hr
= wined3d_texture_get_sub_resource_desc(texture
->wined3d_texture
, level
, &wined3d_desc
)))
601 desc
->Format
= d3dformat_from_wined3dformat(wined3d_desc
.format
);
602 desc
->Type
= D3DRTYPE_SURFACE
;
603 desc
->Usage
= d3dusage_from_wined3dusage(wined3d_desc
.usage
, wined3d_desc
.bind_flags
);
604 desc
->Pool
= d3dpool_from_wined3daccess(wined3d_desc
.access
, wined3d_desc
.usage
);
605 desc
->Size
= wined3d_desc
.size
;
606 desc
->MultiSampleType
= wined3d_desc
.multisample_type
;
607 desc
->Width
= wined3d_desc
.width
;
608 desc
->Height
= wined3d_desc
.height
;
610 wined3d_mutex_unlock();
615 static HRESULT WINAPI
d3d8_texture_cube_GetCubeMapSurface(IDirect3DCubeTexture8
*iface
,
616 D3DCUBEMAP_FACES face
, UINT level
, IDirect3DSurface8
**surface
)
618 struct d3d8_texture
*texture
= impl_from_IDirect3DCubeTexture8(iface
);
619 struct d3d8_surface
*surface_impl
;
620 UINT sub_resource_idx
;
623 TRACE("iface %p, face %#x, level %u, surface %p.\n", iface
, face
, level
, surface
);
625 wined3d_mutex_lock();
626 level_count
= wined3d_texture_get_level_count(texture
->wined3d_texture
);
627 if (level
>= level_count
)
629 wined3d_mutex_unlock();
630 return D3DERR_INVALIDCALL
;
633 sub_resource_idx
= level_count
* face
+ level
;
634 if (!(surface_impl
= wined3d_texture_get_sub_resource_parent(texture
->wined3d_texture
, sub_resource_idx
)))
636 wined3d_mutex_unlock();
637 return D3DERR_INVALIDCALL
;
640 *surface
= &surface_impl
->IDirect3DSurface8_iface
;
641 IDirect3DSurface8_AddRef(*surface
);
642 wined3d_mutex_unlock();
647 static HRESULT WINAPI
d3d8_texture_cube_LockRect(IDirect3DCubeTexture8
*iface
,
648 D3DCUBEMAP_FACES face
, UINT level
, D3DLOCKED_RECT
*locked_rect
, const RECT
*rect
,
651 struct d3d8_texture
*texture
= impl_from_IDirect3DCubeTexture8(iface
);
652 struct d3d8_surface
*surface_impl
;
653 UINT sub_resource_idx
;
656 TRACE("iface %p, face %#x, level %u, locked_rect %p, rect %p, flags %#x.\n",
657 iface
, face
, level
, locked_rect
, rect
, flags
);
659 wined3d_mutex_lock();
660 sub_resource_idx
= wined3d_texture_get_level_count(texture
->wined3d_texture
) * face
+ level
;
661 if (!(surface_impl
= wined3d_texture_get_sub_resource_parent(texture
->wined3d_texture
, sub_resource_idx
)))
662 hr
= D3DERR_INVALIDCALL
;
664 hr
= IDirect3DSurface8_LockRect(&surface_impl
->IDirect3DSurface8_iface
, locked_rect
, rect
, flags
);
665 wined3d_mutex_unlock();
670 static HRESULT WINAPI
d3d8_texture_cube_UnlockRect(IDirect3DCubeTexture8
*iface
,
671 D3DCUBEMAP_FACES face
, UINT level
)
673 struct d3d8_texture
*texture
= impl_from_IDirect3DCubeTexture8(iface
);
674 struct d3d8_surface
*surface_impl
;
675 UINT sub_resource_idx
;
678 TRACE("iface %p, face %#x, level %u.\n", iface
, face
, level
);
680 wined3d_mutex_lock();
681 sub_resource_idx
= wined3d_texture_get_level_count(texture
->wined3d_texture
) * face
+ level
;
682 if (!(surface_impl
= wined3d_texture_get_sub_resource_parent(texture
->wined3d_texture
, sub_resource_idx
)))
683 hr
= D3DERR_INVALIDCALL
;
685 hr
= IDirect3DSurface8_UnlockRect(&surface_impl
->IDirect3DSurface8_iface
);
686 wined3d_mutex_unlock();
691 static HRESULT WINAPI
d3d8_texture_cube_AddDirtyRect(IDirect3DCubeTexture8
*iface
,
692 D3DCUBEMAP_FACES face
, const RECT
*dirty_rect
)
694 struct d3d8_texture
*texture
= impl_from_IDirect3DCubeTexture8(iface
);
697 TRACE("iface %p, face %#x, dirty_rect %s.\n",
698 iface
, face
, wine_dbgstr_rect(dirty_rect
));
700 wined3d_mutex_lock();
702 hr
= wined3d_texture_add_dirty_region(texture
->wined3d_texture
, face
, NULL
);
705 struct wined3d_box dirty_region
;
707 wined3d_box_set(&dirty_region
, dirty_rect
->left
, dirty_rect
->top
, dirty_rect
->right
, dirty_rect
->bottom
, 0, 1);
708 hr
= wined3d_texture_add_dirty_region(texture
->wined3d_texture
, face
, &dirty_region
);
710 wined3d_mutex_unlock();
715 static const IDirect3DCubeTexture8Vtbl Direct3DCubeTexture8_Vtbl
=
718 d3d8_texture_cube_QueryInterface
,
719 d3d8_texture_cube_AddRef
,
720 d3d8_texture_cube_Release
,
721 /* IDirect3DResource8 */
722 d3d8_texture_cube_GetDevice
,
723 d3d8_texture_cube_SetPrivateData
,
724 d3d8_texture_cube_GetPrivateData
,
725 d3d8_texture_cube_FreePrivateData
,
726 d3d8_texture_cube_SetPriority
,
727 d3d8_texture_cube_GetPriority
,
728 d3d8_texture_cube_PreLoad
,
729 d3d8_texture_cube_GetType
,
730 /* IDirect3DBaseTexture8 */
731 d3d8_texture_cube_SetLOD
,
732 d3d8_texture_cube_GetLOD
,
733 d3d8_texture_cube_GetLevelCount
,
734 /* IDirect3DCubeTexture8 */
735 d3d8_texture_cube_GetLevelDesc
,
736 d3d8_texture_cube_GetCubeMapSurface
,
737 d3d8_texture_cube_LockRect
,
738 d3d8_texture_cube_UnlockRect
,
739 d3d8_texture_cube_AddDirtyRect
,
742 static HRESULT WINAPI
d3d8_texture_3d_QueryInterface(IDirect3DVolumeTexture8
*iface
, REFIID riid
, void **out
)
744 TRACE("iface %p, riid %s, out %p.\n", iface
, debugstr_guid(riid
), out
);
746 if (IsEqualGUID(riid
, &IID_IDirect3DVolumeTexture8
)
747 || IsEqualGUID(riid
, &IID_IDirect3DBaseTexture8
)
748 || IsEqualGUID(riid
, &IID_IDirect3DResource8
)
749 || IsEqualGUID(riid
, &IID_IUnknown
))
751 IDirect3DVolumeTexture8_AddRef(iface
);
756 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid
));
759 return E_NOINTERFACE
;
762 static ULONG WINAPI
d3d8_texture_3d_AddRef(IDirect3DVolumeTexture8
*iface
)
764 struct d3d8_texture
*texture
= impl_from_IDirect3DVolumeTexture8(iface
);
765 ULONG ref
= InterlockedIncrement(&texture
->resource
.refcount
);
767 TRACE("%p increasing refcount to %u.\n", iface
, ref
);
771 IDirect3DDevice8_AddRef(texture
->parent_device
);
772 wined3d_mutex_lock();
773 wined3d_texture_incref(texture
->wined3d_texture
);
774 wined3d_mutex_unlock();
780 static ULONG WINAPI
d3d8_texture_3d_Release(IDirect3DVolumeTexture8
*iface
)
782 struct d3d8_texture
*texture
= impl_from_IDirect3DVolumeTexture8(iface
);
783 ULONG ref
= InterlockedDecrement(&texture
->resource
.refcount
);
785 TRACE("%p decreasing refcount to %u.\n", iface
, ref
);
789 IDirect3DDevice8
*parent_device
= texture
->parent_device
;
791 wined3d_mutex_lock();
792 wined3d_texture_decref(texture
->wined3d_texture
);
793 wined3d_mutex_unlock();
795 /* Release the device last, as it may cause the device to be destroyed. */
796 IDirect3DDevice8_Release(parent_device
);
801 static HRESULT WINAPI
d3d8_texture_3d_GetDevice(IDirect3DVolumeTexture8
*iface
, IDirect3DDevice8
**device
)
803 struct d3d8_texture
*texture
= impl_from_IDirect3DVolumeTexture8(iface
);
805 TRACE("iface %p, device %p.\n", iface
, device
);
807 *device
= texture
->parent_device
;
808 IDirect3DDevice8_AddRef(*device
);
810 TRACE("Returning device %p.\n", *device
);
815 static HRESULT WINAPI
d3d8_texture_3d_SetPrivateData(IDirect3DVolumeTexture8
*iface
,
816 REFGUID guid
, const void *data
, DWORD data_size
, DWORD flags
)
818 struct d3d8_texture
*texture
= impl_from_IDirect3DVolumeTexture8(iface
);
819 TRACE("iface %p, guid %s, data %p, data_size %u, flags %#x.\n",
820 iface
, debugstr_guid(guid
), data
, data_size
, flags
);
822 return d3d8_resource_set_private_data(&texture
->resource
, guid
, data
, data_size
, flags
);
825 static HRESULT WINAPI
d3d8_texture_3d_GetPrivateData(IDirect3DVolumeTexture8
*iface
,
826 REFGUID guid
, void *data
, DWORD
*data_size
)
828 struct d3d8_texture
*texture
= impl_from_IDirect3DVolumeTexture8(iface
);
829 TRACE("iface %p, guid %s, data %p, data_size %p.\n",
830 iface
, debugstr_guid(guid
), data
, data_size
);
832 return d3d8_resource_get_private_data(&texture
->resource
, guid
, data
, data_size
);
835 static HRESULT WINAPI
d3d8_texture_3d_FreePrivateData(IDirect3DVolumeTexture8
*iface
, REFGUID guid
)
837 struct d3d8_texture
*texture
= impl_from_IDirect3DVolumeTexture8(iface
);
838 TRACE("iface %p, guid %s.\n", iface
, debugstr_guid(guid
));
840 return d3d8_resource_free_private_data(&texture
->resource
, guid
);
843 static DWORD WINAPI
d3d8_texture_3d_SetPriority(IDirect3DVolumeTexture8
*iface
, DWORD priority
)
845 struct d3d8_texture
*texture
= impl_from_IDirect3DVolumeTexture8(iface
);
846 struct wined3d_resource
*resource
;
849 TRACE("iface %p, priority %u.\n", iface
, priority
);
851 wined3d_mutex_lock();
852 resource
= wined3d_texture_get_resource(texture
->wined3d_texture
);
853 ret
= wined3d_resource_set_priority(resource
, priority
);
854 wined3d_mutex_unlock();
859 static DWORD WINAPI
d3d8_texture_3d_GetPriority(IDirect3DVolumeTexture8
*iface
)
861 struct d3d8_texture
*texture
= impl_from_IDirect3DVolumeTexture8(iface
);
862 const struct wined3d_resource
*resource
;
865 TRACE("iface %p.\n", iface
);
867 wined3d_mutex_lock();
868 resource
= wined3d_texture_get_resource(texture
->wined3d_texture
);
869 ret
= wined3d_resource_get_priority(resource
);
870 wined3d_mutex_unlock();
875 static void WINAPI
d3d8_texture_3d_PreLoad(IDirect3DVolumeTexture8
*iface
)
877 struct d3d8_texture
*texture
= impl_from_IDirect3DVolumeTexture8(iface
);
879 TRACE("iface %p.\n", iface
);
881 wined3d_mutex_lock();
882 wined3d_resource_preload(wined3d_texture_get_resource(texture
->wined3d_texture
));
883 wined3d_mutex_unlock();
886 static D3DRESOURCETYPE WINAPI
d3d8_texture_3d_GetType(IDirect3DVolumeTexture8
*iface
)
888 TRACE("iface %p.\n", iface
);
890 return D3DRTYPE_VOLUMETEXTURE
;
893 static DWORD WINAPI
d3d8_texture_3d_SetLOD(IDirect3DVolumeTexture8
*iface
, DWORD lod
)
895 struct d3d8_texture
*texture
= impl_from_IDirect3DVolumeTexture8(iface
);
898 TRACE("iface %p, lod %u.\n", iface
, lod
);
900 wined3d_mutex_lock();
901 ret
= wined3d_texture_set_lod(texture
->wined3d_texture
, lod
);
902 wined3d_mutex_unlock();
907 static DWORD WINAPI
d3d8_texture_3d_GetLOD(IDirect3DVolumeTexture8
*iface
)
909 struct d3d8_texture
*texture
= impl_from_IDirect3DVolumeTexture8(iface
);
912 TRACE("iface %p.\n", iface
);
914 wined3d_mutex_lock();
915 ret
= wined3d_texture_get_lod(texture
->wined3d_texture
);
916 wined3d_mutex_unlock();
921 static DWORD WINAPI
d3d8_texture_3d_GetLevelCount(IDirect3DVolumeTexture8
*iface
)
923 struct d3d8_texture
*texture
= impl_from_IDirect3DVolumeTexture8(iface
);
926 TRACE("iface %p.\n", iface
);
928 wined3d_mutex_lock();
929 ret
= wined3d_texture_get_level_count(texture
->wined3d_texture
);
930 wined3d_mutex_unlock();
935 static HRESULT WINAPI
d3d8_texture_3d_GetLevelDesc(IDirect3DVolumeTexture8
*iface
, UINT level
, D3DVOLUME_DESC
*desc
)
937 struct d3d8_texture
*texture
= impl_from_IDirect3DVolumeTexture8(iface
);
938 struct wined3d_sub_resource_desc wined3d_desc
;
941 TRACE("iface %p, level %u, desc %p.\n", iface
, level
, desc
);
943 wined3d_mutex_lock();
944 if (SUCCEEDED(hr
= wined3d_texture_get_sub_resource_desc(texture
->wined3d_texture
, level
, &wined3d_desc
)))
946 desc
->Format
= d3dformat_from_wined3dformat(wined3d_desc
.format
);
947 desc
->Type
= D3DRTYPE_VOLUME
;
948 desc
->Usage
= d3dusage_from_wined3dusage(wined3d_desc
.usage
, wined3d_desc
.bind_flags
);
949 desc
->Pool
= d3dpool_from_wined3daccess(wined3d_desc
.access
, wined3d_desc
.usage
);
950 desc
->Size
= wined3d_desc
.size
;
951 desc
->Width
= wined3d_desc
.width
;
952 desc
->Height
= wined3d_desc
.height
;
953 desc
->Depth
= wined3d_desc
.depth
;
955 wined3d_mutex_unlock();
960 static HRESULT WINAPI
d3d8_texture_3d_GetVolumeLevel(IDirect3DVolumeTexture8
*iface
,
961 UINT level
, IDirect3DVolume8
**volume
)
963 struct d3d8_texture
*texture
= impl_from_IDirect3DVolumeTexture8(iface
);
964 struct d3d8_volume
*volume_impl
;
966 TRACE("iface %p, level %u, volume %p.\n", iface
, level
, volume
);
968 wined3d_mutex_lock();
969 if (!(volume_impl
= wined3d_texture_get_sub_resource_parent(texture
->wined3d_texture
, level
)))
971 wined3d_mutex_unlock();
972 return D3DERR_INVALIDCALL
;
975 *volume
= &volume_impl
->IDirect3DVolume8_iface
;
976 IDirect3DVolume8_AddRef(*volume
);
977 wined3d_mutex_unlock();
982 static HRESULT WINAPI
d3d8_texture_3d_LockBox(IDirect3DVolumeTexture8
*iface
,
983 UINT level
, D3DLOCKED_BOX
*locked_box
, const D3DBOX
*box
, DWORD flags
)
985 struct d3d8_texture
*texture
= impl_from_IDirect3DVolumeTexture8(iface
);
986 struct d3d8_volume
*volume_impl
;
989 TRACE("iface %p, level %u, locked_box %p, box %p, flags %#x.\n",
990 iface
, level
, locked_box
, box
, flags
);
992 wined3d_mutex_lock();
993 if (!(volume_impl
= wined3d_texture_get_sub_resource_parent(texture
->wined3d_texture
, level
)))
994 hr
= D3DERR_INVALIDCALL
;
996 hr
= IDirect3DVolume8_LockBox(&volume_impl
->IDirect3DVolume8_iface
, locked_box
, box
, flags
);
997 wined3d_mutex_unlock();
1002 static HRESULT WINAPI
d3d8_texture_3d_UnlockBox(IDirect3DVolumeTexture8
*iface
, UINT level
)
1004 struct d3d8_texture
*texture
= impl_from_IDirect3DVolumeTexture8(iface
);
1005 struct d3d8_volume
*volume_impl
;
1008 TRACE("iface %p, level %u.\n", iface
, level
);
1010 wined3d_mutex_lock();
1011 if (!(volume_impl
= wined3d_texture_get_sub_resource_parent(texture
->wined3d_texture
, level
)))
1012 hr
= D3DERR_INVALIDCALL
;
1014 hr
= IDirect3DVolume8_UnlockBox(&volume_impl
->IDirect3DVolume8_iface
);
1015 wined3d_mutex_unlock();
1020 static HRESULT WINAPI
d3d8_texture_3d_AddDirtyBox(IDirect3DVolumeTexture8
*iface
, const D3DBOX
*dirty_box
)
1022 struct d3d8_texture
*texture
= impl_from_IDirect3DVolumeTexture8(iface
);
1025 TRACE("iface %p, dirty_box %p.\n", iface
, dirty_box
);
1027 wined3d_mutex_lock();
1028 hr
= wined3d_texture_add_dirty_region(texture
->wined3d_texture
, 0, (const struct wined3d_box
*)dirty_box
);
1029 wined3d_mutex_unlock();
1034 static const IDirect3DVolumeTexture8Vtbl Direct3DVolumeTexture8_Vtbl
=
1037 d3d8_texture_3d_QueryInterface
,
1038 d3d8_texture_3d_AddRef
,
1039 d3d8_texture_3d_Release
,
1040 /* IDirect3DResource8 */
1041 d3d8_texture_3d_GetDevice
,
1042 d3d8_texture_3d_SetPrivateData
,
1043 d3d8_texture_3d_GetPrivateData
,
1044 d3d8_texture_3d_FreePrivateData
,
1045 d3d8_texture_3d_SetPriority
,
1046 d3d8_texture_3d_GetPriority
,
1047 d3d8_texture_3d_PreLoad
,
1048 d3d8_texture_3d_GetType
,
1049 /* IDirect3DBaseTexture8 */
1050 d3d8_texture_3d_SetLOD
,
1051 d3d8_texture_3d_GetLOD
,
1052 d3d8_texture_3d_GetLevelCount
,
1053 /* IDirect3DVolumeTexture8 */
1054 d3d8_texture_3d_GetLevelDesc
,
1055 d3d8_texture_3d_GetVolumeLevel
,
1056 d3d8_texture_3d_LockBox
,
1057 d3d8_texture_3d_UnlockBox
,
1058 d3d8_texture_3d_AddDirtyBox
1061 struct d3d8_texture
*unsafe_impl_from_IDirect3DBaseTexture8(IDirect3DBaseTexture8
*iface
)
1066 /* SetTexture() in particular doesn't do a lot of validation on the pointer
1067 * that gets passed in, and passing an invalid pointer works as long as the
1068 * application doesn't try to actually render anything with it, so we print
1069 * a WARN and return NULL instead of having the usual assert() here.
1070 * One application affected by this is Fishdom 2. */
1071 if (iface
->lpVtbl
!= (const IDirect3DBaseTexture8Vtbl
*)&Direct3DTexture8_Vtbl
1072 && iface
->lpVtbl
!= (const IDirect3DBaseTexture8Vtbl
*)&Direct3DCubeTexture8_Vtbl
1073 && iface
->lpVtbl
!= (const IDirect3DBaseTexture8Vtbl
*)&Direct3DVolumeTexture8_Vtbl
)
1075 WARN("%p is not a valid IDirect3DBaseTexture8 interface.\n", iface
);
1079 return CONTAINING_RECORD(iface
, struct d3d8_texture
, IDirect3DBaseTexture8_iface
);
1082 static void STDMETHODCALLTYPE
d3d8_texture_wined3d_object_destroyed(void *parent
)
1084 struct d3d8_texture
*texture
= parent
;
1085 d3d8_resource_cleanup(&texture
->resource
);
1089 static const struct wined3d_parent_ops d3d8_texture_wined3d_parent_ops
=
1091 d3d8_texture_wined3d_object_destroyed
,
1094 HRESULT
texture_init(struct d3d8_texture
*texture
, struct d3d8_device
*device
,
1095 UINT width
, UINT height
, UINT levels
, DWORD usage
, D3DFORMAT format
, D3DPOOL pool
)
1097 struct wined3d_resource_desc desc
;
1101 texture
->IDirect3DBaseTexture8_iface
.lpVtbl
= (const IDirect3DBaseTexture8Vtbl
*)&Direct3DTexture8_Vtbl
;
1102 d3d8_resource_init(&texture
->resource
);
1103 list_init(&texture
->rtv_list
);
1105 desc
.resource_type
= WINED3D_RTYPE_TEXTURE_2D
;
1106 desc
.format
= wined3dformat_from_d3dformat(format
);
1107 desc
.multisample_type
= WINED3D_MULTISAMPLE_NONE
;
1108 desc
.multisample_quality
= 0;
1109 desc
.usage
= usage
& WINED3DUSAGE_MASK
;
1110 if (pool
== D3DPOOL_SCRATCH
)
1111 desc
.usage
|= WINED3DUSAGE_SCRATCH
;
1112 desc
.bind_flags
= wined3d_bind_flags_from_d3d8_usage(usage
) | WINED3D_BIND_SHADER_RESOURCE
;
1113 desc
.access
= wined3daccess_from_d3dpool(pool
, usage
)
1114 | WINED3D_RESOURCE_ACCESS_MAP_R
| WINED3D_RESOURCE_ACCESS_MAP_W
;
1116 desc
.height
= height
;
1120 if (pool
!= D3DPOOL_DEFAULT
|| (usage
& D3DUSAGE_DYNAMIC
))
1121 flags
|= WINED3D_TEXTURE_CREATE_MAPPABLE
;
1124 levels
= wined3d_log2i(max(width
, height
)) + 1;
1126 wined3d_mutex_lock();
1127 hr
= wined3d_texture_create(device
->wined3d_device
, &desc
, 1, levels
, flags
,
1128 NULL
, texture
, &d3d8_texture_wined3d_parent_ops
, &texture
->wined3d_texture
);
1129 wined3d_mutex_unlock();
1132 WARN("Failed to create wined3d texture, hr %#x.\n", hr
);
1136 texture
->parent_device
= &device
->IDirect3DDevice8_iface
;
1137 IDirect3DDevice8_AddRef(texture
->parent_device
);
1142 HRESULT
cubetexture_init(struct d3d8_texture
*texture
, struct d3d8_device
*device
,
1143 UINT edge_length
, UINT levels
, DWORD usage
, D3DFORMAT format
, D3DPOOL pool
)
1145 struct wined3d_resource_desc desc
;
1149 texture
->IDirect3DBaseTexture8_iface
.lpVtbl
= (const IDirect3DBaseTexture8Vtbl
*)&Direct3DCubeTexture8_Vtbl
;
1150 d3d8_resource_init(&texture
->resource
);
1151 list_init(&texture
->rtv_list
);
1153 desc
.resource_type
= WINED3D_RTYPE_TEXTURE_2D
;
1154 desc
.format
= wined3dformat_from_d3dformat(format
);
1155 desc
.multisample_type
= WINED3D_MULTISAMPLE_NONE
;
1156 desc
.multisample_quality
= 0;
1157 desc
.usage
= usage
& WINED3DUSAGE_MASK
;
1158 desc
.usage
|= WINED3DUSAGE_LEGACY_CUBEMAP
;
1159 if (pool
== D3DPOOL_SCRATCH
)
1160 desc
.usage
|= WINED3DUSAGE_SCRATCH
;
1161 desc
.bind_flags
= wined3d_bind_flags_from_d3d8_usage(usage
) | WINED3D_BIND_SHADER_RESOURCE
;
1162 desc
.access
= wined3daccess_from_d3dpool(pool
, usage
)
1163 | WINED3D_RESOURCE_ACCESS_MAP_R
| WINED3D_RESOURCE_ACCESS_MAP_W
;
1164 desc
.width
= edge_length
;
1165 desc
.height
= edge_length
;
1169 if (pool
!= D3DPOOL_DEFAULT
|| (usage
& D3DUSAGE_DYNAMIC
))
1170 flags
|= WINED3D_TEXTURE_CREATE_MAPPABLE
;
1173 levels
= wined3d_log2i(edge_length
) + 1;
1175 wined3d_mutex_lock();
1176 hr
= wined3d_texture_create(device
->wined3d_device
, &desc
, 6, levels
, flags
,
1177 NULL
, texture
, &d3d8_texture_wined3d_parent_ops
, &texture
->wined3d_texture
);
1178 wined3d_mutex_unlock();
1181 WARN("Failed to create wined3d cube texture, hr %#x.\n", hr
);
1185 texture
->parent_device
= &device
->IDirect3DDevice8_iface
;
1186 IDirect3DDevice8_AddRef(texture
->parent_device
);
1191 HRESULT
volumetexture_init(struct d3d8_texture
*texture
, struct d3d8_device
*device
,
1192 UINT width
, UINT height
, UINT depth
, UINT levels
, DWORD usage
, D3DFORMAT format
, D3DPOOL pool
)
1194 struct wined3d_resource_desc desc
;
1197 texture
->IDirect3DBaseTexture8_iface
.lpVtbl
= (const IDirect3DBaseTexture8Vtbl
*)&Direct3DVolumeTexture8_Vtbl
;
1198 d3d8_resource_init(&texture
->resource
);
1199 list_init(&texture
->rtv_list
);
1201 desc
.resource_type
= WINED3D_RTYPE_TEXTURE_3D
;
1202 desc
.format
= wined3dformat_from_d3dformat(format
);
1203 desc
.multisample_type
= WINED3D_MULTISAMPLE_NONE
;
1204 desc
.multisample_quality
= 0;
1205 desc
.usage
= usage
& WINED3DUSAGE_MASK
;
1206 if (pool
== D3DPOOL_SCRATCH
)
1207 desc
.usage
|= WINED3DUSAGE_SCRATCH
;
1208 desc
.bind_flags
= wined3d_bind_flags_from_d3d8_usage(usage
) | WINED3D_BIND_SHADER_RESOURCE
;
1209 desc
.access
= wined3daccess_from_d3dpool(pool
, usage
);
1211 desc
.height
= height
;
1216 levels
= wined3d_log2i(max(max(width
, height
), depth
)) + 1;
1218 wined3d_mutex_lock();
1219 hr
= wined3d_texture_create(device
->wined3d_device
, &desc
, 1, levels
, 0,
1220 NULL
, texture
, &d3d8_texture_wined3d_parent_ops
, &texture
->wined3d_texture
);
1221 wined3d_mutex_unlock();
1224 WARN("Failed to create wined3d volume texture, hr %#x.\n", hr
);
1228 texture
->parent_device
= &device
->IDirect3DDevice8_iface
;
1229 IDirect3DDevice8_AddRef(texture
->parent_device
);