2 * Copyright 2006 Stefan Dösinger
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.
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.
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
19 #ifndef __WINE_DLLS_DDRAW_DDRAW_PRIVATE_H
20 #define __WINE_DLLS_DDRAW_DDRAW_PRIVATE_H
22 /* MAY NOT CONTAIN X11 or DGA specific includes/defines/structs! */
36 #include "wine/list.h"
37 #ifdef DDRAW_INIT_GUID
40 #include "wine/wined3d.h"
42 /*****************************************************************************
43 * IParent - a helper interface
44 *****************************************************************************/
45 DEFINE_GUID(IID_IParent, 0xc20e4c88, 0x74e7, 0x4940, 0xba, 0x9f, 0x2e, 0x32, 0x3f, 0x9d, 0xc9, 0x81);
46 typedef struct IParent *LPPARENT, *PPARENT;
48 #define INTERFACE IParent
49 DECLARE_INTERFACE_(IParent,IUnknown)
51 /*** IUnknown methods ***/
52 STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE;
53 STDMETHOD_(ULONG,AddRef)(THIS) PURE;
54 STDMETHOD_(ULONG,Release)(THIS) PURE;
58 #if !defined(__cplusplus) || defined(CINTERFACE)
59 /*** IUnknown methods ***/
60 #define IParent_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
61 #define IParent_AddRef(p) (p)->lpVtbl->AddRef(p)
62 #define IParent_Release(p) (p)->lpVtbl->Release(p)
66 /* Typdef the interfaces */
67 typedef struct IDirectDrawImpl IDirectDrawImpl;
68 typedef struct IDirectDrawSurfaceImpl IDirectDrawSurfaceImpl;
69 typedef struct IDirectDrawClipperImpl IDirectDrawClipperImpl;
70 typedef struct IDirectDrawPaletteImpl IDirectDrawPaletteImpl;
71 typedef struct IDirect3DDeviceImpl IDirect3DDeviceImpl;
72 typedef struct IDirect3DLightImpl IDirect3DLightImpl;
73 typedef struct IDirect3DViewportImpl IDirect3DViewportImpl;
74 typedef struct IDirect3DMaterialImpl IDirect3DMaterialImpl;
75 typedef struct IDirect3DExecuteBufferImpl IDirect3DExecuteBufferImpl;
76 typedef struct IDirect3DVertexBufferImpl IDirect3DVertexBufferImpl;
77 typedef struct IParentImpl IParentImpl;
79 /* Callbacks for implicit object destruction */
80 extern ULONG WINAPI D3D7CB_DestroySwapChain(IWineD3DSwapChain *pSwapChain);
82 extern ULONG WINAPI D3D7CB_DestroyDepthStencilSurface(IWineD3DSurface *pSurface);
84 /* Global critical section */
85 extern CRITICAL_SECTION ddraw_cs;
87 extern DWORD force_refresh_rate;
89 /*****************************************************************************
90 * IDirectDraw implementation structure
91 *****************************************************************************/
95 IWineD3DVertexDeclaration *decl;
98 struct IDirectDrawImpl
100 /* IUnknown fields */
101 const IDirectDraw7Vtbl *lpVtbl;
102 const IDirectDraw4Vtbl *IDirectDraw4_vtbl;
103 const IDirectDraw3Vtbl *IDirectDraw3_vtbl;
104 const IDirectDraw2Vtbl *IDirectDraw2_vtbl;
105 const IDirectDrawVtbl *IDirectDraw_vtbl;
106 const IDirect3D7Vtbl *IDirect3D7_vtbl;
107 const IDirect3D3Vtbl *IDirect3D3_vtbl;
108 const IDirect3D2Vtbl *IDirect3D2_vtbl;
109 const IDirect3DVtbl *IDirect3D_vtbl;
110 const IWineD3DDeviceParentVtbl *device_parent_vtbl;
112 /* See comment in IDirectDraw::AddRef */
113 LONG ref7, ref4, ref2, ref3, ref1, numIfaces;
115 /* WineD3D linkage */
117 IWineD3DDevice *wineD3DDevice;
118 IDirectDrawSurfaceImpl *DepthStencilBuffer;
119 BOOL d3d_initialized;
121 /* Misc ddraw fields */
127 /* DirectDraw things, which are not handled by WineD3D */
128 DWORD cooperative_level;
130 DWORD orig_width, orig_height;
134 IDirectDrawSurfaceImpl *d3d_target;
136 IDirect3DDeviceImpl *d3ddevice;
144 /* The surface type to request */
145 WINED3DSURFTYPE ImplType;
148 /* Our private window class */
152 /* Helpers for surface creation */
153 IDirectDrawSurfaceImpl *tex_root;
156 /* For the dll unload cleanup code */
157 struct list ddraw_list_entry;
158 /* The surface list - can't relay this to WineD3D
161 struct list surface_list;
165 struct FvfToDecl *decls;
166 UINT numConvertedDecls, declArraySize;
169 /* Declare the VTables. They can be found ddraw.c */
170 extern const IDirectDraw7Vtbl IDirectDraw7_Vtbl;
171 extern const IDirectDraw4Vtbl IDirectDraw4_Vtbl;
172 extern const IDirectDraw3Vtbl IDirectDraw3_Vtbl;
173 extern const IDirectDraw2Vtbl IDirectDraw2_Vtbl;
174 extern const IDirectDrawVtbl IDirectDraw1_Vtbl;
175 extern const IWineD3DDeviceParentVtbl ddraw_wined3d_device_parent_vtbl;
177 /* Helper structures */
178 typedef struct EnumDisplayModesCBS
181 LPDDENUMMODESCALLBACK2 callback;
182 } EnumDisplayModesCBS;
184 typedef struct EnumSurfacesCBS
187 LPDDENUMSURFACESCALLBACK7 callback;
188 LPDDSURFACEDESC2 pDDSD;
192 /* Utility functions */
194 DDRAW_Convert_DDSCAPS_1_To_2(const DDSCAPS* pIn,
197 DDRAW_Convert_DDDEVICEIDENTIFIER_2_To_1(const DDDEVICEIDENTIFIER2* pIn,
198 DDDEVICEIDENTIFIER* pOut);
200 IDirectDrawImpl_Destroy(IDirectDrawImpl *This);
203 IDirectDrawImpl_RecreateSurfacesCallback(IDirectDrawSurface7 *surf,
204 DDSURFACEDESC2 *desc,
206 IWineD3DVertexDeclaration *
207 IDirectDrawImpl_FindDecl(IDirectDrawImpl *This,
210 static inline IDirectDrawImpl *ddraw_from_d3d1(IDirect3D *iface)
212 return (IDirectDrawImpl *)((char*)iface - FIELD_OFFSET(IDirectDrawImpl, IDirect3D_vtbl));
215 static inline IDirectDrawImpl *ddraw_from_d3d2(IDirect3D2 *iface)
217 return (IDirectDrawImpl *)((char*)iface - FIELD_OFFSET(IDirectDrawImpl, IDirect3D2_vtbl));
220 static inline IDirectDrawImpl *ddraw_from_d3d3(IDirect3D3 *iface)
222 return (IDirectDrawImpl *)((char*)iface - FIELD_OFFSET(IDirectDrawImpl, IDirect3D3_vtbl));
225 static inline IDirectDrawImpl *ddraw_from_d3d7(IDirect3D7 *iface)
227 return (IDirectDrawImpl *)((char*)iface - FIELD_OFFSET(IDirectDrawImpl, IDirect3D7_vtbl));
230 static inline IDirectDrawImpl *ddraw_from_ddraw1(IDirectDraw *iface)
232 return (IDirectDrawImpl *)((char*)iface - FIELD_OFFSET(IDirectDrawImpl, IDirectDraw_vtbl));
235 static inline IDirectDrawImpl *ddraw_from_ddraw2(IDirectDraw2 *iface)
237 return (IDirectDrawImpl *)((char*)iface - FIELD_OFFSET(IDirectDrawImpl, IDirectDraw2_vtbl));
240 static inline IDirectDrawImpl *ddraw_from_ddraw3(IDirectDraw3 *iface)
242 return (IDirectDrawImpl *)((char*)iface - FIELD_OFFSET(IDirectDrawImpl, IDirectDraw3_vtbl));
245 static inline IDirectDrawImpl *ddraw_from_ddraw4(IDirectDraw4 *iface)
247 return (IDirectDrawImpl *)((char*)iface - FIELD_OFFSET(IDirectDrawImpl, IDirectDraw4_vtbl));
250 /* The default surface type */
251 extern WINED3DSURFTYPE DefaultSurfaceType;
253 /*****************************************************************************
254 * IDirectDrawSurface implementation structure
255 *****************************************************************************/
257 struct IDirectDrawSurfaceImpl
259 /* IUnknown fields */
260 const IDirectDrawSurface7Vtbl *lpVtbl;
261 const IDirectDrawSurface3Vtbl *IDirectDrawSurface3_vtbl;
262 const IDirectDrawGammaControlVtbl *IDirectDrawGammaControl_vtbl;
263 const IDirect3DTexture2Vtbl *IDirect3DTexture2_vtbl;
264 const IDirect3DTextureVtbl *IDirect3DTexture_vtbl;
267 IUnknown *ifaceToRelease;
271 /* Connections to other Objects */
272 IDirectDrawImpl *ddraw;
273 IWineD3DSurface *WineD3DSurface;
274 IWineD3DBaseTexture *wineD3DTexture;
275 IWineD3DSwapChain *wineD3DSwapChain;
277 /* This implementation handles attaching surfaces to other surfaces */
278 IDirectDrawSurfaceImpl *next_attached;
279 IDirectDrawSurfaceImpl *first_attached;
281 /* Complex surfaces are organized in a tree, although the tree is degenerated to a list in most cases.
282 * In mipmap and primary surfaces each level has only one attachment, which is the next surface level.
283 * Only the cube texture root has 6 surfaces attached, which then have a normal mipmap chain attached
284 * to them. So hardcode the array to 6, a dynamic array or a list would be an overkill.
286 #define MAX_COMPLEX_ATTACHED 6
287 IDirectDrawSurfaceImpl *complex_array[MAX_COMPLEX_ATTACHED];
288 /* You can't traverse the tree upwards. Only a flag for Surface::Release because its needed there,
289 * but no pointer to prevent temptations to traverse it in the wrong direction.
291 BOOL is_complex_root;
293 /* Surface description, for GetAttachedSurface */
294 DDSURFACEDESC2 surface_desc;
297 DWORD uniqueness_value;
299 WINED3DSURFTYPE ImplType;
301 /* For D3DDevice creation */
304 /* Clipper objects */
305 IDirectDrawClipperImpl *clipper;
307 /* For the ddraw surface list */
308 struct list surface_list_entry;
313 /* VTable declaration. It's located in surface.c / surface_thunks.c */
314 extern const IDirectDrawSurface7Vtbl IDirectDrawSurface7_Vtbl;
315 extern const IDirectDrawSurface3Vtbl IDirectDrawSurface3_Vtbl;
316 extern const IDirectDrawGammaControlVtbl IDirectDrawGammaControl_Vtbl;
317 extern const IDirect3DTexture2Vtbl IDirect3DTexture2_Vtbl;
318 extern const IDirect3DTextureVtbl IDirect3DTexture1_Vtbl;
320 HRESULT WINAPI IDirectDrawSurfaceImpl_AddAttachedSurface(IDirectDrawSurfaceImpl *This, IDirectDrawSurfaceImpl *Surf);
321 void IDirectDrawSurfaceImpl_Destroy(IDirectDrawSurfaceImpl *This);
323 static inline IDirectDrawSurfaceImpl *surface_from_texture1(IDirect3DTexture *iface)
325 return (IDirectDrawSurfaceImpl *)((char*)iface - FIELD_OFFSET(IDirectDrawSurfaceImpl, IDirect3DTexture_vtbl));
328 static inline IDirectDrawSurfaceImpl *surface_from_texture2(IDirect3DTexture2 *iface)
330 return (IDirectDrawSurfaceImpl *)((char*)iface - FIELD_OFFSET(IDirectDrawSurfaceImpl, IDirect3DTexture2_vtbl));
333 static inline IDirectDrawSurfaceImpl *surface_from_surface3(IDirectDrawSurface3 *iface)
335 return (IDirectDrawSurfaceImpl *)((char*)iface - FIELD_OFFSET(IDirectDrawSurfaceImpl, IDirectDrawSurface3_vtbl));
338 /* Get the number of bytes per pixel for a given surface */
339 #define PFGET_BPP(pf) (pf.dwFlags&DDPF_PALETTEINDEXED8?1:((pf.dwRGBBitCount+7)/8))
340 #define GET_BPP(desc) PFGET_BPP(desc.ddpfPixelFormat)
342 /*****************************************************************************
343 * IParent Implementation
344 *****************************************************************************/
347 /* IUnknown fields */
348 const IParentVtbl *lpVtbl;
351 /* IParentImpl fields */
356 extern const IParentVtbl IParent_Vtbl;
358 /*****************************************************************************
359 * IDirect3DDevice implementation
360 *****************************************************************************/
363 DDrawHandle_Unknown = 0,
364 DDrawHandle_Texture = 1,
365 DDrawHandle_Material = 2,
366 DDrawHandle_Matrix = 3,
367 DDrawHandle_StateBlock = 4
373 DDrawHandleTypes type;
376 struct IDirect3DDeviceImpl
379 const IDirect3DDevice7Vtbl *lpVtbl;
380 const IDirect3DDevice3Vtbl *IDirect3DDevice3_vtbl;
381 const IDirect3DDevice2Vtbl *IDirect3DDevice2_vtbl;
382 const IDirect3DDeviceVtbl *IDirect3DDevice_vtbl;
385 /* Other object connections */
386 IWineD3DDevice *wineD3DDevice;
387 IDirectDrawImpl *ddraw;
388 IWineD3DBuffer *indexbuffer;
389 IDirectDrawSurfaceImpl *target;
390 BOOL OffScreenTarget;
392 /* Viewport management */
393 IDirect3DViewportImpl *viewport_list;
394 IDirect3DViewportImpl *current_viewport;
395 D3DVIEWPORT7 active_viewport;
397 /* Required to keep track which of two available texture blending modes in d3ddevice3 is used */
398 BOOL legacyTextureBlending;
403 /* Rendering functions to wrap D3D(1-3) to D3D7 */
404 D3DPRIMITIVETYPE primitive_type;
408 LPBYTE vertex_buffer;
412 /* Handle management */
413 struct HandleEntry *Handles;
415 D3DMATRIXHANDLE world, proj, view;
418 /* Vtables in various versions */
419 extern const IDirect3DDevice7Vtbl IDirect3DDevice7_FPUSetup_Vtbl;
420 extern const IDirect3DDevice7Vtbl IDirect3DDevice7_FPUPreserve_Vtbl;
421 extern const IDirect3DDevice3Vtbl IDirect3DDevice3_Vtbl;
422 extern const IDirect3DDevice2Vtbl IDirect3DDevice2_Vtbl;
423 extern const IDirect3DDeviceVtbl IDirect3DDevice1_Vtbl;
426 extern const GUID IID_D3DDEVICE_WineD3D;
428 /* Helper functions */
429 HRESULT IDirect3DImpl_GetCaps(IWineD3D *WineD3D, D3DDEVICEDESC *Desc123, D3DDEVICEDESC7 *Desc7);
430 DWORD IDirect3DDeviceImpl_CreateHandle(IDirect3DDeviceImpl *This);
431 WINED3DZBUFFERTYPE IDirect3DDeviceImpl_UpdateDepthStencil(IDirect3DDeviceImpl *This);
433 static inline IDirect3DDeviceImpl *device_from_device1(IDirect3DDevice *iface)
435 return (IDirect3DDeviceImpl *)((char*)iface - FIELD_OFFSET(IDirect3DDeviceImpl, IDirect3DDevice_vtbl));
438 static inline IDirect3DDeviceImpl *device_from_device2(IDirect3DDevice2 *iface)
440 return (IDirect3DDeviceImpl *)((char*)iface - FIELD_OFFSET(IDirect3DDeviceImpl, IDirect3DDevice2_vtbl));
443 static inline IDirect3DDeviceImpl *device_from_device3(IDirect3DDevice3 *iface)
445 return (IDirect3DDeviceImpl *)((char*)iface - FIELD_OFFSET(IDirect3DDeviceImpl, IDirect3DDevice3_vtbl));
449 struct EnumTextureFormatsCBS
451 LPD3DENUMTEXTUREFORMATSCALLBACK cbv2;
452 LPD3DENUMPIXELFORMATSCALLBACK cbv7;
456 /*****************************************************************************
457 * IDirect3D implementation
458 *****************************************************************************/
460 /* No implementation structure as this is only another interface to DirectDraw */
463 extern const IDirect3DVtbl IDirect3D1_Vtbl;
464 extern const IDirect3D2Vtbl IDirect3D2_Vtbl;
465 extern const IDirect3D3Vtbl IDirect3D3_Vtbl;
466 extern const IDirect3D7Vtbl IDirect3D7_Vtbl;
468 /* Structure for EnumZBufferFormats */
469 struct EnumZBufferFormatsData
471 LPD3DENUMPIXELFORMATSCALLBACK Callback;
475 /*****************************************************************************
476 * IDirectDrawClipper implementation structure
477 *****************************************************************************/
478 struct IDirectDrawClipperImpl
480 /* IUnknown fields */
481 const IDirectDrawClipperVtbl *lpVtbl;
484 IWineD3DClipper *wineD3DClipper;
485 IDirectDrawImpl *ddraw_owner;
488 extern const IDirectDrawClipperVtbl IDirectDrawClipper_Vtbl;
490 typeof(WineDirect3DCreateClipper) *pWineDirect3DCreateClipper;
492 /*****************************************************************************
493 * IDirectDrawPalette implementation structure
494 *****************************************************************************/
495 struct IDirectDrawPaletteImpl
497 /* IUnknown fields */
498 const IDirectDrawPaletteVtbl *lpVtbl;
502 IWineD3DPalette *wineD3DPalette;
504 /* IDirectDrawPalette fields */
505 IDirectDrawImpl *ddraw_owner;
506 IUnknown *ifaceToRelease;
508 extern const IDirectDrawPaletteVtbl IDirectDrawPalette_Vtbl;
510 /******************************************************************************
511 * DirectDraw ClassFactory implementation - incomplete
512 ******************************************************************************/
515 const IClassFactoryVtbl *lpVtbl;
518 HRESULT (*pfnCreateInstance)(IUnknown *pUnkOuter, REFIID iid, LPVOID *ppObj);
521 /* Helper structures */
522 struct object_creation_info
525 HRESULT (*pfnCreateInstance)(IUnknown *pUnkOuter, REFIID riid,
529 /******************************************************************************
530 * IDirect3DLight implementation structure - Wraps to D3D7
531 ******************************************************************************/
532 struct IDirect3DLightImpl
534 const IDirect3DLightVtbl *lpVtbl;
537 /* IDirect3DLight fields */
538 IDirectDrawImpl *ddraw;
540 /* If this light is active for one viewport, put the viewport here */
541 IDirect3DViewportImpl *active_viewport;
548 /* Chained list used for adding / removing from viewports */
549 IDirect3DLightImpl *next;
551 /* Activation function */
552 void (*activate)(IDirect3DLightImpl*);
553 void (*desactivate)(IDirect3DLightImpl*);
554 void (*update)(IDirect3DLightImpl*);
558 extern const IDirect3DLightVtbl IDirect3DLight_Vtbl;
560 /* Helper functions */
561 void light_update(IDirect3DLightImpl* This);
562 void light_activate(IDirect3DLightImpl* This);
563 void light_desactivate(IDirect3DLightImpl* This);
565 /******************************************************************************
566 * IDirect3DMaterial implementation structure - Wraps to D3D7
567 ******************************************************************************/
568 struct IDirect3DMaterialImpl
570 const IDirect3DMaterial3Vtbl *lpVtbl;
571 const IDirect3DMaterial2Vtbl *IDirect3DMaterial2_vtbl;
572 const IDirect3DMaterialVtbl *IDirect3DMaterial_vtbl;
575 /* IDirect3DMaterial2 fields */
576 IDirectDrawImpl *ddraw;
577 IDirect3DDeviceImpl *active_device;
582 void (*activate)(IDirect3DMaterialImpl* this);
585 /* VTables in various versions */
586 extern const IDirect3DMaterialVtbl IDirect3DMaterial_Vtbl;
587 extern const IDirect3DMaterial2Vtbl IDirect3DMaterial2_Vtbl;
588 extern const IDirect3DMaterial3Vtbl IDirect3DMaterial3_Vtbl;
590 /* Helper functions */
591 void material_activate(IDirect3DMaterialImpl* This);
593 /*****************************************************************************
594 * IDirect3DViewport - Wraps to D3D7
595 *****************************************************************************/
596 struct IDirect3DViewportImpl
598 const IDirect3DViewport3Vtbl *lpVtbl;
601 /* IDirect3DViewport fields */
602 IDirectDrawImpl *ddraw;
604 /* If this viewport is active for one device, put the device here */
605 IDirect3DDeviceImpl *active_device;
618 /* Activation function */
619 void (*activate)(IDirect3DViewportImpl*, BOOL);
621 /* Field used to chain viewports together */
622 IDirect3DViewportImpl *next;
625 IDirect3DLightImpl *lights;
627 /* Background material */
628 IDirect3DMaterialImpl *background;
632 extern const IDirect3DViewport3Vtbl IDirect3DViewport3_Vtbl;
634 /* Helper functions */
635 void viewport_activate(IDirect3DViewportImpl* This, BOOL ignore_lights);
637 /*****************************************************************************
638 * IDirect3DExecuteBuffer - Wraps to D3D7
639 *****************************************************************************/
640 struct IDirect3DExecuteBufferImpl
643 const IDirect3DExecuteBufferVtbl *lpVtbl;
646 /* IDirect3DExecuteBuffer fields */
647 IDirectDrawImpl *ddraw;
648 IDirect3DDeviceImpl *d3ddev;
650 D3DEXECUTEBUFFERDESC desc;
653 /* This buffer will store the transformed vertices */
658 /* This flags is set to TRUE if we allocated ourselves the
665 extern const IDirect3DExecuteBufferVtbl IDirect3DExecuteBuffer_Vtbl;
667 /* The execute function */
669 IDirect3DExecuteBufferImpl_Execute(IDirect3DExecuteBufferImpl *This,
670 IDirect3DDeviceImpl *Device,
671 IDirect3DViewportImpl *ViewportImpl);
673 /*****************************************************************************
674 * IDirect3DVertexBuffer
675 *****************************************************************************/
676 struct IDirect3DVertexBufferImpl
678 /*** IUnknown Methods ***/
679 const IDirect3DVertexBuffer7Vtbl *lpVtbl;
680 const IDirect3DVertexBufferVtbl *IDirect3DVertexBuffer_vtbl;
683 /*** WineD3D and ddraw links ***/
684 IWineD3DBuffer *wineD3DVertexBuffer;
685 IWineD3DVertexDeclaration *wineD3DVertexDeclaration;
686 IDirectDrawImpl *ddraw;
688 /*** Storage for D3D7 specific things ***/
694 extern const IDirect3DVertexBuffer7Vtbl IDirect3DVertexBuffer7_Vtbl;
695 extern const IDirect3DVertexBufferVtbl IDirect3DVertexBuffer1_Vtbl;
697 static inline IDirect3DVertexBufferImpl *vb_from_vb1(IDirect3DVertexBuffer *iface)
699 return (IDirect3DVertexBufferImpl *)((char*)iface
700 - FIELD_OFFSET(IDirect3DVertexBufferImpl, IDirect3DVertexBuffer_vtbl));
703 /*****************************************************************************
704 * Helper functions from utils.c
705 *****************************************************************************/
707 #define GET_TEXCOUNT_FROM_FVF(d3dvtVertexType) \
708 (((d3dvtVertexType) & D3DFVF_TEXCOUNT_MASK) >> D3DFVF_TEXCOUNT_SHIFT)
710 #define GET_TEXCOORD_SIZE_FROM_FVF(d3dvtVertexType, tex_num) \
711 (((((d3dvtVertexType) >> (16 + (2 * (tex_num)))) + 1) & 0x03) + 1)
713 void PixelFormat_WineD3DtoDD(DDPIXELFORMAT *DDPixelFormat, WINED3DFORMAT WineD3DFormat);
714 WINED3DFORMAT PixelFormat_DD2WineD3D(const DDPIXELFORMAT *DDPixelFormat);
715 void DDRAW_dump_surface_desc(const DDSURFACEDESC2 *lpddsd);
716 void dump_D3DMATRIX(const D3DMATRIX *mat);
717 void DDRAW_dump_DDCAPS(const DDCAPS *lpcaps);
718 DWORD get_flexible_vertex_size(DWORD d3dvtVertexType);
719 void DDRAW_dump_DDSCAPS2(const DDSCAPS2 *in);
720 void DDRAW_dump_cooperativelevel(DWORD cooplevel);
722 /* This only needs to be here as long the processvertices functionality of
723 * IDirect3DExecuteBuffer isn't in WineD3D */
724 void multiply_matrix(LPD3DMATRIX dest, const D3DMATRIX *src1, const D3DMATRIX *src2);
726 void multiply_matrix_D3D_way(LPD3DMATRIX result, const D3DMATRIX *m1, const D3DMATRIX *m2);
728 /* Helper function in main.c */
729 BOOL LoadWineD3D(void);
731 /* Used for generic dumping */
738 #define FE(x) { x, #x }
744 void (*func)(const void *);
749 #define ME(x,f,e) { x, #x, (void (*)(const void *))(f), offsetof(STRUCT, e) }
751 #define DD_STRUCT_COPY_BYSIZE(to,from) \
753 DWORD __size = (to)->dwSize; \
754 DWORD __copysize = __size; \
755 DWORD __resetsize = __size; \
756 assert(to != from); \
757 if (__resetsize > sizeof(*to)) \
758 __resetsize = sizeof(*to); \
759 memset(to,0,__resetsize); \
760 if ((from)->dwSize < __size) \
761 __copysize = (from)->dwSize; \
762 memcpy(to,from,__copysize); \
763 (to)->dwSize = __size;/*restore size*/ \
769 HRESULT hr_ddraw_from_wined3d(HRESULT hr);