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