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
19 #include "d3d8_private.h"
21 WINE_DEFAULT_DEBUG_CHANNEL(d3d8
);
23 static ULONG
d3d8_texture_incref(struct d3d8_texture
*texture
)
25 ULONG ref
= InterlockedIncrement(&texture
->resource
.refcount
);
27 TRACE("%p increasing refcount to %lu.\n", texture
, ref
);
31 struct d3d8_surface
*surface
;
33 IDirect3DDevice8_AddRef(texture
->parent_device
);
35 LIST_FOR_EACH_ENTRY(surface
, &texture
->rtv_list
, struct d3d8_surface
, rtv_entry
)
37 wined3d_rendertarget_view_incref(surface
->wined3d_rtv
);
39 wined3d_texture_incref(d3d8_texture_get_draw_texture(texture
));
40 wined3d_mutex_unlock();
46 static ULONG
d3d8_texture_decref(struct d3d8_texture
*texture
)
48 ULONG ref
= InterlockedDecrement(&texture
->resource
.refcount
);
50 TRACE("%p decreasing refcount to %lu.\n", texture
, ref
);
54 IDirect3DDevice8
*parent_device
= texture
->parent_device
;
55 struct d3d8_surface
*surface
;
58 LIST_FOR_EACH_ENTRY(surface
, &texture
->rtv_list
, struct d3d8_surface
, rtv_entry
)
60 wined3d_rendertarget_view_decref(surface
->wined3d_rtv
);
62 wined3d_texture_decref(d3d8_texture_get_draw_texture(texture
));
63 wined3d_mutex_unlock();
65 /* Release the device last, as it may cause the device to be destroyed. */
66 IDirect3DDevice8_Release(parent_device
);
71 static void d3d8_texture_preload(struct d3d8_texture
*texture
)
73 struct d3d8_device
*device
= impl_from_IDirect3DDevice8(texture
->parent_device
);
76 if (texture
->draw_texture
)
77 wined3d_device_update_texture(device
->wined3d_device
, texture
->wined3d_texture
, texture
->draw_texture
);
79 wined3d_resource_preload(wined3d_texture_get_resource(texture
->wined3d_texture
));
80 wined3d_mutex_unlock();
83 static inline struct d3d8_texture
*impl_from_IDirect3DTexture8(IDirect3DTexture8
*iface
)
85 return CONTAINING_RECORD(iface
, struct d3d8_texture
, IDirect3DBaseTexture8_iface
);
88 static inline struct d3d8_texture
*impl_from_IDirect3DCubeTexture8(IDirect3DCubeTexture8
*iface
)
90 return CONTAINING_RECORD(iface
, struct d3d8_texture
, IDirect3DBaseTexture8_iface
);
93 static inline struct d3d8_texture
*impl_from_IDirect3DVolumeTexture8(IDirect3DVolumeTexture8
*iface
)
95 return CONTAINING_RECORD(iface
, struct d3d8_texture
, IDirect3DBaseTexture8_iface
);
98 static HRESULT WINAPI
d3d8_texture_2d_QueryInterface(IDirect3DTexture8
*iface
, REFIID riid
, void **out
)
100 TRACE("iface %p, riid %s, out %p.\n", iface
, debugstr_guid(riid
), out
);
102 if (IsEqualGUID(riid
, &IID_IDirect3DTexture8
)
103 || IsEqualGUID(riid
, &IID_IDirect3DBaseTexture8
)
104 || IsEqualGUID(riid
, &IID_IDirect3DResource8
)
105 || IsEqualGUID(riid
, &IID_IUnknown
))
107 IDirect3DTexture8_AddRef(iface
);
112 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid
));
115 return E_NOINTERFACE
;
118 static ULONG WINAPI
d3d8_texture_2d_AddRef(IDirect3DTexture8
*iface
)
120 struct d3d8_texture
*texture
= impl_from_IDirect3DTexture8(iface
);
122 return d3d8_texture_incref(texture
);
125 static ULONG WINAPI
d3d8_texture_2d_Release(IDirect3DTexture8
*iface
)
127 struct d3d8_texture
*texture
= impl_from_IDirect3DTexture8(iface
);
129 return d3d8_texture_decref(texture
);
132 static HRESULT WINAPI
d3d8_texture_2d_GetDevice(IDirect3DTexture8
*iface
, IDirect3DDevice8
**device
)
134 struct d3d8_texture
*texture
= impl_from_IDirect3DTexture8(iface
);
136 TRACE("iface %p, device %p.\n", iface
, device
);
138 *device
= texture
->parent_device
;
139 IDirect3DDevice8_AddRef(*device
);
141 TRACE("Returning device %p.\n", *device
);
146 static HRESULT WINAPI
d3d8_texture_2d_SetPrivateData(IDirect3DTexture8
*iface
,
147 REFGUID guid
, const void *data
, DWORD data_size
, DWORD flags
)
149 struct d3d8_texture
*texture
= impl_from_IDirect3DTexture8(iface
);
150 TRACE("iface %p, guid %s, data %p, data_size %lu, flags %#lx.\n",
151 iface
, debugstr_guid(guid
), data
, data_size
, flags
);
153 return d3d8_resource_set_private_data(&texture
->resource
, guid
, data
, data_size
, flags
);
156 static HRESULT WINAPI
d3d8_texture_2d_GetPrivateData(IDirect3DTexture8
*iface
,
157 REFGUID guid
, void *data
, DWORD
*data_size
)
159 struct d3d8_texture
*texture
= impl_from_IDirect3DTexture8(iface
);
160 TRACE("iface %p, guid %s, data %p, data_size %p.\n",
161 iface
, debugstr_guid(guid
), data
, data_size
);
163 return d3d8_resource_get_private_data(&texture
->resource
, guid
, data
, data_size
);
166 static HRESULT WINAPI
d3d8_texture_2d_FreePrivateData(IDirect3DTexture8
*iface
, REFGUID guid
)
168 struct d3d8_texture
*texture
= impl_from_IDirect3DTexture8(iface
);
169 TRACE("iface %p, guid %s.\n", iface
, debugstr_guid(guid
));
171 return d3d8_resource_free_private_data(&texture
->resource
, guid
);
174 static DWORD WINAPI
d3d8_texture_2d_SetPriority(IDirect3DTexture8
*iface
, DWORD priority
)
176 struct d3d8_texture
*texture
= impl_from_IDirect3DTexture8(iface
);
177 struct wined3d_resource
*resource
;
180 TRACE("iface %p, priority %lu.\n", iface
, priority
);
182 wined3d_mutex_lock();
183 resource
= wined3d_texture_get_resource(d3d8_texture_get_draw_texture(texture
));
184 ret
= wined3d_resource_set_priority(resource
, priority
);
185 wined3d_mutex_unlock();
190 static DWORD WINAPI
d3d8_texture_2d_GetPriority(IDirect3DTexture8
*iface
)
192 struct d3d8_texture
*texture
= impl_from_IDirect3DTexture8(iface
);
193 const struct wined3d_resource
*resource
;
196 TRACE("iface %p.\n", iface
);
198 wined3d_mutex_lock();
199 resource
= wined3d_texture_get_resource(d3d8_texture_get_draw_texture(texture
));
200 ret
= wined3d_resource_get_priority(resource
);
201 wined3d_mutex_unlock();
206 static void WINAPI
d3d8_texture_2d_PreLoad(IDirect3DTexture8
*iface
)
208 struct d3d8_texture
*texture
= impl_from_IDirect3DTexture8(iface
);
210 TRACE("iface %p.\n", iface
);
212 d3d8_texture_preload(texture
);
215 static D3DRESOURCETYPE WINAPI
d3d8_texture_2d_GetType(IDirect3DTexture8
*iface
)
217 TRACE("iface %p.\n", iface
);
219 return D3DRTYPE_TEXTURE
;
222 static DWORD WINAPI
d3d8_texture_2d_SetLOD(IDirect3DTexture8
*iface
, DWORD lod
)
224 struct d3d8_texture
*texture
= impl_from_IDirect3DTexture8(iface
);
227 TRACE("iface %p, lod %lu.\n", iface
, lod
);
229 wined3d_mutex_lock();
230 ret
= wined3d_texture_set_lod(d3d8_texture_get_draw_texture(texture
), lod
);
231 wined3d_mutex_unlock();
236 static DWORD WINAPI
d3d8_texture_2d_GetLOD(IDirect3DTexture8
*iface
)
238 struct d3d8_texture
*texture
= impl_from_IDirect3DTexture8(iface
);
241 TRACE("iface %p.\n", iface
);
243 wined3d_mutex_lock();
244 ret
= wined3d_texture_get_lod(d3d8_texture_get_draw_texture(texture
));
245 wined3d_mutex_unlock();
250 static DWORD WINAPI
d3d8_texture_2d_GetLevelCount(IDirect3DTexture8
*iface
)
252 struct d3d8_texture
*texture
= impl_from_IDirect3DTexture8(iface
);
255 TRACE("iface %p.\n", iface
);
257 wined3d_mutex_lock();
258 ret
= wined3d_texture_get_level_count(texture
->wined3d_texture
);
259 wined3d_mutex_unlock();
264 static HRESULT WINAPI
d3d8_texture_2d_GetLevelDesc(IDirect3DTexture8
*iface
, UINT level
, D3DSURFACE_DESC
*desc
)
266 struct d3d8_texture
*texture
= impl_from_IDirect3DTexture8(iface
);
267 struct wined3d_sub_resource_desc wined3d_desc
;
270 TRACE("iface %p, level %u, desc %p.\n", iface
, level
, desc
);
272 wined3d_mutex_lock();
273 if (SUCCEEDED(hr
= wined3d_texture_get_sub_resource_desc(texture
->wined3d_texture
, level
, &wined3d_desc
)))
275 desc
->Format
= d3dformat_from_wined3dformat(wined3d_desc
.format
);
276 desc
->Type
= D3DRTYPE_SURFACE
;
277 desc
->Usage
= d3dusage_from_wined3dusage(wined3d_desc
.usage
, wined3d_desc
.bind_flags
);
278 desc
->Pool
= d3dpool_from_wined3daccess(wined3d_desc
.access
, wined3d_desc
.usage
);
279 desc
->Size
= wined3d_desc
.size
;
280 desc
->MultiSampleType
= d3dmultisample_type_from_wined3d(wined3d_desc
.multisample_type
);
281 desc
->Width
= wined3d_desc
.width
;
282 desc
->Height
= wined3d_desc
.height
;
284 wined3d_mutex_unlock();
289 static HRESULT WINAPI
d3d8_texture_2d_GetSurfaceLevel(IDirect3DTexture8
*iface
,
290 UINT level
, IDirect3DSurface8
**surface
)
292 struct d3d8_texture
*texture
= impl_from_IDirect3DTexture8(iface
);
293 struct d3d8_surface
*surface_impl
;
295 TRACE("iface %p, level %u, surface %p.\n", iface
, level
, surface
);
297 wined3d_mutex_lock();
298 if (!(surface_impl
= wined3d_texture_get_sub_resource_parent(texture
->wined3d_texture
, level
)))
300 wined3d_mutex_unlock();
301 return D3DERR_INVALIDCALL
;
304 *surface
= &surface_impl
->IDirect3DSurface8_iface
;
305 IDirect3DSurface8_AddRef(*surface
);
306 wined3d_mutex_unlock();
311 static HRESULT WINAPI
d3d8_texture_2d_LockRect(IDirect3DTexture8
*iface
, UINT level
,
312 D3DLOCKED_RECT
*locked_rect
, const RECT
*rect
, DWORD flags
)
314 struct d3d8_texture
*texture
= impl_from_IDirect3DTexture8(iface
);
315 struct d3d8_surface
*surface_impl
;
318 TRACE("iface %p, level %u, locked_rect %p, rect %p, flags %#lx.\n",
319 iface
, level
, locked_rect
, rect
, flags
);
321 wined3d_mutex_lock();
322 if (!(surface_impl
= wined3d_texture_get_sub_resource_parent(texture
->wined3d_texture
, level
)))
323 hr
= D3DERR_INVALIDCALL
;
325 hr
= IDirect3DSurface8_LockRect(&surface_impl
->IDirect3DSurface8_iface
, locked_rect
, rect
, flags
);
326 wined3d_mutex_unlock();
331 static HRESULT WINAPI
d3d8_texture_2d_UnlockRect(IDirect3DTexture8
*iface
, UINT level
)
333 struct d3d8_texture
*texture
= impl_from_IDirect3DTexture8(iface
);
334 struct d3d8_surface
*surface_impl
;
337 TRACE("iface %p, level %u.\n", iface
, level
);
339 wined3d_mutex_lock();
340 if (!(surface_impl
= wined3d_texture_get_sub_resource_parent(texture
->wined3d_texture
, level
)))
341 hr
= D3DERR_INVALIDCALL
;
343 hr
= IDirect3DSurface8_UnlockRect(&surface_impl
->IDirect3DSurface8_iface
);
344 wined3d_mutex_unlock();
349 static HRESULT WINAPI
d3d8_texture_2d_AddDirtyRect(IDirect3DTexture8
*iface
, const RECT
*dirty_rect
)
351 struct d3d8_texture
*texture
= impl_from_IDirect3DTexture8(iface
);
354 TRACE("iface %p, dirty_rect %s.\n",
355 iface
, wine_dbgstr_rect(dirty_rect
));
357 wined3d_mutex_lock();
359 hr
= wined3d_texture_add_dirty_region(texture
->wined3d_texture
, 0, NULL
);
362 struct wined3d_box dirty_region
;
364 wined3d_box_set(&dirty_region
, dirty_rect
->left
, dirty_rect
->top
, dirty_rect
->right
, dirty_rect
->bottom
, 0, 1);
365 hr
= wined3d_texture_add_dirty_region(texture
->wined3d_texture
, 0, &dirty_region
);
367 wined3d_mutex_unlock();
372 static const IDirect3DTexture8Vtbl Direct3DTexture8_Vtbl
=
375 d3d8_texture_2d_QueryInterface
,
376 d3d8_texture_2d_AddRef
,
377 d3d8_texture_2d_Release
,
378 /* IDirect3DResource8 */
379 d3d8_texture_2d_GetDevice
,
380 d3d8_texture_2d_SetPrivateData
,
381 d3d8_texture_2d_GetPrivateData
,
382 d3d8_texture_2d_FreePrivateData
,
383 d3d8_texture_2d_SetPriority
,
384 d3d8_texture_2d_GetPriority
,
385 d3d8_texture_2d_PreLoad
,
386 d3d8_texture_2d_GetType
,
387 /* IDirect3dBaseTexture8 */
388 d3d8_texture_2d_SetLOD
,
389 d3d8_texture_2d_GetLOD
,
390 d3d8_texture_2d_GetLevelCount
,
391 /* IDirect3DTexture8 */
392 d3d8_texture_2d_GetLevelDesc
,
393 d3d8_texture_2d_GetSurfaceLevel
,
394 d3d8_texture_2d_LockRect
,
395 d3d8_texture_2d_UnlockRect
,
396 d3d8_texture_2d_AddDirtyRect
,
399 static HRESULT WINAPI
d3d8_texture_cube_QueryInterface(IDirect3DCubeTexture8
*iface
, REFIID riid
, void **out
)
401 TRACE("iface %p, riid %s, out %p.\n", iface
, debugstr_guid(riid
), out
);
403 if (IsEqualGUID(riid
, &IID_IDirect3DCubeTexture8
)
404 || IsEqualGUID(riid
, &IID_IDirect3DBaseTexture8
)
405 || IsEqualGUID(riid
, &IID_IDirect3DResource8
)
406 || IsEqualGUID(riid
, &IID_IUnknown
))
408 IDirect3DCubeTexture8_AddRef(iface
);
413 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid
));
416 return E_NOINTERFACE
;
419 static ULONG WINAPI
d3d8_texture_cube_AddRef(IDirect3DCubeTexture8
*iface
)
421 struct d3d8_texture
*texture
= impl_from_IDirect3DCubeTexture8(iface
);
423 return d3d8_texture_incref(texture
);
426 static ULONG WINAPI
d3d8_texture_cube_Release(IDirect3DCubeTexture8
*iface
)
428 struct d3d8_texture
*texture
= impl_from_IDirect3DCubeTexture8(iface
);
430 return d3d8_texture_decref(texture
);
433 static HRESULT WINAPI
d3d8_texture_cube_GetDevice(IDirect3DCubeTexture8
*iface
, IDirect3DDevice8
**device
)
435 struct d3d8_texture
*texture
= impl_from_IDirect3DCubeTexture8(iface
);
437 TRACE("iface %p, device %p.\n", iface
, device
);
439 *device
= texture
->parent_device
;
440 IDirect3DDevice8_AddRef(*device
);
442 TRACE("Returning device %p.\n", *device
);
447 static HRESULT WINAPI
d3d8_texture_cube_SetPrivateData(IDirect3DCubeTexture8
*iface
,
448 REFGUID guid
, const void *data
, DWORD data_size
, DWORD flags
)
450 struct d3d8_texture
*texture
= impl_from_IDirect3DCubeTexture8(iface
);
451 TRACE("iface %p, guid %s, data %p, data_size %lu, flags %#lx.\n",
452 iface
, debugstr_guid(guid
), data
, data_size
, flags
);
454 return d3d8_resource_set_private_data(&texture
->resource
, guid
, data
, data_size
, flags
);
457 static HRESULT WINAPI
d3d8_texture_cube_GetPrivateData(IDirect3DCubeTexture8
*iface
,
458 REFGUID guid
, void *data
, DWORD
*data_size
)
460 struct d3d8_texture
*texture
= impl_from_IDirect3DCubeTexture8(iface
);
461 TRACE("iface %p, guid %s, data %p, data_size %p.\n",
462 iface
, debugstr_guid(guid
), data
, data_size
);
464 return d3d8_resource_get_private_data(&texture
->resource
, guid
, data
, data_size
);
467 static HRESULT WINAPI
d3d8_texture_cube_FreePrivateData(IDirect3DCubeTexture8
*iface
, REFGUID guid
)
469 struct d3d8_texture
*texture
= impl_from_IDirect3DCubeTexture8(iface
);
470 TRACE("iface %p, guid %s.\n", iface
, debugstr_guid(guid
));
472 return d3d8_resource_free_private_data(&texture
->resource
, guid
);
475 static DWORD WINAPI
d3d8_texture_cube_SetPriority(IDirect3DCubeTexture8
*iface
, DWORD priority
)
477 struct d3d8_texture
*texture
= impl_from_IDirect3DCubeTexture8(iface
);
478 struct wined3d_resource
*resource
;
481 TRACE("iface %p, priority %lu.\n", iface
, priority
);
483 wined3d_mutex_lock();
484 resource
= wined3d_texture_get_resource(d3d8_texture_get_draw_texture(texture
));
485 ret
= wined3d_resource_set_priority(resource
, priority
);
486 wined3d_mutex_unlock();
491 static DWORD WINAPI
d3d8_texture_cube_GetPriority(IDirect3DCubeTexture8
*iface
)
493 struct d3d8_texture
*texture
= impl_from_IDirect3DCubeTexture8(iface
);
494 const struct wined3d_resource
*resource
;
497 TRACE("iface %p.\n", iface
);
499 wined3d_mutex_lock();
500 resource
= wined3d_texture_get_resource(d3d8_texture_get_draw_texture(texture
));
501 ret
= wined3d_resource_get_priority(resource
);
502 wined3d_mutex_unlock();
507 static void WINAPI
d3d8_texture_cube_PreLoad(IDirect3DCubeTexture8
*iface
)
509 struct d3d8_texture
*texture
= impl_from_IDirect3DCubeTexture8(iface
);
511 TRACE("iface %p.\n", iface
);
513 d3d8_texture_preload(texture
);
516 static D3DRESOURCETYPE WINAPI
d3d8_texture_cube_GetType(IDirect3DCubeTexture8
*iface
)
518 TRACE("iface %p.\n", iface
);
520 return D3DRTYPE_CUBETEXTURE
;
523 static DWORD WINAPI
d3d8_texture_cube_SetLOD(IDirect3DCubeTexture8
*iface
, DWORD lod
)
525 struct d3d8_texture
*texture
= impl_from_IDirect3DCubeTexture8(iface
);
528 TRACE("iface %p, lod %lu.\n", iface
, lod
);
530 wined3d_mutex_lock();
531 ret
= wined3d_texture_set_lod(d3d8_texture_get_draw_texture(texture
), lod
);
532 wined3d_mutex_unlock();
537 static DWORD WINAPI
d3d8_texture_cube_GetLOD(IDirect3DCubeTexture8
*iface
)
539 struct d3d8_texture
*texture
= impl_from_IDirect3DCubeTexture8(iface
);
542 TRACE("iface %p.\n", iface
);
544 wined3d_mutex_lock();
545 ret
= wined3d_texture_get_lod(d3d8_texture_get_draw_texture(texture
));
546 wined3d_mutex_unlock();
551 static DWORD WINAPI
d3d8_texture_cube_GetLevelCount(IDirect3DCubeTexture8
*iface
)
553 struct d3d8_texture
*texture
= impl_from_IDirect3DCubeTexture8(iface
);
556 TRACE("iface %p.\n", iface
);
558 wined3d_mutex_lock();
559 ret
= wined3d_texture_get_level_count(texture
->wined3d_texture
);
560 wined3d_mutex_unlock();
565 static HRESULT WINAPI
d3d8_texture_cube_GetLevelDesc(IDirect3DCubeTexture8
*iface
, UINT level
, D3DSURFACE_DESC
*desc
)
567 struct d3d8_texture
*texture
= impl_from_IDirect3DCubeTexture8(iface
);
568 struct wined3d_sub_resource_desc wined3d_desc
;
571 TRACE("iface %p, level %u, desc %p.\n", iface
, level
, desc
);
573 wined3d_mutex_lock();
574 if (level
>= wined3d_texture_get_level_count(texture
->wined3d_texture
))
576 wined3d_mutex_unlock();
577 return D3DERR_INVALIDCALL
;
580 if (SUCCEEDED(hr
= wined3d_texture_get_sub_resource_desc(texture
->wined3d_texture
, level
, &wined3d_desc
)))
582 desc
->Format
= d3dformat_from_wined3dformat(wined3d_desc
.format
);
583 desc
->Type
= D3DRTYPE_SURFACE
;
584 desc
->Usage
= d3dusage_from_wined3dusage(wined3d_desc
.usage
, wined3d_desc
.bind_flags
);
585 desc
->Pool
= d3dpool_from_wined3daccess(wined3d_desc
.access
, wined3d_desc
.usage
);
586 desc
->Size
= wined3d_desc
.size
;
587 desc
->MultiSampleType
= d3dmultisample_type_from_wined3d(wined3d_desc
.multisample_type
);
588 desc
->Width
= wined3d_desc
.width
;
589 desc
->Height
= wined3d_desc
.height
;
591 wined3d_mutex_unlock();
596 static HRESULT WINAPI
d3d8_texture_cube_GetCubeMapSurface(IDirect3DCubeTexture8
*iface
,
597 D3DCUBEMAP_FACES face
, UINT level
, IDirect3DSurface8
**surface
)
599 struct d3d8_texture
*texture
= impl_from_IDirect3DCubeTexture8(iface
);
600 struct d3d8_surface
*surface_impl
;
601 UINT sub_resource_idx
;
604 TRACE("iface %p, face %#x, level %u, surface %p.\n", iface
, face
, level
, surface
);
606 wined3d_mutex_lock();
607 level_count
= wined3d_texture_get_level_count(texture
->wined3d_texture
);
608 if (level
>= level_count
)
610 wined3d_mutex_unlock();
611 return D3DERR_INVALIDCALL
;
614 sub_resource_idx
= level_count
* face
+ level
;
615 if (!(surface_impl
= wined3d_texture_get_sub_resource_parent(texture
->wined3d_texture
, sub_resource_idx
)))
617 wined3d_mutex_unlock();
618 return D3DERR_INVALIDCALL
;
621 *surface
= &surface_impl
->IDirect3DSurface8_iface
;
622 IDirect3DSurface8_AddRef(*surface
);
623 wined3d_mutex_unlock();
628 static HRESULT WINAPI
d3d8_texture_cube_LockRect(IDirect3DCubeTexture8
*iface
,
629 D3DCUBEMAP_FACES face
, UINT level
, D3DLOCKED_RECT
*locked_rect
, const RECT
*rect
,
632 struct d3d8_texture
*texture
= impl_from_IDirect3DCubeTexture8(iface
);
633 struct d3d8_surface
*surface_impl
;
634 UINT sub_resource_idx
;
637 TRACE("iface %p, face %#x, level %u, locked_rect %p, rect %p, flags %#lx.\n",
638 iface
, face
, level
, locked_rect
, rect
, flags
);
640 wined3d_mutex_lock();
641 sub_resource_idx
= wined3d_texture_get_level_count(texture
->wined3d_texture
) * face
+ level
;
642 if (!(surface_impl
= wined3d_texture_get_sub_resource_parent(texture
->wined3d_texture
, sub_resource_idx
)))
643 hr
= D3DERR_INVALIDCALL
;
645 hr
= IDirect3DSurface8_LockRect(&surface_impl
->IDirect3DSurface8_iface
, locked_rect
, rect
, flags
);
646 wined3d_mutex_unlock();
651 static HRESULT WINAPI
d3d8_texture_cube_UnlockRect(IDirect3DCubeTexture8
*iface
,
652 D3DCUBEMAP_FACES face
, UINT level
)
654 struct d3d8_texture
*texture
= impl_from_IDirect3DCubeTexture8(iface
);
655 struct d3d8_surface
*surface_impl
;
656 UINT sub_resource_idx
;
659 TRACE("iface %p, face %#x, level %u.\n", iface
, face
, level
);
661 wined3d_mutex_lock();
662 sub_resource_idx
= wined3d_texture_get_level_count(texture
->wined3d_texture
) * face
+ level
;
663 if (!(surface_impl
= wined3d_texture_get_sub_resource_parent(texture
->wined3d_texture
, sub_resource_idx
)))
664 hr
= D3DERR_INVALIDCALL
;
666 hr
= IDirect3DSurface8_UnlockRect(&surface_impl
->IDirect3DSurface8_iface
);
667 wined3d_mutex_unlock();
672 static HRESULT WINAPI
d3d8_texture_cube_AddDirtyRect(IDirect3DCubeTexture8
*iface
,
673 D3DCUBEMAP_FACES face
, const RECT
*dirty_rect
)
675 struct d3d8_texture
*texture
= impl_from_IDirect3DCubeTexture8(iface
);
678 TRACE("iface %p, face %#x, dirty_rect %s.\n",
679 iface
, face
, wine_dbgstr_rect(dirty_rect
));
681 wined3d_mutex_lock();
683 hr
= wined3d_texture_add_dirty_region(texture
->wined3d_texture
, face
, NULL
);
686 struct wined3d_box dirty_region
;
688 wined3d_box_set(&dirty_region
, dirty_rect
->left
, dirty_rect
->top
, dirty_rect
->right
, dirty_rect
->bottom
, 0, 1);
689 hr
= wined3d_texture_add_dirty_region(texture
->wined3d_texture
, face
, &dirty_region
);
691 wined3d_mutex_unlock();
696 static const IDirect3DCubeTexture8Vtbl Direct3DCubeTexture8_Vtbl
=
699 d3d8_texture_cube_QueryInterface
,
700 d3d8_texture_cube_AddRef
,
701 d3d8_texture_cube_Release
,
702 /* IDirect3DResource8 */
703 d3d8_texture_cube_GetDevice
,
704 d3d8_texture_cube_SetPrivateData
,
705 d3d8_texture_cube_GetPrivateData
,
706 d3d8_texture_cube_FreePrivateData
,
707 d3d8_texture_cube_SetPriority
,
708 d3d8_texture_cube_GetPriority
,
709 d3d8_texture_cube_PreLoad
,
710 d3d8_texture_cube_GetType
,
711 /* IDirect3DBaseTexture8 */
712 d3d8_texture_cube_SetLOD
,
713 d3d8_texture_cube_GetLOD
,
714 d3d8_texture_cube_GetLevelCount
,
715 /* IDirect3DCubeTexture8 */
716 d3d8_texture_cube_GetLevelDesc
,
717 d3d8_texture_cube_GetCubeMapSurface
,
718 d3d8_texture_cube_LockRect
,
719 d3d8_texture_cube_UnlockRect
,
720 d3d8_texture_cube_AddDirtyRect
,
723 static HRESULT WINAPI
d3d8_texture_3d_QueryInterface(IDirect3DVolumeTexture8
*iface
, REFIID riid
, void **out
)
725 TRACE("iface %p, riid %s, out %p.\n", iface
, debugstr_guid(riid
), out
);
727 if (IsEqualGUID(riid
, &IID_IDirect3DVolumeTexture8
)
728 || IsEqualGUID(riid
, &IID_IDirect3DBaseTexture8
)
729 || IsEqualGUID(riid
, &IID_IDirect3DResource8
)
730 || IsEqualGUID(riid
, &IID_IUnknown
))
732 IDirect3DVolumeTexture8_AddRef(iface
);
737 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid
));
740 return E_NOINTERFACE
;
743 static ULONG WINAPI
d3d8_texture_3d_AddRef(IDirect3DVolumeTexture8
*iface
)
745 struct d3d8_texture
*texture
= impl_from_IDirect3DVolumeTexture8(iface
);
747 return d3d8_texture_incref(texture
);
750 static ULONG WINAPI
d3d8_texture_3d_Release(IDirect3DVolumeTexture8
*iface
)
752 struct d3d8_texture
*texture
= impl_from_IDirect3DVolumeTexture8(iface
);
754 return d3d8_texture_decref(texture
);
757 static HRESULT WINAPI
d3d8_texture_3d_GetDevice(IDirect3DVolumeTexture8
*iface
, IDirect3DDevice8
**device
)
759 struct d3d8_texture
*texture
= impl_from_IDirect3DVolumeTexture8(iface
);
761 TRACE("iface %p, device %p.\n", iface
, device
);
763 *device
= texture
->parent_device
;
764 IDirect3DDevice8_AddRef(*device
);
766 TRACE("Returning device %p.\n", *device
);
771 static HRESULT WINAPI
d3d8_texture_3d_SetPrivateData(IDirect3DVolumeTexture8
*iface
,
772 REFGUID guid
, const void *data
, DWORD data_size
, DWORD flags
)
774 struct d3d8_texture
*texture
= impl_from_IDirect3DVolumeTexture8(iface
);
775 TRACE("iface %p, guid %s, data %p, data_size %lu, flags %#lx.\n",
776 iface
, debugstr_guid(guid
), data
, data_size
, flags
);
778 return d3d8_resource_set_private_data(&texture
->resource
, guid
, data
, data_size
, flags
);
781 static HRESULT WINAPI
d3d8_texture_3d_GetPrivateData(IDirect3DVolumeTexture8
*iface
,
782 REFGUID guid
, void *data
, DWORD
*data_size
)
784 struct d3d8_texture
*texture
= impl_from_IDirect3DVolumeTexture8(iface
);
785 TRACE("iface %p, guid %s, data %p, data_size %p.\n",
786 iface
, debugstr_guid(guid
), data
, data_size
);
788 return d3d8_resource_get_private_data(&texture
->resource
, guid
, data
, data_size
);
791 static HRESULT WINAPI
d3d8_texture_3d_FreePrivateData(IDirect3DVolumeTexture8
*iface
, REFGUID guid
)
793 struct d3d8_texture
*texture
= impl_from_IDirect3DVolumeTexture8(iface
);
794 TRACE("iface %p, guid %s.\n", iface
, debugstr_guid(guid
));
796 return d3d8_resource_free_private_data(&texture
->resource
, guid
);
799 static DWORD WINAPI
d3d8_texture_3d_SetPriority(IDirect3DVolumeTexture8
*iface
, DWORD priority
)
801 struct d3d8_texture
*texture
= impl_from_IDirect3DVolumeTexture8(iface
);
802 struct wined3d_resource
*resource
;
805 TRACE("iface %p, priority %lu.\n", iface
, priority
);
807 wined3d_mutex_lock();
808 resource
= wined3d_texture_get_resource(d3d8_texture_get_draw_texture(texture
));
809 ret
= wined3d_resource_set_priority(resource
, priority
);
810 wined3d_mutex_unlock();
815 static DWORD WINAPI
d3d8_texture_3d_GetPriority(IDirect3DVolumeTexture8
*iface
)
817 struct d3d8_texture
*texture
= impl_from_IDirect3DVolumeTexture8(iface
);
818 const struct wined3d_resource
*resource
;
821 TRACE("iface %p.\n", iface
);
823 wined3d_mutex_lock();
824 resource
= wined3d_texture_get_resource(d3d8_texture_get_draw_texture(texture
));
825 ret
= wined3d_resource_get_priority(resource
);
826 wined3d_mutex_unlock();
831 static void WINAPI
d3d8_texture_3d_PreLoad(IDirect3DVolumeTexture8
*iface
)
833 struct d3d8_texture
*texture
= impl_from_IDirect3DVolumeTexture8(iface
);
835 TRACE("iface %p.\n", iface
);
837 d3d8_texture_preload(texture
);
840 static D3DRESOURCETYPE WINAPI
d3d8_texture_3d_GetType(IDirect3DVolumeTexture8
*iface
)
842 TRACE("iface %p.\n", iface
);
844 return D3DRTYPE_VOLUMETEXTURE
;
847 static DWORD WINAPI
d3d8_texture_3d_SetLOD(IDirect3DVolumeTexture8
*iface
, DWORD lod
)
849 struct d3d8_texture
*texture
= impl_from_IDirect3DVolumeTexture8(iface
);
852 TRACE("iface %p, lod %lu.\n", iface
, lod
);
854 wined3d_mutex_lock();
855 ret
= wined3d_texture_set_lod(d3d8_texture_get_draw_texture(texture
), lod
);
856 wined3d_mutex_unlock();
861 static DWORD WINAPI
d3d8_texture_3d_GetLOD(IDirect3DVolumeTexture8
*iface
)
863 struct d3d8_texture
*texture
= impl_from_IDirect3DVolumeTexture8(iface
);
866 TRACE("iface %p.\n", iface
);
868 wined3d_mutex_lock();
869 ret
= wined3d_texture_get_lod(d3d8_texture_get_draw_texture(texture
));
870 wined3d_mutex_unlock();
875 static DWORD WINAPI
d3d8_texture_3d_GetLevelCount(IDirect3DVolumeTexture8
*iface
)
877 struct d3d8_texture
*texture
= impl_from_IDirect3DVolumeTexture8(iface
);
880 TRACE("iface %p.\n", iface
);
882 wined3d_mutex_lock();
883 ret
= wined3d_texture_get_level_count(texture
->wined3d_texture
);
884 wined3d_mutex_unlock();
889 static HRESULT WINAPI
d3d8_texture_3d_GetLevelDesc(IDirect3DVolumeTexture8
*iface
, UINT level
, D3DVOLUME_DESC
*desc
)
891 struct d3d8_texture
*texture
= impl_from_IDirect3DVolumeTexture8(iface
);
892 struct wined3d_sub_resource_desc wined3d_desc
;
895 TRACE("iface %p, level %u, desc %p.\n", iface
, level
, desc
);
897 wined3d_mutex_lock();
898 if (SUCCEEDED(hr
= wined3d_texture_get_sub_resource_desc(texture
->wined3d_texture
, level
, &wined3d_desc
)))
900 desc
->Format
= d3dformat_from_wined3dformat(wined3d_desc
.format
);
901 desc
->Type
= D3DRTYPE_VOLUME
;
902 desc
->Usage
= d3dusage_from_wined3dusage(wined3d_desc
.usage
, wined3d_desc
.bind_flags
);
903 desc
->Pool
= d3dpool_from_wined3daccess(wined3d_desc
.access
, wined3d_desc
.usage
);
904 desc
->Size
= wined3d_desc
.size
;
905 desc
->Width
= wined3d_desc
.width
;
906 desc
->Height
= wined3d_desc
.height
;
907 desc
->Depth
= wined3d_desc
.depth
;
909 wined3d_mutex_unlock();
914 static HRESULT WINAPI
d3d8_texture_3d_GetVolumeLevel(IDirect3DVolumeTexture8
*iface
,
915 UINT level
, IDirect3DVolume8
**volume
)
917 struct d3d8_texture
*texture
= impl_from_IDirect3DVolumeTexture8(iface
);
918 struct d3d8_volume
*volume_impl
;
920 TRACE("iface %p, level %u, volume %p.\n", iface
, level
, volume
);
922 wined3d_mutex_lock();
923 if (!(volume_impl
= wined3d_texture_get_sub_resource_parent(texture
->wined3d_texture
, level
)))
925 wined3d_mutex_unlock();
926 return D3DERR_INVALIDCALL
;
929 *volume
= &volume_impl
->IDirect3DVolume8_iface
;
930 IDirect3DVolume8_AddRef(*volume
);
931 wined3d_mutex_unlock();
936 static HRESULT WINAPI
d3d8_texture_3d_LockBox(IDirect3DVolumeTexture8
*iface
,
937 UINT level
, D3DLOCKED_BOX
*locked_box
, const D3DBOX
*box
, DWORD flags
)
939 struct d3d8_texture
*texture
= impl_from_IDirect3DVolumeTexture8(iface
);
940 struct d3d8_volume
*volume_impl
;
943 TRACE("iface %p, level %u, locked_box %p, box %p, flags %#lx.\n",
944 iface
, level
, locked_box
, box
, flags
);
946 wined3d_mutex_lock();
947 if (!(volume_impl
= wined3d_texture_get_sub_resource_parent(texture
->wined3d_texture
, level
)))
948 hr
= D3DERR_INVALIDCALL
;
950 hr
= IDirect3DVolume8_LockBox(&volume_impl
->IDirect3DVolume8_iface
, locked_box
, box
, flags
);
951 wined3d_mutex_unlock();
956 static HRESULT WINAPI
d3d8_texture_3d_UnlockBox(IDirect3DVolumeTexture8
*iface
, UINT level
)
958 struct d3d8_texture
*texture
= impl_from_IDirect3DVolumeTexture8(iface
);
959 struct d3d8_volume
*volume_impl
;
962 TRACE("iface %p, level %u.\n", iface
, level
);
964 wined3d_mutex_lock();
965 if (!(volume_impl
= wined3d_texture_get_sub_resource_parent(texture
->wined3d_texture
, level
)))
966 hr
= D3DERR_INVALIDCALL
;
968 hr
= IDirect3DVolume8_UnlockBox(&volume_impl
->IDirect3DVolume8_iface
);
969 wined3d_mutex_unlock();
974 static HRESULT WINAPI
d3d8_texture_3d_AddDirtyBox(IDirect3DVolumeTexture8
*iface
, const D3DBOX
*dirty_box
)
976 struct d3d8_texture
*texture
= impl_from_IDirect3DVolumeTexture8(iface
);
979 TRACE("iface %p, dirty_box %p.\n", iface
, dirty_box
);
981 wined3d_mutex_lock();
982 hr
= wined3d_texture_add_dirty_region(texture
->wined3d_texture
, 0, (const struct wined3d_box
*)dirty_box
);
983 wined3d_mutex_unlock();
988 static const IDirect3DVolumeTexture8Vtbl Direct3DVolumeTexture8_Vtbl
=
991 d3d8_texture_3d_QueryInterface
,
992 d3d8_texture_3d_AddRef
,
993 d3d8_texture_3d_Release
,
994 /* IDirect3DResource8 */
995 d3d8_texture_3d_GetDevice
,
996 d3d8_texture_3d_SetPrivateData
,
997 d3d8_texture_3d_GetPrivateData
,
998 d3d8_texture_3d_FreePrivateData
,
999 d3d8_texture_3d_SetPriority
,
1000 d3d8_texture_3d_GetPriority
,
1001 d3d8_texture_3d_PreLoad
,
1002 d3d8_texture_3d_GetType
,
1003 /* IDirect3DBaseTexture8 */
1004 d3d8_texture_3d_SetLOD
,
1005 d3d8_texture_3d_GetLOD
,
1006 d3d8_texture_3d_GetLevelCount
,
1007 /* IDirect3DVolumeTexture8 */
1008 d3d8_texture_3d_GetLevelDesc
,
1009 d3d8_texture_3d_GetVolumeLevel
,
1010 d3d8_texture_3d_LockBox
,
1011 d3d8_texture_3d_UnlockBox
,
1012 d3d8_texture_3d_AddDirtyBox
1015 struct d3d8_texture
*unsafe_impl_from_IDirect3DBaseTexture8(IDirect3DBaseTexture8
*iface
)
1020 /* SetTexture() in particular doesn't do a lot of validation on the pointer
1021 * that gets passed in, and passing an invalid pointer works as long as the
1022 * application doesn't try to actually render anything with it, so we print
1023 * a WARN and return NULL instead of having the usual assert() here.
1024 * One application affected by this is Fishdom 2. */
1025 if (iface
->lpVtbl
!= (const IDirect3DBaseTexture8Vtbl
*)&Direct3DTexture8_Vtbl
1026 && iface
->lpVtbl
!= (const IDirect3DBaseTexture8Vtbl
*)&Direct3DCubeTexture8_Vtbl
1027 && iface
->lpVtbl
!= (const IDirect3DBaseTexture8Vtbl
*)&Direct3DVolumeTexture8_Vtbl
)
1029 WARN("%p is not a valid IDirect3DBaseTexture8 interface.\n", iface
);
1033 return CONTAINING_RECORD(iface
, struct d3d8_texture
, IDirect3DBaseTexture8_iface
);
1036 static void STDMETHODCALLTYPE
d3d8_texture_wined3d_object_destroyed(void *parent
)
1038 struct d3d8_texture
*texture
= parent
;
1040 /* If the texture was managed, release the sysmem copy now. */
1041 if (texture
->draw_texture
)
1042 wined3d_texture_decref(texture
->wined3d_texture
);
1043 d3d8_resource_cleanup(&texture
->resource
);
1047 static const struct wined3d_parent_ops d3d8_texture_wined3d_parent_ops
=
1049 d3d8_texture_wined3d_object_destroyed
,
1052 static HRESULT
d3d8_texture_init(struct d3d8_texture
*texture
, struct d3d8_device
*device
,
1053 const struct wined3d_resource_desc
*desc
, D3DPOOL pool
, unsigned int layer_count
, unsigned int level_count
)
1055 unsigned int flags
= 0;
1058 d3d8_resource_init(&texture
->resource
);
1059 list_init(&texture
->rtv_list
);
1062 level_count
= wined3d_log2i(max(max(desc
->width
, desc
->height
), desc
->depth
)) + 1;
1064 if (pool
== D3DPOOL_SYSTEMMEM
|| pool
== D3DPOOL_MANAGED
)
1065 flags
|= WINED3D_TEXTURE_CREATE_RECORD_DIRTY_REGIONS
;
1067 wined3d_mutex_lock();
1069 if (pool
== D3DPOOL_MANAGED
)
1071 struct wined3d_resource_desc managed_desc
= *desc
;
1073 managed_desc
.access
= WINED3D_RESOURCE_ACCESS_CPU
| WINED3D_RESOURCE_ACCESS_MAP_R
| WINED3D_RESOURCE_ACCESS_MAP_W
;
1074 managed_desc
.bind_flags
= 0;
1075 if (FAILED(hr
= wined3d_texture_create(device
->wined3d_device
, &managed_desc
, layer_count
, level_count
, flags
,
1076 NULL
, texture
, &d3d8_null_wined3d_parent_ops
, &texture
->wined3d_texture
)))
1078 wined3d_mutex_unlock();
1079 WARN("Failed to create sysmem texture, hr %#lx.\n", hr
);
1083 managed_desc
.access
= WINED3D_RESOURCE_ACCESS_GPU
;
1084 managed_desc
.bind_flags
= desc
->bind_flags
;
1085 if (FAILED(hr
= wined3d_texture_create(device
->wined3d_device
, &managed_desc
, layer_count
, level_count
, 0,
1086 NULL
, texture
, &d3d8_texture_wined3d_parent_ops
, &texture
->draw_texture
)))
1088 wined3d_texture_decref(texture
->wined3d_texture
);
1089 wined3d_mutex_unlock();
1090 WARN("Failed to create draw texture, hr %#lx.\n", hr
);
1096 if (FAILED(hr
= wined3d_texture_create(device
->wined3d_device
, desc
, layer_count
, level_count
, flags
,
1097 NULL
, texture
, &d3d8_texture_wined3d_parent_ops
, &texture
->wined3d_texture
)))
1099 wined3d_mutex_unlock();
1100 WARN("Failed to create wined3d texture, hr %#lx.\n", hr
);
1104 wined3d_mutex_unlock();
1106 texture
->parent_device
= &device
->IDirect3DDevice8_iface
;
1107 IDirect3DDevice8_AddRef(texture
->parent_device
);
1112 HRESULT
d3d8_texture_2d_init(struct d3d8_texture
*texture
, struct d3d8_device
*device
, unsigned int width
,
1113 unsigned int height
, unsigned int level_count
, DWORD usage
, D3DFORMAT format
, D3DPOOL pool
)
1115 struct wined3d_resource_desc desc
;
1117 desc
.resource_type
= WINED3D_RTYPE_TEXTURE_2D
;
1118 desc
.format
= wined3dformat_from_d3dformat(format
);
1119 desc
.multisample_type
= WINED3D_MULTISAMPLE_NONE
;
1120 desc
.multisample_quality
= 0;
1121 desc
.usage
= wined3d_usage_from_d3d(pool
, usage
);
1122 desc
.bind_flags
= wined3d_bind_flags_from_d3d8_usage(usage
) | WINED3D_BIND_SHADER_RESOURCE
;
1123 desc
.access
= wined3daccess_from_d3dpool(pool
, usage
);
1125 desc
.height
= height
;
1129 if (usage
& D3DUSAGE_WRITEONLY
)
1131 WARN("Texture can't be created with the D3DUSAGE_WRITEONLY flag, returning D3DERR_INVALIDCALL.\n");
1132 return D3DERR_INVALIDCALL
;
1135 texture
->IDirect3DBaseTexture8_iface
.lpVtbl
= (const IDirect3DBaseTexture8Vtbl
*)&Direct3DTexture8_Vtbl
;
1136 return d3d8_texture_init(texture
, device
, &desc
, pool
, 1, level_count
);
1139 HRESULT
d3d8_texture_cube_init(struct d3d8_texture
*texture
, struct d3d8_device
*device
,
1140 unsigned int edge_length
, unsigned int level_count
, DWORD usage
, D3DFORMAT format
, D3DPOOL pool
)
1142 struct wined3d_resource_desc desc
;
1144 desc
.resource_type
= WINED3D_RTYPE_TEXTURE_2D
;
1145 desc
.format
= wined3dformat_from_d3dformat(format
);
1146 desc
.multisample_type
= WINED3D_MULTISAMPLE_NONE
;
1147 desc
.multisample_quality
= 0;
1148 desc
.usage
= wined3d_usage_from_d3d(pool
, usage
) | WINED3DUSAGE_LEGACY_CUBEMAP
;
1149 desc
.bind_flags
= wined3d_bind_flags_from_d3d8_usage(usage
) | WINED3D_BIND_SHADER_RESOURCE
;
1150 desc
.access
= wined3daccess_from_d3dpool(pool
, usage
);
1151 desc
.width
= edge_length
;
1152 desc
.height
= edge_length
;
1156 if (usage
& D3DUSAGE_WRITEONLY
)
1158 WARN("Texture can't be created with the D3DUSAGE_WRITEONLY flag, returning D3DERR_INVALIDCALL.\n");
1159 return D3DERR_INVALIDCALL
;
1162 texture
->IDirect3DBaseTexture8_iface
.lpVtbl
= (const IDirect3DBaseTexture8Vtbl
*)&Direct3DCubeTexture8_Vtbl
;
1163 return d3d8_texture_init(texture
, device
, &desc
, pool
, 6, level_count
);
1166 HRESULT
d3d8_texture_3d_init(struct d3d8_texture
*texture
, struct d3d8_device
*device
, unsigned int width
,
1167 unsigned int height
, unsigned int depth
, unsigned int level_count
, DWORD usage
, D3DFORMAT format
, D3DPOOL pool
)
1169 struct wined3d_resource_desc desc
;
1171 /* In d3d8, 3D textures can't be used as rendertarget or depth/stencil buffer. */
1172 if (usage
& (D3DUSAGE_RENDERTARGET
| D3DUSAGE_DEPTHSTENCIL
))
1173 return D3DERR_INVALIDCALL
;
1175 desc
.resource_type
= WINED3D_RTYPE_TEXTURE_3D
;
1176 desc
.format
= wined3dformat_from_d3dformat(format
);
1177 desc
.multisample_type
= WINED3D_MULTISAMPLE_NONE
;
1178 desc
.multisample_quality
= 0;
1179 desc
.usage
= wined3d_usage_from_d3d(pool
, usage
);
1180 desc
.bind_flags
= wined3d_bind_flags_from_d3d8_usage(usage
) | WINED3D_BIND_SHADER_RESOURCE
;
1181 desc
.access
= wined3daccess_from_d3dpool(pool
, usage
);
1183 desc
.height
= height
;
1187 if (usage
& D3DUSAGE_WRITEONLY
)
1189 WARN("Texture can't be created with the D3DUSAGE_WRITEONLY flags, returning D3DERR_INVALIDCALL.\n");
1190 return D3DERR_INVALIDCALL
;
1193 texture
->IDirect3DBaseTexture8_iface
.lpVtbl
= (const IDirect3DBaseTexture8Vtbl
*)&Direct3DVolumeTexture8_Vtbl
;
1194 return d3d8_texture_init(texture
, device
, &desc
, pool
, 1, level_count
);