wsdapi: Add a trailing '\n' to a WARN() message.
[wine.git] / dlls / d3d8 / buffer.c
blobfb6b7bc1e92285341a8142470073a8cc48f642ba
1 /*
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 "config.h"
20 #include "d3d8_private.h"
22 WINE_DEFAULT_DEBUG_CHANNEL(d3d8);
24 static inline struct d3d8_vertexbuffer *impl_from_IDirect3DVertexBuffer8(IDirect3DVertexBuffer8 *iface)
26 return CONTAINING_RECORD(iface, struct d3d8_vertexbuffer, IDirect3DVertexBuffer8_iface);
29 static HRESULT WINAPI d3d8_vertexbuffer_QueryInterface(IDirect3DVertexBuffer8 *iface, REFIID riid, void **object)
31 TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
33 if (IsEqualGUID(riid, &IID_IDirect3DVertexBuffer8)
34 || IsEqualGUID(riid, &IID_IDirect3DResource8)
35 || IsEqualGUID(riid, &IID_IUnknown))
37 IDirect3DVertexBuffer8_AddRef(iface);
38 *object = iface;
39 return S_OK;
42 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
44 *object = NULL;
45 return E_NOINTERFACE;
48 static ULONG WINAPI d3d8_vertexbuffer_AddRef(IDirect3DVertexBuffer8 *iface)
50 struct d3d8_vertexbuffer *buffer = impl_from_IDirect3DVertexBuffer8(iface);
51 ULONG refcount = InterlockedIncrement(&buffer->resource.refcount);
53 TRACE("%p increasing refcount to %u.\n", iface, refcount);
55 if (refcount == 1)
57 IDirect3DDevice8_AddRef(buffer->parent_device);
58 wined3d_mutex_lock();
59 wined3d_buffer_incref(buffer->wined3d_buffer);
60 wined3d_mutex_unlock();
63 return refcount;
66 static ULONG WINAPI d3d8_vertexbuffer_Release(IDirect3DVertexBuffer8 *iface)
68 struct d3d8_vertexbuffer *buffer = impl_from_IDirect3DVertexBuffer8(iface);
69 ULONG refcount = InterlockedDecrement(&buffer->resource.refcount);
71 TRACE("%p decreasing refcount to %u.\n", iface, refcount);
73 if (!refcount)
75 IDirect3DDevice8 *device = buffer->parent_device;
77 wined3d_mutex_lock();
78 wined3d_buffer_decref(buffer->wined3d_buffer);
79 wined3d_mutex_unlock();
81 /* Release the device last, as it may cause the device to be destroyed. */
82 IDirect3DDevice8_Release(device);
85 return refcount;
88 static HRESULT WINAPI d3d8_vertexbuffer_GetDevice(IDirect3DVertexBuffer8 *iface,
89 IDirect3DDevice8 **device)
91 struct d3d8_vertexbuffer *buffer = impl_from_IDirect3DVertexBuffer8(iface);
93 TRACE("iface %p, device %p.\n", iface, device);
95 *device = buffer->parent_device;
96 IDirect3DDevice8_AddRef(*device);
98 TRACE("Returning device %p.\n", *device);
100 return D3D_OK;
103 static HRESULT WINAPI d3d8_vertexbuffer_SetPrivateData(IDirect3DVertexBuffer8 *iface,
104 REFGUID guid, const void *data, DWORD data_size, DWORD flags)
106 struct d3d8_vertexbuffer *buffer = impl_from_IDirect3DVertexBuffer8(iface);
107 TRACE("iface %p, guid %s, data %p, data_size %u, flags %#x.\n",
108 iface, debugstr_guid(guid), data, data_size, flags);
110 return d3d8_resource_set_private_data(&buffer->resource, guid, data, data_size, flags);
113 static HRESULT WINAPI d3d8_vertexbuffer_GetPrivateData(IDirect3DVertexBuffer8 *iface,
114 REFGUID guid, void *data, DWORD *data_size)
116 struct d3d8_vertexbuffer *buffer = impl_from_IDirect3DVertexBuffer8(iface);
117 TRACE("iface %p, guid %s, data %p, data_size %p.\n",
118 iface, debugstr_guid(guid), data, data_size);
120 return d3d8_resource_get_private_data(&buffer->resource, guid, data, data_size);
123 static HRESULT WINAPI d3d8_vertexbuffer_FreePrivateData(IDirect3DVertexBuffer8 *iface, REFGUID guid)
125 struct d3d8_vertexbuffer *buffer = impl_from_IDirect3DVertexBuffer8(iface);
126 TRACE("iface %p, guid %s.\n", iface, debugstr_guid(guid));
128 return d3d8_resource_free_private_data(&buffer->resource, guid);
131 static DWORD WINAPI d3d8_vertexbuffer_SetPriority(IDirect3DVertexBuffer8 *iface, DWORD priority)
133 struct d3d8_vertexbuffer *buffer = impl_from_IDirect3DVertexBuffer8(iface);
134 struct wined3d_resource *resource;
135 DWORD previous;
137 TRACE("iface %p, priority %u.\n", iface, priority);
139 wined3d_mutex_lock();
140 resource = wined3d_buffer_get_resource(buffer->wined3d_buffer);
141 previous = wined3d_resource_set_priority(resource, priority);
142 wined3d_mutex_unlock();
144 return previous;
147 static DWORD WINAPI d3d8_vertexbuffer_GetPriority(IDirect3DVertexBuffer8 *iface)
149 struct d3d8_vertexbuffer *buffer = impl_from_IDirect3DVertexBuffer8(iface);
150 const struct wined3d_resource *resource;
151 DWORD priority;
153 TRACE("iface %p.\n", iface);
155 wined3d_mutex_lock();
156 resource = wined3d_buffer_get_resource(buffer->wined3d_buffer);
157 priority = wined3d_resource_get_priority(resource);
158 wined3d_mutex_unlock();
160 return priority;
163 static void WINAPI d3d8_vertexbuffer_PreLoad(IDirect3DVertexBuffer8 *iface)
165 struct d3d8_vertexbuffer *buffer = impl_from_IDirect3DVertexBuffer8(iface);
167 TRACE("iface %p.\n", iface);
169 wined3d_mutex_lock();
170 wined3d_resource_preload(wined3d_buffer_get_resource(buffer->wined3d_buffer));
171 wined3d_mutex_unlock();
174 static D3DRESOURCETYPE WINAPI d3d8_vertexbuffer_GetType(IDirect3DVertexBuffer8 *iface)
176 TRACE("iface %p.\n", iface);
178 return D3DRTYPE_VERTEXBUFFER;
181 static HRESULT WINAPI d3d8_vertexbuffer_Lock(IDirect3DVertexBuffer8 *iface, UINT offset, UINT size,
182 BYTE **data, DWORD flags)
184 struct d3d8_vertexbuffer *buffer = impl_from_IDirect3DVertexBuffer8(iface);
185 struct wined3d_map_desc wined3d_map_desc;
186 struct wined3d_box wined3d_box = {0};
187 HRESULT hr;
189 TRACE("iface %p, offset %u, size %u, data %p, flags %#x.\n",
190 iface, offset, size, data, flags);
192 wined3d_box.left = offset;
193 wined3d_box.right = offset + size;
194 wined3d_mutex_lock();
195 hr = wined3d_resource_map(wined3d_buffer_get_resource(buffer->wined3d_buffer),
196 0, &wined3d_map_desc, &wined3d_box, wined3dmapflags_from_d3dmapflags(flags));
197 wined3d_mutex_unlock();
198 *data = wined3d_map_desc.data;
200 return hr;
203 static HRESULT WINAPI d3d8_vertexbuffer_Unlock(IDirect3DVertexBuffer8 *iface)
205 struct d3d8_vertexbuffer *buffer = impl_from_IDirect3DVertexBuffer8(iface);
207 TRACE("iface %p.\n", iface);
209 wined3d_mutex_lock();
210 wined3d_resource_unmap(wined3d_buffer_get_resource(buffer->wined3d_buffer), 0);
211 wined3d_mutex_unlock();
213 return D3D_OK;
216 static HRESULT WINAPI d3d8_vertexbuffer_GetDesc(IDirect3DVertexBuffer8 *iface,
217 D3DVERTEXBUFFER_DESC *desc)
219 struct d3d8_vertexbuffer *buffer = impl_from_IDirect3DVertexBuffer8(iface);
220 struct wined3d_resource_desc wined3d_desc;
221 struct wined3d_resource *wined3d_resource;
223 TRACE("iface %p, desc %p.\n", iface, desc);
225 wined3d_mutex_lock();
226 wined3d_resource = wined3d_buffer_get_resource(buffer->wined3d_buffer);
227 wined3d_resource_get_desc(wined3d_resource, &wined3d_desc);
228 wined3d_mutex_unlock();
230 desc->Format = D3DFMT_VERTEXDATA;
231 desc->Type = D3DRTYPE_VERTEXBUFFER;
232 desc->Usage = d3dusage_from_wined3dusage(wined3d_desc.usage);
233 desc->Pool = d3dpool_from_wined3daccess(wined3d_desc.access, wined3d_desc.usage);
234 desc->Size = wined3d_desc.size;
235 desc->FVF = buffer->fvf;
237 return D3D_OK;
240 static const IDirect3DVertexBuffer8Vtbl Direct3DVertexBuffer8_Vtbl =
242 /* IUnknown */
243 d3d8_vertexbuffer_QueryInterface,
244 d3d8_vertexbuffer_AddRef,
245 d3d8_vertexbuffer_Release,
246 /* IDirect3DResource8 */
247 d3d8_vertexbuffer_GetDevice,
248 d3d8_vertexbuffer_SetPrivateData,
249 d3d8_vertexbuffer_GetPrivateData,
250 d3d8_vertexbuffer_FreePrivateData,
251 d3d8_vertexbuffer_SetPriority,
252 d3d8_vertexbuffer_GetPriority,
253 d3d8_vertexbuffer_PreLoad,
254 d3d8_vertexbuffer_GetType,
255 /* IDirect3DVertexBuffer8 */
256 d3d8_vertexbuffer_Lock,
257 d3d8_vertexbuffer_Unlock,
258 d3d8_vertexbuffer_GetDesc,
261 static void STDMETHODCALLTYPE d3d8_vertexbuffer_wined3d_object_destroyed(void *parent)
263 struct d3d8_vertexbuffer *buffer = parent;
264 d3d8_resource_cleanup(&buffer->resource);
265 heap_free(buffer);
268 static const struct wined3d_parent_ops d3d8_vertexbuffer_wined3d_parent_ops =
270 d3d8_vertexbuffer_wined3d_object_destroyed,
273 HRESULT vertexbuffer_init(struct d3d8_vertexbuffer *buffer, struct d3d8_device *device,
274 UINT size, DWORD usage, DWORD fvf, D3DPOOL pool)
276 struct wined3d_buffer_desc desc;
277 HRESULT hr;
279 if (pool == D3DPOOL_SCRATCH)
281 WARN("Vertex buffer with D3DPOOL_SCRATCH requested.\n");
282 return D3DERR_INVALIDCALL;
285 buffer->IDirect3DVertexBuffer8_iface.lpVtbl = &Direct3DVertexBuffer8_Vtbl;
286 d3d8_resource_init(&buffer->resource);
287 buffer->fvf = fvf;
289 desc.byte_width = size;
290 desc.usage = usage & WINED3DUSAGE_MASK;
291 desc.bind_flags = WINED3D_BIND_VERTEX_BUFFER;
292 desc.access = wined3daccess_from_d3dpool(pool, usage)
293 | WINED3D_RESOURCE_ACCESS_MAP_R | WINED3D_RESOURCE_ACCESS_MAP_W;
294 desc.misc_flags = 0;
295 desc.structure_byte_stride = 0;
297 wined3d_mutex_lock();
298 hr = wined3d_buffer_create(device->wined3d_device, &desc, NULL, buffer,
299 &d3d8_vertexbuffer_wined3d_parent_ops, &buffer->wined3d_buffer);
300 wined3d_mutex_unlock();
301 if (FAILED(hr))
303 WARN("Failed to create wined3d buffer, hr %#x.\n", hr);
304 return hr;
307 buffer->parent_device = &device->IDirect3DDevice8_iface;
308 IDirect3DDevice8_AddRef(buffer->parent_device);
310 return D3D_OK;
313 struct d3d8_vertexbuffer *unsafe_impl_from_IDirect3DVertexBuffer8(IDirect3DVertexBuffer8 *iface)
315 if (!iface)
316 return NULL;
317 assert(iface->lpVtbl == &Direct3DVertexBuffer8_Vtbl);
319 return impl_from_IDirect3DVertexBuffer8(iface);
322 static inline struct d3d8_indexbuffer *impl_from_IDirect3DIndexBuffer8(IDirect3DIndexBuffer8 *iface)
324 return CONTAINING_RECORD(iface, struct d3d8_indexbuffer, IDirect3DIndexBuffer8_iface);
327 static HRESULT WINAPI d3d8_indexbuffer_QueryInterface(IDirect3DIndexBuffer8 *iface, REFIID riid, void **object)
329 TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
331 if (IsEqualGUID(riid, &IID_IDirect3DIndexBuffer8)
332 || IsEqualGUID(riid, &IID_IDirect3DResource8)
333 || IsEqualGUID(riid, &IID_IUnknown))
335 IDirect3DIndexBuffer8_AddRef(iface);
336 *object = iface;
337 return S_OK;
340 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
342 *object = NULL;
343 return E_NOINTERFACE;
346 static ULONG WINAPI d3d8_indexbuffer_AddRef(IDirect3DIndexBuffer8 *iface)
348 struct d3d8_indexbuffer *buffer = impl_from_IDirect3DIndexBuffer8(iface);
349 ULONG refcount = InterlockedIncrement(&buffer->resource.refcount);
351 TRACE("%p increasing refcount to %u.\n", iface, refcount);
353 if (refcount == 1)
355 IDirect3DDevice8_AddRef(buffer->parent_device);
356 wined3d_mutex_lock();
357 wined3d_buffer_incref(buffer->wined3d_buffer);
358 wined3d_mutex_unlock();
361 return refcount;
364 static ULONG WINAPI d3d8_indexbuffer_Release(IDirect3DIndexBuffer8 *iface)
366 struct d3d8_indexbuffer *buffer = impl_from_IDirect3DIndexBuffer8(iface);
367 ULONG refcount = InterlockedDecrement(&buffer->resource.refcount);
369 TRACE("%p decreasing refcount to %u.\n", iface, refcount);
371 if (!refcount)
373 IDirect3DDevice8 *device = buffer->parent_device;
375 wined3d_mutex_lock();
376 wined3d_buffer_decref(buffer->wined3d_buffer);
377 wined3d_mutex_unlock();
379 /* Release the device last, as it may cause the device to be destroyed. */
380 IDirect3DDevice8_Release(device);
383 return refcount;
386 static HRESULT WINAPI d3d8_indexbuffer_GetDevice(IDirect3DIndexBuffer8 *iface,
387 IDirect3DDevice8 **device)
389 struct d3d8_indexbuffer *buffer = impl_from_IDirect3DIndexBuffer8(iface);
391 TRACE("iface %p, device %p.\n", iface, device);
393 *device = buffer->parent_device;
394 IDirect3DDevice8_AddRef(*device);
396 TRACE("Returning device %p.\n", *device);
398 return D3D_OK;
401 static HRESULT WINAPI d3d8_indexbuffer_SetPrivateData(IDirect3DIndexBuffer8 *iface,
402 REFGUID guid, const void *data, DWORD data_size, DWORD flags)
404 struct d3d8_indexbuffer *buffer = impl_from_IDirect3DIndexBuffer8(iface);
405 TRACE("iface %p, guid %s, data %p, data_size %u, flags %#x.\n",
406 iface, debugstr_guid(guid), data, data_size, flags);
408 return d3d8_resource_set_private_data(&buffer->resource, guid, data, data_size, flags);
411 static HRESULT WINAPI d3d8_indexbuffer_GetPrivateData(IDirect3DIndexBuffer8 *iface,
412 REFGUID guid, void *data, DWORD *data_size)
414 struct d3d8_indexbuffer *buffer = impl_from_IDirect3DIndexBuffer8(iface);
415 TRACE("iface %p, guid %s, data %p, data_size %p.\n",
416 iface, debugstr_guid(guid), data, data_size);
418 return d3d8_resource_get_private_data(&buffer->resource, guid, data, data_size);
421 static HRESULT WINAPI d3d8_indexbuffer_FreePrivateData(IDirect3DIndexBuffer8 *iface, REFGUID guid)
423 struct d3d8_indexbuffer *buffer = impl_from_IDirect3DIndexBuffer8(iface);
424 TRACE("iface %p, guid %s.\n", iface, debugstr_guid(guid));
426 return d3d8_resource_free_private_data(&buffer->resource, guid);
429 static DWORD WINAPI d3d8_indexbuffer_SetPriority(IDirect3DIndexBuffer8 *iface, DWORD priority)
431 struct d3d8_indexbuffer *buffer = impl_from_IDirect3DIndexBuffer8(iface);
432 struct wined3d_resource *resource;
433 DWORD previous;
435 TRACE("iface %p, priority %u.\n", iface, priority);
437 wined3d_mutex_lock();
438 resource = wined3d_buffer_get_resource(buffer->wined3d_buffer);
439 previous = wined3d_resource_set_priority(resource, priority);
440 wined3d_mutex_unlock();
442 return previous;
445 static DWORD WINAPI d3d8_indexbuffer_GetPriority(IDirect3DIndexBuffer8 *iface)
447 struct d3d8_indexbuffer *buffer = impl_from_IDirect3DIndexBuffer8(iface);
448 const struct wined3d_resource *resource;
449 DWORD priority;
451 TRACE("iface %p.\n", iface);
453 wined3d_mutex_lock();
454 resource = wined3d_buffer_get_resource(buffer->wined3d_buffer);
455 priority = wined3d_resource_get_priority(resource);
456 wined3d_mutex_unlock();
458 return priority;
461 static void WINAPI d3d8_indexbuffer_PreLoad(IDirect3DIndexBuffer8 *iface)
463 struct d3d8_indexbuffer *buffer = impl_from_IDirect3DIndexBuffer8(iface);
465 TRACE("iface %p.\n", iface);
467 wined3d_mutex_lock();
468 wined3d_resource_preload(wined3d_buffer_get_resource(buffer->wined3d_buffer));
469 wined3d_mutex_unlock();
472 static D3DRESOURCETYPE WINAPI d3d8_indexbuffer_GetType(IDirect3DIndexBuffer8 *iface)
474 TRACE("iface %p.\n", iface);
476 return D3DRTYPE_INDEXBUFFER;
479 static HRESULT WINAPI d3d8_indexbuffer_Lock(IDirect3DIndexBuffer8 *iface, UINT offset, UINT size,
480 BYTE **data, DWORD flags)
482 struct d3d8_indexbuffer *buffer = impl_from_IDirect3DIndexBuffer8(iface);
483 struct wined3d_map_desc wined3d_map_desc;
484 struct wined3d_box wined3d_box = {0};
485 HRESULT hr;
487 TRACE("iface %p, offset %u, size %u, data %p, flags %#x.\n",
488 iface, offset, size, data, flags);
490 wined3d_box.left = offset;
491 wined3d_box.right = offset + size;
492 wined3d_mutex_lock();
493 hr = wined3d_resource_map(wined3d_buffer_get_resource(buffer->wined3d_buffer),
494 0, &wined3d_map_desc, &wined3d_box, wined3dmapflags_from_d3dmapflags(flags));
495 wined3d_mutex_unlock();
496 *data = wined3d_map_desc.data;
498 return hr;
501 static HRESULT WINAPI d3d8_indexbuffer_Unlock(IDirect3DIndexBuffer8 *iface)
503 struct d3d8_indexbuffer *buffer = impl_from_IDirect3DIndexBuffer8(iface);
505 TRACE("iface %p.\n", iface);
507 wined3d_mutex_lock();
508 wined3d_resource_unmap(wined3d_buffer_get_resource(buffer->wined3d_buffer), 0);
509 wined3d_mutex_unlock();
511 return D3D_OK;
514 static HRESULT WINAPI d3d8_indexbuffer_GetDesc(IDirect3DIndexBuffer8 *iface,
515 D3DINDEXBUFFER_DESC *desc)
517 struct d3d8_indexbuffer *buffer = impl_from_IDirect3DIndexBuffer8(iface);
518 struct wined3d_resource_desc wined3d_desc;
519 struct wined3d_resource *wined3d_resource;
521 TRACE("iface %p, desc %p.\n", iface, desc);
523 wined3d_mutex_lock();
524 wined3d_resource = wined3d_buffer_get_resource(buffer->wined3d_buffer);
525 wined3d_resource_get_desc(wined3d_resource, &wined3d_desc);
526 wined3d_mutex_unlock();
528 desc->Format = d3dformat_from_wined3dformat(buffer->format);
529 desc->Type = D3DRTYPE_INDEXBUFFER;
530 desc->Usage = d3dusage_from_wined3dusage(wined3d_desc.usage);
531 desc->Pool = d3dpool_from_wined3daccess(wined3d_desc.access, wined3d_desc.usage);
532 desc->Size = wined3d_desc.size;
534 return D3D_OK;
537 static const IDirect3DIndexBuffer8Vtbl d3d8_indexbuffer_vtbl =
539 /* IUnknown */
540 d3d8_indexbuffer_QueryInterface,
541 d3d8_indexbuffer_AddRef,
542 d3d8_indexbuffer_Release,
543 /* IDirect3DResource8 */
544 d3d8_indexbuffer_GetDevice,
545 d3d8_indexbuffer_SetPrivateData,
546 d3d8_indexbuffer_GetPrivateData,
547 d3d8_indexbuffer_FreePrivateData,
548 d3d8_indexbuffer_SetPriority,
549 d3d8_indexbuffer_GetPriority,
550 d3d8_indexbuffer_PreLoad,
551 d3d8_indexbuffer_GetType,
552 /* IDirect3DIndexBuffer8 */
553 d3d8_indexbuffer_Lock,
554 d3d8_indexbuffer_Unlock,
555 d3d8_indexbuffer_GetDesc,
558 static void STDMETHODCALLTYPE d3d8_indexbuffer_wined3d_object_destroyed(void *parent)
560 struct d3d8_indexbuffer *buffer = parent;
561 d3d8_resource_cleanup(&buffer->resource);
562 heap_free(buffer);
565 static const struct wined3d_parent_ops d3d8_indexbuffer_wined3d_parent_ops =
567 d3d8_indexbuffer_wined3d_object_destroyed,
570 HRESULT indexbuffer_init(struct d3d8_indexbuffer *buffer, struct d3d8_device *device,
571 UINT size, DWORD usage, D3DFORMAT format, D3DPOOL pool)
573 struct wined3d_buffer_desc desc;
574 HRESULT hr;
576 desc.byte_width = size;
577 desc.usage = (usage & WINED3DUSAGE_MASK) | WINED3DUSAGE_STATICDECL;
578 if (pool == D3DPOOL_SCRATCH)
579 desc.usage |= WINED3DUSAGE_SCRATCH;
580 desc.bind_flags = WINED3D_BIND_INDEX_BUFFER;
581 desc.access = wined3daccess_from_d3dpool(pool, usage)
582 | WINED3D_RESOURCE_ACCESS_MAP_R | WINED3D_RESOURCE_ACCESS_MAP_W;
583 desc.misc_flags = 0;
584 desc.structure_byte_stride = 0;
586 buffer->IDirect3DIndexBuffer8_iface.lpVtbl = &d3d8_indexbuffer_vtbl;
587 d3d8_resource_init(&buffer->resource);
588 buffer->format = wined3dformat_from_d3dformat(format);
590 wined3d_mutex_lock();
591 hr = wined3d_buffer_create(device->wined3d_device, &desc, NULL, buffer,
592 &d3d8_indexbuffer_wined3d_parent_ops, &buffer->wined3d_buffer);
593 wined3d_mutex_unlock();
594 if (FAILED(hr))
596 WARN("Failed to create wined3d buffer, hr %#x.\n", hr);
597 return hr;
600 buffer->parent_device = &device->IDirect3DDevice8_iface;
601 IDirect3DDevice8_AddRef(buffer->parent_device);
603 return D3D_OK;
606 struct d3d8_indexbuffer *unsafe_impl_from_IDirect3DIndexBuffer8(IDirect3DIndexBuffer8 *iface)
608 if (!iface)
609 return NULL;
610 assert(iface->lpVtbl == &d3d8_indexbuffer_vtbl);
612 return impl_from_IDirect3DIndexBuffer8(iface);