2 * Direct3D wine internal private include file
4 * Copyright 2002-2003 The wine-d3d team
5 * Copyright 2002-2003 Raphael Junqueira
6 * Copyright 2004 Jason Edmeades
7 * Copyright 2005 Oliver Stieber
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 #ifndef __WINE_WINED3D_PRIVATE_H
25 #define __WINE_WINED3D_PRIVATE_H
29 #define NONAMELESSUNION
30 #define NONAMELESSSTRUCT
37 #include "wine/debug.h"
38 #include "wine/unicode.h"
41 #include "d3d9types.h"
42 #include "wine/wined3d_interface.h"
43 #include "wine/wined3d_gl.h"
46 #define MAX_PALETTES 256
47 #define MAX_STREAMS 16
48 #define MAX_TEXTURES 8
49 #define MAX_SAMPLERS 16
50 #define MAX_ACTIVE_LIGHTS 8
51 #define MAX_CLIPPLANES D3DMAXUSERCLIPPLANES
52 #define MAX_LEVELS 256
55 #define MAX_SWAPCHAINS 256
57 /* Used for CreateStateBlock */
58 #define NUM_SAVEDPIXELSTATES_R 35
59 #define NUM_SAVEDPIXELSTATES_T 18
60 #define NUM_SAVEDPIXELSTATES_S 12
61 #define NUM_SAVEDVERTEXSTATES_R 31
62 #define NUM_SAVEDVERTEXSTATES_T 2
63 #define NUM_SAVEDVERTEXSTATES_S 1
65 extern const DWORD SavedPixelStates_R[NUM_SAVEDPIXELSTATES_R];
66 extern const DWORD SavedPixelStates_T[NUM_SAVEDPIXELSTATES_T];
67 extern const DWORD SavedPixelStates_S[NUM_SAVEDPIXELSTATES_S];
68 extern const DWORD SavedVertexStates_R[NUM_SAVEDVERTEXSTATES_R];
69 extern const DWORD SavedVertexStates_T[NUM_SAVEDVERTEXSTATES_T];
70 extern const DWORD SavedVertexStates_S[NUM_SAVEDVERTEXSTATES_S];
72 /* vertex and pixel shader modes */
84 extern void (*wine_tsx11_lock_ptr)(void);
85 extern void (*wine_tsx11_unlock_ptr)(void);
87 /* As GLX relies on X, this is needed */
91 #define ENTER_GL() ++num_lock; if (num_lock > 1) FIXME("Recursive use of GL lock to: %d\n", num_lock); wine_tsx11_lock_ptr()
92 #define LEAVE_GL() if (num_lock != 1) FIXME("Recursive use of GL lock: %d\n", num_lock); --num_lock; wine_tsx11_unlock_ptr()
94 #define ENTER_GL() wine_tsx11_lock_ptr()
95 #define LEAVE_GL() wine_tsx11_unlock_ptr()
98 /*****************************************************************************
102 /* GL related defines */
103 /* ------------------ */
104 #define GL_SUPPORT(ExtName) (GLINFO_LOCATION.supported[ExtName] != 0)
105 #define GL_LIMITS(ExtName) (GLINFO_LOCATION.max_##ExtName)
106 #define GL_EXTCALL(FuncName) (GLINFO_LOCATION.FuncName)
108 #define D3DCOLOR_R(dw) (((float) (((dw) >> 16) & 0xFF)) / 255.0f)
109 #define D3DCOLOR_G(dw) (((float) (((dw) >> 8) & 0xFF)) / 255.0f)
110 #define D3DCOLOR_B(dw) (((float) (((dw) >> 0) & 0xFF)) / 255.0f)
111 #define D3DCOLOR_A(dw) (((float) (((dw) >> 24) & 0xFF)) / 255.0f)
113 #define D3DCOLORTOGLFLOAT4(dw, vec) \
114 (vec)[0] = D3DCOLOR_R(dw); \
115 (vec)[1] = D3DCOLOR_G(dw); \
116 (vec)[2] = D3DCOLOR_B(dw); \
117 (vec)[3] = D3DCOLOR_A(dw);
119 /* Note: The following is purely to keep the source code as clear from #ifdefs as possible */
120 #if defined(GL_VERSION_1_3)
121 #define GLACTIVETEXTURE(textureNo) \
122 glActiveTexture(GL_TEXTURE0 + textureNo); \
123 checkGLcall("glActiveTexture");
124 #define GLCLIENTACTIVETEXTURE(textureNo) \
125 glClientActiveTexture(GL_TEXTURE0 + textureNo);
126 #define GLMULTITEXCOORD1F(a,b) \
127 glMultiTexCoord1f(GL_TEXTURE0 + a, b);
128 #define GLMULTITEXCOORD2F(a,b,c) \
129 glMultiTexCoord2f(GL_TEXTURE0 + a, b, c);
130 #define GLMULTITEXCOORD3F(a,b,c,d) \
131 glMultiTexCoord3f(GL_TEXTURE0 + a, b, c, d);
132 #define GLMULTITEXCOORD4F(a,b,c,d,e) \
133 glMultiTexCoord4f(GL_TEXTURE0 + a, b, c, d, e);
134 #define GLTEXTURECUBEMAP GL_TEXTURE_CUBE_MAP
136 #define GLACTIVETEXTURE(textureNo) \
137 glActiveTextureARB(GL_TEXTURE0_ARB + textureNo); \
138 checkGLcall("glActiveTextureARB");
139 #define GLCLIENTACTIVETEXTURE(textureNo) \
140 glClientActiveTextureARB(GL_TEXTURE0_ARB + textureNo);
141 #define GLMULTITEXCOORD1F(a,b) \
142 glMultiTexCoord1fARB(GL_TEXTURE0_ARB + a, b);
143 #define GLMULTITEXCOORD2F(a,b,c) \
144 glMultiTexCoord2fARB(GL_TEXTURE0_ARB + a, b, c);
145 #define GLMULTITEXCOORD3F(a,b,c,d) \
146 glMultiTexCoord3fARB(GL_TEXTURE0_ARB + a, b, c, d);
147 #define GLMULTITEXCOORD4F(a,b,c,d,e) \
148 glMultiTexCoord4fARB(GL_TEXTURE0_ARB + a, b, c, d, e);
149 #define GLTEXTURECUBEMAP GL_TEXTURE_CUBE_MAP_ARB
152 /* DirectX Device Limits */
153 /* --------------------- */
154 #define MAX_LEVELS 256 /* Maximum number of mipmap levels. Guessed at 256 */
156 #define MAX_STREAMS 16 /* Maximum possible streams - used for fixed size arrays
157 See MaxStreams in MSDN under GetDeviceCaps */
158 /* Maximum number of constants provided to the shaders */
159 #define HIGHEST_TRANSFORMSTATE 512
160 /* Highest value in D3DTRANSFORMSTATETYPE */
161 #define HIGHEST_TEXTURE_STATE D3DTSS_CONSTANT
162 /* Highest D3DTSS_ value */
163 #define HIGHEST_SAMPLER_STATE D3DSAMP_DMAPOFFSET
164 /* Maximum number of constants provided to the shaders */
165 #define MAX_CLIPPLANES D3DMAXUSERCLIPPLANES
167 #define MAX_PALETTES 256
169 /* Checking of API calls */
170 /* --------------------- */
171 #define checkGLcall(A) \
173 GLint err = glGetError(); \
174 if (err != GL_NO_ERROR) { \
175 FIXME(">>>>>>>>>>>>>>>>> %x from %s @ %s / %d\n", err, A, __FILE__, __LINE__); \
177 TRACE("%s call ok %s / %d\n", A, __FILE__, __LINE__); \
181 /* Trace routines / diagnostics */
182 /* ---------------------------- */
184 /* Dump out a matrix and copy it */
185 #define conv_mat(mat,gl_mat) \
187 TRACE("%f %f %f %f\n", (mat)->u.s._11, (mat)->u.s._12, (mat)->u.s._13, (mat)->u.s._14); \
188 TRACE("%f %f %f %f\n", (mat)->u.s._21, (mat)->u.s._22, (mat)->u.s._23, (mat)->u.s._24); \
189 TRACE("%f %f %f %f\n", (mat)->u.s._31, (mat)->u.s._32, (mat)->u.s._33, (mat)->u.s._34); \
190 TRACE("%f %f %f %f\n", (mat)->u.s._41, (mat)->u.s._42, (mat)->u.s._43, (mat)->u.s._44); \
191 memcpy(gl_mat, (mat), 16 * sizeof(float)); \
194 /* Macro to dump out the current state of the light chain */
195 #define DUMP_LIGHT_CHAIN() \
197 PLIGHTINFOEL *el = This->stateBlock->lights;\
199 TRACE("Light %p (glIndex %ld, d3dIndex %ld, enabled %d)\n", el, el->glIndex, el->OriginalIndex, el->lightEnabled);\
204 /* Trace vector and strided data information */
205 #define TRACE_VECTOR(name) TRACE( #name "=(%f, %f, %f, %f)\n", name.x, name.y, name.z, name.w);
206 #define TRACE_STRIDED(sd,name) TRACE( #name "=(data:%p, stride:%ld, type:%ld)\n", sd->u.s.name.lpData, sd->u.s.name.dwStride, sd->u.s.name.dwType);
208 /* Defines used for optimizations */
210 /* Only reapply what is necessary */
211 #define REAPPLY_ALPHAOP 0x0001
212 #define REAPPLY_ALL 0xFFFF
214 /* Advance declaration of structures to satisfy compiler */
215 typedef struct IWineD3DStateBlockImpl IWineD3DStateBlockImpl;
216 typedef struct IWineD3DSurfaceImpl IWineD3DSurfaceImpl;
218 /* Global variables */
219 extern const float identity[16];
221 /*****************************************************************************
222 * Compilable extra diagnostics
225 /* Trace information per-vertex: (extremely high amount of trace) */
226 #if 0 /* NOTE: Must be 0 in cvs */
227 # define VTRACE(A) TRACE A
232 /* Checking of per-vertex related GL calls */
233 #define vcheckGLcall(A) \
235 GLint err = glGetError(); \
236 if (err != GL_NO_ERROR) { \
237 FIXME(">>>>>>>>>>>>>>>>> %x from %s @ %s / %d\n", err, A, __FILE__, __LINE__); \
239 VTRACE(("%s call ok %s / %d\n", A, __FILE__, __LINE__)); \
243 /* TODO: Confirm each of these works when wined3d move completed */
244 #if 0 /* NOTE: Must be 0 in cvs */
245 /* To avoid having to get gigabytes of trace, the following can be compiled in, and at the start
246 of each frame, a check is made for the existence of C:\D3DTRACE, and if if exists d3d trace
247 is enabled, and if it doesn't exists it is disabled. */
248 # define FRAME_DEBUGGING
249 /* Adding in the SINGLE_FRAME_DEBUGGING gives a trace of just what makes up a single frame, before
250 the file is deleted */
251 # if 1 /* NOTE: Must be 1 in cvs, as this is mostly more useful than a trace from program start */
252 # define SINGLE_FRAME_DEBUGGING
254 /* The following, when enabled, lets you see the makeup of the frame, by drawprimitive calls.
255 It can only be enabled when FRAME_DEBUGGING is also enabled
256 The contents of the back buffer are written into /tmp/backbuffer_* after each primitive
258 # if 0 /* NOTE: Must be 0 in cvs, as this give a lot of ppm files when compiled in */
259 # define SHOW_FRAME_MAKEUP 1
261 /* The following, when enabled, lets you see the makeup of the all the textures used during each
262 of the drawprimitive calls. It can only be enabled when SHOW_FRAME_MAKEUP is also enabled.
263 The contents of the textures assigned to each stage are written into
264 /tmp/texture_*_<Stage>.ppm after each primitive array is drawn. */
265 # if 0 /* NOTE: Must be 0 in cvs, as this give a lot of ppm files when compiled in */
266 # define SHOW_TEXTURE_MAKEUP 0
269 extern BOOL isDumpingFrames;
270 extern LONG primCounter;
273 /*****************************************************************************
277 /* Routine common to the draw primitive and draw indexed primitive routines */
278 void drawPrimitive(IWineD3DDevice *iface,
283 long StartVertexIndex,
289 /*****************************************************************************
290 * Structures required to draw primitives
293 typedef struct Direct3DStridedData {
294 BYTE *lpData; /* Pointer to start of data */
295 DWORD dwStride; /* Stride between occurances of this data */
296 DWORD dwType; /* Type (as in D3DVSDT_TYPE) */
297 } Direct3DStridedData;
299 typedef struct Direct3DVertexStridedData {
302 Direct3DStridedData position;
303 Direct3DStridedData blendWeights;
304 Direct3DStridedData blendMatrixIndices;
305 Direct3DStridedData normal;
306 Direct3DStridedData pSize;
307 Direct3DStridedData diffuse;
308 Direct3DStridedData specular;
309 Direct3DStridedData texCoords[MAX_TEXTURES];
311 Direct3DStridedData input[16]; /* Indexed by constants in D3DVSDE_REGISTER */
313 } Direct3DVertexStridedData;
315 /*****************************************************************************
316 * Internal representation of a light
318 typedef struct PLIGHTINFOEL PLIGHTINFOEL;
319 struct PLIGHTINFOEL {
320 WINED3DLIGHT OriginalParms; /* Note D3D8LIGHT == D3D9LIGHT */
327 /* Converted parms to speed up swapping lights */
337 /*****************************************************************************
338 * IWineD3D implementation structure
340 typedef struct IWineD3DImpl
342 /* IUnknown fields */
343 const IWineD3DVtbl *lpVtbl;
344 DWORD ref; /* Note: Ref counting not required */
346 /* WineD3D Information */
352 WineD3D_GL_Info gl_info;
355 extern const IWineD3DVtbl IWineD3D_Vtbl;
357 /*****************************************************************************
358 * IWineD3DDevice implementation structure
360 typedef struct IWineD3DDeviceImpl
362 /* IUnknown fields */
363 const IWineD3DDeviceVtbl *lpVtbl;
364 DWORD ref; /* Note: Ref counting not required */
366 /* WineD3D Information */
370 /* X and GL Information */
371 GLint maxConcurrentLights;
374 BOOL modelview_valid;
376 BOOL view_ident; /* true iff view matrix is identity */
377 BOOL last_was_rhw; /* true iff last draw_primitive was in xyzrhw mode */
378 GLenum tracking_parm; /* Which source is tracking current colour */
379 LONG tracking_color; /* used iff GL_COLOR_MATERIAL was enabled */
380 #define DISABLED_TRACKING 0 /* Disabled */
381 #define IS_TRACKING 1 /* tracking_parm is tracking diffuse color */
382 #define NEEDS_TRACKING 2 /* Tracking needs to be enabled when needed */
383 #define NEEDS_DISABLE 3 /* Tracking needs to be disabled when needed*/
388 BOOL texture_shader_active; /* TODO: Confirm use is correct */
390 /* State block related */
391 BOOL isRecordingState;
392 IWineD3DStateBlockImpl *stateBlock;
393 IWineD3DStateBlockImpl *updateStateBlock;
395 /* Internal use fields */
396 D3DDEVICE_CREATION_PARAMETERS createParms;
397 D3DPRESENT_PARAMETERS presentParms;
401 /* TODO: Replace with a linked list */
402 IWineD3DSwapChain *swapchains[MAX_SWAPCHAINS]; /* no-one wil ever need more that MAX_SWAPCHAINS swapchains */
403 int numberOfSwapChains;
405 /* Render Target Support */
406 IWineD3DSurface *frontBuffer;
407 IWineD3DSurface *backBuffer;
408 IWineD3DSurface *depthStencilBuffer;
410 IWineD3DSurface *renderTarget;
411 IWineD3DSurface *stencilBufferTarget;
413 /* palettes texture management */
414 PALETTEENTRY palettes[MAX_PALETTES][256];
417 /* For rendering to a texture using glCopyTexImage */
418 BOOL renderUpsideDown;
420 /* Cursor management */
427 /* Textures for when no other textures are mapped */
428 UINT dummyTextureName[MAX_TEXTURES];
430 /* Debug stream management */
433 } IWineD3DDeviceImpl;
435 extern const IWineD3DDeviceVtbl IWineD3DDevice_Vtbl;
437 /*****************************************************************************
438 * IWineD3DResource implementation structure
440 typedef struct IWineD3DResourceClass
442 /* IUnknown fields */
443 DWORD ref; /* Note: Ref counting not required */
445 /* WineD3DResource Information */
447 D3DRESOURCETYPE resourceType;
448 IWineD3DDeviceImpl *wineD3DDevice;
452 WINED3DFORMAT format;
453 BYTE *allocatedMemory;
455 } IWineD3DResourceClass;
457 typedef struct IWineD3DResourceImpl
459 /* IUnknown & WineD3DResource Information */
460 const IWineD3DResourceVtbl *lpVtbl;
461 IWineD3DResourceClass resource;
462 } IWineD3DResourceImpl;
465 /*****************************************************************************
466 * IWineD3DVertexBuffer implementation structure (extends IWineD3DResourceImpl)
468 typedef struct IWineD3DVertexBufferImpl
470 /* IUnknown & WineD3DResource Information */
471 const IWineD3DVertexBufferVtbl *lpVtbl;
472 IWineD3DResourceClass resource;
474 /* WineD3DVertexBuffer specifics */
477 } IWineD3DVertexBufferImpl;
479 extern const IWineD3DVertexBufferVtbl IWineD3DVertexBuffer_Vtbl;
482 /*****************************************************************************
483 * IWineD3DIndexBuffer implementation structure (extends IWineD3DResourceImpl)
485 typedef struct IWineD3DIndexBufferImpl
487 /* IUnknown & WineD3DResource Information */
488 const IWineD3DIndexBufferVtbl *lpVtbl;
489 IWineD3DResourceClass resource;
491 /* WineD3DVertexBuffer specifics */
492 } IWineD3DIndexBufferImpl;
494 extern const IWineD3DIndexBufferVtbl IWineD3DIndexBuffer_Vtbl;
496 /*****************************************************************************
497 * IWineD3DBaseTexture implementation structure (extends IWineD3DResourceImpl)
499 typedef struct IWineD3DBaseTextureClass
507 D3DTEXTUREFILTERTYPE filterType;
509 } IWineD3DBaseTextureClass;
511 typedef struct IWineD3DBaseTextureImpl
513 /* IUnknown & WineD3DResource Information */
514 const IWineD3DBaseTextureVtbl *lpVtbl;
515 IWineD3DResourceClass resource;
516 IWineD3DBaseTextureClass baseTexture;
518 } IWineD3DBaseTextureImpl;
520 /*****************************************************************************
521 * IWineD3DTexture implementation structure (extends IWineD3DBaseTextureImpl)
523 typedef struct IWineD3DTextureImpl
525 /* IUnknown & WineD3DResource/WineD3DBaseTexture Information */
526 const IWineD3DTextureVtbl *lpVtbl;
527 IWineD3DResourceClass resource;
528 IWineD3DBaseTextureClass baseTexture;
530 /* IWineD3DTexture */
531 IWineD3DSurface *surfaces[MAX_LEVELS];
536 } IWineD3DTextureImpl;
538 extern const IWineD3DTextureVtbl IWineD3DTexture_Vtbl;
540 /*****************************************************************************
541 * IWineD3DCubeTexture implementation structure (extends IWineD3DBaseTextureImpl)
543 typedef struct IWineD3DCubeTextureImpl
545 /* IUnknown & WineD3DResource/WineD3DBaseTexture Information */
546 const IWineD3DCubeTextureVtbl *lpVtbl;
547 IWineD3DResourceClass resource;
548 IWineD3DBaseTextureClass baseTexture;
550 /* IWineD3DCubeTexture */
551 IWineD3DSurface *surfaces[6][MAX_LEVELS];
555 } IWineD3DCubeTextureImpl;
557 extern const IWineD3DCubeTextureVtbl IWineD3DCubeTexture_Vtbl;
559 /*****************************************************************************
560 * IWineD3DVolume implementation structure (extends IUnknown)
562 typedef struct IWineD3DVolumeImpl
564 /* IUnknown & WineD3DResource fields */
565 const IWineD3DVolumeVtbl *lpVtbl;
566 IWineD3DResourceClass resource;
568 /* WineD3DVolume Information */
569 D3DVOLUME_DESC currentDesc;
580 } IWineD3DVolumeImpl;
582 extern const IWineD3DVolumeVtbl IWineD3DVolume_Vtbl;
584 /*****************************************************************************
585 * IWineD3DVolumeTexture implementation structure (extends IWineD3DBaseTextureImpl)
587 typedef struct IWineD3DVolumeTextureImpl
589 /* IUnknown & WineD3DResource/WineD3DBaseTexture Information */
590 const IWineD3DVolumeTextureVtbl *lpVtbl;
591 IWineD3DResourceClass resource;
592 IWineD3DBaseTextureClass baseTexture;
594 /* IWineD3DVolumeTexture */
595 IWineD3DVolume *volumes[MAX_LEVELS];
600 } IWineD3DVolumeTextureImpl;
602 extern const IWineD3DVolumeTextureVtbl IWineD3DVolumeTexture_Vtbl;
604 typedef struct _WINED3DSURFACET_DESC
607 D3DMULTISAMPLE_TYPE MultiSampleType;
608 DWORD MultiSampleQuality;
611 } WINED3DSURFACET_DESC;
613 /*****************************************************************************
614 * IWineD3DSurface implementation structure
616 struct IWineD3DSurfaceImpl
618 /* IUnknown & IWineD3DResource Information */
619 const IWineD3DSurfaceVtbl *lpVtbl;
620 IWineD3DResourceClass resource;
622 /* IWineD3DSurface fields */
624 WINED3DSURFACET_DESC currentDesc;
641 extern const IWineD3DSurfaceVtbl IWineD3DSurface_Vtbl;
643 /*****************************************************************************
644 * IWineD3DVertexDeclaration implementation structure
646 typedef struct IWineD3DVertexDeclarationImpl {
647 /* IUnknown Information */
648 const IWineD3DVertexDeclarationVtbl *lpVtbl;
649 DWORD ref; /* Note: Ref counting not required */
652 /** precomputed fvf if simple declaration */
653 IWineD3DDeviceImpl *wineD3DDevice;
654 DWORD fvf[MAX_STREAMS];
657 /** dx8 compatible Declaration fields */
658 DWORD* pDeclaration8;
659 DWORD declaration8Length;
662 D3DVERTEXELEMENT9* pDeclaration9;
663 UINT declaration9NumElements;
664 } IWineD3DVertexDeclarationImpl;
666 extern const IWineD3DVertexDeclarationVtbl IWineD3DVertexDeclaration_Vtbl;
668 /*****************************************************************************
669 * IWineD3DStateBlock implementation structure
672 /* Internal state Block for Begin/End/Capture/Create/Apply info */
673 /* Note: Very long winded but gl Lists are not flexible enough */
674 /* to resolve everything we need, so doing it manually for now */
675 typedef struct SAVEDSTATES {
679 BOOL streamSource[MAX_STREAMS];
680 BOOL streamFreq[MAX_STREAMS];
681 BOOL textures[MAX_TEXTURES];
682 BOOL transform[HIGHEST_TRANSFORMSTATE + 1];
684 BOOL renderState[WINEHIGHEST_RENDER_STATE + 1];
685 BOOL textureState[MAX_TEXTURES][HIGHEST_TEXTURE_STATE + 1];
686 BOOL clipplane[MAX_CLIPPLANES];
687 BOOL samplerState[MAX_SAMPLERS][HIGHEST_SAMPLER_STATE + 1];
693 struct IWineD3DStateBlockImpl
695 /* IUnknown fields */
696 const IWineD3DStateBlockVtbl *lpVtbl;
697 DWORD ref; /* Note: Ref counting not required */
699 /* IWineD3DStateBlock information */
701 IWineD3DDeviceImpl *wineD3DDevice;
702 D3DSTATEBLOCKTYPE blockType;
704 /* Array indicating whether things have been set or changed */
708 /* Drawing - Vertex Shader or FVF related */
710 /* Vertex Shader Declaration */
711 IWineD3DVertexDeclaration* vertexDecl;
713 void *vertexShader; /* @TODO: Replace void * with IWineD3DVertexShader * */
717 UINT streamStride[MAX_STREAMS];
718 UINT streamOffset[MAX_STREAMS];
719 IWineD3DVertexBuffer *streamSource[MAX_STREAMS];
720 UINT streamFreq[MAX_STREAMS];
721 UINT streamFlags[MAX_STREAMS]; /*0 | D3DSTREAMSOURCE_INSTANCEDATA | D3DSTREAMSOURCE_INDEXEDDATA */
724 IWineD3DIndexBuffer* pIndexData;
725 UINT baseVertexIndex; /* Note: only used for d3d8 */
728 D3DMATRIX transforms[HIGHEST_TRANSFORMSTATE + 1];
731 PLIGHTINFOEL *lights; /* NOTE: active GL lights must be front of the chain */
734 double clipplane[MAX_CLIPPLANES][4];
735 WINED3DCLIPSTATUS clip_status;
738 WINED3DVIEWPORT viewport;
741 WINED3DMATERIAL material;
744 void *pixelShader; /* TODO: Replace void * with IWineD3DPixelShader * */
746 /* Indexed Vertex Blending */
747 D3DVERTEXBLENDFLAGS vertex_blend;
751 DWORD renderState[WINEHIGHEST_RENDER_STATE + 1];
754 IWineD3DBaseTexture *textures[MAX_TEXTURES];
755 int textureDimensions[MAX_SAMPLERS];
757 /* Texture State Stage */
758 DWORD textureState[MAX_TEXTURES][HIGHEST_TEXTURE_STATE + 1];
760 DWORD samplerState[MAX_SAMPLERS][HIGHEST_SAMPLER_STATE + 1];
764 extern const IWineD3DStateBlockVtbl IWineD3DStateBlock_Vtbl;
766 /*****************************************************************************
767 * IWineD3DQueryImpl implementation structure (extends IUnknown)
769 typedef struct IWineD3DQueryImpl
771 const IWineD3DQueryVtbl *lpVtbl;
772 DWORD ref; /* Note: Ref counting not required */
775 /*TODO: replace with iface usage */
777 IWineD3DDevice *wineD3DDevice;
779 IWineD3DDeviceImpl *wineD3DDevice;
781 /* IWineD3DQuery fields */
789 extern const IWineD3DQueryVtbl IWineD3DQuery_Vtbl;
791 /*****************************************************************************
792 * IWineD3DSwapChainImpl implementation structure (extends IUnknown)
795 typedef struct IWineD3DSwapChainImpl
798 IWineD3DSwapChainVtbl *lpVtbl;
799 DWORD ref; /* Note: Ref counting not required */
802 IWineD3DDeviceImpl *wineD3DDevice;
804 /* IWineD3DSwapChain fields */
805 IWineD3DSurface *backBuffer;
806 IWineD3DSurface *frontBuffer;
807 BOOL wantsDepthStencilBuffer;
808 D3DPRESENT_PARAMETERS presentParms;
810 /* TODO: move everything upto drawable off into a context manager
811 and store the 'data' in the contextManagerData interface.
812 IUnknown *contextManagerData;
820 XVisualInfo *visInfo;
821 GLXContext render_ctx;
822 /* This has been left in device for now, but needs moving off into a rendertarget management class and separated out from swapchains and devices. */
824 } IWineD3DSwapChainImpl;
826 extern IWineD3DSwapChainVtbl IWineD3DSwapChain_Vtbl;
828 /*****************************************************************************
829 * Utility function prototypes
833 const char* debug_d3dformat(D3DFORMAT fmt);
834 const char* debug_d3ddevicetype(D3DDEVTYPE devtype);
835 const char* debug_d3dresourcetype(D3DRESOURCETYPE res);
836 const char* debug_d3dusage(DWORD usage);
837 const char* debug_d3dprimitivetype(D3DPRIMITIVETYPE PrimitiveType);
838 const char* debug_d3drenderstate(DWORD state);
839 const char* debug_d3dtexturestate(DWORD state);
840 const char* debug_d3dpool(D3DPOOL pool);
842 /* Routines for GL <-> D3D values */
843 GLenum StencilOp(DWORD op);
844 void set_tex_op(IWineD3DDevice *iface, BOOL isAlpha, int Stage, D3DTEXTUREOP op, DWORD arg1, DWORD arg2, DWORD arg3);
845 void set_texture_matrix(const float *smat, DWORD flags);
846 void GetSrcAndOpFromValue(DWORD iValue, BOOL isAlphaArg, GLenum* source, GLenum* operand);
848 SHORT D3DFmtGetBpp(IWineD3DDeviceImpl* This, D3DFORMAT fmt);
849 GLenum D3DFmt2GLFmt(IWineD3DDeviceImpl* This, D3DFORMAT fmt);
850 GLenum D3DFmt2GLType(IWineD3DDeviceImpl *This, D3DFORMAT fmt);
851 GLint D3DFmt2GLIntFmt(IWineD3DDeviceImpl* This, D3DFORMAT fmt);
853 /*****************************************************************************
854 * To enable calling of inherited functions, requires prototypes
856 * Note: Only require classes which are subclassed, ie resource, basetexture,
858 /*** IUnknown methods ***/
859 extern HRESULT WINAPI IWineD3DResourceImpl_QueryInterface(IWineD3DResource *iface, REFIID riid, void** ppvObject);
860 extern ULONG WINAPI IWineD3DResourceImpl_AddRef(IWineD3DResource *iface);
861 extern ULONG WINAPI IWineD3DResourceImpl_Release(IWineD3DResource *iface);
862 /*** IWineD3DResource methods ***/
863 extern HRESULT WINAPI IWineD3DResourceImpl_GetParent(IWineD3DResource *iface, IUnknown **pParent);
864 extern HRESULT WINAPI IWineD3DResourceImpl_GetDevice(IWineD3DResource *iface, IWineD3DDevice ** ppDevice);
865 extern HRESULT WINAPI IWineD3DResourceImpl_SetPrivateData(IWineD3DResource *iface, REFGUID refguid, CONST void * pData, DWORD SizeOfData, DWORD Flags);
866 extern HRESULT WINAPI IWineD3DResourceImpl_GetPrivateData(IWineD3DResource *iface, REFGUID refguid, void * pData, DWORD * pSizeOfData);
867 extern HRESULT WINAPI IWineD3DResourceImpl_FreePrivateData(IWineD3DResource *iface, REFGUID refguid);
868 extern DWORD WINAPI IWineD3DResourceImpl_SetPriority(IWineD3DResource *iface, DWORD PriorityNew);
869 extern DWORD WINAPI IWineD3DResourceImpl_GetPriority(IWineD3DResource *iface);
870 extern void WINAPI IWineD3DResourceImpl_PreLoad(IWineD3DResource *iface);
871 extern D3DRESOURCETYPE WINAPI IWineD3DResourceImpl_GetType(IWineD3DResource *iface);
872 /*** class static members ***/
873 void IWineD3DResourceImpl_CleanUp(IWineD3DResource *iface);
875 /*** IUnknown methods ***/
876 extern HRESULT WINAPI IWineD3DBaseTextureImpl_QueryInterface(IWineD3DBaseTexture *iface, REFIID riid, void** ppvObject);
877 extern ULONG WINAPI IWineD3DBaseTextureImpl_AddRef(IWineD3DBaseTexture *iface);
878 extern ULONG WINAPI IWineD3DBaseTextureImpl_Release(IWineD3DBaseTexture *iface);
879 /*** IWineD3DResource methods ***/
880 extern HRESULT WINAPI IWineD3DBaseTextureImpl_GetParent(IWineD3DBaseTexture *iface, IUnknown **pParent);
881 extern HRESULT WINAPI IWineD3DBaseTextureImpl_GetDevice(IWineD3DBaseTexture *iface, IWineD3DDevice ** ppDevice);
882 extern HRESULT WINAPI IWineD3DBaseTextureImpl_SetPrivateData(IWineD3DBaseTexture *iface, REFGUID refguid, CONST void * pData, DWORD SizeOfData, DWORD Flags);
883 extern HRESULT WINAPI IWineD3DBaseTextureImpl_GetPrivateData(IWineD3DBaseTexture *iface, REFGUID refguid, void * pData, DWORD * pSizeOfData);
884 extern HRESULT WINAPI IWineD3DBaseTextureImpl_FreePrivateData(IWineD3DBaseTexture *iface, REFGUID refguid);
885 extern DWORD WINAPI IWineD3DBaseTextureImpl_SetPriority(IWineD3DBaseTexture *iface, DWORD PriorityNew);
886 extern DWORD WINAPI IWineD3DBaseTextureImpl_GetPriority(IWineD3DBaseTexture *iface);
887 extern void WINAPI IWineD3DBaseTextureImpl_PreLoad(IWineD3DBaseTexture *iface);
888 extern D3DRESOURCETYPE WINAPI IWineD3DBaseTextureImpl_GetType(IWineD3DBaseTexture *iface);
889 /*** IWineD3DBaseTexture methods ***/
890 extern DWORD WINAPI IWineD3DBaseTextureImpl_SetLOD(IWineD3DBaseTexture *iface, DWORD LODNew);
891 extern DWORD WINAPI IWineD3DBaseTextureImpl_GetLOD(IWineD3DBaseTexture *iface);
892 extern DWORD WINAPI IWineD3DBaseTextureImpl_GetLevelCount(IWineD3DBaseTexture *iface);
893 extern HRESULT WINAPI IWineD3DBaseTextureImpl_SetAutoGenFilterType(IWineD3DBaseTexture *iface, D3DTEXTUREFILTERTYPE FilterType);
894 extern D3DTEXTUREFILTERTYPE WINAPI IWineD3DBaseTextureImpl_GetAutoGenFilterType(IWineD3DBaseTexture *iface);
895 extern void WINAPI IWineD3DBaseTextureImpl_GenerateMipSubLevels(IWineD3DBaseTexture *iface);
896 extern BOOL WINAPI IWineD3DBaseTextureImpl_SetDirty(IWineD3DBaseTexture *iface, BOOL);
897 extern BOOL WINAPI IWineD3DBaseTextureImpl_GetDirty(IWineD3DBaseTexture *iface);
898 extern HRESULT WINAPI IWineD3DBaseTextureImpl_BindTexture(IWineD3DBaseTexture *iface);
899 extern HRESULT WINAPI IWineD3DBaseTextureImpl_UnBindTexture(IWineD3DBaseTexture *iface);
900 /*** class static members ***/
901 void IWineD3DBaseTextureImpl_CleanUp(IWineD3DBaseTexture *iface);
903 /*****************************************************************************
904 * IDirect3DVertexShader implementation structure
906 typedef struct IWineD3DVertexShaderImpl {
908 const IWineD3DVertexShaderVtbl *lpVtbl;
909 DWORD ref; /* Note: Ref counting not required */
912 IWineD3DDeviceImpl *wineD3DDevice;
914 /* IWineD3DVertexShaderImpl*/
915 CONST DWORD *function;
918 #if 0 /* needs reworking */
923 VSHADERINPUTDATA input;
924 VSHADEROUTPUTDATA output;
926 } IWineD3DVertexShaderImpl;
927 extern const IWineD3DVertexShaderVtbl IWineD3DVertexShader_Vtbl;
929 /*****************************************************************************
930 * IDirect3DPixelShader implementation structure
932 typedef struct IWineD3DPixelShaderImpl {
934 const IWineD3DPixelShaderVtbl *lpVtbl;
935 DWORD ref; /* Note: Ref counting not required */
938 IWineD3DDeviceImpl *wineD3DDevice;
941 /* IWineD3DPixelShaderImpl*/
942 CONST DWORD *function;
945 #if 0 /* needs reworking */
950 PSHADERINPUTDATA input;
951 PSHADEROUTPUTDATA output;
953 } IWineD3DPixelShaderImpl;
955 extern const IWineD3DPixelShaderVtbl IWineD3DPixelShader_Vtbl;