VirtualBox

source: vbox/trunk/src/VBox/Additions/WINNT/Graphics/Wine_new/d3d9/buffer.c@ 51270

Last change on this file since 51270 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.8 KB
Line 
1/*
2 * Copyright 2002-2004 Jason Edmeades
3 * Copyright 2002-2004 Raphael Junqueira
4 * Copyright 2005 Oliver Stieber
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 */
20
21/*
22 * Oracle LGPL Disclaimer: For the avoidance of doubt, except that if any license choice
23 * other than GPL or LGPL is available it will apply instead, Oracle elects to use only
24 * the Lesser General Public License version 2.1 (LGPLv2) at this time for any software where
25 * a choice of LGPL license versions is made available with the language indicating
26 * that LGPLv2 or any later version may be used, or where a choice of which version
27 * of the LGPL is applied is otherwise unspecified.
28 */
29
30#include "config.h"
31#include "d3d9_private.h"
32
33WINE_DEFAULT_DEBUG_CHANNEL(d3d9);
34
35static inline struct d3d9_vertexbuffer *impl_from_IDirect3DVertexBuffer9(IDirect3DVertexBuffer9 *iface)
36{
37 return CONTAINING_RECORD(iface, struct d3d9_vertexbuffer, IDirect3DVertexBuffer9_iface);
38}
39
40static HRESULT WINAPI d3d9_vertexbuffer_QueryInterface(IDirect3DVertexBuffer9 *iface, REFIID riid, void **out)
41{
42 TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out);
43
44 if (IsEqualGUID(riid, &IID_IDirect3DVertexBuffer9)
45 || IsEqualGUID(riid, &IID_IDirect3DResource9)
46 || IsEqualGUID(riid, &IID_IUnknown))
47 {
48 IDirect3DVertexBuffer9_AddRef(iface);
49 *out = iface;
50 return S_OK;
51 }
52
53 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
54
55 *out = NULL;
56 return E_NOINTERFACE;
57}
58
59static ULONG WINAPI d3d9_vertexbuffer_AddRef(IDirect3DVertexBuffer9 *iface)
60{
61 struct d3d9_vertexbuffer *buffer = impl_from_IDirect3DVertexBuffer9(iface);
62 ULONG refcount = InterlockedIncrement(&buffer->refcount);
63
64 TRACE("%p increasing refcount to %u.\n", iface, refcount);
65
66 if (refcount == 1)
67 {
68 IDirect3DDevice9Ex_AddRef(buffer->parent_device);
69 wined3d_mutex_lock();
70 wined3d_buffer_incref(buffer->wined3d_buffer);
71 wined3d_mutex_unlock();
72 }
73
74 return refcount;
75}
76
77static ULONG WINAPI d3d9_vertexbuffer_Release(IDirect3DVertexBuffer9 *iface)
78{
79 struct d3d9_vertexbuffer *buffer = impl_from_IDirect3DVertexBuffer9(iface);
80 ULONG refcount = InterlockedDecrement(&buffer->refcount);
81
82 TRACE("%p decreasing refcount to %u.\n", iface, refcount);
83
84 if (!refcount)
85 {
86 IDirect3DDevice9Ex *device = buffer->parent_device;
87
88 wined3d_mutex_lock();
89 wined3d_buffer_decref(buffer->wined3d_buffer);
90 wined3d_mutex_unlock();
91
92 /* Release the device last, as it may cause the device to be destroyed. */
93 IDirect3DDevice9Ex_Release(device);
94 }
95
96 return refcount;
97}
98
99static HRESULT WINAPI d3d9_vertexbuffer_GetDevice(IDirect3DVertexBuffer9 *iface, IDirect3DDevice9 **device)
100{
101 struct d3d9_vertexbuffer *buffer = impl_from_IDirect3DVertexBuffer9(iface);
102
103 TRACE("iface %p, device %p.\n", iface, device);
104
105 *device = (IDirect3DDevice9 *)buffer->parent_device;
106 IDirect3DDevice9_AddRef(*device);
107
108 TRACE("Returning device %p.\n", *device);
109
110 return D3D_OK;
111}
112
113static HRESULT WINAPI d3d9_vertexbuffer_SetPrivateData(IDirect3DVertexBuffer9 *iface,
114 REFGUID guid, const void *data, DWORD data_size, DWORD flags)
115{
116 struct d3d9_vertexbuffer *buffer = impl_from_IDirect3DVertexBuffer9(iface);
117 struct wined3d_resource *resource;
118 HRESULT hr;
119
120 TRACE("iface %p, guid %s, data %p, data_size %u, flags %#x.\n",
121 iface, debugstr_guid(guid), data, data_size, flags);
122
123 wined3d_mutex_lock();
124 resource = wined3d_buffer_get_resource(buffer->wined3d_buffer);
125 hr = wined3d_resource_set_private_data(resource, guid, data, data_size, flags);
126 wined3d_mutex_unlock();
127
128 return hr;
129}
130
131static HRESULT WINAPI d3d9_vertexbuffer_GetPrivateData(IDirect3DVertexBuffer9 *iface,
132 REFGUID guid, void *data, DWORD *data_size)
133{
134 struct d3d9_vertexbuffer *buffer = impl_from_IDirect3DVertexBuffer9(iface);
135 struct wined3d_resource *resource;
136 HRESULT hr;
137
138 TRACE("iface %p, guid %s, data %p, data_size %p.\n",
139 iface, debugstr_guid(guid), data, data_size);
140
141 wined3d_mutex_lock();
142 resource = wined3d_buffer_get_resource(buffer->wined3d_buffer);
143 hr = wined3d_resource_get_private_data(resource, guid, data, data_size);
144 wined3d_mutex_unlock();
145
146 return hr;
147}
148
149static HRESULT WINAPI d3d9_vertexbuffer_FreePrivateData(IDirect3DVertexBuffer9 *iface, REFGUID guid)
150{
151 struct d3d9_vertexbuffer *buffer = impl_from_IDirect3DVertexBuffer9(iface);
152 struct wined3d_resource *resource;
153 HRESULT hr;
154
155 TRACE("iface %p, guid %s.\n", iface, debugstr_guid(guid));
156
157 wined3d_mutex_lock();
158 resource = wined3d_buffer_get_resource(buffer->wined3d_buffer);
159 hr = wined3d_resource_free_private_data(resource, guid);
160 wined3d_mutex_unlock();
161
162 return hr;
163}
164
165static DWORD WINAPI d3d9_vertexbuffer_SetPriority(IDirect3DVertexBuffer9 *iface, DWORD priority)
166{
167 struct d3d9_vertexbuffer *buffer = impl_from_IDirect3DVertexBuffer9(iface);
168 DWORD previous;
169
170 TRACE("iface %p, priority %u.\n", iface, priority);
171
172 wined3d_mutex_lock();
173 previous = wined3d_buffer_set_priority(buffer->wined3d_buffer, priority);
174 wined3d_mutex_unlock();
175
176 return previous;
177}
178
179static DWORD WINAPI d3d9_vertexbuffer_GetPriority(IDirect3DVertexBuffer9 *iface)
180{
181 struct d3d9_vertexbuffer *buffer = impl_from_IDirect3DVertexBuffer9(iface);
182 DWORD priority;
183
184 TRACE("iface %p.\n", iface);
185
186 wined3d_mutex_lock();
187 priority = wined3d_buffer_get_priority(buffer->wined3d_buffer);
188 wined3d_mutex_unlock();
189
190 return priority;
191}
192
193static void WINAPI d3d9_vertexbuffer_PreLoad(IDirect3DVertexBuffer9 *iface)
194{
195 struct d3d9_vertexbuffer *buffer = impl_from_IDirect3DVertexBuffer9(iface);
196
197 TRACE("iface %p.\n", iface);
198
199 wined3d_mutex_lock();
200 wined3d_buffer_preload(buffer->wined3d_buffer);
201 wined3d_mutex_unlock();
202}
203
204static D3DRESOURCETYPE WINAPI d3d9_vertexbuffer_GetType(IDirect3DVertexBuffer9 *iface)
205{
206 TRACE("iface %p.\n", iface);
207
208 return D3DRTYPE_VERTEXBUFFER;
209}
210
211static HRESULT WINAPI d3d9_vertexbuffer_Lock(IDirect3DVertexBuffer9 *iface, UINT offset, UINT size,
212 void **data, DWORD flags)
213{
214 struct d3d9_vertexbuffer *buffer = impl_from_IDirect3DVertexBuffer9(iface);
215 HRESULT hr;
216
217 TRACE("iface %p, offset %u, size %u, data %p, flags %#x.\n",
218 iface, offset, size, data, flags);
219
220 wined3d_mutex_lock();
221 hr = wined3d_buffer_map(buffer->wined3d_buffer, offset, size, (BYTE **)data, flags);
222 wined3d_mutex_unlock();
223
224 return hr;
225}
226
227static HRESULT WINAPI d3d9_vertexbuffer_Unlock(IDirect3DVertexBuffer9 *iface)
228{
229 struct d3d9_vertexbuffer *buffer = impl_from_IDirect3DVertexBuffer9(iface);
230
231 TRACE("iface %p.\n", iface);
232
233 wined3d_mutex_lock();
234 wined3d_buffer_unmap(buffer->wined3d_buffer);
235 wined3d_mutex_unlock();
236
237 return D3D_OK;
238}
239
240static HRESULT WINAPI d3d9_vertexbuffer_GetDesc(IDirect3DVertexBuffer9 *iface,
241 D3DVERTEXBUFFER_DESC *desc)
242{
243 struct d3d9_vertexbuffer *buffer = impl_from_IDirect3DVertexBuffer9(iface);
244 struct wined3d_resource_desc wined3d_desc;
245 struct wined3d_resource *wined3d_resource;
246
247 TRACE("iface %p, desc %p.\n", iface, desc);
248
249 wined3d_mutex_lock();
250 wined3d_resource = wined3d_buffer_get_resource(buffer->wined3d_buffer);
251 wined3d_resource_get_desc(wined3d_resource, &wined3d_desc);
252 wined3d_mutex_unlock();
253
254 desc->Format = D3DFMT_VERTEXDATA;
255 desc->Usage = wined3d_desc.usage & WINED3DUSAGE_MASK;
256 desc->Pool = wined3d_desc.pool;
257 desc->Size = wined3d_desc.size;
258 desc->Type = D3DRTYPE_VERTEXBUFFER;
259 desc->FVF = buffer->fvf;
260
261 return D3D_OK;
262}
263
264static const IDirect3DVertexBuffer9Vtbl d3d9_vertexbuffer_vtbl =
265{
266 /* IUnknown */
267 d3d9_vertexbuffer_QueryInterface,
268 d3d9_vertexbuffer_AddRef,
269 d3d9_vertexbuffer_Release,
270 /* IDirect3DResource9 */
271 d3d9_vertexbuffer_GetDevice,
272 d3d9_vertexbuffer_SetPrivateData,
273 d3d9_vertexbuffer_GetPrivateData,
274 d3d9_vertexbuffer_FreePrivateData,
275 d3d9_vertexbuffer_SetPriority,
276 d3d9_vertexbuffer_GetPriority,
277 d3d9_vertexbuffer_PreLoad,
278 d3d9_vertexbuffer_GetType,
279 /* IDirect3DVertexBuffer9 */
280 d3d9_vertexbuffer_Lock,
281 d3d9_vertexbuffer_Unlock,
282 d3d9_vertexbuffer_GetDesc,
283};
284
285static void STDMETHODCALLTYPE d3d9_vertexbuffer_wined3d_object_destroyed(void *parent)
286{
287 HeapFree(GetProcessHeap(), 0, parent);
288}
289
290static const struct wined3d_parent_ops d3d9_vertexbuffer_wined3d_parent_ops =
291{
292 d3d9_vertexbuffer_wined3d_object_destroyed,
293};
294
295HRESULT vertexbuffer_init(struct d3d9_vertexbuffer *buffer, struct d3d9_device *device,
296 UINT size, UINT usage, DWORD fvf, D3DPOOL pool)
297{
298 HRESULT hr;
299
300 buffer->IDirect3DVertexBuffer9_iface.lpVtbl = &d3d9_vertexbuffer_vtbl;
301 buffer->refcount = 1;
302 buffer->fvf = fvf;
303
304 wined3d_mutex_lock();
305 hr = wined3d_buffer_create_vb(device->wined3d_device, size, usage & WINED3DUSAGE_MASK,
306 (enum wined3d_pool)pool, buffer, &d3d9_vertexbuffer_wined3d_parent_ops, &buffer->wined3d_buffer);
307 wined3d_mutex_unlock();
308 if (FAILED(hr))
309 {
310 WARN("Failed to create wined3d buffer, hr %#x.\n", hr);
311 return hr;
312 }
313
314 buffer->parent_device = &device->IDirect3DDevice9Ex_iface;
315 IDirect3DDevice9Ex_AddRef(buffer->parent_device);
316
317 return D3D_OK;
318}
319
320struct d3d9_vertexbuffer *unsafe_impl_from_IDirect3DVertexBuffer9(IDirect3DVertexBuffer9 *iface)
321{
322 if (!iface)
323 return NULL;
324 assert(iface->lpVtbl == &d3d9_vertexbuffer_vtbl);
325
326 return impl_from_IDirect3DVertexBuffer9(iface);
327}
328
329static inline struct d3d9_indexbuffer *impl_from_IDirect3DIndexBuffer9(IDirect3DIndexBuffer9 *iface)
330{
331 return CONTAINING_RECORD(iface, struct d3d9_indexbuffer, IDirect3DIndexBuffer9_iface);
332}
333
334static HRESULT WINAPI d3d9_indexbuffer_QueryInterface(IDirect3DIndexBuffer9 *iface, REFIID riid, void **out)
335{
336 TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out);
337
338 if (IsEqualGUID(riid, &IID_IDirect3DIndexBuffer9)
339 || IsEqualGUID(riid, &IID_IDirect3DResource9)
340 || IsEqualGUID(riid, &IID_IUnknown))
341 {
342 IDirect3DIndexBuffer9_AddRef(iface);
343 *out = iface;
344 return S_OK;
345 }
346
347 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
348
349 *out = NULL;
350 return E_NOINTERFACE;
351}
352
353static ULONG WINAPI d3d9_indexbuffer_AddRef(IDirect3DIndexBuffer9 *iface)
354{
355 struct d3d9_indexbuffer *buffer = impl_from_IDirect3DIndexBuffer9(iface);
356 ULONG refcount = InterlockedIncrement(&buffer->refcount);
357
358 TRACE("%p increasing refcount to %u.\n", iface, refcount);
359
360 if (refcount == 1)
361 {
362 IDirect3DDevice9Ex_AddRef(buffer->parent_device);
363 wined3d_mutex_lock();
364 wined3d_buffer_incref(buffer->wined3d_buffer);
365 wined3d_mutex_unlock();
366 }
367
368 return refcount;
369}
370
371static ULONG WINAPI d3d9_indexbuffer_Release(IDirect3DIndexBuffer9 *iface)
372{
373 struct d3d9_indexbuffer *buffer = impl_from_IDirect3DIndexBuffer9(iface);
374 ULONG refcount = InterlockedDecrement(&buffer->refcount);
375
376 TRACE("%p decreasing refcount to %u.\n", iface, refcount);
377
378 if (!refcount)
379 {
380 IDirect3DDevice9Ex *device = buffer->parent_device;
381
382 wined3d_mutex_lock();
383 wined3d_buffer_decref(buffer->wined3d_buffer);
384 wined3d_mutex_unlock();
385
386 /* Release the device last, as it may cause the device to be destroyed. */
387 IDirect3DDevice9Ex_Release(device);
388 }
389
390 return refcount;
391}
392
393static HRESULT WINAPI d3d9_indexbuffer_GetDevice(IDirect3DIndexBuffer9 *iface, IDirect3DDevice9 **device)
394{
395 struct d3d9_indexbuffer *buffer = impl_from_IDirect3DIndexBuffer9(iface);
396
397 TRACE("iface %p, device %p.\n", iface, device);
398
399 *device = (IDirect3DDevice9 *)buffer->parent_device;
400 IDirect3DDevice9_AddRef(*device);
401
402 TRACE("Returning device %p.\n", *device);
403
404 return D3D_OK;
405}
406
407static HRESULT WINAPI d3d9_indexbuffer_SetPrivateData(IDirect3DIndexBuffer9 *iface,
408 REFGUID guid, const void *data, DWORD data_size, DWORD flags)
409{
410 struct d3d9_indexbuffer *buffer = impl_from_IDirect3DIndexBuffer9(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 d3d9_indexbuffer_GetPrivateData(IDirect3DIndexBuffer9 *iface,
426 REFGUID guid, void *data, DWORD *data_size)
427{
428 struct d3d9_indexbuffer *buffer = impl_from_IDirect3DIndexBuffer9(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 d3d9_indexbuffer_FreePrivateData(IDirect3DIndexBuffer9 *iface, REFGUID guid)
444{
445 struct d3d9_indexbuffer *buffer = impl_from_IDirect3DIndexBuffer9(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 d3d9_indexbuffer_SetPriority(IDirect3DIndexBuffer9 *iface, DWORD priority)
460{
461 struct d3d9_indexbuffer *buffer = impl_from_IDirect3DIndexBuffer9(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 d3d9_indexbuffer_GetPriority(IDirect3DIndexBuffer9 *iface)
474{
475 struct d3d9_indexbuffer *buffer = impl_from_IDirect3DIndexBuffer9(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 d3d9_indexbuffer_PreLoad(IDirect3DIndexBuffer9 *iface)
488{
489 struct d3d9_indexbuffer *buffer = impl_from_IDirect3DIndexBuffer9(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 d3d9_indexbuffer_GetType(IDirect3DIndexBuffer9 *iface)
499{
500 TRACE("iface %p.\n", iface);
501
502 return D3DRTYPE_INDEXBUFFER;
503}
504
505static HRESULT WINAPI d3d9_indexbuffer_Lock(IDirect3DIndexBuffer9 *iface,
506 UINT offset, UINT size, void **data, DWORD flags)
507{
508 struct d3d9_indexbuffer *buffer = impl_from_IDirect3DIndexBuffer9(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, (BYTE **)data, flags);
516 wined3d_mutex_unlock();
517
518 return hr;
519}
520
521static HRESULT WINAPI d3d9_indexbuffer_Unlock(IDirect3DIndexBuffer9 *iface)
522{
523 struct d3d9_indexbuffer *buffer = impl_from_IDirect3DIndexBuffer9(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 d3d9_indexbuffer_GetDesc(IDirect3DIndexBuffer9 *iface, D3DINDEXBUFFER_DESC *desc)
535{
536 struct d3d9_indexbuffer *buffer = impl_from_IDirect3DIndexBuffer9(iface);
537 struct wined3d_resource_desc wined3d_desc;
538 struct wined3d_resource *wined3d_resource;
539
540 TRACE("iface %p, desc %p.\n", iface, desc);
541
542 wined3d_mutex_lock();
543 wined3d_resource = wined3d_buffer_get_resource(buffer->wined3d_buffer);
544 wined3d_resource_get_desc(wined3d_resource, &wined3d_desc);
545 wined3d_mutex_unlock();
546
547 desc->Format = d3dformat_from_wined3dformat(buffer->format);
548 desc->Usage = wined3d_desc.usage & WINED3DUSAGE_MASK;
549 desc->Pool = wined3d_desc.pool;
550 desc->Size = wined3d_desc.size;
551 desc->Type = D3DRTYPE_INDEXBUFFER;
552
553 return D3D_OK;
554}
555
556static const IDirect3DIndexBuffer9Vtbl d3d9_indexbuffer_vtbl =
557{
558 /* IUnknown */
559 d3d9_indexbuffer_QueryInterface,
560 d3d9_indexbuffer_AddRef,
561 d3d9_indexbuffer_Release,
562 /* IDirect3DResource9 */
563 d3d9_indexbuffer_GetDevice,
564 d3d9_indexbuffer_SetPrivateData,
565 d3d9_indexbuffer_GetPrivateData,
566 d3d9_indexbuffer_FreePrivateData,
567 d3d9_indexbuffer_SetPriority,
568 d3d9_indexbuffer_GetPriority,
569 d3d9_indexbuffer_PreLoad,
570 d3d9_indexbuffer_GetType,
571 /* IDirect3DIndexBuffer9 */
572 d3d9_indexbuffer_Lock,
573 d3d9_indexbuffer_Unlock,
574 d3d9_indexbuffer_GetDesc,
575};
576
577static void STDMETHODCALLTYPE d3d9_indexbuffer_wined3d_object_destroyed(void *parent)
578{
579 HeapFree(GetProcessHeap(), 0, parent);
580}
581
582static const struct wined3d_parent_ops d3d9_indexbuffer_wined3d_parent_ops =
583{
584 d3d9_indexbuffer_wined3d_object_destroyed,
585};
586
587HRESULT indexbuffer_init(struct d3d9_indexbuffer *buffer, struct d3d9_device *device,
588 UINT size, DWORD usage, D3DFORMAT format, D3DPOOL pool)
589{
590 HRESULT hr;
591
592 buffer->IDirect3DIndexBuffer9_iface.lpVtbl = &d3d9_indexbuffer_vtbl;
593 buffer->refcount = 1;
594 buffer->format = wined3dformat_from_d3dformat(format);
595
596 wined3d_mutex_lock();
597 hr = wined3d_buffer_create_ib(device->wined3d_device, size, usage & WINED3DUSAGE_MASK,
598 (enum wined3d_pool)pool, buffer, &d3d9_indexbuffer_wined3d_parent_ops, &buffer->wined3d_buffer);
599 wined3d_mutex_unlock();
600 if (FAILED(hr))
601 {
602 WARN("Failed to create wined3d buffer, hr %#x.\n", hr);
603 return hr;
604 }
605
606 buffer->parent_device = &device->IDirect3DDevice9Ex_iface;
607 IDirect3DDevice9Ex_AddRef(buffer->parent_device);
608
609 return D3D_OK;
610}
611
612struct d3d9_indexbuffer *unsafe_impl_from_IDirect3DIndexBuffer9(IDirect3DIndexBuffer9 *iface)
613{
614 if (!iface)
615 return NULL;
616 assert(iface->lpVtbl == &d3d9_indexbuffer_vtbl);
617
618 return impl_from_IDirect3DIndexBuffer9(iface);
619}
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