ddraw: Complex surfaces form a tree.
[wine] / dlls / ddraw / ddraw_private.h
1 /*
2  * Copyright 2006 Stefan Dösinger
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 #ifndef __WINE_DLLS_DDRAW_DDRAW_PRIVATE_H
20 #define __WINE_DLLS_DDRAW_DDRAW_PRIVATE_H
21
22 /* MAY NOT CONTAIN X11 or DGA specific includes/defines/structs! */
23
24 #include <stdarg.h>
25 #include <stdio.h>
26
27 #include "windef.h"
28 #include "winbase.h"
29 #include "wtypes.h"
30 #include "wingdi.h"
31 #include "winuser.h"
32 #include "ddraw.h"
33 #include "ddrawi.h"
34 #include "d3d.h"
35
36 #include "ddcomimpl.h"
37
38 #include "wine/wined3d_interface.h"
39 #include "wine/list.h"
40
41 /*****************************************************************************
42  * IParent - a helper interface
43  *****************************************************************************/
44 DEFINE_GUID(IID_IParent, 0xc20e4c88, 0x74e7, 0x4940, 0xba, 0x9f, 0x2e, 0x32, 0x3f, 0x9d, 0xc9, 0x81);
45 typedef struct IParent *LPPARENT, *PPARENT;
46
47 #define INTERFACE IParent
48 DECLARE_INTERFACE_(IParent,IUnknown)
49 {
50     /*** IUnknown methods ***/
51     STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE;
52     STDMETHOD_(ULONG,AddRef)(THIS) PURE;
53     STDMETHOD_(ULONG,Release)(THIS) PURE;
54 };
55 #undef INTERFACE
56
57 #if !defined(__cplusplus) || defined(CINTERFACE)
58 /*** IUnknown methods ***/
59 #define IParent_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
60 #define IParent_AddRef(p)             (p)->lpVtbl->AddRef(p)
61 #define IParent_Release(p)            (p)->lpVtbl->Release(p)
62 #endif
63
64
65 /* Typdef the interfaces */
66 typedef struct IDirectDrawImpl            IDirectDrawImpl;
67 typedef struct IDirectDrawSurfaceImpl     IDirectDrawSurfaceImpl;
68 typedef struct IDirectDrawClipperImpl     IDirectDrawClipperImpl;
69 typedef struct IDirectDrawPaletteImpl     IDirectDrawPaletteImpl;
70 typedef struct IDirect3DDeviceImpl        IDirect3DDeviceImpl;
71 typedef struct IDirect3DLightImpl         IDirect3DLightImpl;
72 typedef struct IDirect3DViewportImpl      IDirect3DViewportImpl;
73 typedef struct IDirect3DMaterialImpl      IDirect3DMaterialImpl;
74 typedef struct IDirect3DExecuteBufferImpl IDirect3DExecuteBufferImpl;
75 typedef struct IDirect3DVertexBufferImpl  IDirect3DVertexBufferImpl;
76 typedef struct IParentImpl                IParentImpl;
77
78 /* Callbacks for implicit object destruction */
79 extern ULONG WINAPI D3D7CB_DestroySwapChain(IWineD3DSwapChain *pSwapChain);
80
81 extern ULONG WINAPI D3D7CB_DestroyDepthStencilSurface(IWineD3DSurface *pSurface);
82
83 /*****************************************************************************
84  * IDirectDraw implementation structure
85  *****************************************************************************/
86 struct FvfToDecl
87 {
88     DWORD fvf;
89     IWineD3DVertexDeclaration *decl;
90 };
91
92 struct IDirectDrawImpl
93 {
94     /* IUnknown fields */
95     ICOM_VFIELD_MULTI(IDirectDraw7);
96     ICOM_VFIELD_MULTI(IDirectDraw4);
97     ICOM_VFIELD_MULTI(IDirectDraw3);
98     ICOM_VFIELD_MULTI(IDirectDraw2);
99     ICOM_VFIELD_MULTI(IDirectDraw);
100     ICOM_VFIELD_MULTI(IDirect3D7);
101     ICOM_VFIELD_MULTI(IDirect3D3);
102     ICOM_VFIELD_MULTI(IDirect3D2);
103     ICOM_VFIELD_MULTI(IDirect3D);
104
105     /* See comment in IDirectDraw::AddRef */
106     LONG                    ref7, ref4, ref2, ref3, ref1, numIfaces;
107
108     /* WineD3D linkage */
109     IWineD3D                *wineD3D;
110     IWineD3DDevice          *wineD3DDevice;
111     IDirectDrawSurfaceImpl  *DepthStencilBuffer;
112     BOOL                    d3d_initialized;
113
114     /* Misc ddraw fields */
115     UINT                    total_vidmem;
116     DWORD                   cur_scanline;
117     BOOL                    fake_vblank;
118     BOOL                    initialized;
119
120     /* DirectDraw things, which are not handled by WineD3D */
121     DWORD                   cooperative_level;
122
123     DWORD                   orig_width, orig_height;
124     DWORD                   orig_bpp;
125
126     DDCAPS                  caps;
127
128     /* D3D things */
129     IDirectDrawSurfaceImpl  *d3d_target;
130     HWND                    d3d_window;
131     IDirect3DDeviceImpl     *d3ddevice;
132     int                     d3dversion;
133
134     /* Various HWNDs */
135     HWND                    focuswindow;
136     HWND                    devicewindow;
137
138     /* The surface type to request */
139     WINED3DSURFTYPE         ImplType;
140
141
142     /* Our private window class */
143     char classname[32];
144     WNDCLASSA wnd_class;
145
146     /* Helpers for surface creation */
147     IDirectDrawSurfaceImpl *tex_root;
148     BOOL                    depthstencil;
149
150     /* For the dll unload cleanup code */
151     struct list ddraw_list_entry;
152     /* The surface list - can't relay this to WineD3D
153      * because of IParent
154      */
155     struct list surface_list;
156     LONG surfaces;
157
158     /* FVF management */
159     struct FvfToDecl       *decls;
160     UINT                    numConvertedDecls, declArraySize;
161 };
162
163 /* Declare the VTables. They can be found ddraw.c */
164 const IDirectDraw7Vtbl IDirectDraw7_Vtbl;
165 const IDirectDraw4Vtbl IDirectDraw4_Vtbl;
166 const IDirectDraw3Vtbl IDirectDraw3_Vtbl;
167 const IDirectDraw2Vtbl IDirectDraw2_Vtbl;
168 const IDirectDrawVtbl  IDirectDraw1_Vtbl;
169
170 /* Helper structures */
171 typedef struct EnumDisplayModesCBS
172 {
173     void *context;
174     LPDDENUMMODESCALLBACK2 callback;
175 } EnumDisplayModesCBS;
176
177 typedef struct EnumSurfacesCBS
178 {
179     void *context;
180     LPDDENUMSURFACESCALLBACK7 callback;
181     LPDDSURFACEDESC2 pDDSD;
182     DWORD Flags;
183 } EnumSurfacesCBS;
184
185 /* Utility functions */
186 void
187 DDRAW_Convert_DDSCAPS_1_To_2(const DDSCAPS* pIn,
188                              DDSCAPS2* pOut);
189 void
190 DDRAW_Convert_DDDEVICEIDENTIFIER_2_To_1(const DDDEVICEIDENTIFIER2* pIn,
191                                         DDDEVICEIDENTIFIER* pOut);
192 void
193 IDirectDrawImpl_Destroy(IDirectDrawImpl *This);
194
195 HRESULT WINAPI
196 IDirectDrawImpl_RecreateSurfacesCallback(IDirectDrawSurface7 *surf,
197                                          DDSURFACEDESC2 *desc,
198                                          void *Context);
199 IWineD3DVertexDeclaration *
200 IDirectDrawImpl_FindDecl(IDirectDrawImpl *This,
201                          DWORD fvf);
202
203 void
204 remove_ddraw_object(IDirectDrawImpl *ddraw);
205
206 /* The default surface type */
207 extern WINED3DSURFTYPE DefaultSurfaceType;
208
209 /*****************************************************************************
210  * IDirectDrawSurface implementation structure
211  *****************************************************************************/
212
213 struct IDirectDrawSurfaceImpl
214 {
215     /* IUnknown fields */
216     ICOM_VFIELD_MULTI(IDirectDrawSurface7);
217     ICOM_VFIELD_MULTI(IDirectDrawSurface3);
218     ICOM_VFIELD_MULTI(IDirectDrawGammaControl);
219     ICOM_VFIELD_MULTI(IDirect3DTexture2);
220     ICOM_VFIELD_MULTI(IDirect3DTexture);
221
222     LONG                     ref;
223     IUnknown                *ifaceToRelease;
224
225     int                     version;
226
227     /* Connections to other Objects */
228     IDirectDrawImpl         *ddraw;
229     IWineD3DSurface         *WineD3DSurface;
230     IWineD3DTexture         *wineD3DTexture;
231
232     /* This implementation handles attaching surfaces to other surfaces */
233     IDirectDrawSurfaceImpl  *next_attached;
234     IDirectDrawSurfaceImpl  *first_attached;
235
236     /* Complex surfaces are organized in a tree, although the tree is degenerated to a list in most cases.
237      * In mipmap and primary surfaces each level has only one attachment, which is the next surface level.
238      * Only the cube texture root has 6 surfaces attached, which then have a normal mipmap chain attached
239      * to them. So hardcode the array to 6, a dynamic array or a list would be an overkill.
240      */
241 #define MAX_COMPLEX_ATTACHED 6
242     IDirectDrawSurfaceImpl  *complex_array[MAX_COMPLEX_ATTACHED];
243     /* You can't traverse the tree upwards. Only a flag for Surface::Release because its needed there,
244      * but no pointer to prevent temptations to traverse it in the wrong direction.
245      */
246     BOOL                    is_complex_root;
247
248     /* Surface description, for GetAttachedSurface */
249     DDSURFACEDESC2          surface_desc;
250
251     /* Misc things */
252     DWORD                   uniqueness_value;
253     UINT                    mipmap_level;
254     WINED3DSURFTYPE         ImplType;
255
256     /* For D3DDevice creation */
257     BOOL                    isRenderTarget;
258
259     /* Clipper objects */
260     IDirectDrawClipperImpl  *clipper;
261
262     /* For the ddraw surface list */
263     struct list             surface_list_entry;
264
265     DWORD                   Handle;
266 };
267
268 /* VTable declaration. It's located in surface.c / surface_thunks.c */
269 const IDirectDrawSurface7Vtbl IDirectDrawSurface7_Vtbl;
270 const IDirectDrawSurface3Vtbl IDirectDrawSurface3_Vtbl;
271 const IDirectDrawGammaControlVtbl IDirectDrawGammaControl_Vtbl;
272 const IDirect3DTexture2Vtbl IDirect3DTexture2_Vtbl;
273 const IDirect3DTextureVtbl IDirect3DTexture1_Vtbl;
274
275 /* Get the number of bytes per pixel for a given surface */
276 #define PFGET_BPP(pf) (pf.dwFlags&DDPF_PALETTEINDEXED8?1:((pf.dwRGBBitCount+7)/8))
277 #define GET_BPP(desc) PFGET_BPP(desc.ddpfPixelFormat)
278
279 /*****************************************************************************
280  * IParent Implementation
281  *****************************************************************************/
282 struct IParentImpl
283 {
284     /* IUnknown fields */
285     ICOM_VFIELD_MULTI(IParent);
286     LONG                    ref;
287
288     /* IParentImpl fields */
289     IUnknown      *child;
290
291 };
292
293 const IParentVtbl IParent_Vtbl;
294
295 /*****************************************************************************
296  * IDirect3DDevice implementation
297  *****************************************************************************/
298 typedef enum
299 {
300     DDrawHandle_Unknown       = 0,
301     DDrawHandle_Texture       = 1,
302     DDrawHandle_Material      = 2,
303     DDrawHandle_Matrix        = 3,
304     DDrawHandle_StateBlock    = 4
305 } DDrawHandleTypes;
306
307 struct HandleEntry
308 {
309     void    *ptr;
310     DDrawHandleTypes      type;
311 };
312
313 struct IDirect3DDeviceImpl
314 {
315     /* IUnknown */
316     ICOM_VFIELD_MULTI(IDirect3DDevice7);
317     ICOM_VFIELD_MULTI(IDirect3DDevice3);
318     ICOM_VFIELD_MULTI(IDirect3DDevice2);
319     ICOM_VFIELD_MULTI(IDirect3DDevice);
320     LONG                    ref;
321
322     /* Other object connections */
323     IWineD3DDevice          *wineD3DDevice;
324     IDirectDrawImpl         *ddraw;
325     IWineD3DIndexBuffer     *indexbuffer;
326     IDirectDrawSurfaceImpl  *target;
327     BOOL                    OffScreenTarget;
328
329     /* Viewport management */
330     IDirect3DViewportImpl *viewport_list;
331     IDirect3DViewportImpl *current_viewport;
332     D3DVIEWPORT7 active_viewport;
333
334     /* Light state */
335     DWORD material;
336
337     /* Rendering functions to wrap D3D(1-3) to D3D7 */
338     D3DPRIMITIVETYPE primitive_type;
339     DWORD vertex_type;
340     DWORD render_flags;
341     DWORD nb_vertices;
342     LPBYTE vertex_buffer;
343     DWORD vertex_size;
344     DWORD buffer_size;
345
346     /* Handle management */
347     struct HandleEntry      *Handles;
348     DWORD                    numHandles;
349 };
350
351 /* Vtables in various versions */
352 const IDirect3DDevice7Vtbl IDirect3DDevice7_Vtbl;
353 const IDirect3DDevice3Vtbl IDirect3DDevice3_Vtbl;
354 const IDirect3DDevice2Vtbl IDirect3DDevice2_Vtbl;
355 const IDirect3DDeviceVtbl  IDirect3DDevice1_Vtbl;
356
357 /* The IID */
358 const GUID IID_D3DDEVICE_WineD3D;
359
360 /* Helper functions */
361 HRESULT IDirect3DImpl_GetCaps(IWineD3D *WineD3D, D3DDEVICEDESC *Desc123, D3DDEVICEDESC7 *Desc7);
362 DWORD IDirect3DDeviceImpl_CreateHandle(IDirect3DDeviceImpl *This);
363
364 /* Structures */
365 struct EnumTextureFormatsCBS
366 {
367     LPD3DENUMTEXTUREFORMATSCALLBACK cbv2;
368     LPD3DENUMPIXELFORMATSCALLBACK cbv7;
369     void *Context;
370 };
371
372 /*****************************************************************************
373  * IDirect3D implementation
374  *****************************************************************************/
375
376 /* No implementation structure as this is only another interface to DirectDraw */
377
378 /* the Vtables */
379 const IDirect3DVtbl  IDirect3D1_Vtbl;
380 const IDirect3D2Vtbl IDirect3D2_Vtbl;
381 const IDirect3D3Vtbl IDirect3D3_Vtbl;
382 const IDirect3D7Vtbl IDirect3D7_Vtbl;
383
384 /* Structure for EnumZBufferFormats */
385 struct EnumZBufferFormatsData
386 {
387     LPD3DENUMPIXELFORMATSCALLBACK Callback;
388     void *Context;
389 };
390
391 /*****************************************************************************
392  * IDirectDrawClipper implementation structure
393  *****************************************************************************/
394 struct IDirectDrawClipperImpl
395 {
396     /* IUnknown fields */
397     ICOM_VFIELD_MULTI(IDirectDrawClipper);
398     LONG ref;
399
400     /* IDirectDrawClipper fields */
401     HWND hWnd;
402
403     IDirectDrawImpl* ddraw_owner;
404     struct IDirectDrawClipperImpl* prev_ddraw;
405     struct IDirectDrawClipperImpl* next_ddraw;
406 };
407
408 const IDirectDrawClipperVtbl IDirectDrawClipper_Vtbl;
409
410 /*****************************************************************************
411  * IDirectDrawPalette implementation structure
412  *****************************************************************************/
413 struct IDirectDrawPaletteImpl
414 {
415     /* IUnknown fields */
416     ICOM_VFIELD_MULTI(IDirectDrawPalette);
417     LONG ref;
418
419     /* WineD3D uplink */
420     IWineD3DPalette           *wineD3DPalette;
421
422     /* IDirectDrawPalette fields */
423     IDirectDrawImpl           *ddraw_owner;
424     IUnknown                  *ifaceToRelease;
425 };
426 const IDirectDrawPaletteVtbl IDirectDrawPalette_Vtbl;
427
428 /******************************************************************************
429  * DirectDraw ClassFactory implementation - incomplete
430  ******************************************************************************/
431 typedef struct
432 {
433     ICOM_VFIELD_MULTI(IClassFactory);
434
435     LONG ref;
436     HRESULT (*pfnCreateInstance)(IUnknown *pUnkOuter, REFIID iid, LPVOID *ppObj);
437 } IClassFactoryImpl;
438
439 /* Helper structures */
440 struct object_creation_info
441 {
442     const CLSID *clsid;
443     HRESULT (*pfnCreateInstance)(IUnknown *pUnkOuter, REFIID riid,
444                                  void **ppObj);
445 };
446
447 /******************************************************************************
448  * IDirect3DLight implementation structure - Wraps to D3D7
449  ******************************************************************************/
450 struct IDirect3DLightImpl
451 {
452     ICOM_VFIELD_MULTI(IDirect3DLight);
453     LONG ref;
454
455     /* IDirect3DLight fields */
456     IDirectDrawImpl           *ddraw;
457
458     /* If this light is active for one viewport, put the viewport here */
459     IDirect3DViewportImpl     *active_viewport;
460
461     D3DLIGHT2 light;
462     D3DLIGHT7 light7;
463
464     DWORD dwLightIndex;
465
466     /* Chained list used for adding / removing from viewports */
467     IDirect3DLightImpl        *next;
468
469     /* Activation function */
470     void                      (*activate)(IDirect3DLightImpl*);
471     void                      (*desactivate)(IDirect3DLightImpl*);
472     void                      (*update)(IDirect3DLightImpl*);
473 };
474
475 /* Vtable */
476 const IDirect3DLightVtbl IDirect3DLight_Vtbl;
477
478 /* Helper functions */
479 void light_update(IDirect3DLightImpl* This);
480 void light_activate(IDirect3DLightImpl* This);
481 void light_desactivate(IDirect3DLightImpl* This);
482
483 /******************************************************************************
484  * IDirect3DMaterial implementation structure - Wraps to D3D7
485  ******************************************************************************/
486 struct IDirect3DMaterialImpl
487 {
488     ICOM_VFIELD_MULTI(IDirect3DMaterial3);
489     ICOM_VFIELD_MULTI(IDirect3DMaterial2);
490     ICOM_VFIELD_MULTI(IDirect3DMaterial);
491     LONG  ref;
492
493     /* IDirect3DMaterial2 fields */
494     IDirectDrawImpl               *ddraw;
495     IDirect3DDeviceImpl           *active_device;
496
497     D3DMATERIAL mat;
498     DWORD Handle;
499
500     void (*activate)(IDirect3DMaterialImpl* this);
501 };
502
503 /* VTables in various versions */
504 const IDirect3DMaterialVtbl IDirect3DMaterial_Vtbl;
505 const IDirect3DMaterial2Vtbl IDirect3DMaterial2_Vtbl;
506 const IDirect3DMaterial3Vtbl IDirect3DMaterial3_Vtbl;
507
508 /* Helper functions */
509 void material_activate(IDirect3DMaterialImpl* This);
510
511 /*****************************************************************************
512  * IDirect3DViewport - Wraps to D3D7
513  *****************************************************************************/
514 struct IDirect3DViewportImpl
515 {
516     ICOM_VFIELD_MULTI(IDirect3DViewport3);
517     LONG ref;
518
519     /* IDirect3DViewport fields */
520     IDirectDrawImpl           *ddraw;
521
522     /* If this viewport is active for one device, put the device here */
523     IDirect3DDeviceImpl       *active_device;
524
525     DWORD                     num_lights;
526     DWORD                     map_lights;
527
528     int                       use_vp2;
529
530     union
531     {
532         D3DVIEWPORT vp1;
533         D3DVIEWPORT2 vp2;
534     } viewports;
535
536     /* Activation function */
537     void                      (*activate)(IDirect3DViewportImpl*);
538
539     /* Field used to chain viewports together */
540     IDirect3DViewportImpl     *next;
541
542     /* Lights list */
543     IDirect3DLightImpl        *lights;
544
545     /* Background material */
546     IDirect3DMaterialImpl     *background;
547 };
548
549 /* Vtable */
550 const IDirect3DViewport3Vtbl IDirect3DViewport3_Vtbl;
551
552 /* Helper functions */
553 void viewport_activate(IDirect3DViewportImpl* This);
554
555 /*****************************************************************************
556  * IDirect3DExecuteBuffer - Wraps to D3D7
557  *****************************************************************************/
558 struct IDirect3DExecuteBufferImpl
559 {
560     /* IUnknown */
561     ICOM_VFIELD_MULTI(IDirect3DExecuteBuffer);
562     LONG                 ref;
563
564     /* IDirect3DExecuteBuffer fields */
565     IDirectDrawImpl      *ddraw;
566     IDirect3DDeviceImpl  *d3ddev;
567
568     D3DEXECUTEBUFFERDESC desc;
569     D3DEXECUTEDATA       data;
570
571     /* This buffer will store the transformed vertices */
572     void                 *vertex_data;
573     WORD                 *indices;
574     int                  nb_indices;
575
576     /* This flags is set to TRUE if we allocated ourselves the
577      * data buffer
578      */
579     BOOL                 need_free;
580 };
581
582 /* The VTable */
583 const IDirect3DExecuteBufferVtbl IDirect3DExecuteBuffer_Vtbl;
584
585 /* The execute function */
586 void
587 IDirect3DExecuteBufferImpl_Execute(IDirect3DExecuteBufferImpl *This,
588                                    IDirect3DDeviceImpl *Device,
589                                    IDirect3DViewportImpl *ViewportImpl);
590
591 /*****************************************************************************
592  * IDirect3DVertexBuffer
593  *****************************************************************************/
594 struct IDirect3DVertexBufferImpl
595 {
596     /*** IUnknown Methods ***/
597     ICOM_VFIELD_MULTI(IDirect3DVertexBuffer7);
598     ICOM_VFIELD_MULTI(IDirect3DVertexBuffer);
599     LONG                 ref;
600
601     /*** WineD3D and ddraw links ***/
602     IWineD3DVertexBuffer *wineD3DVertexBuffer;
603     IWineD3DVertexDeclaration *wineD3DVertexDeclaration;
604     IDirectDrawImpl *ddraw;
605
606     /*** Storage for D3D7 specific things ***/
607     DWORD                Caps;
608 };
609
610 /* The Vtables */
611 const IDirect3DVertexBuffer7Vtbl IDirect3DVertexBuffer7_Vtbl;
612 const IDirect3DVertexBufferVtbl IDirect3DVertexBuffer1_Vtbl;
613
614 /*****************************************************************************
615  * Helper functions from utils.c
616  *****************************************************************************/
617
618 #define GET_TEXCOUNT_FROM_FVF(d3dvtVertexType) \
619     (((d3dvtVertexType) & D3DFVF_TEXCOUNT_MASK) >> D3DFVF_TEXCOUNT_SHIFT)
620
621 #define GET_TEXCOORD_SIZE_FROM_FVF(d3dvtVertexType, tex_num) \
622     (((((d3dvtVertexType) >> (16 + (2 * (tex_num)))) + 1) & 0x03) + 1)
623
624 void PixelFormat_WineD3DtoDD(DDPIXELFORMAT *DDPixelFormat, WINED3DFORMAT WineD3DFormat);
625 WINED3DFORMAT PixelFormat_DD2WineD3D(const DDPIXELFORMAT *DDPixelFormat);
626 void DDRAW_dump_surface_desc(const DDSURFACEDESC2 *lpddsd);
627 void DDRAW_dump_pixelformat(const DDPIXELFORMAT *PixelFormat);
628 void dump_D3DMATRIX(const D3DMATRIX *mat);
629 void DDRAW_dump_DDCAPS(const DDCAPS *lpcaps);
630 DWORD get_flexible_vertex_size(DWORD d3dvtVertexType);
631 void DDRAW_dump_DDSCAPS2(const DDSCAPS2 *in);
632 void DDRAW_dump_cooperativelevel(DWORD cooplevel);
633
634 /* This only needs to be here as long the processvertices functionality of
635  * IDirect3DExecuteBuffer isn't in WineD3D */
636 void multiply_matrix(LPD3DMATRIX dest, const D3DMATRIX *src1, const D3DMATRIX *src2);
637
638 /* Used for generic dumping */
639 typedef struct
640 {
641     DWORD val;
642     const char* name;
643 } flag_info;
644
645 #define FE(x) { x, #x }
646
647 typedef struct
648 {
649     DWORD val;
650     const char* name;
651     void (*func)(const void *);
652     ptrdiff_t offset;
653 } member_info;
654
655 /* Structure copy */
656 #define ME(x,f,e) { x, #x, (void (*)(const void *))(f), offsetof(STRUCT, e) }
657
658 #define DD_STRUCT_COPY_BYSIZE(to,from)                  \
659         do {                                            \
660                 DWORD __size = (to)->dwSize;            \
661                 DWORD __copysize = __size;              \
662                 DWORD __resetsize = __size;             \
663                 assert(to != from);                     \
664                 if (__resetsize > sizeof(*to))          \
665                     __resetsize = sizeof(*to);          \
666                 memset(to,0,__resetsize);               \
667                 if ((from)->dwSize < __size)            \
668                     __copysize = (from)->dwSize;        \
669                 memcpy(to,from,__copysize);             \
670                 (to)->dwSize = __size;/*restore size*/  \
671         } while (0)
672
673
674 #endif
675
676 HRESULT hr_ddraw_from_wined3d(HRESULT hr);