2 * Copyright 2009 Henri Verbeet for CodeWeavers
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
21 #include "wine/port.h"
23 #include "d3d11_private.h"
25 WINE_DEFAULT_DEBUG_CHANNEL(d3d11
);
27 static inline struct d3d10_texture2d
*impl_from_ID3D10Texture2D(ID3D10Texture2D
*iface
)
29 return CONTAINING_RECORD(iface
, struct d3d10_texture2d
, ID3D10Texture2D_iface
);
32 /* IUnknown methods */
34 static HRESULT STDMETHODCALLTYPE
d3d10_texture2d_QueryInterface(ID3D10Texture2D
*iface
, REFIID riid
, void **object
)
36 struct d3d10_texture2d
*This
= impl_from_ID3D10Texture2D(iface
);
38 TRACE("iface %p, riid %s, object %p\n", iface
, debugstr_guid(riid
), object
);
40 if (IsEqualGUID(riid
, &IID_ID3D10Texture2D
)
41 || IsEqualGUID(riid
, &IID_ID3D10Resource
)
42 || IsEqualGUID(riid
, &IID_ID3D10DeviceChild
)
43 || IsEqualGUID(riid
, &IID_IUnknown
))
45 IUnknown_AddRef(iface
);
50 if (This
->dxgi_surface
)
52 TRACE("Forwarding to dxgi surface\n");
53 return IUnknown_QueryInterface(This
->dxgi_surface
, riid
, object
);
56 WARN("%s not implemented, returning E_NOINTERFACE\n", debugstr_guid(riid
));
62 static ULONG STDMETHODCALLTYPE
d3d10_texture2d_AddRef(ID3D10Texture2D
*iface
)
64 struct d3d10_texture2d
*This
= impl_from_ID3D10Texture2D(iface
);
65 ULONG refcount
= InterlockedIncrement(&This
->refcount
);
67 TRACE("%p increasing refcount to %u\n", This
, refcount
);
71 ID3D10Device1_AddRef(This
->device
);
73 wined3d_texture_incref(This
->wined3d_texture
);
74 wined3d_mutex_unlock();
80 static void STDMETHODCALLTYPE
d3d10_texture2d_wined3d_object_released(void *parent
)
82 struct d3d10_texture2d
*This
= parent
;
84 if (This
->dxgi_surface
) IUnknown_Release(This
->dxgi_surface
);
85 wined3d_private_store_cleanup(&This
->private_store
);
86 HeapFree(GetProcessHeap(), 0, This
);
89 static ULONG STDMETHODCALLTYPE
d3d10_texture2d_Release(ID3D10Texture2D
*iface
)
91 struct d3d10_texture2d
*This
= impl_from_ID3D10Texture2D(iface
);
92 ULONG refcount
= InterlockedDecrement(&This
->refcount
);
94 TRACE("%p decreasing refcount to %u\n", This
, refcount
);
98 ID3D10Device1
*device
= This
->device
;
100 wined3d_mutex_lock();
101 wined3d_texture_decref(This
->wined3d_texture
);
102 wined3d_mutex_unlock();
103 /* Release the device last, it may cause the wined3d device to be
105 ID3D10Device1_Release(device
);
111 /* ID3D10DeviceChild methods */
113 static void STDMETHODCALLTYPE
d3d10_texture2d_GetDevice(ID3D10Texture2D
*iface
, ID3D10Device
**device
)
115 struct d3d10_texture2d
*texture
= impl_from_ID3D10Texture2D(iface
);
117 TRACE("iface %p, device %p.\n", iface
, device
);
119 *device
= (ID3D10Device
*)texture
->device
;
120 ID3D10Device_AddRef(*device
);
123 static HRESULT STDMETHODCALLTYPE
d3d10_texture2d_GetPrivateData(ID3D10Texture2D
*iface
,
124 REFGUID guid
, UINT
*data_size
, void *data
)
126 struct d3d10_texture2d
*texture
= impl_from_ID3D10Texture2D(iface
);
127 IDXGISurface
*dxgi_surface
;
130 TRACE("iface %p, guid %s, data_size %p, data %p.\n",
131 iface
, debugstr_guid(guid
), data_size
, data
);
133 if (texture
->dxgi_surface
134 && SUCCEEDED(IUnknown_QueryInterface(texture
->dxgi_surface
, &IID_IDXGISurface
, (void **)&dxgi_surface
)))
136 hr
= IDXGISurface_GetPrivateData(dxgi_surface
, guid
, data_size
, data
);
137 IDXGISurface_Release(dxgi_surface
);
141 return d3d10_get_private_data(&texture
->private_store
, guid
, data_size
, data
);
144 static HRESULT STDMETHODCALLTYPE
d3d10_texture2d_SetPrivateData(ID3D10Texture2D
*iface
,
145 REFGUID guid
, UINT data_size
, const void *data
)
147 struct d3d10_texture2d
*texture
= impl_from_ID3D10Texture2D(iface
);
148 IDXGISurface
*dxgi_surface
;
151 TRACE("iface %p, guid %s, data_size %u, data %p.\n",
152 iface
, debugstr_guid(guid
), data_size
, data
);
154 if (texture
->dxgi_surface
155 && SUCCEEDED(IUnknown_QueryInterface(texture
->dxgi_surface
, &IID_IDXGISurface
, (void **)&dxgi_surface
)))
157 hr
= IDXGISurface_SetPrivateData(dxgi_surface
, guid
, data_size
, data
);
158 IDXGISurface_Release(dxgi_surface
);
162 return d3d10_set_private_data(&texture
->private_store
, guid
, data_size
, data
);
165 static HRESULT STDMETHODCALLTYPE
d3d10_texture2d_SetPrivateDataInterface(ID3D10Texture2D
*iface
,
166 REFGUID guid
, const IUnknown
*data
)
168 struct d3d10_texture2d
*texture
= impl_from_ID3D10Texture2D(iface
);
169 IDXGISurface
*dxgi_surface
;
172 TRACE("iface %p, guid %s, data %p.\n", iface
, debugstr_guid(guid
), data
);
174 if (texture
->dxgi_surface
175 && SUCCEEDED(IUnknown_QueryInterface(texture
->dxgi_surface
, &IID_IDXGISurface
, (void **)&dxgi_surface
)))
177 hr
= IDXGISurface_SetPrivateDataInterface(dxgi_surface
, guid
, data
);
178 IDXGISurface_Release(dxgi_surface
);
182 return d3d10_set_private_data_interface(&texture
->private_store
, guid
, data
);
185 /* ID3D10Resource methods */
187 static void STDMETHODCALLTYPE
d3d10_texture2d_GetType(ID3D10Texture2D
*iface
,
188 D3D10_RESOURCE_DIMENSION
*resource_dimension
)
190 TRACE("iface %p, resource_dimension %p\n", iface
, resource_dimension
);
192 *resource_dimension
= D3D10_RESOURCE_DIMENSION_TEXTURE2D
;
195 static void STDMETHODCALLTYPE
d3d10_texture2d_SetEvictionPriority(ID3D10Texture2D
*iface
, UINT eviction_priority
)
197 FIXME("iface %p, eviction_priority %u stub!\n", iface
, eviction_priority
);
200 static UINT STDMETHODCALLTYPE
d3d10_texture2d_GetEvictionPriority(ID3D10Texture2D
*iface
)
202 FIXME("iface %p stub!\n", iface
);
207 /* ID3D10Texture2D methods */
209 static HRESULT STDMETHODCALLTYPE
d3d10_texture2d_Map(ID3D10Texture2D
*iface
, UINT sub_resource_idx
,
210 D3D10_MAP map_type
, UINT map_flags
, D3D10_MAPPED_TEXTURE2D
*mapped_texture
)
212 struct d3d10_texture2d
*texture
= impl_from_ID3D10Texture2D(iface
);
213 struct wined3d_map_desc wined3d_map_desc
;
214 struct wined3d_resource
*sub_resource
;
217 TRACE("iface %p, sub_resource_idx %u, map_type %u, map_flags %#x, mapped_texture %p.\n",
218 iface
, sub_resource_idx
, map_type
, map_flags
, mapped_texture
);
221 FIXME("Ignoring map_flags %#x.\n", map_flags
);
223 wined3d_mutex_lock();
224 if (!(sub_resource
= wined3d_texture_get_sub_resource(texture
->wined3d_texture
, sub_resource_idx
)))
226 else if (SUCCEEDED(hr
= wined3d_surface_map(wined3d_surface_from_resource(sub_resource
),
227 &wined3d_map_desc
, NULL
, wined3d_map_flags_from_d3d10_map_type(map_type
))))
229 mapped_texture
->pData
= wined3d_map_desc
.data
;
230 mapped_texture
->RowPitch
= wined3d_map_desc
.row_pitch
;
232 wined3d_mutex_unlock();
237 static void STDMETHODCALLTYPE
d3d10_texture2d_Unmap(ID3D10Texture2D
*iface
, UINT sub_resource_idx
)
239 struct d3d10_texture2d
*texture
= impl_from_ID3D10Texture2D(iface
);
240 struct wined3d_resource
*sub_resource
;
242 TRACE("iface %p, sub_resource_idx %u.\n", iface
, sub_resource_idx
);
244 wined3d_mutex_lock();
245 if (!(sub_resource
= wined3d_texture_get_sub_resource(texture
->wined3d_texture
, sub_resource_idx
)))
247 wined3d_mutex_unlock();
251 wined3d_surface_unmap(wined3d_surface_from_resource(sub_resource
));
252 wined3d_mutex_unlock();
255 static void STDMETHODCALLTYPE
d3d10_texture2d_GetDesc(ID3D10Texture2D
*iface
, D3D10_TEXTURE2D_DESC
*desc
)
257 struct d3d10_texture2d
*texture
= impl_from_ID3D10Texture2D(iface
);
258 struct wined3d_resource_desc wined3d_desc
;
260 TRACE("iface %p, desc %p\n", iface
, desc
);
262 *desc
= texture
->desc
;
264 wined3d_mutex_lock();
265 wined3d_resource_get_desc(wined3d_texture_get_resource(texture
->wined3d_texture
), &wined3d_desc
);
266 wined3d_mutex_unlock();
268 /* FIXME: Resizing swapchain buffers can cause these to change. We'd like
269 * to get everything from wined3d, but e.g. bind flags don't exist as such
271 desc
->Width
= wined3d_desc
.width
;
272 desc
->Height
= wined3d_desc
.height
;
273 desc
->Format
= dxgi_format_from_wined3dformat(wined3d_desc
.format
);
274 desc
->SampleDesc
.Count
= wined3d_desc
.multisample_type
== WINED3D_MULTISAMPLE_NONE
275 ? 1 : wined3d_desc
.multisample_type
;
276 desc
->SampleDesc
.Quality
= wined3d_desc
.multisample_quality
;
279 static const struct ID3D10Texture2DVtbl d3d10_texture2d_vtbl
=
281 /* IUnknown methods */
282 d3d10_texture2d_QueryInterface
,
283 d3d10_texture2d_AddRef
,
284 d3d10_texture2d_Release
,
285 /* ID3D10DeviceChild methods */
286 d3d10_texture2d_GetDevice
,
287 d3d10_texture2d_GetPrivateData
,
288 d3d10_texture2d_SetPrivateData
,
289 d3d10_texture2d_SetPrivateDataInterface
,
290 /* ID3D10Resource methods */
291 d3d10_texture2d_GetType
,
292 d3d10_texture2d_SetEvictionPriority
,
293 d3d10_texture2d_GetEvictionPriority
,
294 /* ID3D10Texture2D methods */
296 d3d10_texture2d_Unmap
,
297 d3d10_texture2d_GetDesc
,
300 struct d3d10_texture2d
*unsafe_impl_from_ID3D10Texture2D(ID3D10Texture2D
*iface
)
304 assert(iface
->lpVtbl
== &d3d10_texture2d_vtbl
);
305 return CONTAINING_RECORD(iface
, struct d3d10_texture2d
, ID3D10Texture2D_iface
);
308 static const struct wined3d_parent_ops d3d10_texture2d_wined3d_parent_ops
=
310 d3d10_texture2d_wined3d_object_released
,
313 HRESULT
d3d10_texture2d_init(struct d3d10_texture2d
*texture
, struct d3d10_device
*device
,
314 const D3D10_TEXTURE2D_DESC
*desc
, const D3D10_SUBRESOURCE_DATA
*data
)
316 struct wined3d_resource_desc wined3d_desc
;
320 texture
->ID3D10Texture2D_iface
.lpVtbl
= &d3d10_texture2d_vtbl
;
321 texture
->refcount
= 1;
322 wined3d_mutex_lock();
323 wined3d_private_store_init(&texture
->private_store
);
324 texture
->desc
= *desc
;
326 if (desc
->ArraySize
!= 1)
327 FIXME("Array textures not implemented.\n");
328 if (desc
->SampleDesc
.Count
> 1)
329 FIXME("Multisampled textures not implemented.\n");
331 wined3d_desc
.resource_type
= WINED3D_RTYPE_TEXTURE
;
332 wined3d_desc
.format
= wined3dformat_from_dxgi_format(desc
->Format
);
333 wined3d_desc
.multisample_type
= desc
->SampleDesc
.Count
> 1 ? desc
->SampleDesc
.Count
: WINED3D_MULTISAMPLE_NONE
;
334 wined3d_desc
.multisample_quality
= desc
->SampleDesc
.Quality
;
335 wined3d_desc
.usage
= wined3d_usage_from_d3d10core(desc
->BindFlags
, desc
->Usage
);
336 wined3d_desc
.pool
= WINED3D_POOL_DEFAULT
;
337 wined3d_desc
.width
= desc
->Width
;
338 wined3d_desc
.height
= desc
->Height
;
339 wined3d_desc
.depth
= 1;
340 wined3d_desc
.size
= 0;
342 levels
= desc
->MipLevels
? desc
->MipLevels
: wined3d_log2i(max(desc
->Width
, desc
->Height
)) + 1;
344 if (FAILED(hr
= wined3d_texture_create(device
->wined3d_device
, &wined3d_desc
,
345 levels
, 0, (struct wined3d_sub_resource_data
*)data
, texture
,
346 &d3d10_texture2d_wined3d_parent_ops
, &texture
->wined3d_texture
)))
348 WARN("Failed to create wined3d texture, hr %#x.\n", hr
);
349 wined3d_private_store_cleanup(&texture
->private_store
);
350 wined3d_mutex_unlock();
353 texture
->desc
.MipLevels
= levels
;
355 if (desc
->MipLevels
== 1 && desc
->ArraySize
== 1)
357 IWineDXGIDevice
*wine_device
;
359 if (FAILED(hr
= ID3D10Device1_QueryInterface(&device
->ID3D10Device1_iface
, &IID_IWineDXGIDevice
,
360 (void **)&wine_device
)))
362 ERR("Device should implement IWineDXGIDevice.\n");
363 wined3d_texture_decref(texture
->wined3d_texture
);
364 wined3d_mutex_unlock();
368 hr
= IWineDXGIDevice_create_surface(wine_device
, wined3d_texture_get_resource(texture
->wined3d_texture
),
369 0, NULL
, (IUnknown
*)&texture
->ID3D10Texture2D_iface
, (void **)&texture
->dxgi_surface
);
370 IWineDXGIDevice_Release(wine_device
);
373 ERR("Failed to create DXGI surface, returning %#x\n", hr
);
374 texture
->dxgi_surface
= NULL
;
375 wined3d_texture_decref(texture
->wined3d_texture
);
376 wined3d_mutex_unlock();
380 wined3d_mutex_unlock();
382 texture
->device
= &device
->ID3D10Device1_iface
;
383 ID3D10Device1_AddRef(texture
->device
);
388 static inline struct d3d10_texture3d
*impl_from_ID3D10Texture3D(ID3D10Texture3D
*iface
)
390 return CONTAINING_RECORD(iface
, struct d3d10_texture3d
, ID3D10Texture3D_iface
);
393 static HRESULT STDMETHODCALLTYPE
d3d10_texture3d_QueryInterface(ID3D10Texture3D
*iface
, REFIID riid
, void **object
)
395 TRACE("iface %p, riid %s, object %p.\n", iface
, debugstr_guid(riid
), object
);
397 if (IsEqualGUID(riid
, &IID_ID3D10Texture3D
)
398 || IsEqualGUID(riid
, &IID_ID3D10Resource
)
399 || IsEqualGUID(riid
, &IID_ID3D10DeviceChild
)
400 || IsEqualGUID(riid
, &IID_IUnknown
))
402 IUnknown_AddRef(iface
);
407 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid
));
410 return E_NOINTERFACE
;
413 static ULONG STDMETHODCALLTYPE
d3d10_texture3d_AddRef(ID3D10Texture3D
*iface
)
415 struct d3d10_texture3d
*texture
= impl_from_ID3D10Texture3D(iface
);
416 ULONG refcount
= InterlockedIncrement(&texture
->refcount
);
418 TRACE("%p increasing refcount to %u.\n", texture
, refcount
);
422 ID3D10Device1_AddRef(texture
->device
);
423 wined3d_mutex_lock();
424 wined3d_texture_incref(texture
->wined3d_texture
);
425 wined3d_mutex_unlock();
431 static void STDMETHODCALLTYPE
d3d10_texture3d_wined3d_object_released(void *parent
)
433 struct d3d10_texture3d
*texture
= parent
;
435 wined3d_private_store_cleanup(&texture
->private_store
);
436 HeapFree(GetProcessHeap(), 0, parent
);
439 static ULONG STDMETHODCALLTYPE
d3d10_texture3d_Release(ID3D10Texture3D
*iface
)
441 struct d3d10_texture3d
*texture
= impl_from_ID3D10Texture3D(iface
);
442 ULONG refcount
= InterlockedDecrement(&texture
->refcount
);
444 TRACE("%p decreasing refcount to %u.\n", texture
, refcount
);
448 ID3D10Device1
*device
= texture
->device
;
450 wined3d_mutex_lock();
451 wined3d_texture_decref(texture
->wined3d_texture
);
452 wined3d_mutex_unlock();
453 /* Release the device last, it may cause the wined3d device to be
455 ID3D10Device1_Release(device
);
461 static void STDMETHODCALLTYPE
d3d10_texture3d_GetDevice(ID3D10Texture3D
*iface
, ID3D10Device
**device
)
463 struct d3d10_texture3d
*texture
= impl_from_ID3D10Texture3D(iface
);
465 TRACE("iface %p, device %p.\n", iface
, device
);
467 *device
= (ID3D10Device
*)texture
->device
;
468 ID3D10Device_AddRef(*device
);
471 static HRESULT STDMETHODCALLTYPE
d3d10_texture3d_GetPrivateData(ID3D10Texture3D
*iface
,
472 REFGUID guid
, UINT
*data_size
, void *data
)
474 struct d3d10_texture3d
*texture
= impl_from_ID3D10Texture3D(iface
);
476 TRACE("iface %p, guid %s, data_size %p, data %p.\n",
477 iface
, debugstr_guid(guid
), data_size
, data
);
479 return d3d10_get_private_data(&texture
->private_store
, guid
, data_size
, data
);
482 static HRESULT STDMETHODCALLTYPE
d3d10_texture3d_SetPrivateData(ID3D10Texture3D
*iface
,
483 REFGUID guid
, UINT data_size
, const void *data
)
485 struct d3d10_texture3d
*texture
= impl_from_ID3D10Texture3D(iface
);
487 TRACE("iface %p, guid %s, data_size %u, data %p.\n",
488 iface
, debugstr_guid(guid
), data_size
, data
);
490 return d3d10_set_private_data(&texture
->private_store
, guid
, data_size
, data
);
493 static HRESULT STDMETHODCALLTYPE
d3d10_texture3d_SetPrivateDataInterface(ID3D10Texture3D
*iface
,
494 REFGUID guid
, const IUnknown
*data
)
496 struct d3d10_texture3d
*texture
= impl_from_ID3D10Texture3D(iface
);
498 TRACE("iface %p, guid %s, data %p.\n", iface
, debugstr_guid(guid
), data
);
500 return d3d10_set_private_data_interface(&texture
->private_store
, guid
, data
);
503 static void STDMETHODCALLTYPE
d3d10_texture3d_GetType(ID3D10Texture3D
*iface
,
504 D3D10_RESOURCE_DIMENSION
*resource_dimension
)
506 TRACE("iface %p, resource_dimension %p.\n", iface
, resource_dimension
);
508 *resource_dimension
= D3D10_RESOURCE_DIMENSION_TEXTURE3D
;
511 static void STDMETHODCALLTYPE
d3d10_texture3d_SetEvictionPriority(ID3D10Texture3D
*iface
, UINT eviction_priority
)
513 FIXME("iface %p, eviction_priority %u stub!\n", iface
, eviction_priority
);
516 static UINT STDMETHODCALLTYPE
d3d10_texture3d_GetEvictionPriority(ID3D10Texture3D
*iface
)
518 FIXME("iface %p stub!\n", iface
);
523 static HRESULT STDMETHODCALLTYPE
d3d10_texture3d_Map(ID3D10Texture3D
*iface
, UINT sub_resource_idx
,
524 D3D10_MAP map_type
, UINT map_flags
, D3D10_MAPPED_TEXTURE3D
*mapped_texture
)
526 struct d3d10_texture3d
*texture
= impl_from_ID3D10Texture3D(iface
);
527 struct wined3d_map_desc wined3d_map_desc
;
528 struct wined3d_resource
*sub_resource
;
531 TRACE("iface %p, sub_resource_idx %u, map_type %u, map_flags %#x, mapped_texture %p.\n",
532 iface
, sub_resource_idx
, map_type
, map_flags
, mapped_texture
);
535 FIXME("Ignoring map_flags %#x.\n", map_flags
);
537 wined3d_mutex_lock();
538 if (!(sub_resource
= wined3d_texture_get_sub_resource(texture
->wined3d_texture
, sub_resource_idx
)))
540 else if (SUCCEEDED(hr
= wined3d_volume_map(wined3d_volume_from_resource(sub_resource
),
541 &wined3d_map_desc
, NULL
, wined3d_map_flags_from_d3d10_map_type(map_type
))))
543 mapped_texture
->pData
= wined3d_map_desc
.data
;
544 mapped_texture
->RowPitch
= wined3d_map_desc
.row_pitch
;
545 mapped_texture
->DepthPitch
= wined3d_map_desc
.slice_pitch
;
547 wined3d_mutex_unlock();
552 static void STDMETHODCALLTYPE
d3d10_texture3d_Unmap(ID3D10Texture3D
*iface
, UINT sub_resource_idx
)
554 struct d3d10_texture3d
*texture
= impl_from_ID3D10Texture3D(iface
);
555 struct wined3d_resource
*sub_resource
;
557 TRACE("iface %p, sub_resource_idx %u.\n", iface
, sub_resource_idx
);
559 wined3d_mutex_lock();
560 if (!(sub_resource
= wined3d_texture_get_sub_resource(texture
->wined3d_texture
, sub_resource_idx
)))
562 wined3d_mutex_unlock();
566 wined3d_volume_unmap(wined3d_volume_from_resource(sub_resource
));
567 wined3d_mutex_unlock();
570 static void STDMETHODCALLTYPE
d3d10_texture3d_GetDesc(ID3D10Texture3D
*iface
, D3D10_TEXTURE3D_DESC
*desc
)
572 struct d3d10_texture3d
*texture
= impl_from_ID3D10Texture3D(iface
);
574 TRACE("iface %p, desc %p.\n", iface
, desc
);
576 *desc
= texture
->desc
;
579 static const struct ID3D10Texture3DVtbl d3d10_texture3d_vtbl
=
581 /* IUnknown methods */
582 d3d10_texture3d_QueryInterface
,
583 d3d10_texture3d_AddRef
,
584 d3d10_texture3d_Release
,
585 /* ID3D10DeviceChild methods */
586 d3d10_texture3d_GetDevice
,
587 d3d10_texture3d_GetPrivateData
,
588 d3d10_texture3d_SetPrivateData
,
589 d3d10_texture3d_SetPrivateDataInterface
,
590 /* ID3D10Resource methods */
591 d3d10_texture3d_GetType
,
592 d3d10_texture3d_SetEvictionPriority
,
593 d3d10_texture3d_GetEvictionPriority
,
594 /* ID3D10Texture3D methods */
596 d3d10_texture3d_Unmap
,
597 d3d10_texture3d_GetDesc
,
600 static const struct wined3d_parent_ops d3d10_texture3d_wined3d_parent_ops
=
602 d3d10_texture3d_wined3d_object_released
,
605 HRESULT
d3d10_texture3d_init(struct d3d10_texture3d
*texture
, struct d3d10_device
*device
,
606 const D3D10_TEXTURE3D_DESC
*desc
, const D3D10_SUBRESOURCE_DATA
*data
)
608 struct wined3d_resource_desc wined3d_desc
;
612 texture
->ID3D10Texture3D_iface
.lpVtbl
= &d3d10_texture3d_vtbl
;
613 texture
->refcount
= 1;
614 wined3d_mutex_lock();
615 wined3d_private_store_init(&texture
->private_store
);
616 texture
->desc
= *desc
;
618 wined3d_desc
.resource_type
= WINED3D_RTYPE_VOLUME_TEXTURE
;
619 wined3d_desc
.format
= wined3dformat_from_dxgi_format(desc
->Format
);
620 wined3d_desc
.multisample_type
= WINED3D_MULTISAMPLE_NONE
;
621 wined3d_desc
.multisample_quality
= 0;
622 wined3d_desc
.usage
= wined3d_usage_from_d3d10core(desc
->BindFlags
, desc
->Usage
);
623 wined3d_desc
.pool
= WINED3D_POOL_DEFAULT
;
624 wined3d_desc
.width
= desc
->Width
;
625 wined3d_desc
.height
= desc
->Height
;
626 wined3d_desc
.depth
= desc
->Depth
;
627 wined3d_desc
.size
= 0;
629 levels
= desc
->MipLevels
? desc
->MipLevels
: wined3d_log2i(max(max(desc
->Width
, desc
->Height
), desc
->Depth
)) + 1;
631 if (FAILED(hr
= wined3d_texture_create(device
->wined3d_device
, &wined3d_desc
,
632 levels
, 0, (struct wined3d_sub_resource_data
*)data
, texture
,
633 &d3d10_texture3d_wined3d_parent_ops
, &texture
->wined3d_texture
)))
635 WARN("Failed to create wined3d texture, hr %#x.\n", hr
);
636 wined3d_private_store_cleanup(&texture
->private_store
);
637 wined3d_mutex_unlock();
640 wined3d_mutex_unlock();
641 texture
->desc
.MipLevels
= levels
;
643 texture
->device
= &device
->ID3D10Device1_iface
;
644 ID3D10Device1_AddRef(texture
->device
);