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_texture_preload(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_resource
*sub_resource
;
249 TRACE("iface %p, level %u, desc %p.\n", iface
, level
, desc
);
251 wined3d_mutex_lock();
252 if (!(sub_resource
= wined3d_texture_get_sub_resource(texture
->wined3d_texture
, level
)))
253 hr
= D3DERR_INVALIDCALL
;
256 struct wined3d_resource_desc wined3d_desc
;
258 wined3d_resource_get_desc(sub_resource
, &wined3d_desc
);
259 desc
->Format
= d3dformat_from_wined3dformat(wined3d_desc
.format
);
260 desc
->Type
= wined3d_desc
.resource_type
;
261 desc
->Usage
= wined3d_desc
.usage
& WINED3DUSAGE_MASK
;
262 desc
->Pool
= wined3d_desc
.pool
;
263 desc
->Size
= wined3d_desc
.size
;
264 desc
->MultiSampleType
= wined3d_desc
.multisample_type
;
265 desc
->Width
= wined3d_desc
.width
;
266 desc
->Height
= wined3d_desc
.height
;
268 wined3d_mutex_unlock();
273 static HRESULT WINAPI
d3d8_texture_2d_GetSurfaceLevel(IDirect3DTexture8
*iface
,
274 UINT level
, IDirect3DSurface8
**surface
)
276 struct d3d8_texture
*texture
= impl_from_IDirect3DTexture8(iface
);
277 struct wined3d_resource
*sub_resource
;
278 struct d3d8_surface
*surface_impl
;
280 TRACE("iface %p, level %u, surface %p.\n", iface
, level
, surface
);
282 wined3d_mutex_lock();
283 if (!(sub_resource
= wined3d_texture_get_sub_resource(texture
->wined3d_texture
, level
)))
285 wined3d_mutex_unlock();
286 return D3DERR_INVALIDCALL
;
289 surface_impl
= wined3d_resource_get_parent(sub_resource
);
290 *surface
= &surface_impl
->IDirect3DSurface8_iface
;
291 IDirect3DSurface8_AddRef(*surface
);
292 wined3d_mutex_unlock();
297 static HRESULT WINAPI
d3d8_texture_2d_LockRect(IDirect3DTexture8
*iface
, UINT level
,
298 D3DLOCKED_RECT
*locked_rect
, const RECT
*rect
, DWORD flags
)
300 struct d3d8_texture
*texture
= impl_from_IDirect3DTexture8(iface
);
301 struct wined3d_resource
*sub_resource
;
302 struct d3d8_surface
*surface_impl
;
305 TRACE("iface %p, level %u, locked_rect %p, rect %p, flags %#x.\n",
306 iface
, level
, locked_rect
, rect
, flags
);
308 wined3d_mutex_lock();
309 if (!(sub_resource
= wined3d_texture_get_sub_resource(texture
->wined3d_texture
, level
)))
310 hr
= D3DERR_INVALIDCALL
;
313 surface_impl
= wined3d_resource_get_parent(sub_resource
);
314 hr
= IDirect3DSurface8_LockRect(&surface_impl
->IDirect3DSurface8_iface
, locked_rect
, rect
, flags
);
316 wined3d_mutex_unlock();
321 static HRESULT WINAPI
d3d8_texture_2d_UnlockRect(IDirect3DTexture8
*iface
, UINT level
)
323 struct d3d8_texture
*texture
= impl_from_IDirect3DTexture8(iface
);
324 struct wined3d_resource
*sub_resource
;
325 struct d3d8_surface
*surface_impl
;
328 TRACE("iface %p, level %u.\n", iface
, level
);
330 wined3d_mutex_lock();
331 if (!(sub_resource
= wined3d_texture_get_sub_resource(texture
->wined3d_texture
, level
)))
332 hr
= D3DERR_INVALIDCALL
;
335 surface_impl
= wined3d_resource_get_parent(sub_resource
);
336 hr
= IDirect3DSurface8_UnlockRect(&surface_impl
->IDirect3DSurface8_iface
);
338 wined3d_mutex_unlock();
343 static HRESULT WINAPI
d3d8_texture_2d_AddDirtyRect(IDirect3DTexture8
*iface
, const RECT
*dirty_rect
)
345 struct d3d8_texture
*texture
= impl_from_IDirect3DTexture8(iface
);
348 TRACE("iface %p, dirty_rect %s.\n",
349 iface
, wine_dbgstr_rect(dirty_rect
));
351 wined3d_mutex_lock();
353 hr
= wined3d_texture_add_dirty_region(texture
->wined3d_texture
, 0, NULL
);
356 struct wined3d_box dirty_region
;
358 dirty_region
.left
= dirty_rect
->left
;
359 dirty_region
.top
= dirty_rect
->top
;
360 dirty_region
.right
= dirty_rect
->right
;
361 dirty_region
.bottom
= dirty_rect
->bottom
;
362 dirty_region
.front
= 0;
363 dirty_region
.back
= 1;
364 hr
= wined3d_texture_add_dirty_region(texture
->wined3d_texture
, 0, &dirty_region
);
366 wined3d_mutex_unlock();
371 static const IDirect3DTexture8Vtbl Direct3DTexture8_Vtbl
=
374 d3d8_texture_2d_QueryInterface
,
375 d3d8_texture_2d_AddRef
,
376 d3d8_texture_2d_Release
,
377 /* IDirect3DResource8 */
378 d3d8_texture_2d_GetDevice
,
379 d3d8_texture_2d_SetPrivateData
,
380 d3d8_texture_2d_GetPrivateData
,
381 d3d8_texture_2d_FreePrivateData
,
382 d3d8_texture_2d_SetPriority
,
383 d3d8_texture_2d_GetPriority
,
384 d3d8_texture_2d_PreLoad
,
385 d3d8_texture_2d_GetType
,
386 /* IDirect3dBaseTexture8 */
387 d3d8_texture_2d_SetLOD
,
388 d3d8_texture_2d_GetLOD
,
389 d3d8_texture_2d_GetLevelCount
,
390 /* IDirect3DTexture8 */
391 d3d8_texture_2d_GetLevelDesc
,
392 d3d8_texture_2d_GetSurfaceLevel
,
393 d3d8_texture_2d_LockRect
,
394 d3d8_texture_2d_UnlockRect
,
395 d3d8_texture_2d_AddDirtyRect
,
398 static HRESULT WINAPI
d3d8_texture_cube_QueryInterface(IDirect3DCubeTexture8
*iface
, REFIID riid
, void **out
)
400 TRACE("iface %p, riid %s, out %p.\n", iface
, debugstr_guid(riid
), out
);
402 if (IsEqualGUID(riid
, &IID_IDirect3DCubeTexture8
)
403 || IsEqualGUID(riid
, &IID_IDirect3DBaseTexture8
)
404 || IsEqualGUID(riid
, &IID_IDirect3DResource8
)
405 || IsEqualGUID(riid
, &IID_IUnknown
))
407 IDirect3DCubeTexture8_AddRef(iface
);
412 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid
));
415 return E_NOINTERFACE
;
418 static ULONG WINAPI
d3d8_texture_cube_AddRef(IDirect3DCubeTexture8
*iface
)
420 struct d3d8_texture
*texture
= impl_from_IDirect3DCubeTexture8(iface
);
421 ULONG ref
= InterlockedIncrement(&texture
->resource
.refcount
);
423 TRACE("%p increasing refcount to %u.\n", iface
, ref
);
427 struct d3d8_surface
*surface
;
429 IDirect3DDevice8_AddRef(texture
->parent_device
);
430 wined3d_mutex_lock();
431 LIST_FOR_EACH_ENTRY(surface
, &texture
->rtv_list
, struct d3d8_surface
, rtv_entry
)
433 wined3d_rendertarget_view_incref(surface
->wined3d_rtv
);
435 wined3d_texture_incref(texture
->wined3d_texture
);
436 wined3d_mutex_unlock();
442 static ULONG WINAPI
d3d8_texture_cube_Release(IDirect3DCubeTexture8
*iface
)
444 struct d3d8_texture
*texture
= impl_from_IDirect3DCubeTexture8(iface
);
445 ULONG ref
= InterlockedDecrement(&texture
->resource
.refcount
);
447 TRACE("%p decreasing refcount to %u.\n", iface
, ref
);
451 IDirect3DDevice8
*parent_device
= texture
->parent_device
;
452 struct d3d8_surface
*surface
;
454 TRACE("Releasing child %p.\n", texture
->wined3d_texture
);
456 wined3d_mutex_lock();
457 LIST_FOR_EACH_ENTRY(surface
, &texture
->rtv_list
, struct d3d8_surface
, rtv_entry
)
459 wined3d_rendertarget_view_decref(surface
->wined3d_rtv
);
461 wined3d_texture_decref(texture
->wined3d_texture
);
462 wined3d_mutex_unlock();
464 /* Release the device last, as it may cause the device to be destroyed. */
465 IDirect3DDevice8_Release(parent_device
);
470 static HRESULT WINAPI
d3d8_texture_cube_GetDevice(IDirect3DCubeTexture8
*iface
, IDirect3DDevice8
**device
)
472 struct d3d8_texture
*texture
= impl_from_IDirect3DCubeTexture8(iface
);
474 TRACE("iface %p, device %p.\n", iface
, device
);
476 *device
= texture
->parent_device
;
477 IDirect3DDevice8_AddRef(*device
);
479 TRACE("Returning device %p.\n", *device
);
484 static HRESULT WINAPI
d3d8_texture_cube_SetPrivateData(IDirect3DCubeTexture8
*iface
,
485 REFGUID guid
, const void *data
, DWORD data_size
, DWORD flags
)
487 struct d3d8_texture
*texture
= impl_from_IDirect3DCubeTexture8(iface
);
488 TRACE("iface %p, guid %s, data %p, data_size %u, flags %#x.\n",
489 iface
, debugstr_guid(guid
), data
, data_size
, flags
);
491 return d3d8_resource_set_private_data(&texture
->resource
, guid
, data
, data_size
, flags
);
494 static HRESULT WINAPI
d3d8_texture_cube_GetPrivateData(IDirect3DCubeTexture8
*iface
,
495 REFGUID guid
, void *data
, DWORD
*data_size
)
497 struct d3d8_texture
*texture
= impl_from_IDirect3DCubeTexture8(iface
);
498 TRACE("iface %p, guid %s, data %p, data_size %p.\n",
499 iface
, debugstr_guid(guid
), data
, data_size
);
501 return d3d8_resource_get_private_data(&texture
->resource
, guid
, data
, data_size
);
504 static HRESULT WINAPI
d3d8_texture_cube_FreePrivateData(IDirect3DCubeTexture8
*iface
, REFGUID guid
)
506 struct d3d8_texture
*texture
= impl_from_IDirect3DCubeTexture8(iface
);
507 TRACE("iface %p, guid %s.\n", iface
, debugstr_guid(guid
));
509 return d3d8_resource_free_private_data(&texture
->resource
, guid
);
512 static DWORD WINAPI
d3d8_texture_cube_SetPriority(IDirect3DCubeTexture8
*iface
, DWORD priority
)
514 struct d3d8_texture
*texture
= impl_from_IDirect3DCubeTexture8(iface
);
515 struct wined3d_resource
*resource
;
518 TRACE("iface %p, priority %u.\n", iface
, priority
);
520 wined3d_mutex_lock();
521 resource
= wined3d_texture_get_resource(texture
->wined3d_texture
);
522 ret
= wined3d_resource_set_priority(resource
, priority
);
523 wined3d_mutex_unlock();
528 static DWORD WINAPI
d3d8_texture_cube_GetPriority(IDirect3DCubeTexture8
*iface
)
530 struct d3d8_texture
*texture
= impl_from_IDirect3DCubeTexture8(iface
);
531 const struct wined3d_resource
*resource
;
534 TRACE("iface %p.\n", iface
);
536 wined3d_mutex_lock();
537 resource
= wined3d_texture_get_resource(texture
->wined3d_texture
);
538 ret
= wined3d_resource_get_priority(resource
);
539 wined3d_mutex_unlock();
544 static void WINAPI
d3d8_texture_cube_PreLoad(IDirect3DCubeTexture8
*iface
)
546 struct d3d8_texture
*texture
= impl_from_IDirect3DCubeTexture8(iface
);
548 TRACE("iface %p.\n", iface
);
550 wined3d_mutex_lock();
551 wined3d_texture_preload(texture
->wined3d_texture
);
552 wined3d_mutex_unlock();
555 static D3DRESOURCETYPE WINAPI
d3d8_texture_cube_GetType(IDirect3DCubeTexture8
*iface
)
557 TRACE("iface %p.\n", iface
);
559 return D3DRTYPE_CUBETEXTURE
;
562 static DWORD WINAPI
d3d8_texture_cube_SetLOD(IDirect3DCubeTexture8
*iface
, DWORD lod
)
564 struct d3d8_texture
*texture
= impl_from_IDirect3DCubeTexture8(iface
);
567 TRACE("iface %p, lod %u.\n", iface
, lod
);
569 wined3d_mutex_lock();
570 ret
= wined3d_texture_set_lod(texture
->wined3d_texture
, lod
);
571 wined3d_mutex_unlock();
576 static DWORD WINAPI
d3d8_texture_cube_GetLOD(IDirect3DCubeTexture8
*iface
)
578 struct d3d8_texture
*texture
= impl_from_IDirect3DCubeTexture8(iface
);
581 TRACE("iface %p.\n", iface
);
583 wined3d_mutex_lock();
584 ret
= wined3d_texture_get_lod(texture
->wined3d_texture
);
585 wined3d_mutex_unlock();
590 static DWORD WINAPI
d3d8_texture_cube_GetLevelCount(IDirect3DCubeTexture8
*iface
)
592 struct d3d8_texture
*texture
= impl_from_IDirect3DCubeTexture8(iface
);
595 TRACE("iface %p.\n", iface
);
597 wined3d_mutex_lock();
598 ret
= wined3d_texture_get_level_count(texture
->wined3d_texture
);
599 wined3d_mutex_unlock();
604 static HRESULT WINAPI
d3d8_texture_cube_GetLevelDesc(IDirect3DCubeTexture8
*iface
, UINT level
, D3DSURFACE_DESC
*desc
)
606 struct d3d8_texture
*texture
= impl_from_IDirect3DCubeTexture8(iface
);
607 struct wined3d_resource
*sub_resource
;
610 TRACE("iface %p, level %u, desc %p.\n", iface
, level
, desc
);
612 wined3d_mutex_lock();
613 if (level
>= wined3d_texture_get_level_count(texture
->wined3d_texture
))
615 wined3d_mutex_unlock();
616 return D3DERR_INVALIDCALL
;
619 if (!(sub_resource
= wined3d_texture_get_sub_resource(texture
->wined3d_texture
, level
)))
620 hr
= D3DERR_INVALIDCALL
;
623 struct wined3d_resource_desc wined3d_desc
;
625 wined3d_resource_get_desc(sub_resource
, &wined3d_desc
);
626 desc
->Format
= d3dformat_from_wined3dformat(wined3d_desc
.format
);
627 desc
->Type
= wined3d_desc
.resource_type
;
628 desc
->Usage
= wined3d_desc
.usage
& WINED3DUSAGE_MASK
;
629 desc
->Pool
= wined3d_desc
.pool
;
630 desc
->Size
= wined3d_desc
.size
;
631 desc
->MultiSampleType
= wined3d_desc
.multisample_type
;
632 desc
->Width
= wined3d_desc
.width
;
633 desc
->Height
= wined3d_desc
.height
;
635 wined3d_mutex_unlock();
640 static HRESULT WINAPI
d3d8_texture_cube_GetCubeMapSurface(IDirect3DCubeTexture8
*iface
,
641 D3DCUBEMAP_FACES face
, UINT level
, IDirect3DSurface8
**surface
)
643 struct d3d8_texture
*texture
= impl_from_IDirect3DCubeTexture8(iface
);
644 struct wined3d_resource
*sub_resource
;
645 struct d3d8_surface
*surface_impl
;
646 UINT sub_resource_idx
;
649 TRACE("iface %p, face %#x, level %u, surface %p.\n", iface
, face
, level
, surface
);
651 wined3d_mutex_lock();
652 level_count
= wined3d_texture_get_level_count(texture
->wined3d_texture
);
653 if (level
>= level_count
)
655 wined3d_mutex_unlock();
656 return D3DERR_INVALIDCALL
;
659 sub_resource_idx
= level_count
* face
+ level
;
660 if (!(sub_resource
= wined3d_texture_get_sub_resource(texture
->wined3d_texture
, sub_resource_idx
)))
662 wined3d_mutex_unlock();
663 return D3DERR_INVALIDCALL
;
666 surface_impl
= wined3d_resource_get_parent(sub_resource
);
667 *surface
= &surface_impl
->IDirect3DSurface8_iface
;
668 IDirect3DSurface8_AddRef(*surface
);
669 wined3d_mutex_unlock();
674 static HRESULT WINAPI
d3d8_texture_cube_LockRect(IDirect3DCubeTexture8
*iface
,
675 D3DCUBEMAP_FACES face
, UINT level
, D3DLOCKED_RECT
*locked_rect
, const RECT
*rect
,
678 struct d3d8_texture
*texture
= impl_from_IDirect3DCubeTexture8(iface
);
679 struct wined3d_resource
*sub_resource
;
680 struct d3d8_surface
*surface_impl
;
681 UINT sub_resource_idx
;
684 TRACE("iface %p, face %#x, level %u, locked_rect %p, rect %p, flags %#x.\n",
685 iface
, face
, level
, locked_rect
, rect
, flags
);
687 wined3d_mutex_lock();
688 sub_resource_idx
= wined3d_texture_get_level_count(texture
->wined3d_texture
) * face
+ level
;
689 if (!(sub_resource
= wined3d_texture_get_sub_resource(texture
->wined3d_texture
, sub_resource_idx
)))
690 hr
= D3DERR_INVALIDCALL
;
693 surface_impl
= wined3d_resource_get_parent(sub_resource
);
694 hr
= IDirect3DSurface8_LockRect(&surface_impl
->IDirect3DSurface8_iface
, locked_rect
, rect
, flags
);
696 wined3d_mutex_unlock();
701 static HRESULT WINAPI
d3d8_texture_cube_UnlockRect(IDirect3DCubeTexture8
*iface
,
702 D3DCUBEMAP_FACES face
, UINT level
)
704 struct d3d8_texture
*texture
= impl_from_IDirect3DCubeTexture8(iface
);
705 struct wined3d_resource
*sub_resource
;
706 struct d3d8_surface
*surface_impl
;
707 UINT sub_resource_idx
;
710 TRACE("iface %p, face %#x, level %u.\n", iface
, face
, level
);
712 wined3d_mutex_lock();
713 sub_resource_idx
= wined3d_texture_get_level_count(texture
->wined3d_texture
) * face
+ level
;
714 if (!(sub_resource
= wined3d_texture_get_sub_resource(texture
->wined3d_texture
, sub_resource_idx
)))
715 hr
= D3DERR_INVALIDCALL
;
718 surface_impl
= wined3d_resource_get_parent(sub_resource
);
719 hr
= IDirect3DSurface8_UnlockRect(&surface_impl
->IDirect3DSurface8_iface
);
721 wined3d_mutex_unlock();
726 static HRESULT WINAPI
d3d8_texture_cube_AddDirtyRect(IDirect3DCubeTexture8
*iface
,
727 D3DCUBEMAP_FACES face
, const RECT
*dirty_rect
)
729 struct d3d8_texture
*texture
= impl_from_IDirect3DCubeTexture8(iface
);
732 TRACE("iface %p, face %#x, dirty_rect %s.\n",
733 iface
, face
, wine_dbgstr_rect(dirty_rect
));
735 wined3d_mutex_lock();
737 hr
= wined3d_texture_add_dirty_region(texture
->wined3d_texture
, face
, NULL
);
740 struct wined3d_box dirty_region
;
742 dirty_region
.left
= dirty_rect
->left
;
743 dirty_region
.top
= dirty_rect
->top
;
744 dirty_region
.right
= dirty_rect
->right
;
745 dirty_region
.bottom
= dirty_rect
->bottom
;
746 dirty_region
.front
= 0;
747 dirty_region
.back
= 1;
748 hr
= wined3d_texture_add_dirty_region(texture
->wined3d_texture
, face
, &dirty_region
);
750 wined3d_mutex_unlock();
755 static const IDirect3DCubeTexture8Vtbl Direct3DCubeTexture8_Vtbl
=
758 d3d8_texture_cube_QueryInterface
,
759 d3d8_texture_cube_AddRef
,
760 d3d8_texture_cube_Release
,
761 /* IDirect3DResource8 */
762 d3d8_texture_cube_GetDevice
,
763 d3d8_texture_cube_SetPrivateData
,
764 d3d8_texture_cube_GetPrivateData
,
765 d3d8_texture_cube_FreePrivateData
,
766 d3d8_texture_cube_SetPriority
,
767 d3d8_texture_cube_GetPriority
,
768 d3d8_texture_cube_PreLoad
,
769 d3d8_texture_cube_GetType
,
770 /* IDirect3DBaseTexture8 */
771 d3d8_texture_cube_SetLOD
,
772 d3d8_texture_cube_GetLOD
,
773 d3d8_texture_cube_GetLevelCount
,
774 /* IDirect3DCubeTexture8 */
775 d3d8_texture_cube_GetLevelDesc
,
776 d3d8_texture_cube_GetCubeMapSurface
,
777 d3d8_texture_cube_LockRect
,
778 d3d8_texture_cube_UnlockRect
,
779 d3d8_texture_cube_AddDirtyRect
,
782 static HRESULT WINAPI
d3d8_texture_3d_QueryInterface(IDirect3DVolumeTexture8
*iface
, REFIID riid
, void **out
)
784 TRACE("iface %p, riid %s, out %p.\n", iface
, debugstr_guid(riid
), out
);
786 if (IsEqualGUID(riid
, &IID_IDirect3DVolumeTexture8
)
787 || IsEqualGUID(riid
, &IID_IDirect3DBaseTexture8
)
788 || IsEqualGUID(riid
, &IID_IDirect3DResource8
)
789 || IsEqualGUID(riid
, &IID_IUnknown
))
791 IDirect3DVolumeTexture8_AddRef(iface
);
796 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid
));
799 return E_NOINTERFACE
;
802 static ULONG WINAPI
d3d8_texture_3d_AddRef(IDirect3DVolumeTexture8
*iface
)
804 struct d3d8_texture
*texture
= impl_from_IDirect3DVolumeTexture8(iface
);
805 ULONG ref
= InterlockedIncrement(&texture
->resource
.refcount
);
807 TRACE("%p increasing refcount to %u.\n", iface
, ref
);
811 IDirect3DDevice8_AddRef(texture
->parent_device
);
812 wined3d_mutex_lock();
813 wined3d_texture_incref(texture
->wined3d_texture
);
814 wined3d_mutex_unlock();
820 static ULONG WINAPI
d3d8_texture_3d_Release(IDirect3DVolumeTexture8
*iface
)
822 struct d3d8_texture
*texture
= impl_from_IDirect3DVolumeTexture8(iface
);
823 ULONG ref
= InterlockedDecrement(&texture
->resource
.refcount
);
825 TRACE("%p decreasing refcount to %u.\n", iface
, ref
);
829 IDirect3DDevice8
*parent_device
= texture
->parent_device
;
831 wined3d_mutex_lock();
832 wined3d_texture_decref(texture
->wined3d_texture
);
833 wined3d_mutex_unlock();
835 /* Release the device last, as it may cause the device to be destroyed. */
836 IDirect3DDevice8_Release(parent_device
);
841 static HRESULT WINAPI
d3d8_texture_3d_GetDevice(IDirect3DVolumeTexture8
*iface
, IDirect3DDevice8
**device
)
843 struct d3d8_texture
*texture
= impl_from_IDirect3DVolumeTexture8(iface
);
845 TRACE("iface %p, device %p.\n", iface
, device
);
847 *device
= texture
->parent_device
;
848 IDirect3DDevice8_AddRef(*device
);
850 TRACE("Returning device %p.\n", *device
);
855 static HRESULT WINAPI
d3d8_texture_3d_SetPrivateData(IDirect3DVolumeTexture8
*iface
,
856 REFGUID guid
, const void *data
, DWORD data_size
, DWORD flags
)
858 struct d3d8_texture
*texture
= impl_from_IDirect3DVolumeTexture8(iface
);
859 TRACE("iface %p, guid %s, data %p, data_size %u, flags %#x.\n",
860 iface
, debugstr_guid(guid
), data
, data_size
, flags
);
862 return d3d8_resource_set_private_data(&texture
->resource
, guid
, data
, data_size
, flags
);
865 static HRESULT WINAPI
d3d8_texture_3d_GetPrivateData(IDirect3DVolumeTexture8
*iface
,
866 REFGUID guid
, void *data
, DWORD
*data_size
)
868 struct d3d8_texture
*texture
= impl_from_IDirect3DVolumeTexture8(iface
);
869 TRACE("iface %p, guid %s, data %p, data_size %p.\n",
870 iface
, debugstr_guid(guid
), data
, data_size
);
872 return d3d8_resource_get_private_data(&texture
->resource
, guid
, data
, data_size
);
875 static HRESULT WINAPI
d3d8_texture_3d_FreePrivateData(IDirect3DVolumeTexture8
*iface
, REFGUID guid
)
877 struct d3d8_texture
*texture
= impl_from_IDirect3DVolumeTexture8(iface
);
878 TRACE("iface %p, guid %s.\n", iface
, debugstr_guid(guid
));
880 return d3d8_resource_free_private_data(&texture
->resource
, guid
);
883 static DWORD WINAPI
d3d8_texture_3d_SetPriority(IDirect3DVolumeTexture8
*iface
, DWORD priority
)
885 struct d3d8_texture
*texture
= impl_from_IDirect3DVolumeTexture8(iface
);
886 struct wined3d_resource
*resource
;
889 TRACE("iface %p, priority %u.\n", iface
, priority
);
891 wined3d_mutex_lock();
892 resource
= wined3d_texture_get_resource(texture
->wined3d_texture
);
893 ret
= wined3d_resource_set_priority(resource
, priority
);
894 wined3d_mutex_unlock();
899 static DWORD WINAPI
d3d8_texture_3d_GetPriority(IDirect3DVolumeTexture8
*iface
)
901 struct d3d8_texture
*texture
= impl_from_IDirect3DVolumeTexture8(iface
);
902 const struct wined3d_resource
*resource
;
905 TRACE("iface %p.\n", iface
);
907 wined3d_mutex_lock();
908 resource
= wined3d_texture_get_resource(texture
->wined3d_texture
);
909 ret
= wined3d_resource_get_priority(resource
);
910 wined3d_mutex_unlock();
915 static void WINAPI
d3d8_texture_3d_PreLoad(IDirect3DVolumeTexture8
*iface
)
917 struct d3d8_texture
*texture
= impl_from_IDirect3DVolumeTexture8(iface
);
919 TRACE("iface %p.\n", iface
);
921 wined3d_mutex_lock();
922 wined3d_texture_preload(texture
->wined3d_texture
);
923 wined3d_mutex_unlock();
926 static D3DRESOURCETYPE WINAPI
d3d8_texture_3d_GetType(IDirect3DVolumeTexture8
*iface
)
928 TRACE("iface %p.\n", iface
);
930 return D3DRTYPE_VOLUMETEXTURE
;
933 static DWORD WINAPI
d3d8_texture_3d_SetLOD(IDirect3DVolumeTexture8
*iface
, DWORD lod
)
935 struct d3d8_texture
*texture
= impl_from_IDirect3DVolumeTexture8(iface
);
938 TRACE("iface %p, lod %u.\n", iface
, lod
);
940 wined3d_mutex_lock();
941 ret
= wined3d_texture_set_lod(texture
->wined3d_texture
, lod
);
942 wined3d_mutex_unlock();
947 static DWORD WINAPI
d3d8_texture_3d_GetLOD(IDirect3DVolumeTexture8
*iface
)
949 struct d3d8_texture
*texture
= impl_from_IDirect3DVolumeTexture8(iface
);
952 TRACE("iface %p.\n", iface
);
954 wined3d_mutex_lock();
955 ret
= wined3d_texture_get_lod(texture
->wined3d_texture
);
956 wined3d_mutex_unlock();
961 static DWORD WINAPI
d3d8_texture_3d_GetLevelCount(IDirect3DVolumeTexture8
*iface
)
963 struct d3d8_texture
*texture
= impl_from_IDirect3DVolumeTexture8(iface
);
966 TRACE("iface %p.\n", iface
);
968 wined3d_mutex_lock();
969 ret
= wined3d_texture_get_level_count(texture
->wined3d_texture
);
970 wined3d_mutex_unlock();
975 static HRESULT WINAPI
d3d8_texture_3d_GetLevelDesc(IDirect3DVolumeTexture8
*iface
, UINT level
, D3DVOLUME_DESC
*desc
)
977 struct d3d8_texture
*texture
= impl_from_IDirect3DVolumeTexture8(iface
);
978 struct wined3d_resource
*sub_resource
;
981 TRACE("iface %p, level %u, desc %p.\n", iface
, level
, desc
);
983 wined3d_mutex_lock();
984 if (!(sub_resource
= wined3d_texture_get_sub_resource(texture
->wined3d_texture
, level
)))
985 hr
= D3DERR_INVALIDCALL
;
988 struct wined3d_resource_desc wined3d_desc
;
990 wined3d_resource_get_desc(sub_resource
, &wined3d_desc
);
991 desc
->Format
= d3dformat_from_wined3dformat(wined3d_desc
.format
);
992 desc
->Type
= wined3d_desc
.resource_type
;
993 desc
->Usage
= wined3d_desc
.usage
& WINED3DUSAGE_MASK
;
994 desc
->Pool
= wined3d_desc
.pool
;
995 desc
->Size
= wined3d_desc
.size
;
996 desc
->Width
= wined3d_desc
.width
;
997 desc
->Height
= wined3d_desc
.height
;
998 desc
->Depth
= wined3d_desc
.depth
;
1000 wined3d_mutex_unlock();
1005 static HRESULT WINAPI
d3d8_texture_3d_GetVolumeLevel(IDirect3DVolumeTexture8
*iface
,
1006 UINT level
, IDirect3DVolume8
**volume
)
1008 struct d3d8_texture
*texture
= impl_from_IDirect3DVolumeTexture8(iface
);
1009 struct wined3d_resource
*sub_resource
;
1010 struct d3d8_volume
*volume_impl
;
1012 TRACE("iface %p, level %u, volume %p.\n", iface
, level
, volume
);
1014 wined3d_mutex_lock();
1015 if (!(sub_resource
= wined3d_texture_get_sub_resource(texture
->wined3d_texture
, level
)))
1017 wined3d_mutex_unlock();
1018 return D3DERR_INVALIDCALL
;
1021 volume_impl
= wined3d_resource_get_parent(sub_resource
);
1022 *volume
= &volume_impl
->IDirect3DVolume8_iface
;
1023 IDirect3DVolume8_AddRef(*volume
);
1024 wined3d_mutex_unlock();
1029 static HRESULT WINAPI
d3d8_texture_3d_LockBox(IDirect3DVolumeTexture8
*iface
,
1030 UINT level
, D3DLOCKED_BOX
*locked_box
, const D3DBOX
*box
, DWORD flags
)
1032 struct d3d8_texture
*texture
= impl_from_IDirect3DVolumeTexture8(iface
);
1033 struct wined3d_resource
*sub_resource
;
1034 struct d3d8_volume
*volume_impl
;
1037 TRACE("iface %p, level %u, locked_box %p, box %p, flags %#x.\n",
1038 iface
, level
, locked_box
, box
, flags
);
1040 wined3d_mutex_lock();
1041 if (!(sub_resource
= wined3d_texture_get_sub_resource(texture
->wined3d_texture
, level
)))
1042 hr
= D3DERR_INVALIDCALL
;
1045 volume_impl
= wined3d_resource_get_parent(sub_resource
);
1046 hr
= IDirect3DVolume8_LockBox(&volume_impl
->IDirect3DVolume8_iface
, locked_box
, box
, flags
);
1048 wined3d_mutex_unlock();
1053 static HRESULT WINAPI
d3d8_texture_3d_UnlockBox(IDirect3DVolumeTexture8
*iface
, UINT level
)
1055 struct d3d8_texture
*texture
= impl_from_IDirect3DVolumeTexture8(iface
);
1056 struct wined3d_resource
*sub_resource
;
1057 struct d3d8_volume
*volume_impl
;
1060 TRACE("iface %p, level %u.\n", iface
, level
);
1062 wined3d_mutex_lock();
1063 if (!(sub_resource
= wined3d_texture_get_sub_resource(texture
->wined3d_texture
, level
)))
1064 hr
= D3DERR_INVALIDCALL
;
1067 volume_impl
= wined3d_resource_get_parent(sub_resource
);
1068 hr
= IDirect3DVolume8_UnlockBox(&volume_impl
->IDirect3DVolume8_iface
);
1070 wined3d_mutex_unlock();
1075 static HRESULT WINAPI
d3d8_texture_3d_AddDirtyBox(IDirect3DVolumeTexture8
*iface
, const D3DBOX
*dirty_box
)
1077 struct d3d8_texture
*texture
= impl_from_IDirect3DVolumeTexture8(iface
);
1080 TRACE("iface %p, dirty_box %p.\n", iface
, dirty_box
);
1082 wined3d_mutex_lock();
1083 hr
= wined3d_texture_add_dirty_region(texture
->wined3d_texture
, 0, (const struct wined3d_box
*)dirty_box
);
1084 wined3d_mutex_unlock();
1089 static const IDirect3DVolumeTexture8Vtbl Direct3DVolumeTexture8_Vtbl
=
1092 d3d8_texture_3d_QueryInterface
,
1093 d3d8_texture_3d_AddRef
,
1094 d3d8_texture_3d_Release
,
1095 /* IDirect3DResource8 */
1096 d3d8_texture_3d_GetDevice
,
1097 d3d8_texture_3d_SetPrivateData
,
1098 d3d8_texture_3d_GetPrivateData
,
1099 d3d8_texture_3d_FreePrivateData
,
1100 d3d8_texture_3d_SetPriority
,
1101 d3d8_texture_3d_GetPriority
,
1102 d3d8_texture_3d_PreLoad
,
1103 d3d8_texture_3d_GetType
,
1104 /* IDirect3DBaseTexture8 */
1105 d3d8_texture_3d_SetLOD
,
1106 d3d8_texture_3d_GetLOD
,
1107 d3d8_texture_3d_GetLevelCount
,
1108 /* IDirect3DVolumeTexture8 */
1109 d3d8_texture_3d_GetLevelDesc
,
1110 d3d8_texture_3d_GetVolumeLevel
,
1111 d3d8_texture_3d_LockBox
,
1112 d3d8_texture_3d_UnlockBox
,
1113 d3d8_texture_3d_AddDirtyBox
1116 struct d3d8_texture
*unsafe_impl_from_IDirect3DBaseTexture8(IDirect3DBaseTexture8
*iface
)
1121 /* SetTexture() in particular doesn't do a lot of validation on the pointer
1122 * that gets passed in, and passing an invalid pointer works as long as the
1123 * application doesn't try to actually render anything with it, so we print
1124 * a WARN and return NULL instead of having the usual assert() here.
1125 * One application affected by this is Fishdom 2. */
1126 if (iface
->lpVtbl
!= (const IDirect3DBaseTexture8Vtbl
*)&Direct3DTexture8_Vtbl
1127 && iface
->lpVtbl
!= (const IDirect3DBaseTexture8Vtbl
*)&Direct3DCubeTexture8_Vtbl
1128 && iface
->lpVtbl
!= (const IDirect3DBaseTexture8Vtbl
*)&Direct3DVolumeTexture8_Vtbl
)
1130 WARN("%p is not a valid IDirect3DBaseTexture8 interface.\n", iface
);
1134 return CONTAINING_RECORD(iface
, struct d3d8_texture
, IDirect3DBaseTexture8_iface
);
1137 static void STDMETHODCALLTYPE
d3d8_texture_wined3d_object_destroyed(void *parent
)
1139 struct d3d8_texture
*texture
= parent
;
1140 d3d8_resource_cleanup(&texture
->resource
);
1141 HeapFree(GetProcessHeap(), 0, texture
);
1144 static const struct wined3d_parent_ops d3d8_texture_wined3d_parent_ops
=
1146 d3d8_texture_wined3d_object_destroyed
,
1149 HRESULT
texture_init(struct d3d8_texture
*texture
, struct d3d8_device
*device
,
1150 UINT width
, UINT height
, UINT levels
, DWORD usage
, D3DFORMAT format
, D3DPOOL pool
)
1152 struct wined3d_resource_desc desc
;
1153 DWORD surface_flags
= 0;
1156 texture
->IDirect3DBaseTexture8_iface
.lpVtbl
= (const IDirect3DBaseTexture8Vtbl
*)&Direct3DTexture8_Vtbl
;
1157 d3d8_resource_init(&texture
->resource
);
1158 list_init(&texture
->rtv_list
);
1160 desc
.resource_type
= WINED3D_RTYPE_TEXTURE
;
1161 desc
.format
= wined3dformat_from_d3dformat(format
);
1162 desc
.multisample_type
= WINED3D_MULTISAMPLE_NONE
;
1163 desc
.multisample_quality
= 0;
1164 desc
.usage
= usage
& WINED3DUSAGE_MASK
;
1165 desc
.usage
|= WINED3DUSAGE_TEXTURE
;
1168 desc
.height
= height
;
1172 if (pool
!= D3DPOOL_DEFAULT
|| (usage
& D3DUSAGE_DYNAMIC
))
1173 surface_flags
|= WINED3D_SURFACE_MAPPABLE
;
1176 levels
= wined3d_log2i(max(width
, height
)) + 1;
1178 wined3d_mutex_lock();
1179 hr
= wined3d_texture_create(device
->wined3d_device
, &desc
, levels
, surface_flags
,
1180 NULL
, texture
, &d3d8_texture_wined3d_parent_ops
, &texture
->wined3d_texture
);
1181 wined3d_mutex_unlock();
1184 WARN("Failed to create wined3d texture, hr %#x.\n", hr
);
1188 texture
->parent_device
= &device
->IDirect3DDevice8_iface
;
1189 IDirect3DDevice8_AddRef(texture
->parent_device
);
1194 HRESULT
cubetexture_init(struct d3d8_texture
*texture
, struct d3d8_device
*device
,
1195 UINT edge_length
, UINT levels
, DWORD usage
, D3DFORMAT format
, D3DPOOL pool
)
1197 struct wined3d_resource_desc desc
;
1198 DWORD surface_flags
= 0;
1201 texture
->IDirect3DBaseTexture8_iface
.lpVtbl
= (const IDirect3DBaseTexture8Vtbl
*)&Direct3DCubeTexture8_Vtbl
;
1202 d3d8_resource_init(&texture
->resource
);
1203 list_init(&texture
->rtv_list
);
1205 desc
.resource_type
= WINED3D_RTYPE_CUBE_TEXTURE
;
1206 desc
.format
= wined3dformat_from_d3dformat(format
);
1207 desc
.multisample_type
= WINED3D_MULTISAMPLE_NONE
;
1208 desc
.multisample_quality
= 0;
1209 desc
.usage
= usage
& WINED3DUSAGE_MASK
;
1210 desc
.usage
|= WINED3DUSAGE_TEXTURE
;
1212 desc
.width
= edge_length
;
1213 desc
.height
= edge_length
;
1217 if (pool
!= D3DPOOL_DEFAULT
|| (usage
& D3DUSAGE_DYNAMIC
))
1218 surface_flags
|= WINED3D_SURFACE_MAPPABLE
;
1221 levels
= wined3d_log2i(edge_length
) + 1;
1223 wined3d_mutex_lock();
1224 hr
= wined3d_texture_create(device
->wined3d_device
, &desc
, levels
, surface_flags
,
1225 NULL
, texture
, &d3d8_texture_wined3d_parent_ops
, &texture
->wined3d_texture
);
1226 wined3d_mutex_unlock();
1229 WARN("Failed to create wined3d cube texture, hr %#x.\n", hr
);
1233 texture
->parent_device
= &device
->IDirect3DDevice8_iface
;
1234 IDirect3DDevice8_AddRef(texture
->parent_device
);
1239 HRESULT
volumetexture_init(struct d3d8_texture
*texture
, struct d3d8_device
*device
,
1240 UINT width
, UINT height
, UINT depth
, UINT levels
, DWORD usage
, D3DFORMAT format
, D3DPOOL pool
)
1242 struct wined3d_resource_desc desc
;
1245 texture
->IDirect3DBaseTexture8_iface
.lpVtbl
= (const IDirect3DBaseTexture8Vtbl
*)&Direct3DVolumeTexture8_Vtbl
;
1246 d3d8_resource_init(&texture
->resource
);
1247 list_init(&texture
->rtv_list
);
1249 desc
.resource_type
= WINED3D_RTYPE_VOLUME_TEXTURE
;
1250 desc
.format
= wined3dformat_from_d3dformat(format
);
1251 desc
.multisample_type
= WINED3D_MULTISAMPLE_NONE
;
1252 desc
.multisample_quality
= 0;
1253 desc
.usage
= usage
& WINED3DUSAGE_MASK
;
1254 desc
.usage
|= WINED3DUSAGE_TEXTURE
;
1257 desc
.height
= height
;
1262 levels
= wined3d_log2i(max(max(width
, height
), depth
)) + 1;
1264 wined3d_mutex_lock();
1265 hr
= wined3d_texture_create(device
->wined3d_device
, &desc
, levels
, 0,
1266 NULL
, texture
, &d3d8_texture_wined3d_parent_ops
, &texture
->wined3d_texture
);
1267 wined3d_mutex_unlock();
1270 WARN("Failed to create wined3d volume texture, hr %#x.\n", hr
);
1274 texture
->parent_device
= &device
->IDirect3DDevice8_iface
;
1275 IDirect3DDevice8_AddRef(texture
->parent_device
);