VirtualBox

source: vbox/trunk/src/VBox/Additions/WINNT/Graphics/Wine_new/d3d8/buffer.c@ 65381

Last change on this file since 65381 was 48345, checked in by vboxsync, 11 years ago

header fixes

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 18.7 KB
Line 
1/*
2 * Copyright 2005 Oliver Stieber
3 *
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.
8 *
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.
13 *
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
17 */
18
19/*
20 * Oracle LGPL Disclaimer: For the avoidance of doubt, except that if any license choice
21 * other than GPL or LGPL is available it will apply instead, Oracle elects to use only
22 * the Lesser General Public License version 2.1 (LGPLv2) at this time for any software where
23 * a choice of LGPL license versions is made available with the language indicating
24 * that LGPLv2 or any later version may be used, or where a choice of which version
25 * of the LGPL is applied is otherwise unspecified.
26 */
27
28#include "config.h"
29#include "d3d8_private.h"
30
31WINE_DEFAULT_DEBUG_CHANNEL(d3d8);
32
33static inline struct d3d8_vertexbuffer *impl_from_IDirect3DVertexBuffer8(IDirect3DVertexBuffer8 *iface)
34{
35 return CONTAINING_RECORD(iface, struct d3d8_vertexbuffer, IDirect3DVertexBuffer8_iface);
36}
37
38static HRESULT WINAPI d3d8_vertexbuffer_QueryInterface(IDirect3DVertexBuffer8 *iface, REFIID riid, void **object)
39{
40 TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
41
42 if (IsEqualGUID(riid, &IID_IDirect3DVertexBuffer8)
43 || IsEqualGUID(riid, &IID_IDirect3DResource8)
44 || IsEqualGUID(riid, &IID_IUnknown))
45 {
46 IDirect3DVertexBuffer8_AddRef(iface);
47 *object = iface;
48 return S_OK;
49 }
50
51 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
52
53 *object = NULL;
54 return E_NOINTERFACE;
55}
56
57static ULONG WINAPI d3d8_vertexbuffer_AddRef(IDirect3DVertexBuffer8 *iface)
58{
59 struct d3d8_vertexbuffer *buffer = impl_from_IDirect3DVertexBuffer8(iface);
60 ULONG refcount = InterlockedIncrement(&buffer->refcount);
61
62 TRACE("%p increasing refcount to %u.\n", iface, refcount);
63
64 if (refcount == 1)
65 {
66 IDirect3DDevice8_AddRef(buffer->parent_device);
67 wined3d_mutex_lock();
68 wined3d_buffer_incref(buffer->wined3d_buffer);
69 wined3d_mutex_unlock();
70 }
71
72 return refcount;
73}
74
75static ULONG WINAPI d3d8_vertexbuffer_Release(IDirect3DVertexBuffer8 *iface)
76{
77 struct d3d8_vertexbuffer *buffer = impl_from_IDirect3DVertexBuffer8(iface);
78 ULONG refcount = InterlockedDecrement(&buffer->refcount);
79
80 TRACE("%p decreasing refcount to %u.\n", iface, refcount);
81
82 if (!refcount)
83 {
84 IDirect3DDevice8 *device = buffer->parent_device;
85
86 wined3d_mutex_lock();
87 wined3d_buffer_decref(buffer->wined3d_buffer);
88 wined3d_mutex_unlock();
89
90 /* Release the device last, as it may cause the device to be destroyed. */
91 IDirect3DDevice8_Release(device);
92 }
93
94 return refcount;
95}
96
97static HRESULT WINAPI d3d8_vertexbuffer_GetDevice(IDirect3DVertexBuffer8 *iface,
98 IDirect3DDevice8 **device)
99{
100 struct d3d8_vertexbuffer *buffer = impl_from_IDirect3DVertexBuffer8(iface);
101
102 TRACE("iface %p, device %p.\n", iface, device);
103
104 *device = buffer->parent_device;
105 IDirect3DDevice8_AddRef(*device);
106
107 TRACE("Returning device %p.\n", *device);
108
109 return D3D_OK;
110}
111
112static HRESULT WINAPI d3d8_vertexbuffer_SetPrivateData(IDirect3DVertexBuffer8 *iface,
113 REFGUID guid, const void *data, DWORD data_size, DWORD flags)
114{
115 struct d3d8_vertexbuffer *buffer = impl_from_IDirect3DVertexBuffer8(iface);
116 struct wined3d_resource *resource;
117 HRESULT hr;
118
119 TRACE("iface %p, guid %s, data %p, data_size %u, flags %#x.\n",
120 iface, debugstr_guid(guid), data, data_size, flags);
121
122 wined3d_mutex_lock();
123 resource = wined3d_buffer_get_resource(buffer->wined3d_buffer);
124 hr = wined3d_resource_set_private_data(resource, guid, data, data_size, flags);
125 wined3d_mutex_unlock();
126
127 return hr;
128}
129
130static HRESULT WINAPI d3d8_vertexbuffer_GetPrivateData(IDirect3DVertexBuffer8 *iface,
131 REFGUID guid, void *data, DWORD *data_size)
132{
133 struct d3d8_vertexbuffer *buffer = impl_from_IDirect3DVertexBuffer8(iface);
134 struct wined3d_resource *resource;
135 HRESULT hr;
136
137 TRACE("iface %p, guid %s, data %p, data_size %p.\n",
138 iface, debugstr_guid(guid), data, data_size);
139
140 wined3d_mutex_lock();
141 resource = wined3d_buffer_get_resource(buffer->wined3d_buffer);
142 hr = wined3d_resource_get_private_data(resource, guid, data, data_size);
143 wined3d_mutex_unlock();
144
145 return hr;
146}
147
148static HRESULT WINAPI d3d8_vertexbuffer_FreePrivateData(IDirect3DVertexBuffer8 *iface, REFGUID guid)
149{
150 struct d3d8_vertexbuffer *buffer = impl_from_IDirect3DVertexBuffer8(iface);
151 struct wined3d_resource *resource;
152 HRESULT hr;
153
154 TRACE("iface %p, guid %s.\n", iface, debugstr_guid(guid));
155
156 wined3d_mutex_lock();
157 resource = wined3d_buffer_get_resource(buffer->wined3d_buffer);
158 hr = wined3d_resource_free_private_data(resource, guid);
159 wined3d_mutex_unlock();
160
161 return hr;
162}
163
164static DWORD WINAPI d3d8_vertexbuffer_SetPriority(IDirect3DVertexBuffer8 *iface, DWORD priority)
165{
166 struct d3d8_vertexbuffer *buffer = impl_from_IDirect3DVertexBuffer8(iface);
167 DWORD previous;
168
169 TRACE("iface %p, priority %u.\n", iface, priority);
170
171 wined3d_mutex_lock();
172 previous = wined3d_buffer_set_priority(buffer->wined3d_buffer, priority);
173 wined3d_mutex_unlock();
174
175 return previous;
176}
177
178static DWORD WINAPI d3d8_vertexbuffer_GetPriority(IDirect3DVertexBuffer8 *iface)
179{
180 struct d3d8_vertexbuffer *buffer = impl_from_IDirect3DVertexBuffer8(iface);
181 DWORD priority;
182
183 TRACE("iface %p.\n", iface);
184
185 wined3d_mutex_lock();
186 priority = wined3d_buffer_get_priority(buffer->wined3d_buffer);
187 wined3d_mutex_unlock();
188
189 return priority;
190}
191
192static void WINAPI d3d8_vertexbuffer_PreLoad(IDirect3DVertexBuffer8 *iface)
193{
194 struct d3d8_vertexbuffer *buffer = impl_from_IDirect3DVertexBuffer8(iface);
195
196 TRACE("iface %p.\n", iface);
197
198 wined3d_mutex_lock();
199 wined3d_buffer_preload(buffer->wined3d_buffer);
200 wined3d_mutex_unlock();
201}
202
203static D3DRESOURCETYPE WINAPI d3d8_vertexbuffer_GetType(IDirect3DVertexBuffer8 *iface)
204{
205 TRACE("iface %p.\n", iface);
206
207 return D3DRTYPE_VERTEXBUFFER;
208}
209
210static HRESULT WINAPI d3d8_vertexbuffer_Lock(IDirect3DVertexBuffer8 *iface, UINT offset, UINT size,
211 BYTE **data, DWORD flags)
212{
213 struct d3d8_vertexbuffer *buffer = impl_from_IDirect3DVertexBuffer8(iface);
214 HRESULT hr;
215
216 TRACE("iface %p, offset %u, size %u, data %p, flags %#x.\n",
217 iface, offset, size, data, flags);
218
219 wined3d_mutex_lock();
220 hr = wined3d_buffer_map(buffer->wined3d_buffer, offset, size, data, flags);
221 wined3d_mutex_unlock();
222
223 return hr;
224}
225
226static HRESULT WINAPI d3d8_vertexbuffer_Unlock(IDirect3DVertexBuffer8 *iface)
227{
228 struct d3d8_vertexbuffer *buffer = impl_from_IDirect3DVertexBuffer8(iface);
229
230 TRACE("iface %p.\n", iface);
231
232 wined3d_mutex_lock();
233 wined3d_buffer_unmap(buffer->wined3d_buffer);
234 wined3d_mutex_unlock();
235
236 return D3D_OK;
237}
238
239static HRESULT WINAPI d3d8_vertexbuffer_GetDesc(IDirect3DVertexBuffer8 *iface,
240 D3DVERTEXBUFFER_DESC *desc)
241{
242 struct d3d8_vertexbuffer *buffer = impl_from_IDirect3DVertexBuffer8(iface);
243 struct wined3d_resource_desc wined3d_desc;
244 struct wined3d_resource *wined3d_resource;
245
246 TRACE("iface %p, desc %p.\n", iface, desc);
247
248 wined3d_mutex_lock();
249 wined3d_resource = wined3d_buffer_get_resource(buffer->wined3d_buffer);
250 wined3d_resource_get_desc(wined3d_resource, &wined3d_desc);
251 wined3d_mutex_unlock();
252
253 desc->Type = D3DRTYPE_VERTEXBUFFER;
254 desc->Usage = wined3d_desc.usage & WINED3DUSAGE_MASK;
255 desc->Pool = wined3d_desc.pool;
256 desc->Size = wined3d_desc.size;
257 desc->FVF = buffer->fvf;
258 desc->Format = D3DFMT_VERTEXDATA;
259
260 return D3D_OK;
261}
262
263static const IDirect3DVertexBuffer8Vtbl Direct3DVertexBuffer8_Vtbl =
264{
265 /* IUnknown */
266 d3d8_vertexbuffer_QueryInterface,
267 d3d8_vertexbuffer_AddRef,
268 d3d8_vertexbuffer_Release,
269 /* IDirect3DResource8 */
270 d3d8_vertexbuffer_GetDevice,
271 d3d8_vertexbuffer_SetPrivateData,
272 d3d8_vertexbuffer_GetPrivateData,
273 d3d8_vertexbuffer_FreePrivateData,
274 d3d8_vertexbuffer_SetPriority,
275 d3d8_vertexbuffer_GetPriority,
276 d3d8_vertexbuffer_PreLoad,
277 d3d8_vertexbuffer_GetType,
278 /* IDirect3DVertexBuffer8 */
279 d3d8_vertexbuffer_Lock,
280 d3d8_vertexbuffer_Unlock,
281 d3d8_vertexbuffer_GetDesc,
282};
283
284static void STDMETHODCALLTYPE d3d8_vertexbuffer_wined3d_object_destroyed(void *parent)
285{
286 HeapFree(GetProcessHeap(), 0, parent);
287}
288
289static const struct wined3d_parent_ops d3d8_vertexbuffer_wined3d_parent_ops =
290{
291 d3d8_vertexbuffer_wined3d_object_destroyed,
292};
293
294HRESULT vertexbuffer_init(struct d3d8_vertexbuffer *buffer, struct d3d8_device *device,
295 UINT size, DWORD usage, DWORD fvf, D3DPOOL pool)
296{
297 HRESULT hr;
298
299 buffer->IDirect3DVertexBuffer8_iface.lpVtbl = &Direct3DVertexBuffer8_Vtbl;
300 buffer->refcount = 1;
301 buffer->fvf = fvf;
302
303 wined3d_mutex_lock();
304 hr = wined3d_buffer_create_vb(device->wined3d_device, size, usage & WINED3DUSAGE_MASK,
305 (enum wined3d_pool)pool, buffer, &d3d8_vertexbuffer_wined3d_parent_ops, &buffer->wined3d_buffer);
306 wined3d_mutex_unlock();
307 if (FAILED(hr))
308 {
309 WARN("Failed to create wined3d buffer, hr %#x.\n", hr);
310 return hr;
311 }
312
313 buffer->parent_device = &device->IDirect3DDevice8_iface;
314 IDirect3DDevice8_AddRef(buffer->parent_device);
315
316 return D3D_OK;
317}
318
319struct d3d8_vertexbuffer *unsafe_impl_from_IDirect3DVertexBuffer8(IDirect3DVertexBuffer8 *iface)
320{
321 if (!iface)
322 return NULL;
323 assert(iface->lpVtbl == &Direct3DVertexBuffer8_Vtbl);
324
325 return impl_from_IDirect3DVertexBuffer8(iface);
326}
327
328static inline struct d3d8_indexbuffer *impl_from_IDirect3DIndexBuffer8(IDirect3DIndexBuffer8 *iface)
329{
330 return CONTAINING_RECORD(iface, struct d3d8_indexbuffer, IDirect3DIndexBuffer8_iface);
331}
332
333static HRESULT WINAPI d3d8_indexbuffer_QueryInterface(IDirect3DIndexBuffer8 *iface, REFIID riid, void **object)
334{
335 TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
336
337 if (IsEqualGUID(riid, &IID_IDirect3DIndexBuffer8)
338 || IsEqualGUID(riid, &IID_IDirect3DResource8)
339 || IsEqualGUID(riid, &IID_IUnknown))
340 {
341 IDirect3DIndexBuffer8_AddRef(iface);
342 *object = iface;
343 return S_OK;
344 }
345
346 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
347
348 *object = NULL;
349 return E_NOINTERFACE;
350}
351
352static ULONG WINAPI d3d8_indexbuffer_AddRef(IDirect3DIndexBuffer8 *iface)
353{
354 struct d3d8_indexbuffer *buffer = impl_from_IDirect3DIndexBuffer8(iface);
355 ULONG refcount = InterlockedIncrement(&buffer->refcount);
356
357 TRACE("%p increasing refcount to %u.\n", iface, refcount);
358
359 if (refcount == 1)
360 {
361 IDirect3DDevice8_AddRef(buffer->parent_device);
362 wined3d_mutex_lock();
363 wined3d_buffer_incref(buffer->wined3d_buffer);
364 wined3d_mutex_unlock();
365 }
366
367 return refcount;
368}
369
370static ULONG WINAPI d3d8_indexbuffer_Release(IDirect3DIndexBuffer8 *iface)
371{
372 struct d3d8_indexbuffer *buffer = impl_from_IDirect3DIndexBuffer8(iface);
373 ULONG refcount = InterlockedDecrement(&buffer->refcount);
374
375 TRACE("%p decreasing refcount to %u.\n", iface, refcount);
376
377 if (!refcount)
378 {
379 IDirect3DDevice8 *device = buffer->parent_device;
380
381 wined3d_mutex_lock();
382 wined3d_buffer_decref(buffer->wined3d_buffer);
383 wined3d_mutex_unlock();
384
385 /* Release the device last, as it may cause the device to be destroyed. */
386 IDirect3DDevice8_Release(device);
387 }
388
389 return refcount;
390}
391
392static HRESULT WINAPI d3d8_indexbuffer_GetDevice(IDirect3DIndexBuffer8 *iface,
393 IDirect3DDevice8 **device)
394{
395 struct d3d8_indexbuffer *buffer = impl_from_IDirect3DIndexBuffer8(iface);
396
397 TRACE("iface %p, device %p.\n", iface, device);
398
399 *device = buffer->parent_device;
400 IDirect3DDevice8_AddRef(*device);
401
402 TRACE("Returning device %p.\n", *device);
403
404 return D3D_OK;
405}
406
407static HRESULT WINAPI d3d8_indexbuffer_SetPrivateData(IDirect3DIndexBuffer8 *iface,
408 REFGUID guid, const void *data, DWORD data_size, DWORD flags)
409{
410 struct d3d8_indexbuffer *buffer = impl_from_IDirect3DIndexBuffer8(iface);
411 struct wined3d_resource *resource;
412 HRESULT hr;
413
414 TRACE("iface %p, guid %s, data %p, data_size %u, flags %#x.\n",
415 iface, debugstr_guid(guid), data, data_size, flags);
416
417 wined3d_mutex_lock();
418 resource = wined3d_buffer_get_resource(buffer->wined3d_buffer);
419 hr = wined3d_resource_set_private_data(resource, guid, data, data_size, flags);
420 wined3d_mutex_unlock();
421
422 return hr;
423}
424
425static HRESULT WINAPI d3d8_indexbuffer_GetPrivateData(IDirect3DIndexBuffer8 *iface,
426 REFGUID guid, void *data, DWORD *data_size)
427{
428 struct d3d8_indexbuffer *buffer = impl_from_IDirect3DIndexBuffer8(iface);
429 struct wined3d_resource *resource;
430 HRESULT hr;
431
432 TRACE("iface %p, guid %s, data %p, data_size %p.\n",
433 iface, debugstr_guid(guid), data, data_size);
434
435 wined3d_mutex_lock();
436 resource = wined3d_buffer_get_resource(buffer->wined3d_buffer);
437 hr = wined3d_resource_get_private_data(resource, guid, data, data_size);
438 wined3d_mutex_unlock();
439
440 return hr;
441}
442
443static HRESULT WINAPI d3d8_indexbuffer_FreePrivateData(IDirect3DIndexBuffer8 *iface, REFGUID guid)
444{
445 struct d3d8_indexbuffer *buffer = impl_from_IDirect3DIndexBuffer8(iface);
446 struct wined3d_resource *resource;
447 HRESULT hr;
448
449 TRACE("iface %p, guid %s.\n", iface, debugstr_guid(guid));
450
451 wined3d_mutex_lock();
452 resource = wined3d_buffer_get_resource(buffer->wined3d_buffer);
453 hr = wined3d_resource_free_private_data(resource, guid);
454 wined3d_mutex_unlock();
455
456 return hr;
457}
458
459static DWORD WINAPI d3d8_indexbuffer_SetPriority(IDirect3DIndexBuffer8 *iface, DWORD priority)
460{
461 struct d3d8_indexbuffer *buffer = impl_from_IDirect3DIndexBuffer8(iface);
462 DWORD previous;
463
464 TRACE("iface %p, priority %u.\n", iface, priority);
465
466 wined3d_mutex_lock();
467 previous = wined3d_buffer_set_priority(buffer->wined3d_buffer, priority);
468 wined3d_mutex_unlock();
469
470 return previous;
471}
472
473static DWORD WINAPI d3d8_indexbuffer_GetPriority(IDirect3DIndexBuffer8 *iface)
474{
475 struct d3d8_indexbuffer *buffer = impl_from_IDirect3DIndexBuffer8(iface);
476 DWORD priority;
477
478 TRACE("iface %p.\n", iface);
479
480 wined3d_mutex_lock();
481 priority = wined3d_buffer_get_priority(buffer->wined3d_buffer);
482 wined3d_mutex_unlock();
483
484 return priority;
485}
486
487static void WINAPI d3d8_indexbuffer_PreLoad(IDirect3DIndexBuffer8 *iface)
488{
489 struct d3d8_indexbuffer *buffer = impl_from_IDirect3DIndexBuffer8(iface);
490
491 TRACE("iface %p.\n", iface);
492
493 wined3d_mutex_lock();
494 wined3d_buffer_preload(buffer->wined3d_buffer);
495 wined3d_mutex_unlock();
496}
497
498static D3DRESOURCETYPE WINAPI d3d8_indexbuffer_GetType(IDirect3DIndexBuffer8 *iface)
499{
500 TRACE("iface %p.\n", iface);
501
502 return D3DRTYPE_INDEXBUFFER;
503}
504
505static HRESULT WINAPI d3d8_indexbuffer_Lock(IDirect3DIndexBuffer8 *iface, UINT offset, UINT size,
506 BYTE **data, DWORD flags)
507{
508 struct d3d8_indexbuffer *buffer = impl_from_IDirect3DIndexBuffer8(iface);
509 HRESULT hr;
510
511 TRACE("iface %p, offset %u, size %u, data %p, flags %#x.\n",
512 iface, offset, size, data, flags);
513
514 wined3d_mutex_lock();
515 hr = wined3d_buffer_map(buffer->wined3d_buffer, offset, size, data, flags);
516 wined3d_mutex_unlock();
517
518 return hr;
519}
520
521static HRESULT WINAPI d3d8_indexbuffer_Unlock(IDirect3DIndexBuffer8 *iface)
522{
523 struct d3d8_indexbuffer *buffer = impl_from_IDirect3DIndexBuffer8(iface);
524
525 TRACE("iface %p.\n", iface);
526
527 wined3d_mutex_lock();
528 wined3d_buffer_unmap(buffer->wined3d_buffer);
529 wined3d_mutex_unlock();
530
531 return D3D_OK;
532}
533
534static HRESULT WINAPI d3d8_indexbuffer_GetDesc(IDirect3DIndexBuffer8 *iface,
535 D3DINDEXBUFFER_DESC *desc)
536{
537 struct d3d8_indexbuffer *buffer = impl_from_IDirect3DIndexBuffer8(iface);
538 struct wined3d_resource_desc wined3d_desc;
539 struct wined3d_resource *wined3d_resource;
540
541 TRACE("iface %p, desc %p.\n", iface, desc);
542
543 wined3d_mutex_lock();
544 wined3d_resource = wined3d_buffer_get_resource(buffer->wined3d_buffer);
545 wined3d_resource_get_desc(wined3d_resource, &wined3d_desc);
546 wined3d_mutex_unlock();
547
548 desc->Format = d3dformat_from_wined3dformat(buffer->format);
549 desc->Type = D3DRTYPE_INDEXBUFFER;
550 desc->Usage = wined3d_desc.usage & WINED3DUSAGE_MASK;
551 desc->Pool = wined3d_desc.pool;
552 desc->Size = wined3d_desc.size;
553
554 return D3D_OK;
555}
556
557static const IDirect3DIndexBuffer8Vtbl d3d8_indexbuffer_vtbl =
558{
559 /* IUnknown */
560 d3d8_indexbuffer_QueryInterface,
561 d3d8_indexbuffer_AddRef,
562 d3d8_indexbuffer_Release,
563 /* IDirect3DResource8 */
564 d3d8_indexbuffer_GetDevice,
565 d3d8_indexbuffer_SetPrivateData,
566 d3d8_indexbuffer_GetPrivateData,
567 d3d8_indexbuffer_FreePrivateData,
568 d3d8_indexbuffer_SetPriority,
569 d3d8_indexbuffer_GetPriority,
570 d3d8_indexbuffer_PreLoad,
571 d3d8_indexbuffer_GetType,
572 /* IDirect3DIndexBuffer8 */
573 d3d8_indexbuffer_Lock,
574 d3d8_indexbuffer_Unlock,
575 d3d8_indexbuffer_GetDesc,
576};
577
578static void STDMETHODCALLTYPE d3d8_indexbuffer_wined3d_object_destroyed(void *parent)
579{
580 HeapFree(GetProcessHeap(), 0, parent);
581}
582
583static const struct wined3d_parent_ops d3d8_indexbuffer_wined3d_parent_ops =
584{
585 d3d8_indexbuffer_wined3d_object_destroyed,
586};
587
588HRESULT indexbuffer_init(struct d3d8_indexbuffer *buffer, struct d3d8_device *device,
589 UINT size, DWORD usage, D3DFORMAT format, D3DPOOL pool)
590{
591 HRESULT hr;
592
593 buffer->IDirect3DIndexBuffer8_iface.lpVtbl = &d3d8_indexbuffer_vtbl;
594 buffer->refcount = 1;
595 buffer->format = wined3dformat_from_d3dformat(format);
596
597 wined3d_mutex_lock();
598 hr = wined3d_buffer_create_ib(device->wined3d_device, size, usage & WINED3DUSAGE_MASK,
599 (enum wined3d_pool)pool, buffer, &d3d8_indexbuffer_wined3d_parent_ops, &buffer->wined3d_buffer);
600 wined3d_mutex_unlock();
601 if (FAILED(hr))
602 {
603 WARN("Failed to create wined3d buffer, hr %#x.\n", hr);
604 return hr;
605 }
606
607 buffer->parent_device = &device->IDirect3DDevice8_iface;
608 IDirect3DDevice8_AddRef(buffer->parent_device);
609
610 return D3D_OK;
611}
612
613struct d3d8_indexbuffer *unsafe_impl_from_IDirect3DIndexBuffer8(IDirect3DIndexBuffer8 *iface)
614{
615 if (!iface)
616 return NULL;
617 assert(iface->lpVtbl == &d3d8_indexbuffer_vtbl);
618
619 return impl_from_IDirect3DIndexBuffer8(iface);
620}
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette