1 /* Direct3D Vertex Buffer
2 * Copyright (c) 2002 Lionel ULMER
3 * Copyright (c) 2006 Stefan DÖSINGER
5 * This file contains the implementation of Direct3DVertexBuffer COM object
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 #include "wine/port.h"
25 #include "ddraw_private.h"
27 WINE_DEFAULT_DEBUG_CHANNEL(ddraw
);
29 static inline struct d3d_vertex_buffer
*impl_from_IDirect3DVertexBuffer(IDirect3DVertexBuffer
*iface
)
31 return CONTAINING_RECORD(iface
, struct d3d_vertex_buffer
, IDirect3DVertexBuffer_iface
);
34 static inline struct d3d_vertex_buffer
*impl_from_IDirect3DVertexBuffer7(IDirect3DVertexBuffer7
*iface
)
36 return CONTAINING_RECORD(iface
, struct d3d_vertex_buffer
, IDirect3DVertexBuffer7_iface
);
39 /*****************************************************************************
41 *****************************************************************************/
43 /*****************************************************************************
44 * IDirect3DVertexBuffer7::QueryInterface
46 * The QueryInterface Method for Vertex Buffers
47 * For a link to QueryInterface rules, see IDirectDraw7::QueryInterface
50 * riid: Queried Interface id
51 * obj: Address to return the interface pointer
55 * E_NOINTERFACE if the interface wasn't found
57 *****************************************************************************/
58 static HRESULT WINAPI
d3d_vertex_buffer7_QueryInterface(IDirect3DVertexBuffer7
*iface
, REFIID riid
, void **obj
)
60 struct d3d_vertex_buffer
*buffer
= impl_from_IDirect3DVertexBuffer7(iface
);
62 TRACE("iface %p, riid %s, object %p.\n", iface
, debugstr_guid(riid
), obj
);
64 /* By default, set the object pointer to NULL */
67 if ( IsEqualGUID( &IID_IUnknown
, riid
) )
69 IUnknown_AddRef(iface
);
71 TRACE(" Creating IUnknown interface at %p.\n", *obj
);
74 if ( IsEqualGUID( &IID_IDirect3DVertexBuffer
, riid
) )
76 IUnknown_AddRef(iface
);
77 *obj
= &buffer
->IDirect3DVertexBuffer_iface
;
78 TRACE(" Creating IDirect3DVertexBuffer interface %p\n", *obj
);
81 if ( IsEqualGUID( &IID_IDirect3DVertexBuffer7
, riid
) )
83 IUnknown_AddRef(iface
);
85 TRACE(" Creating IDirect3DVertexBuffer7 interface %p\n", *obj
);
89 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid
));
94 static HRESULT WINAPI
d3d_vertex_buffer1_QueryInterface(IDirect3DVertexBuffer
*iface
, REFIID riid
, void **obj
)
96 struct d3d_vertex_buffer
*buffer
= impl_from_IDirect3DVertexBuffer(iface
);
98 TRACE("iface %p, riid %s, object %p.\n", iface
, debugstr_guid(riid
), obj
);
100 return d3d_vertex_buffer7_QueryInterface(&buffer
->IDirect3DVertexBuffer7_iface
, riid
, obj
);
103 /*****************************************************************************
104 * IDirect3DVertexBuffer7::AddRef
106 * AddRef for Vertex Buffers
111 *****************************************************************************/
112 static ULONG WINAPI
d3d_vertex_buffer7_AddRef(IDirect3DVertexBuffer7
*iface
)
114 struct d3d_vertex_buffer
*buffer
= impl_from_IDirect3DVertexBuffer7(iface
);
115 ULONG ref
= InterlockedIncrement(&buffer
->ref
);
117 TRACE("%p increasing refcount to %u.\n", buffer
, ref
);
122 static ULONG WINAPI
d3d_vertex_buffer1_AddRef(IDirect3DVertexBuffer
*iface
)
124 struct d3d_vertex_buffer
*buffer
= impl_from_IDirect3DVertexBuffer(iface
);
126 TRACE("iface %p.\n", iface
);
128 return d3d_vertex_buffer7_AddRef(&buffer
->IDirect3DVertexBuffer7_iface
);
132 /*****************************************************************************
133 * IDirect3DVertexBuffer7::Release
135 * Release for Vertex Buffers
140 *****************************************************************************/
141 static ULONG WINAPI
d3d_vertex_buffer7_Release(IDirect3DVertexBuffer7
*iface
)
143 struct d3d_vertex_buffer
*buffer
= impl_from_IDirect3DVertexBuffer7(iface
);
144 ULONG ref
= InterlockedDecrement(&buffer
->ref
);
146 TRACE("%p decreasing refcount to %u.\n", buffer
, ref
);
150 struct wined3d_buffer
*curVB
= NULL
;
153 /* D3D7 Vertex buffers don't stay bound in the device, they are passed
154 * as a parameter to drawPrimitiveVB. DrawPrimitiveVB sets them as the
155 * stream source in wined3d, and they should get unset there before
156 * they are destroyed. */
157 wined3d_mutex_lock();
158 wined3d_device_get_stream_source(buffer
->ddraw
->wined3d_device
,
159 0, &curVB
, &offset
, &stride
);
160 if (curVB
== buffer
->wineD3DVertexBuffer
)
161 wined3d_device_set_stream_source(buffer
->ddraw
->wined3d_device
, 0, NULL
, 0, 0);
163 wined3d_buffer_decref(curVB
); /* For the GetStreamSource */
165 wined3d_vertex_declaration_decref(buffer
->wineD3DVertexDeclaration
);
166 wined3d_buffer_decref(buffer
->wineD3DVertexBuffer
);
167 wined3d_mutex_unlock();
169 HeapFree(GetProcessHeap(), 0, buffer
);
175 static ULONG WINAPI
d3d_vertex_buffer1_Release(IDirect3DVertexBuffer
*iface
)
177 struct d3d_vertex_buffer
*buffer
= impl_from_IDirect3DVertexBuffer(iface
);
179 TRACE("iface %p.\n", iface
);
181 return d3d_vertex_buffer7_Release(&buffer
->IDirect3DVertexBuffer7_iface
);
184 /*****************************************************************************
185 * IDirect3DVertexBuffer Methods
186 *****************************************************************************/
188 /*****************************************************************************
189 * IDirect3DVertexBuffer7::Lock
191 * Locks the vertex buffer and returns a pointer to the vertex data
192 * Locking vertex buffers is similar to locking surfaces, because Windows
193 * uses surfaces to store vertex data internally (According to the DX sdk)
196 * Flags: Locking flags. Relevant here are DDLOCK_READONLY, DDLOCK_WRITEONLY,
197 * DDLOCK_DISCARDCONTENTS and DDLOCK_NOOVERWRITE.
198 * Data: Returns a pointer to the vertex data
199 * Size: Returns the size of the buffer if not NULL
203 * DDERR_INVALIDPARAMS if Data is NULL
204 * D3DERR_VERTEXBUFFEROPTIMIZED if called on an optimized buffer(WineD3D)
206 *****************************************************************************/
207 static HRESULT WINAPI
d3d_vertex_buffer7_Lock(IDirect3DVertexBuffer7
*iface
,
208 DWORD flags
, void **data
, DWORD
*data_size
)
210 struct d3d_vertex_buffer
*buffer
= impl_from_IDirect3DVertexBuffer7(iface
);
211 struct wined3d_resource_desc wined3d_desc
;
212 struct wined3d_resource
*wined3d_resource
;
214 DWORD wined3d_flags
= 0;
216 TRACE("iface %p, flags %#x, data %p, data_size %p.\n", iface
, flags
, data
, data_size
);
218 /* Writeonly: Pointless. Event: Unsupported by native according to the sdk
219 * nosyslock: Not applicable
221 if (!(flags
& DDLOCK_WAIT
))
222 wined3d_flags
|= WINED3D_MAP_DONOTWAIT
;
223 if (flags
& DDLOCK_READONLY
)
224 wined3d_flags
|= WINED3D_MAP_READONLY
;
225 if (flags
& DDLOCK_NOOVERWRITE
)
226 wined3d_flags
|= WINED3D_MAP_NOOVERWRITE
;
227 if (flags
& DDLOCK_DISCARDCONTENTS
)
228 wined3d_flags
|= WINED3D_MAP_DISCARD
;
230 wined3d_mutex_lock();
233 /* Get the size, for returning it, and for locking */
234 wined3d_resource
= wined3d_buffer_get_resource(buffer
->wineD3DVertexBuffer
);
235 wined3d_resource_get_desc(wined3d_resource
, &wined3d_desc
);
236 *data_size
= wined3d_desc
.size
;
239 hr
= wined3d_buffer_map(buffer
->wineD3DVertexBuffer
, 0, 0, (BYTE
**)data
, wined3d_flags
);
240 wined3d_mutex_unlock();
245 static HRESULT WINAPI
d3d_vertex_buffer1_Lock(IDirect3DVertexBuffer
*iface
,
246 DWORD flags
, void **data
, DWORD
*data_size
)
248 struct d3d_vertex_buffer
*buffer
= impl_from_IDirect3DVertexBuffer(iface
);
250 TRACE("iface %p, flags %#x, data %p, data_size %p.\n", iface
, flags
, data
, data_size
);
252 return d3d_vertex_buffer7_Lock(&buffer
->IDirect3DVertexBuffer7_iface
, flags
, data
, data_size
);
255 /*****************************************************************************
256 * IDirect3DVertexBuffer7::Unlock
258 * Unlocks a vertex Buffer
263 *****************************************************************************/
264 static HRESULT WINAPI
d3d_vertex_buffer7_Unlock(IDirect3DVertexBuffer7
*iface
)
266 struct d3d_vertex_buffer
*buffer
= impl_from_IDirect3DVertexBuffer7(iface
);
268 TRACE("iface %p.\n", iface
);
270 wined3d_mutex_lock();
271 wined3d_buffer_unmap(buffer
->wineD3DVertexBuffer
);
272 wined3d_mutex_unlock();
277 static HRESULT WINAPI
d3d_vertex_buffer1_Unlock(IDirect3DVertexBuffer
*iface
)
279 struct d3d_vertex_buffer
*buffer
= impl_from_IDirect3DVertexBuffer(iface
);
281 TRACE("iface %p.\n", iface
);
283 return d3d_vertex_buffer7_Unlock(&buffer
->IDirect3DVertexBuffer7_iface
);
287 /*****************************************************************************
288 * IDirect3DVertexBuffer7::ProcessVertices
290 * Processes untransformed Vertices into a transformed or optimized vertex
291 * buffer. It can also perform other operations, such as lighting or clipping
294 * VertexOp: Operation(s) to perform: D3DVOP_CLIP, _EXTENTS, _LIGHT, _TRANSFORM
295 * DestIndex: Index in the destination buffer(This), where the vertices are
297 * Count: Number of Vertices in the Source buffer to process
298 * SrcBuffer: Source vertex buffer
299 * SrcIndex: Index of the first vertex in the src buffer to process
300 * D3DDevice: Device to use for transformation
301 * Flags: 0 for default, D3DPV_DONOTCOPYDATA to prevent copying
306 * DDERR_INVALIDPARAMS If D3DVOP_TRANSFORM wasn't passed
308 *****************************************************************************/
309 static HRESULT WINAPI
d3d_vertex_buffer7_ProcessVertices(IDirect3DVertexBuffer7
*iface
,
310 DWORD vertex_op
, DWORD dst_idx
, DWORD count
, IDirect3DVertexBuffer7
*src_buffer
,
311 DWORD src_idx
, IDirect3DDevice7
*device
, DWORD flags
)
313 struct d3d_vertex_buffer
*dst_buffer_impl
= impl_from_IDirect3DVertexBuffer7(iface
);
314 struct d3d_vertex_buffer
*src_buffer_impl
= unsafe_impl_from_IDirect3DVertexBuffer7(src_buffer
);
315 struct d3d_device
*device_impl
= unsafe_impl_from_IDirect3DDevice7(device
);
316 BOOL oldClip
, doClip
;
319 TRACE("iface %p, vertex_op %#x, dst_idx %u, count %u, src_buffer %p, src_idx %u, device %p, flags %#x.\n",
320 iface
, vertex_op
, dst_idx
, count
, src_buffer
, src_idx
, device
, flags
);
322 /* Vertex operations:
323 * D3DVOP_CLIP: Clips vertices outside the viewing frustrum. Needs clipping information
324 * in the vertex buffer (Buffer may not be created with D3DVBCAPS_DONOTCLIP)
325 * D3DVOP_EXTENTS: Causes the screen extents to be updated when rendering the vertices
326 * D3DVOP_LIGHT: Lights the vertices
327 * D3DVOP_TRANSFORM: Transform the vertices. This flag is necessary
329 * WineD3D only transforms and clips the vertices by now, so EXTENTS and LIGHT
330 * are not implemented. Clipping is disabled ATM, because of unsure conditions.
332 if (!(vertex_op
& D3DVOP_TRANSFORM
))
333 return DDERR_INVALIDPARAMS
;
335 wined3d_mutex_lock();
337 /* WineD3D doesn't know d3d7 vertex operation, it uses
338 * render states instead. Set the render states according to
341 doClip
= !!(vertex_op
& D3DVOP_CLIP
);
342 wined3d_device_get_render_state(device_impl
->wined3d_device
, WINED3D_RS_CLIPPING
, (DWORD
*)&oldClip
);
343 if (doClip
!= oldClip
)
344 wined3d_device_set_render_state(device_impl
->wined3d_device
, WINED3D_RS_CLIPPING
, doClip
);
346 wined3d_device_set_stream_source(device_impl
->wined3d_device
,
347 0, src_buffer_impl
->wineD3DVertexBuffer
, 0, get_flexible_vertex_size(src_buffer_impl
->fvf
));
348 wined3d_device_set_vertex_declaration(device_impl
->wined3d_device
, src_buffer_impl
->wineD3DVertexDeclaration
);
349 hr
= wined3d_device_process_vertices(device_impl
->wined3d_device
, src_idx
, dst_idx
,
350 count
, dst_buffer_impl
->wineD3DVertexBuffer
, NULL
, flags
, dst_buffer_impl
->fvf
);
352 /* Restore the states if needed */
353 if (doClip
!= oldClip
)
354 wined3d_device_set_render_state(device_impl
->wined3d_device
, WINED3D_RS_CLIPPING
, oldClip
);
356 wined3d_mutex_unlock();
361 static HRESULT WINAPI
d3d_vertex_buffer1_ProcessVertices(IDirect3DVertexBuffer
*iface
,
362 DWORD vertex_op
, DWORD dst_idx
, DWORD count
, IDirect3DVertexBuffer
*src_buffer
,
363 DWORD src_idx
, IDirect3DDevice3
*device
, DWORD flags
)
365 struct d3d_vertex_buffer
*dst_buffer_impl
= impl_from_IDirect3DVertexBuffer(iface
);
366 struct d3d_vertex_buffer
*src_buffer_impl
= unsafe_impl_from_IDirect3DVertexBuffer(src_buffer
);
367 struct d3d_device
*device_impl
= unsafe_impl_from_IDirect3DDevice3(device
);
369 TRACE("iface %p, vertex_op %#x, dst_idx %u, count %u, src_buffer %p, src_idx %u, device %p, flags %#x.\n",
370 iface
, vertex_op
, dst_idx
, count
, src_buffer
, src_idx
, device
, flags
);
372 return d3d_vertex_buffer7_ProcessVertices(&dst_buffer_impl
->IDirect3DVertexBuffer7_iface
, vertex_op
,
373 dst_idx
, count
, &src_buffer_impl
->IDirect3DVertexBuffer7_iface
, src_idx
,
374 device_impl
? &device_impl
->IDirect3DDevice7_iface
: NULL
, flags
);
377 /*****************************************************************************
378 * IDirect3DVertexBuffer7::GetVertexBufferDesc
380 * Returns the description of a vertex buffer
383 * Desc: Address to write the description to
386 * DDERR_INVALIDPARAMS if Desc is NULL
389 *****************************************************************************/
390 static HRESULT WINAPI
d3d_vertex_buffer7_GetVertexBufferDesc(IDirect3DVertexBuffer7
*iface
, D3DVERTEXBUFFERDESC
*desc
)
392 struct d3d_vertex_buffer
*buffer
= impl_from_IDirect3DVertexBuffer7(iface
);
393 struct wined3d_resource_desc wined3d_desc
;
394 struct wined3d_resource
*wined3d_resource
;
396 TRACE("iface %p, desc %p.\n", iface
, desc
);
398 if (!desc
) return DDERR_INVALIDPARAMS
;
400 wined3d_mutex_lock();
401 wined3d_resource
= wined3d_buffer_get_resource(buffer
->wineD3DVertexBuffer
);
402 wined3d_resource_get_desc(wined3d_resource
, &wined3d_desc
);
403 wined3d_mutex_unlock();
405 /* Now fill the desc structure */
406 desc
->dwCaps
= buffer
->Caps
;
407 desc
->dwFVF
= buffer
->fvf
;
408 desc
->dwNumVertices
= wined3d_desc
.size
/ get_flexible_vertex_size(buffer
->fvf
);
413 static HRESULT WINAPI
d3d_vertex_buffer1_GetVertexBufferDesc(IDirect3DVertexBuffer
*iface
, D3DVERTEXBUFFERDESC
*desc
)
415 struct d3d_vertex_buffer
*buffer
= impl_from_IDirect3DVertexBuffer(iface
);
417 TRACE("iface %p, desc %p.\n", iface
, desc
);
419 return d3d_vertex_buffer7_GetVertexBufferDesc(&buffer
->IDirect3DVertexBuffer7_iface
, desc
);
423 /*****************************************************************************
424 * IDirect3DVertexBuffer7::Optimize
426 * Converts an unoptimized vertex buffer into an optimized buffer
429 * D3DDevice: Device for which this buffer is optimized
430 * Flags: Not used, should be set to 0
433 * D3D_OK, because it's a stub
435 *****************************************************************************/
436 static HRESULT WINAPI
d3d_vertex_buffer7_Optimize(IDirect3DVertexBuffer7
*iface
,
437 IDirect3DDevice7
*device
, DWORD flags
)
439 struct d3d_vertex_buffer
*buffer
= impl_from_IDirect3DVertexBuffer7(iface
);
440 static BOOL hide
= FALSE
;
442 TRACE("iface %p, device %p, flags %#x.\n", iface
, device
, flags
);
446 FIXME("iface %p, device %p, flags %#x stub!\n", iface
, device
, flags
);
450 /* We could forward this call to WineD3D and take advantage
451 * of it once we use OpenGL vertex buffers
453 wined3d_mutex_lock();
454 buffer
->Caps
|= D3DVBCAPS_OPTIMIZED
;
455 wined3d_mutex_unlock();
460 static HRESULT WINAPI
d3d_vertex_buffer1_Optimize(IDirect3DVertexBuffer
*iface
,
461 IDirect3DDevice3
*device
, DWORD flags
)
463 struct d3d_vertex_buffer
*buffer
= impl_from_IDirect3DVertexBuffer(iface
);
464 struct d3d_device
*device_impl
= unsafe_impl_from_IDirect3DDevice3(device
);
466 TRACE("iface %p, device %p, flags %#x.\n", iface
, device
, flags
);
468 return d3d_vertex_buffer7_Optimize(&buffer
->IDirect3DVertexBuffer7_iface
,
469 device_impl
? &device_impl
->IDirect3DDevice7_iface
: NULL
, flags
);
472 /*****************************************************************************
473 * IDirect3DVertexBuffer7::ProcessVerticesStrided
475 * This method processes untransformed strided vertices into a processed
476 * or optimized vertex buffer.
478 * For more details on the parameters, see
479 * IDirect3DVertexBuffer7::ProcessVertices
482 * VertexOp: Operations to perform
483 * DestIndex: Destination index to write the vertices to
484 * Count: Number of input vertices
485 * StrideData: Array containing the input vertices
486 * VertexTypeDesc: Vertex Description or source index?????????
487 * D3DDevice: IDirect3DDevice7 to use for processing
488 * Flags: Can be D3DPV_DONOTCOPYDATA to avoid copying unmodified vertices
491 * D3D_OK on success, or DDERR_*
493 *****************************************************************************/
494 static HRESULT WINAPI
d3d_vertex_buffer7_ProcessVerticesStrided(IDirect3DVertexBuffer7
*iface
,
495 DWORD vertex_op
, DWORD dst_idx
, DWORD count
, D3DDRAWPRIMITIVESTRIDEDDATA
*data
,
496 DWORD fvf
, IDirect3DDevice7
*device
, DWORD flags
)
498 FIXME("iface %p, vertex_op %#x, dst_idx %u, count %u, data %p, fvf %#x, device %p, flags %#x stub!\n",
499 iface
, vertex_op
, dst_idx
, count
, data
, fvf
, device
, flags
);
504 /*****************************************************************************
506 *****************************************************************************/
508 static const struct IDirect3DVertexBuffer7Vtbl d3d_vertex_buffer7_vtbl
=
510 d3d_vertex_buffer7_QueryInterface
,
511 d3d_vertex_buffer7_AddRef
,
512 d3d_vertex_buffer7_Release
,
513 d3d_vertex_buffer7_Lock
,
514 d3d_vertex_buffer7_Unlock
,
515 d3d_vertex_buffer7_ProcessVertices
,
516 d3d_vertex_buffer7_GetVertexBufferDesc
,
517 d3d_vertex_buffer7_Optimize
,
518 d3d_vertex_buffer7_ProcessVerticesStrided
,
521 static const struct IDirect3DVertexBufferVtbl d3d_vertex_buffer1_vtbl
=
523 d3d_vertex_buffer1_QueryInterface
,
524 d3d_vertex_buffer1_AddRef
,
525 d3d_vertex_buffer1_Release
,
526 d3d_vertex_buffer1_Lock
,
527 d3d_vertex_buffer1_Unlock
,
528 d3d_vertex_buffer1_ProcessVertices
,
529 d3d_vertex_buffer1_GetVertexBufferDesc
,
530 d3d_vertex_buffer1_Optimize
,
533 HRESULT
d3d_vertex_buffer_create(struct d3d_vertex_buffer
**vertex_buf
,
534 struct ddraw
*ddraw
, D3DVERTEXBUFFERDESC
*desc
)
536 struct d3d_vertex_buffer
*buffer
;
540 TRACE("Vertex buffer description:\n");
541 TRACE(" dwSize %u\n", desc
->dwSize
);
542 TRACE(" dwCaps %#x\n", desc
->dwCaps
);
543 TRACE(" FVF %#x\n", desc
->dwFVF
);
544 TRACE(" dwNumVertices %u\n", desc
->dwNumVertices
);
546 buffer
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*buffer
));
548 return DDERR_OUTOFMEMORY
;
550 buffer
->IDirect3DVertexBuffer7_iface
.lpVtbl
= &d3d_vertex_buffer7_vtbl
;
551 buffer
->IDirect3DVertexBuffer_iface
.lpVtbl
= &d3d_vertex_buffer1_vtbl
;
554 buffer
->ddraw
= ddraw
;
555 buffer
->Caps
= desc
->dwCaps
;
556 buffer
->fvf
= desc
->dwFVF
;
558 usage
= desc
->dwCaps
& D3DVBCAPS_WRITEONLY
? WINED3DUSAGE_WRITEONLY
: 0;
559 usage
|= WINED3DUSAGE_STATICDECL
;
561 wined3d_mutex_lock();
563 hr
= wined3d_buffer_create_vb(ddraw
->wined3d_device
,
564 get_flexible_vertex_size(desc
->dwFVF
) * desc
->dwNumVertices
,
565 usage
, desc
->dwCaps
& D3DVBCAPS_SYSTEMMEMORY
? WINED3D_POOL_SYSTEM_MEM
: WINED3D_POOL_DEFAULT
,
566 buffer
, &ddraw_null_wined3d_parent_ops
, &buffer
->wineD3DVertexBuffer
);
569 WARN("Failed to create wined3d vertex buffer, hr %#x.\n", hr
);
570 if (hr
== WINED3DERR_INVALIDCALL
)
571 hr
= DDERR_INVALIDPARAMS
;
575 buffer
->wineD3DVertexDeclaration
= ddraw_find_decl(ddraw
, desc
->dwFVF
);
576 if (!buffer
->wineD3DVertexDeclaration
)
578 ERR("Failed to find vertex declaration for fvf %#x.\n", desc
->dwFVF
);
579 wined3d_buffer_decref(buffer
->wineD3DVertexBuffer
);
580 hr
= DDERR_INVALIDPARAMS
;
583 wined3d_vertex_declaration_incref(buffer
->wineD3DVertexDeclaration
);
586 wined3d_mutex_unlock();
588 *vertex_buf
= buffer
;
590 HeapFree(GetProcessHeap(), 0, buffer
);
595 struct d3d_vertex_buffer
*unsafe_impl_from_IDirect3DVertexBuffer(IDirect3DVertexBuffer
*iface
)
599 assert(iface
->lpVtbl
== &d3d_vertex_buffer1_vtbl
);
601 return impl_from_IDirect3DVertexBuffer(iface
);
604 struct d3d_vertex_buffer
*unsafe_impl_from_IDirect3DVertexBuffer7(IDirect3DVertexBuffer7
*iface
)
608 assert(iface
->lpVtbl
== &d3d_vertex_buffer7_vtbl
);
610 return impl_from_IDirect3DVertexBuffer7(iface
);