~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Wine Cross Reference
wine/dlls/ddraw/vertexbuffer.c

Version: ~ [ wine-1.5.30 ] ~ [ wine-1.5.29 ] ~ [ wine-1.5.28 ] ~ [ wine-1.5.27 ] ~ [ wine-1.5.26 ] ~ [ wine-1.5.25 ] ~ [ wine-1.5.24 ] ~ [ wine-1.5.23 ] ~ [ wine-1.5.22 ] ~ [ wine-1.5.21 ] ~ [ wine-1.5.20 ] ~ [ wine-1.5.19 ] ~ [ wine-1.5.18 ] ~ [ wine-1.5.17 ] ~ [ wine-1.5.16 ] ~ [ wine-1.5.15 ] ~ [ wine-1.5.14 ] ~ [ wine-1.5.13 ] ~ [ wine-1.5.12 ] ~ [ wine-1.5.11 ] ~ [ wine-1.5.10 ] ~ [ wine-1.5.9 ] ~ [ wine-1.5.8 ] ~ [ wine-1.5.7 ] ~ [ wine-1.4.1 ] ~ [ wine-1.5.6 ] ~ [ wine-1.5.5 ] ~ [ wine-1.5.4 ] ~ [ wine-1.5.3 ] ~ [ wine-1.5.2 ] ~ [ wine-1.5.1 ] ~ [ wine-1.5.0 ] ~ [ wine-1.4 ] ~ [ wine-1.4-rc6 ] ~ [ wine-1.4-rc5 ] ~ [ wine-1.4-rc4 ] ~ [ wine-1.4-rc3 ] ~ [ wine-1.4-rc2 ] ~ [ wine-1.4-rc1 ] ~ [ wine-1.3.37 ] ~ [ wine-1.3.36 ] ~ [ wine-1.3.35 ] ~ [ wine-1.3.34 ] ~ [ wine-1.3.33 ] ~ [ wine-1.3.32 ] ~ [ wine-1.3.31 ] ~ [ wine-1.3.30 ] ~ [ wine-1.3.29 ] ~ [ wine-1.3.28 ] ~ [ wine-1.3.27 ] ~ [ wine-1.3.26 ] ~ [ wine-1.3.25 ] ~ [ wine-1.3.24 ] ~ [ wine-1.3.23 ] ~ [ wine-1.3.22 ] ~ [ wine-1.3.21 ] ~ [ wine-1.3.20 ] ~ [ wine-1.3.19 ] ~ [ wine-1.3.18 ] ~ [ wine-1.2.3 ] ~ [ wine-1.3.17 ] ~ [ wine-1.3.16 ] ~ [ wine-1.3.15 ] ~ [ wine-1.3.14 ] ~ [ wine-1.3.13 ] ~ [ wine-1.3.12 ] ~ [ wine-1.3.11 ] ~ [ wine-1.3.10 ] ~ [ wine-1.3.9 ] ~ [ wine-1.2.2 ] ~ [ wine-1.3.8 ] ~ [ wine-1.3.7 ] ~ [ wine-1.3.6 ] ~ [ wine-1.3.5 ] ~ [ wine-1.2.1 ] ~ [ wine-1.3.4 ] ~ [ wine-1.3.3 ] ~ [ wine-1.3.2 ] ~ [ wine-1.3.1 ] ~ [ wine-1.3.0 ] ~ [ wine-1.2 ] ~ [ wine-1.2-rc7 ] ~ [ wine-1.2-rc6 ] ~ [ wine-1.2-rc5 ] ~ [ wine-1.2-rc4 ] ~ [ wine-1.2-rc3 ] ~ [ wine-1.2-rc2 ] ~ [ wine-1.2-rc1 ] ~ [ wine-1.1.44 ] ~ [ wine-1.1.43 ] ~ [ wine-1.1.42 ] ~ [ wine-1.1.41 ] ~ [ wine-1.1.40 ] ~ [ wine-1.1.39 ] ~ [ wine-1.1.38 ] ~ [ wine-1.1.37 ] ~ [ wine-1.1.36 ] ~ [ wine-1.1.35 ] ~ [ wine-1.1.34 ] ~ [ wine-1.1.33 ] ~ [ wine-1.1.32 ] ~ [ wine-1.1.31 ] ~ [ wine-1.1.30 ] ~ [ wine-1.1.29 ] ~ [ wine-1.1.28 ] ~ [ wine-1.1.27 ] ~ [ wine-1.1.26 ] ~ [ wine-1.1.25 ] ~ [ wine-1.1.24 ] ~ [ wine-1.1.23 ] ~ [ wine-1.1.22 ] ~ [ wine-1.1.21 ] ~ [ wine-1.1.20 ] ~ [ wine-1.1.19 ] ~ [ wine-1.1.18 ] ~ [ wine-1.1.17 ] ~ [ wine-1.1.16 ] ~ [ wine-1.1.15 ] ~ [ wine-1.1.14 ] ~ [ wine-1.1.13 ] ~ [ wine-1.1.12 ] ~ [ wine-1.1.11 ] ~ [ wine-1.1.10 ] ~ [ wine-1.1.9 ] ~ [ wine-1.1.8 ] ~ [ wine-1.1.7 ] ~ [ wine-1.0.1 ] ~ [ wine-1.1.6 ] ~ [ wine-1.1.5 ] ~ [ wine-1.1.4 ] ~ [ wine-1.1.3 ] ~ [ wine-1.1.2 ] ~ [ wine-1.1.1 ] ~ [ wine-1.1.0 ] ~ [ wine-1.0 ] ~

  1 /* Direct3D Vertex Buffer
  2  * Copyright (c) 2002 Lionel ULMER
  3  * Copyright (c) 2006 Stefan DÖSINGER
  4  *
  5  * This file contains the implementation of Direct3DVertexBuffer COM object
  6  *
  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.
 11  *
 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.
 16  *
 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
 20  */
 21 
 22 #include "config.h"
 23 #include "wine/port.h"
 24 #include "wine/debug.h"
 25 
 26 #include <assert.h>
 27 #include <stdarg.h>
 28 #include <string.h>
 29 #include <stdlib.h>
 30 
 31 #define COBJMACROS
 32 
 33 #include "windef.h"
 34 #include "winbase.h"
 35 #include "winerror.h"
 36 #include "wingdi.h"
 37 #include "wine/exception.h"
 38 
 39 #include "ddraw.h"
 40 #include "d3d.h"
 41 
 42 #include "ddraw_private.h"
 43 
 44 WINE_DEFAULT_DEBUG_CHANNEL(d3d7);
 45 WINE_DECLARE_DEBUG_CHANNEL(ddraw_thunk);
 46 
 47 /*****************************************************************************
 48  * IUnknown Methods
 49  *****************************************************************************/
 50 
 51 /*****************************************************************************
 52  * IDirect3DVertexBuffer7::QueryInterface
 53  *
 54  * The QueryInterface Method for Vertex Buffers
 55  * For a link to QueryInterface rules, see IDirectDraw7::QueryInterface
 56  *
 57  * Params
 58  *  riid: Queryied Interface id
 59  *  obj: Address to return the interface pointer
 60  *
 61  * Returns:
 62  *  S_OK on success
 63  *  E_NOINTERFACE if the interface wasn't found
 64  *
 65  *****************************************************************************/
 66 static HRESULT WINAPI
 67 IDirect3DVertexBufferImpl_QueryInterface(IDirect3DVertexBuffer7 *iface,
 68                                          REFIID riid,
 69                                          void  **obj)
 70 {
 71     IDirect3DVertexBufferImpl *This = (IDirect3DVertexBufferImpl *)iface;
 72     TRACE("(%p)->(%s,%p)\n", This, debugstr_guid(riid), obj);
 73 
 74     /* By default, set the object pointer to NULL */
 75     *obj = NULL;
 76 
 77     if ( IsEqualGUID( &IID_IUnknown,  riid ) )
 78     {
 79         IUnknown_AddRef(iface);
 80         *obj = iface;
 81         TRACE("  Creating IUnknown interface at %p.\n", *obj);
 82         return S_OK;
 83     }
 84     if ( IsEqualGUID( &IID_IDirect3DVertexBuffer, riid ) )
 85     {
 86         IUnknown_AddRef(iface);
 87         *obj = &This->IDirect3DVertexBuffer_vtbl;
 88         TRACE("  Creating IDirect3DVertexBuffer interface %p\n", *obj);
 89         return S_OK;
 90     }
 91     if ( IsEqualGUID( &IID_IDirect3DVertexBuffer7, riid ) )
 92     {
 93         IUnknown_AddRef(iface);
 94         *obj = iface;
 95         TRACE("  Creating IDirect3DVertexBuffer7 interface %p\n", *obj);
 96         return S_OK;
 97     }
 98     FIXME("(%p): interface for IID %s NOT found!\n", This, debugstr_guid(riid));
 99     return E_NOINTERFACE;
100 }
101 
102 static HRESULT WINAPI
103 Thunk_IDirect3DVertexBufferImpl_1_QueryInterface(IDirect3DVertexBuffer *iface,
104                                                  REFIID riid,
105                                                  void **obj)
106 {
107     IDirect3DVertexBufferImpl *This = vb_from_vb1(iface);
108     TRACE_(ddraw_thunk)("(%p)->(%s,%p) thunking to IDirect3DVertexBuffer7 interface.\n", This, debugstr_guid(riid), obj);
109 
110     return IDirect3DVertexBuffer7_QueryInterface((IDirect3DVertexBuffer7 *)This, riid, obj);
111 }
112 
113 /*****************************************************************************
114  * IDirect3DVertexBuffer7::AddRef
115  *
116  * AddRef for Vertex Buffers
117  *
118  * Returns:
119  *  The new refcount
120  *
121  *****************************************************************************/
122 static ULONG WINAPI
123 IDirect3DVertexBufferImpl_AddRef(IDirect3DVertexBuffer7 *iface)
124 {
125     IDirect3DVertexBufferImpl *This = (IDirect3DVertexBufferImpl *)iface;
126     ULONG ref = InterlockedIncrement(&This->ref);
127 
128     TRACE("(%p/%p)->() incrementing from %u.\n", This, iface, ref - 1);
129 
130     return ref;
131 }
132 
133 static ULONG WINAPI
134 Thunk_IDirect3DVertexBufferImpl_1_AddRef(IDirect3DVertexBuffer *iface)
135 {
136     IDirect3DVertexBufferImpl *This = vb_from_vb1(iface);
137     TRACE_(ddraw_thunk)("(%p)->() thunking to IDirect3DVertexBuffer7 interface.\n", This);
138 
139     return IDirect3DVertexBuffer7_AddRef((IDirect3DVertexBuffer7 *)This);
140 }
141 
142 
143 /*****************************************************************************
144  * IDirect3DVertexBuffer7::Release
145  *
146  * Release for Vertex Buffers
147  *
148  * Returns:
149  *  The new refcount
150  *
151  *****************************************************************************/
152 static ULONG WINAPI
153 IDirect3DVertexBufferImpl_Release(IDirect3DVertexBuffer7 *iface)
154 {
155     IDirect3DVertexBufferImpl *This = (IDirect3DVertexBufferImpl *)iface;
156     ULONG ref = InterlockedDecrement(&This->ref);
157 
158     TRACE("(%p)->() decrementing from %u.\n", This, ref + 1);
159 
160     if (ref == 0)
161     {
162         IWineD3DBuffer *curVB = NULL;
163         UINT offset, stride;
164 
165         EnterCriticalSection(&ddraw_cs);
166         /* D3D7 Vertex buffers don't stay bound in the device, they are passed as a parameter
167          * to drawPrimitiveVB. DrawPrimitiveVB sets them as the stream source in wined3d,
168          * and they should get unset there before they are destroyed
169          */
170         IWineD3DDevice_GetStreamSource(This->ddraw->wineD3DDevice,
171                                        0 /* Stream number */,
172                                        &curVB,
173                                        &offset,
174                                        &stride);
175         if(curVB == This->wineD3DVertexBuffer)
176         {
177             IWineD3DDevice_SetStreamSource(This->ddraw->wineD3DDevice,
178                                         0 /* Steam number */,
179                                         NULL /* stream data */,
180                                         0 /* Offset */,
181                                         0 /* stride */);
182         }
183         if(curVB)
184         {
185             IWineD3DBuffer_Release(curVB); /* For the GetStreamSource */
186         }
187 
188         IWineD3DVertexDeclaration_Release(This->wineD3DVertexDeclaration);
189         IWineD3DBuffer_Release(This->wineD3DVertexBuffer);
190         LeaveCriticalSection(&ddraw_cs);
191         HeapFree(GetProcessHeap(), 0, This);
192 
193         return 0;
194     }
195     return ref;
196 }
197 
198 static ULONG WINAPI
199 Thunk_IDirect3DVertexBufferImpl_1_Release(IDirect3DVertexBuffer *iface)
200 {
201     IDirect3DVertexBufferImpl *This = vb_from_vb1(iface);
202     TRACE_(ddraw_thunk)("(%p)->() thunking to IDirect3DVertexBuffer7 interface.\n", This);
203 
204     return IDirect3DVertexBuffer7_Release((IDirect3DVertexBuffer7 *)This);
205 }
206 
207 /*****************************************************************************
208  * IDirect3DVertexBuffer Methods
209  *****************************************************************************/
210 
211 /*****************************************************************************
212  * IDirect3DVertexBuffer7::Lock
213  *
214  * Locks the vertex buffer and returns a pointer to the vertex data
215  * Locking vertex buffers is similar to locking surfaces, because Windows
216  * uses surfaces to store vertex data internally (According to the DX sdk)
217  *
218  * Params:
219  *  Flags: Locking flags. Relevant here are DDLOCK_READONLY, DDLOCK_WRITEONLY,
220  *         DDLOCK_DISCARDCONTENTS and DDLOCK_NOOVERWRITE.
221  *  Data:  Returns a pointer to the vertex data
222  *  Size:  Returns the size of the buffer if not NULL
223  *
224  * Returns:
225  *  D3D_OK on success
226  *  DDERR_INVALIDPARAMS if Data is NULL
227  *  D3DERR_VERTEXBUFFEROPTIMIZED if called on an optimized buffer(WineD3D)
228  *
229  *****************************************************************************/
230 static HRESULT WINAPI
231 IDirect3DVertexBufferImpl_Lock(IDirect3DVertexBuffer7 *iface,
232                                DWORD Flags,
233                                void **Data,
234                                DWORD *Size)
235 {
236     IDirect3DVertexBufferImpl *This = (IDirect3DVertexBufferImpl *)iface;
237     WINED3DBUFFER_DESC Desc;
238     HRESULT hr;
239     TRACE("(%p)->(%08x,%p,%p)\n", This, Flags, Data, Size);
240 
241     EnterCriticalSection(&ddraw_cs);
242     if(Size)
243     {
244         /* Get the size, for returning it, and for locking */
245         hr = IWineD3DBuffer_GetDesc(This->wineD3DVertexBuffer, &Desc);
246         if(hr != D3D_OK)
247         {
248             ERR("(%p) IWineD3DBuffer::GetDesc failed with hr=%08x\n", This, hr);
249             LeaveCriticalSection(&ddraw_cs);
250             return hr;
251         }
252         *Size = Desc.Size;
253     }
254 
255     hr = IWineD3DBuffer_Map(This->wineD3DVertexBuffer, 0 /* OffsetToLock */,
256             0 /* SizeToLock, 0 == Full lock */, (BYTE **)Data, Flags);
257     LeaveCriticalSection(&ddraw_cs);
258     return hr;
259 }
260 
261 static HRESULT WINAPI
262 Thunk_IDirect3DVertexBufferImpl_1_Lock(IDirect3DVertexBuffer *iface,
263                                        DWORD Flags,
264                                        void **Data,
265                                        DWORD *Size)
266 {
267     IDirect3DVertexBufferImpl *This = vb_from_vb1(iface);
268     TRACE_(ddraw_thunk)("(%p)->(%08x,%p,%p) thunking to IDirect3DVertexBuffer7 interface.\n", This, Flags, Data, Size);
269 
270     return IDirect3DVertexBuffer7_Lock((IDirect3DVertexBuffer7 *)This, Flags, Data, Size);
271 }
272 
273 /*****************************************************************************
274  * IDirect3DVertexBuffer7::Unlock
275  *
276  * Unlocks a vertex Buffer
277  *
278  * Returns:
279  *  D3D_OK on success
280  *
281  *****************************************************************************/
282 static HRESULT WINAPI
283 IDirect3DVertexBufferImpl_Unlock(IDirect3DVertexBuffer7 *iface)
284 {
285     IDirect3DVertexBufferImpl *This = (IDirect3DVertexBufferImpl *)iface;
286     HRESULT hr;
287     TRACE("(%p)->()\n", This);
288 
289     EnterCriticalSection(&ddraw_cs);
290     hr = IWineD3DBuffer_Unmap(This->wineD3DVertexBuffer);
291     LeaveCriticalSection(&ddraw_cs);
292 
293     return hr;
294 }
295 
296 static HRESULT WINAPI
297 Thunk_IDirect3DVertexBufferImpl_1_Unlock(IDirect3DVertexBuffer *iface)
298 {
299     IDirect3DVertexBufferImpl *This = vb_from_vb1(iface);
300     TRACE_(ddraw_thunk)("(%p)->() thunking to IDirect3DVertexBuffer7 interface.\n", This);
301 
302     return IDirect3DVertexBuffer7_Unlock((IDirect3DVertexBuffer7 *)This);
303 }
304 
305 
306 /*****************************************************************************
307  * IDirect3DVertexBuffer7::ProcessVertices
308  *
309  * Processes untransformed Vertices into a transformed or optimized vertex
310  * buffer. It can also perform other operations, such as lighting or clipping
311  *
312  * Params
313  *  VertexOp: Operation(s) to perform: D3DVOP_CLIP, _EXTENTS, _LIGHT, _TRANSFORM
314  *  DestIndex: Index in the destination buffer(This), where the vertices are
315  *             placed
316  *  Count: Number of Vertices in the Source buffer to process
317  *  SrcBuffer: Source vertex buffer
318  *  SrcIndex: Index of the first vertex in the src buffer to process
319  *  D3DDevice: Device to use for transformation
320  *  Flags: 0 for default, D3DPV_DONOTCOPYDATA to prevent copying
321  *         unchaned vertices
322  *
323  * Returns:
324  *  D3D_OK on success
325  *  DDERR_INVALIDPARAMS If D3DVOP_TRANSFORM wasn't passed
326  *
327  *****************************************************************************/
328 static HRESULT WINAPI
329 IDirect3DVertexBufferImpl_ProcessVertices(IDirect3DVertexBuffer7 *iface,
330                                           DWORD VertexOp,
331                                           DWORD DestIndex,
332                                           DWORD Count,
333                                           IDirect3DVertexBuffer7 *SrcBuffer,
334                                           DWORD SrcIndex,
335                                           IDirect3DDevice7 *D3DDevice,
336                                           DWORD Flags)
337 {
338     IDirect3DVertexBufferImpl *This = (IDirect3DVertexBufferImpl *)iface;
339     IDirect3DVertexBufferImpl *Src = (IDirect3DVertexBufferImpl *)SrcBuffer;
340     IDirect3DDeviceImpl *D3D = (IDirect3DDeviceImpl *)D3DDevice;
341     BOOL oldClip, doClip;
342     HRESULT hr;
343 
344     TRACE("(%p)->(%08x,%d,%d,%p,%d,%p,%08x)\n", This, VertexOp, DestIndex, Count, Src, SrcIndex, D3D, Flags);
345 
346     /* Vertex operations:
347      * D3DVOP_CLIP: Clips vertices outside the viewing frustrum. Needs clipping information
348      * in the vertex buffer (Buffer may not be created with D3DVBCAPS_DONOTCLIP)
349      * D3DVOP_EXTENTS: Causes the screen extents to be updated when rendering the vertices
350      * D3DVOP_LIGHT: Lights the vertices
351      * D3DVOP_TRANSFORM: Transform the vertices. This flag is necessary
352      *
353      * WineD3D only transforms and clips the vertices by now, so EXTENTS and LIGHT
354      * are not implemented. Clipping is disabled ATM, because of unsure conditions.
355      */
356     if( !(VertexOp & D3DVOP_TRANSFORM) ) return DDERR_INVALIDPARAMS;
357 
358     EnterCriticalSection(&ddraw_cs);
359     /* WineD3D doesn't know d3d7 vertex operation, it uses
360      * render states instead. Set the render states according to
361      * the vertex ops
362      */
363     doClip = VertexOp & D3DVOP_CLIP ? TRUE : FALSE;
364     IWineD3DDevice_GetRenderState(D3D->wineD3DDevice,
365                                   WINED3DRS_CLIPPING,
366                                   (DWORD *) &oldClip);
367     if(doClip != oldClip)
368     {
369         IWineD3DDevice_SetRenderState(D3D->wineD3DDevice,
370                                       WINED3DRS_CLIPPING,
371                                       doClip);
372     }
373 
374     IWineD3DDevice_SetStreamSource(D3D->wineD3DDevice,
375                                    0, /* Stream No */
376                                    Src->wineD3DVertexBuffer,
377                                    0, /* Offset */
378                                    get_flexible_vertex_size(Src->fvf));
379     IWineD3DDevice_SetVertexDeclaration(D3D->wineD3DDevice,
380                                         Src->wineD3DVertexDeclaration);
381     hr = IWineD3DDevice_ProcessVertices(D3D->wineD3DDevice,
382                                         SrcIndex,
383                                         DestIndex,
384                                         Count,
385                                         This->wineD3DVertexBuffer,
386                                         NULL /* Output vdecl */,
387                                         Flags,
388                                         This->fvf);
389 
390     /* Restore the states if needed */
391     if(doClip != oldClip)
392         IWineD3DDevice_SetRenderState(D3D->wineD3DDevice,
393                                       WINED3DRS_CLIPPING,
394                                       oldClip);
395     LeaveCriticalSection(&ddraw_cs);
396     return hr;
397 }
398 
399 static HRESULT WINAPI
400 Thunk_IDirect3DVertexBufferImpl_1_ProcessVertices(IDirect3DVertexBuffer *iface,
401                                                   DWORD VertexOp,
402                                                   DWORD DestIndex,
403                                                   DWORD Count,
404                                                   IDirect3DVertexBuffer *SrcBuffer,
405                                                   DWORD SrcIndex,
406                                                   IDirect3DDevice3 *D3DDevice,
407                                                   DWORD Flags)
408 {
409     IDirect3DVertexBufferImpl *This = vb_from_vb1(iface);
410     IDirect3DVertexBufferImpl *Src = SrcBuffer ? vb_from_vb1(SrcBuffer) : NULL;
411     IDirect3DDeviceImpl *D3D = D3DDevice ? device_from_device3(D3DDevice) : NULL;
412 
413     TRACE_(ddraw_thunk)("(%p)->(%08x,%08x,%08x,%p,%08x,%p,%08x) thunking to IDirect3DVertexBuffer7 interface.\n", This, VertexOp, DestIndex, Count, Src, SrcIndex, D3D, Flags);
414 
415     return IDirect3DVertexBuffer7_ProcessVertices((IDirect3DVertexBuffer7 *)This, VertexOp, DestIndex,
416             Count, (IDirect3DVertexBuffer7 *)Src, SrcIndex, (IDirect3DDevice7 *)D3D, Flags);
417 }
418 
419 /*****************************************************************************
420  * IDirect3DVertexBuffer7::GetVertexBufferDesc
421  *
422  * Returns the description of a vertex buffer
423  *
424  * Params:
425  *  Desc: Address to write the description to
426  *
427  * Returns
428  *  DDERR_INVALIDPARAMS if Desc is NULL
429  *  D3D_OK on success
430  *
431  *****************************************************************************/
432 static HRESULT WINAPI
433 IDirect3DVertexBufferImpl_GetVertexBufferDesc(IDirect3DVertexBuffer7 *iface,
434                                               D3DVERTEXBUFFERDESC *Desc)
435 {
436     IDirect3DVertexBufferImpl *This = (IDirect3DVertexBufferImpl *)iface;
437     WINED3DBUFFER_DESC WDesc;
438     HRESULT hr;
439     TRACE("(%p)->(%p)\n", This, Desc);
440 
441     if(!Desc) return DDERR_INVALIDPARAMS;
442 
443     EnterCriticalSection(&ddraw_cs);
444     hr = IWineD3DBuffer_GetDesc(This->wineD3DVertexBuffer, &WDesc);
445     if(hr != D3D_OK)
446     {
447         ERR("(%p) IWineD3DBuffer::GetDesc failed with hr=%08x\n", This, hr);
448         LeaveCriticalSection(&ddraw_cs);
449         return hr;
450     }
451 
452     /* Now fill the Desc structure */
453     Desc->dwCaps = This->Caps;
454     Desc->dwFVF = This->fvf;
455     Desc->dwNumVertices = WDesc.Size / get_flexible_vertex_size(This->fvf);
456     LeaveCriticalSection(&ddraw_cs);
457 
458     return D3D_OK;
459 }
460 
461 static HRESULT WINAPI
462 Thunk_IDirect3DVertexBufferImpl_1_GetVertexBufferDesc(IDirect3DVertexBuffer *iface,
463                                                       D3DVERTEXBUFFERDESC *Desc)
464 {
465     IDirect3DVertexBufferImpl *This = vb_from_vb1(iface);
466     TRACE_(ddraw_thunk)("(%p)->(%p) thunking to IDirect3DVertexBuffer7 interface.\n", This, Desc);
467 
468     return IDirect3DVertexBuffer7_GetVertexBufferDesc((IDirect3DVertexBuffer7 *)This, Desc);
469 }
470 
471 
472 /*****************************************************************************
473  * IDirect3DVertexBuffer7::Optimize
474  *
475  * Converts an unoptimized vertex buffer into an optimized buffer
476  *
477  * Params:
478  *  D3DDevice: Device for which this buffer is optimized
479  *  Flags: Not used, should be set to 0
480  *
481  * Returns
482  *  D3D_OK, because it's a stub
483  *
484  *****************************************************************************/
485 static HRESULT WINAPI
486 IDirect3DVertexBufferImpl_Optimize(IDirect3DVertexBuffer7 *iface,
487                                    IDirect3DDevice7 *D3DDevice,
488                                    DWORD Flags)
489 {
490     IDirect3DVertexBufferImpl *This = (IDirect3DVertexBufferImpl *)iface;
491     IDirect3DDeviceImpl *D3D = (IDirect3DDeviceImpl *)D3DDevice;
492     static BOOL hide = FALSE;
493 
494     if (!hide)
495     {
496         FIXME("(%p)->(%p,%08x): stub!\n", This, D3D, Flags);
497         hide = TRUE;
498     }
499 
500     /* We could forward this call to WineD3D and take advantage
501      * of it once we use OpenGL vertex buffers
502      */
503     EnterCriticalSection(&ddraw_cs);
504     This->Caps |= D3DVBCAPS_OPTIMIZED;
505     LeaveCriticalSection(&ddraw_cs);
506 
507     return DD_OK;
508 }
509 
510 static HRESULT WINAPI
511 Thunk_IDirect3DVertexBufferImpl_1_Optimize(IDirect3DVertexBuffer *iface,
512                                            IDirect3DDevice3 *D3DDevice,
513                                            DWORD Flags)
514 {
515     IDirect3DVertexBufferImpl *This = vb_from_vb1(iface);
516     IDirect3DDeviceImpl *D3D = D3DDevice ? device_from_device3(D3DDevice) : NULL;
517     TRACE_(ddraw_thunk)("(%p)->(%p,%08x) thunking to IDirect3DVertexBuffer7 interface.\n", This, D3D, Flags);
518 
519     return IDirect3DVertexBuffer7_Optimize((IDirect3DVertexBuffer7 *)This, (IDirect3DDevice7 *)D3D, Flags);
520 }
521 
522 /*****************************************************************************
523  * IDirect3DVertexBuffer7::ProcessVerticesStrided
524  *
525  * This method processes untransformed strided vertices into a processed
526  * or optimized vertex buffer.
527  *
528  * For more details on the parameters, see
529  * IDirect3DVertexBuffer7::ProcessVertices
530  *
531  * Params:
532  *  VertexOp: Operations to perform
533  *  DestIndex: Destination index to write the vertices to
534  *  Count: Number of input vertices
535  *  StrideData: Array containing the input vertices
536  *  VertexTypeDesc: Vertex Description or source index?????????
537  *  D3DDevice: IDirect3DDevice7 to use for processing
538  *  Flags: Can be D3DPV_DONOTCOPYDATA to avoid copying unmodified vertices
539  *
540  * Returns
541  *  D3D_OK on success, or DDERR_*
542  *
543  *****************************************************************************/
544 static HRESULT WINAPI
545 IDirect3DVertexBufferImpl_ProcessVerticesStrided(IDirect3DVertexBuffer7 *iface,
546                                                  DWORD VertexOp,
547                                                  DWORD DestIndex,
548                                                  DWORD Count,
549                                                  D3DDRAWPRIMITIVESTRIDEDDATA *StrideData,
550                                                  DWORD VertexTypeDesc,
551                                                  IDirect3DDevice7 *D3DDevice,
552                                                  DWORD Flags)
553 {
554     IDirect3DVertexBufferImpl *This = (IDirect3DVertexBufferImpl *)iface;
555     IDirect3DDeviceImpl *D3D = (IDirect3DDeviceImpl *)D3DDevice;
556     FIXME("(%p)->(%08x,%08x,%08x,%p,%08x,%p,%08x): stub!\n", This, VertexOp, DestIndex, Count, StrideData, VertexTypeDesc, D3D, Flags);
557     return DD_OK;
558 }
559 
560 /*****************************************************************************
561  * The VTables
562  *****************************************************************************/
563 
564 const IDirect3DVertexBuffer7Vtbl IDirect3DVertexBuffer7_Vtbl =
565 {
566     /*** IUnknown Methods ***/
567     IDirect3DVertexBufferImpl_QueryInterface,
568     IDirect3DVertexBufferImpl_AddRef,
569     IDirect3DVertexBufferImpl_Release,
570     /*** IDirect3DVertexBuffer Methods ***/
571     IDirect3DVertexBufferImpl_Lock,
572     IDirect3DVertexBufferImpl_Unlock,
573     IDirect3DVertexBufferImpl_ProcessVertices,
574     IDirect3DVertexBufferImpl_GetVertexBufferDesc,
575     IDirect3DVertexBufferImpl_Optimize,
576     /*** IDirect3DVertexBuffer7 Methods ***/
577     IDirect3DVertexBufferImpl_ProcessVerticesStrided
578 };
579 
580 const IDirect3DVertexBufferVtbl IDirect3DVertexBuffer1_Vtbl =
581 {
582     /*** IUnknown Methods ***/
583     Thunk_IDirect3DVertexBufferImpl_1_QueryInterface,
584     Thunk_IDirect3DVertexBufferImpl_1_AddRef,
585     Thunk_IDirect3DVertexBufferImpl_1_Release,
586     /*** IDirect3DVertexBuffer Methods ***/
587     Thunk_IDirect3DVertexBufferImpl_1_Lock,
588     Thunk_IDirect3DVertexBufferImpl_1_Unlock,
589     Thunk_IDirect3DVertexBufferImpl_1_ProcessVertices,
590     Thunk_IDirect3DVertexBufferImpl_1_GetVertexBufferDesc,
591     Thunk_IDirect3DVertexBufferImpl_1_Optimize
592 };
593 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.