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;
220 /* TODO: Move some of this to the device */
221 long globalChangeGlRam(long glram);
223 /* Memory and object tracking */
225 /*Structure for holding information on all direct3d objects
226 usefull for making sure tracking is ok and when release is called on a device!
227 and probably quite handy for debuggin and dumping states out
229 typedef struct WineD3DGlobalStatistics {
230 int glsurfaceram; /* The aproximate amount of glTexture memory allocated for textures */
231 } WineD3DGlobalStatistics;
233 extern WineD3DGlobalStatistics* wineD3DGlobalStatistics;
235 /* Global variables */
236 extern const float identity[16];
238 /*****************************************************************************
239 * Compilable extra diagnostics
242 /* Trace information per-vertex: (extremely high amount of trace) */
243 #if 0 /* NOTE: Must be 0 in cvs */
244 # define VTRACE(A) TRACE A
249 /* Checking of per-vertex related GL calls */
250 #define vcheckGLcall(A) \
252 GLint err = glGetError(); \
253 if (err != GL_NO_ERROR) { \
254 FIXME(">>>>>>>>>>>>>>>>> %x from %s @ %s / %d\n", err, A, __FILE__, __LINE__); \
256 VTRACE(("%s call ok %s / %d\n", A, __FILE__, __LINE__)); \
260 /* TODO: Confirm each of these works when wined3d move completed */
261 #if 0 /* NOTE: Must be 0 in cvs */
262 /* To avoid having to get gigabytes of trace, the following can be compiled in, and at the start
263 of each frame, a check is made for the existence of C:\D3DTRACE, and if if exists d3d trace
264 is enabled, and if it doesn't exists it is disabled. */
265 # define FRAME_DEBUGGING
266 /* Adding in the SINGLE_FRAME_DEBUGGING gives a trace of just what makes up a single frame, before
267 the file is deleted */
268 # if 1 /* NOTE: Must be 1 in cvs, as this is mostly more useful than a trace from program start */
269 # define SINGLE_FRAME_DEBUGGING
271 /* The following, when enabled, lets you see the makeup of the frame, by drawprimitive calls.
272 It can only be enabled when FRAME_DEBUGGING is also enabled
273 The contents of the back buffer are written into /tmp/backbuffer_* after each primitive
275 # if 0 /* NOTE: Must be 0 in cvs, as this give a lot of ppm files when compiled in */
276 # define SHOW_FRAME_MAKEUP 1
278 /* The following, when enabled, lets you see the makeup of the all the textures used during each
279 of the drawprimitive calls. It can only be enabled when SHOW_FRAME_MAKEUP is also enabled.
280 The contents of the textures assigned to each stage are written into
281 /tmp/texture_*_<Stage>.ppm after each primitive array is drawn. */
282 # if 0 /* NOTE: Must be 0 in cvs, as this give a lot of ppm files when compiled in */
283 # define SHOW_TEXTURE_MAKEUP 0
286 extern BOOL isDumpingFrames;
287 extern LONG primCounter;
290 /*****************************************************************************
294 /* Routine common to the draw primitive and draw indexed primitive routines */
295 void drawPrimitive(IWineD3DDevice *iface,
300 long StartVertexIndex,
306 /*****************************************************************************
307 * Structures required to draw primitives
310 typedef struct Direct3DStridedData {
311 BYTE *lpData; /* Pointer to start of data */
312 DWORD dwStride; /* Stride between occurances of this data */
313 DWORD dwType; /* Type (as in D3DVSDT_TYPE) */
314 } Direct3DStridedData;
316 typedef struct Direct3DVertexStridedData {
319 Direct3DStridedData position;
320 Direct3DStridedData blendWeights;
321 Direct3DStridedData blendMatrixIndices;
322 Direct3DStridedData normal;
323 Direct3DStridedData pSize;
324 Direct3DStridedData diffuse;
325 Direct3DStridedData specular;
326 Direct3DStridedData texCoords[MAX_TEXTURES];
328 Direct3DStridedData input[16]; /* Indexed by constants in D3DVSDE_REGISTER */
330 } Direct3DVertexStridedData;
332 /*****************************************************************************
333 * Internal representation of a light
335 typedef struct PLIGHTINFOEL PLIGHTINFOEL;
336 struct PLIGHTINFOEL {
337 WINED3DLIGHT OriginalParms; /* Note D3D8LIGHT == D3D9LIGHT */
344 /* Converted parms to speed up swapping lights */
354 /*****************************************************************************
355 * IWineD3D implementation structure
357 typedef struct IWineD3DImpl
359 /* IUnknown fields */
360 const IWineD3DVtbl *lpVtbl;
361 DWORD ref; /* Note: Ref counting not required */
363 /* WineD3D Information */
369 WineD3D_GL_Info gl_info;
372 extern const IWineD3DVtbl IWineD3D_Vtbl;
375 /** Hacked out start of a context manager!! **/
376 typedef struct glContext {
383 IWineD3DSurface *pSurface;
384 #if 0 /* TODO: someway to represent the state of the context */
385 IWineD3DStateBlock *pStateBlock;
387 /* a few other things like format */
390 /* TODO: setup some flags in the regestry to enable, disable pbuffer support
391 (since it will break quite a few things until contexts are managed properly!) */
392 extern BOOL pbuffer_support;
393 /* allocate one pbuffer per surface */
394 extern BOOL pbuffer_per_surface;
396 /* Maximum number of contexts/pbuffers to keep in cache,
397 set to 100 because ATI's drivers don't support deleting pBuffers properly
398 this needs to be migrated to a list and some option availalbe for controle the cache size.
400 #define CONTEXT_CACHE 100
403 /*****************************************************************************
404 * IWineD3DDevice implementation structure
406 typedef struct IWineD3DDeviceImpl
408 /* IUnknown fields */
409 const IWineD3DDeviceVtbl *lpVtbl;
410 DWORD ref; /* Note: Ref counting not required */
412 /* WineD3D Information */
416 /* X and GL Information */
417 GLint maxConcurrentLights;
420 BOOL modelview_valid;
422 BOOL view_ident; /* true iff view matrix is identity */
423 BOOL last_was_rhw; /* true iff last draw_primitive was in xyzrhw mode */
424 GLenum tracking_parm; /* Which source is tracking current colour */
425 LONG tracking_color; /* used iff GL_COLOR_MATERIAL was enabled */
426 #define DISABLED_TRACKING 0 /* Disabled */
427 #define IS_TRACKING 1 /* tracking_parm is tracking diffuse color */
428 #define NEEDS_TRACKING 2 /* Tracking needs to be enabled when needed */
429 #define NEEDS_DISABLE 3 /* Tracking needs to be disabled when needed*/
434 BOOL texture_shader_active; /* TODO: Confirm use is correct */
436 /* State block related */
437 BOOL isRecordingState;
438 IWineD3DStateBlockImpl *stateBlock;
439 IWineD3DStateBlockImpl *updateStateBlock;
441 /* Internal use fields */
442 D3DDEVICE_CREATION_PARAMETERS createParms;
446 /* TODO: Replace with a linked list */
447 IWineD3DSwapChain *swapchains[MAX_SWAPCHAINS]; /* no-one wil ever need more that MAX_SWAPCHAINS swapchains */
448 int numberOfSwapChains;
450 /* Render Target Support */
451 IWineD3DSurface *depthStencilBuffer;
453 IWineD3DSurface *renderTarget;
454 IWineD3DSurface *stencilBufferTarget;
456 /* palettes texture management */
457 PALETTEENTRY palettes[MAX_PALETTES][256];
460 /* For rendering to a texture using glCopyTexImage */
461 BOOL renderUpsideDown;
463 /* Cursor management */
470 /* Textures for when no other textures are mapped */
471 UINT dummyTextureName[MAX_TEXTURES];
473 /* Debug stream management */
476 /* Screen buffer resources */
477 glContext contextCache[CONTEXT_CACHE];
479 /* A flag to check if endscene has been called before changing the render tartet */
481 } IWineD3DDeviceImpl;
483 extern const IWineD3DDeviceVtbl IWineD3DDevice_Vtbl;
485 /* Support for IWineD3DResource ::Set/Get/FreePrivateData. I don't think
486 * anybody uses it for much so a good implementation is optional. */
487 typedef struct PrivateData
489 struct PrivateData* next;
492 DWORD flags; /* DDSPD_* */
493 DWORD uniqueness_value;
504 /*****************************************************************************
505 * IWineD3DResource implementation structure
507 typedef struct IWineD3DResourceClass
509 /* IUnknown fields */
510 DWORD ref; /* Note: Ref counting not required */
512 /* WineD3DResource Information */
514 D3DRESOURCETYPE resourceType;
515 IWineD3DDeviceImpl *wineD3DDevice;
519 WINED3DFORMAT format;
520 BYTE *allocatedMemory;
521 PrivateData *privateData;
523 } IWineD3DResourceClass;
525 typedef struct IWineD3DResourceImpl
527 /* IUnknown & WineD3DResource Information */
528 const IWineD3DResourceVtbl *lpVtbl;
529 IWineD3DResourceClass resource;
530 } IWineD3DResourceImpl;
533 /*****************************************************************************
534 * IWineD3DVertexBuffer implementation structure (extends IWineD3DResourceImpl)
536 typedef struct IWineD3DVertexBufferImpl
538 /* IUnknown & WineD3DResource Information */
539 const IWineD3DVertexBufferVtbl *lpVtbl;
540 IWineD3DResourceClass resource;
542 /* WineD3DVertexBuffer specifics */
545 } IWineD3DVertexBufferImpl;
547 extern const IWineD3DVertexBufferVtbl IWineD3DVertexBuffer_Vtbl;
550 /*****************************************************************************
551 * IWineD3DIndexBuffer implementation structure (extends IWineD3DResourceImpl)
553 typedef struct IWineD3DIndexBufferImpl
555 /* IUnknown & WineD3DResource Information */
556 const IWineD3DIndexBufferVtbl *lpVtbl;
557 IWineD3DResourceClass resource;
559 /* WineD3DVertexBuffer specifics */
560 } IWineD3DIndexBufferImpl;
562 extern const IWineD3DIndexBufferVtbl IWineD3DIndexBuffer_Vtbl;
564 /*****************************************************************************
565 * IWineD3DBaseTexture implementation structure (extends IWineD3DResourceImpl)
567 typedef struct IWineD3DBaseTextureClass
575 D3DTEXTUREFILTERTYPE filterType;
577 } IWineD3DBaseTextureClass;
579 typedef struct IWineD3DBaseTextureImpl
581 /* IUnknown & WineD3DResource Information */
582 const IWineD3DBaseTextureVtbl *lpVtbl;
583 IWineD3DResourceClass resource;
584 IWineD3DBaseTextureClass baseTexture;
586 } IWineD3DBaseTextureImpl;
588 /*****************************************************************************
589 * IWineD3DTexture implementation structure (extends IWineD3DBaseTextureImpl)
591 typedef struct IWineD3DTextureImpl
593 /* IUnknown & WineD3DResource/WineD3DBaseTexture Information */
594 const IWineD3DTextureVtbl *lpVtbl;
595 IWineD3DResourceClass resource;
596 IWineD3DBaseTextureClass baseTexture;
598 /* IWineD3DTexture */
599 IWineD3DSurface *surfaces[MAX_LEVELS];
604 } IWineD3DTextureImpl;
606 extern const IWineD3DTextureVtbl IWineD3DTexture_Vtbl;
608 /*****************************************************************************
609 * IWineD3DCubeTexture implementation structure (extends IWineD3DBaseTextureImpl)
611 typedef struct IWineD3DCubeTextureImpl
613 /* IUnknown & WineD3DResource/WineD3DBaseTexture Information */
614 const IWineD3DCubeTextureVtbl *lpVtbl;
615 IWineD3DResourceClass resource;
616 IWineD3DBaseTextureClass baseTexture;
618 /* IWineD3DCubeTexture */
619 IWineD3DSurface *surfaces[6][MAX_LEVELS];
623 } IWineD3DCubeTextureImpl;
625 extern const IWineD3DCubeTextureVtbl IWineD3DCubeTexture_Vtbl;
627 /*****************************************************************************
628 * IWineD3DVolume implementation structure (extends IUnknown)
630 typedef struct IWineD3DVolumeImpl
632 /* IUnknown & WineD3DResource fields */
633 const IWineD3DVolumeVtbl *lpVtbl;
634 IWineD3DResourceClass resource;
636 /* WineD3DVolume Information */
637 D3DVOLUME_DESC currentDesc;
648 } IWineD3DVolumeImpl;
650 extern const IWineD3DVolumeVtbl IWineD3DVolume_Vtbl;
652 /*****************************************************************************
653 * IWineD3DVolumeTexture implementation structure (extends IWineD3DBaseTextureImpl)
655 typedef struct IWineD3DVolumeTextureImpl
657 /* IUnknown & WineD3DResource/WineD3DBaseTexture Information */
658 const IWineD3DVolumeTextureVtbl *lpVtbl;
659 IWineD3DResourceClass resource;
660 IWineD3DBaseTextureClass baseTexture;
662 /* IWineD3DVolumeTexture */
663 IWineD3DVolume *volumes[MAX_LEVELS];
668 } IWineD3DVolumeTextureImpl;
670 extern const IWineD3DVolumeTextureVtbl IWineD3DVolumeTexture_Vtbl;
672 typedef struct _WINED3DSURFACET_DESC
674 D3DMULTISAMPLE_TYPE MultiSampleType;
675 DWORD MultiSampleQuality;
678 } WINED3DSURFACET_DESC;
680 /*****************************************************************************
681 * IWineD3DSurface implementation structure
683 struct IWineD3DSurfaceImpl
685 /* IUnknown & IWineD3DResource Information */
686 const IWineD3DSurfaceVtbl *lpVtbl;
687 IWineD3DResourceClass resource;
689 /* IWineD3DSurface fields */
691 WINED3DSURFACET_DESC currentDesc;
696 /* TODO: move this off into a management class(maybe!) */
703 /* precalculated x and y scalings for texture coords */
704 float pow2scalingFactorX; /* = (Width / pow2Width ) */
705 float pow2scalingFactorY; /* = (Height / pow2Height) */
719 glDescriptor glDescription;
722 extern const IWineD3DSurfaceVtbl IWineD3DSurface_Vtbl;
724 /*****************************************************************************
725 * IWineD3DVertexDeclaration implementation structure
727 typedef struct IWineD3DVertexDeclarationImpl {
728 /* IUnknown Information */
729 const IWineD3DVertexDeclarationVtbl *lpVtbl;
730 DWORD ref; /* Note: Ref counting not required */
733 /** precomputed fvf if simple declaration */
734 IWineD3DDeviceImpl *wineD3DDevice;
735 DWORD fvf[MAX_STREAMS];
738 /** dx8 compatible Declaration fields */
739 DWORD* pDeclaration8;
740 DWORD declaration8Length;
743 D3DVERTEXELEMENT9* pDeclaration9;
744 UINT declaration9NumElements;
745 } IWineD3DVertexDeclarationImpl;
747 extern const IWineD3DVertexDeclarationVtbl IWineD3DVertexDeclaration_Vtbl;
749 /*****************************************************************************
750 * IWineD3DStateBlock implementation structure
753 /* Internal state Block for Begin/End/Capture/Create/Apply info */
754 /* Note: Very long winded but gl Lists are not flexible enough */
755 /* to resolve everything we need, so doing it manually for now */
756 typedef struct SAVEDSTATES {
760 BOOL streamSource[MAX_STREAMS];
761 BOOL streamFreq[MAX_STREAMS];
762 BOOL textures[MAX_TEXTURES];
763 BOOL transform[HIGHEST_TRANSFORMSTATE + 1];
765 BOOL renderState[WINEHIGHEST_RENDER_STATE + 1];
766 BOOL textureState[MAX_TEXTURES][HIGHEST_TEXTURE_STATE + 1];
767 BOOL clipplane[MAX_CLIPPLANES];
768 BOOL samplerState[MAX_SAMPLERS][HIGHEST_SAMPLER_STATE + 1];
774 struct IWineD3DStateBlockImpl
776 /* IUnknown fields */
777 const IWineD3DStateBlockVtbl *lpVtbl;
778 DWORD ref; /* Note: Ref counting not required */
780 /* IWineD3DStateBlock information */
782 IWineD3DDeviceImpl *wineD3DDevice;
783 D3DSTATEBLOCKTYPE blockType;
785 /* Array indicating whether things have been set or changed */
789 /* Drawing - Vertex Shader or FVF related */
791 /* Vertex Shader Declaration */
792 IWineD3DVertexDeclaration* vertexDecl;
794 void *vertexShader; /* @TODO: Replace void * with IWineD3DVertexShader * */
798 UINT streamStride[MAX_STREAMS];
799 UINT streamOffset[MAX_STREAMS];
800 IWineD3DVertexBuffer *streamSource[MAX_STREAMS];
801 UINT streamFreq[MAX_STREAMS];
802 UINT streamFlags[MAX_STREAMS]; /*0 | D3DSTREAMSOURCE_INSTANCEDATA | D3DSTREAMSOURCE_INDEXEDDATA */
805 IWineD3DIndexBuffer* pIndexData;
806 UINT baseVertexIndex; /* Note: only used for d3d8 */
809 D3DMATRIX transforms[HIGHEST_TRANSFORMSTATE + 1];
812 PLIGHTINFOEL *lights; /* NOTE: active GL lights must be front of the chain */
815 double clipplane[MAX_CLIPPLANES][4];
816 WINED3DCLIPSTATUS clip_status;
819 WINED3DVIEWPORT viewport;
822 WINED3DMATERIAL material;
825 void *pixelShader; /* TODO: Replace void * with IWineD3DPixelShader * */
827 /* Indexed Vertex Blending */
828 D3DVERTEXBLENDFLAGS vertex_blend;
832 DWORD renderState[WINEHIGHEST_RENDER_STATE + 1];
835 IWineD3DBaseTexture *textures[MAX_TEXTURES];
836 int textureDimensions[MAX_SAMPLERS];
838 /* Texture State Stage */
839 DWORD textureState[MAX_TEXTURES][HIGHEST_TEXTURE_STATE + 1];
841 DWORD samplerState[MAX_SAMPLERS][HIGHEST_SAMPLER_STATE + 1];
845 extern const IWineD3DStateBlockVtbl IWineD3DStateBlock_Vtbl;
847 /*****************************************************************************
848 * IWineD3DQueryImpl implementation structure (extends IUnknown)
850 typedef struct IWineD3DQueryImpl
852 const IWineD3DQueryVtbl *lpVtbl;
853 DWORD ref; /* Note: Ref counting not required */
856 /*TODO: replace with iface usage */
858 IWineD3DDevice *wineD3DDevice;
860 IWineD3DDeviceImpl *wineD3DDevice;
862 /* IWineD3DQuery fields */
870 extern const IWineD3DQueryVtbl IWineD3DQuery_Vtbl;
872 /*****************************************************************************
873 * IWineD3DSwapChainImpl implementation structure (extends IUnknown)
876 typedef struct IWineD3DSwapChainImpl
879 IWineD3DSwapChainVtbl *lpVtbl;
880 DWORD ref; /* Note: Ref counting not required */
883 IWineD3DDeviceImpl *wineD3DDevice;
885 /* IWineD3DSwapChain fields */
886 IWineD3DSurface *backBuffer;
887 IWineD3DSurface *frontBuffer;
888 BOOL wantsDepthStencilBuffer;
889 D3DPRESENT_PARAMETERS presentParms;
891 /* TODO: move everything upto drawable off into a context manager
892 and store the 'data' in the contextManagerData interface.
893 IUnknown *contextManagerData;
901 XVisualInfo *visInfo;
902 GLXContext render_ctx;
903 /* This has been left in device for now, but needs moving off into a rendertarget management class and separated out from swapchains and devices. */
905 } IWineD3DSwapChainImpl;
907 extern IWineD3DSwapChainVtbl IWineD3DSwapChain_Vtbl;
909 /*****************************************************************************
910 * Utility function prototypes
914 const char* debug_d3dformat(WINED3DFORMAT fmt);
915 const char* debug_d3ddevicetype(D3DDEVTYPE devtype);
916 const char* debug_d3dresourcetype(D3DRESOURCETYPE res);
917 const char* debug_d3dusage(DWORD usage);
918 const char* debug_d3dprimitivetype(D3DPRIMITIVETYPE PrimitiveType);
919 const char* debug_d3drenderstate(DWORD state);
920 const char* debug_d3dtexturestate(DWORD state);
921 const char* debug_d3dpool(D3DPOOL pool);
923 /* Routines for GL <-> D3D values */
924 GLenum StencilOp(DWORD op);
925 void set_tex_op(IWineD3DDevice *iface, BOOL isAlpha, int Stage, D3DTEXTUREOP op, DWORD arg1, DWORD arg2, DWORD arg3);
926 void set_texture_matrix(const float *smat, DWORD flags);
927 void GetSrcAndOpFromValue(DWORD iValue, BOOL isAlphaArg, GLenum* source, GLenum* operand);
929 SHORT D3DFmtGetBpp(IWineD3DDeviceImpl* This, D3DFORMAT fmt);
930 GLenum D3DFmt2GLFmt(IWineD3DDeviceImpl* This, D3DFORMAT fmt);
931 GLenum D3DFmt2GLType(IWineD3DDeviceImpl *This, D3DFORMAT fmt);
932 GLint D3DFmt2GLIntFmt(IWineD3DDeviceImpl* This, D3DFORMAT fmt);
934 int D3DFmtMakeGlCfg(D3DFORMAT BackBufferFormat, D3DFORMAT StencilBufferFormat, int *attribs, int* nAttribs, BOOL alternate);
937 /*****************************************************************************
938 * To enable calling of inherited functions, requires prototypes
940 * Note: Only require classes which are subclassed, ie resource, basetexture,
942 /*** IUnknown methods ***/
943 extern HRESULT WINAPI IWineD3DResourceImpl_QueryInterface(IWineD3DResource *iface, REFIID riid, void** ppvObject);
944 extern ULONG WINAPI IWineD3DResourceImpl_AddRef(IWineD3DResource *iface);
945 extern ULONG WINAPI IWineD3DResourceImpl_Release(IWineD3DResource *iface);
946 /*** IWineD3DResource methods ***/
947 extern HRESULT WINAPI IWineD3DResourceImpl_GetParent(IWineD3DResource *iface, IUnknown **pParent);
948 extern HRESULT WINAPI IWineD3DResourceImpl_GetDevice(IWineD3DResource *iface, IWineD3DDevice ** ppDevice);
949 extern HRESULT WINAPI IWineD3DResourceImpl_SetPrivateData(IWineD3DResource *iface, REFGUID refguid, CONST void * pData, DWORD SizeOfData, DWORD Flags);
950 extern HRESULT WINAPI IWineD3DResourceImpl_GetPrivateData(IWineD3DResource *iface, REFGUID refguid, void * pData, DWORD * pSizeOfData);
951 extern HRESULT WINAPI IWineD3DResourceImpl_FreePrivateData(IWineD3DResource *iface, REFGUID refguid);
952 extern DWORD WINAPI IWineD3DResourceImpl_SetPriority(IWineD3DResource *iface, DWORD PriorityNew);
953 extern DWORD WINAPI IWineD3DResourceImpl_GetPriority(IWineD3DResource *iface);
954 extern void WINAPI IWineD3DResourceImpl_PreLoad(IWineD3DResource *iface);
955 extern D3DRESOURCETYPE WINAPI IWineD3DResourceImpl_GetType(IWineD3DResource *iface);
956 /*** class static members ***/
957 void IWineD3DResourceImpl_CleanUp(IWineD3DResource *iface);
959 /*** IUnknown methods ***/
960 extern HRESULT WINAPI IWineD3DBaseTextureImpl_QueryInterface(IWineD3DBaseTexture *iface, REFIID riid, void** ppvObject);
961 extern ULONG WINAPI IWineD3DBaseTextureImpl_AddRef(IWineD3DBaseTexture *iface);
962 extern ULONG WINAPI IWineD3DBaseTextureImpl_Release(IWineD3DBaseTexture *iface);
963 /*** IWineD3DResource methods ***/
964 extern HRESULT WINAPI IWineD3DBaseTextureImpl_GetParent(IWineD3DBaseTexture *iface, IUnknown **pParent);
965 extern HRESULT WINAPI IWineD3DBaseTextureImpl_GetDevice(IWineD3DBaseTexture *iface, IWineD3DDevice ** ppDevice);
966 extern HRESULT WINAPI IWineD3DBaseTextureImpl_SetPrivateData(IWineD3DBaseTexture *iface, REFGUID refguid, CONST void * pData, DWORD SizeOfData, DWORD Flags);
967 extern HRESULT WINAPI IWineD3DBaseTextureImpl_GetPrivateData(IWineD3DBaseTexture *iface, REFGUID refguid, void * pData, DWORD * pSizeOfData);
968 extern HRESULT WINAPI IWineD3DBaseTextureImpl_FreePrivateData(IWineD3DBaseTexture *iface, REFGUID refguid);
969 extern DWORD WINAPI IWineD3DBaseTextureImpl_SetPriority(IWineD3DBaseTexture *iface, DWORD PriorityNew);
970 extern DWORD WINAPI IWineD3DBaseTextureImpl_GetPriority(IWineD3DBaseTexture *iface);
971 extern void WINAPI IWineD3DBaseTextureImpl_PreLoad(IWineD3DBaseTexture *iface);
972 extern D3DRESOURCETYPE WINAPI IWineD3DBaseTextureImpl_GetType(IWineD3DBaseTexture *iface);
973 /*** IWineD3DBaseTexture methods ***/
974 extern DWORD WINAPI IWineD3DBaseTextureImpl_SetLOD(IWineD3DBaseTexture *iface, DWORD LODNew);
975 extern DWORD WINAPI IWineD3DBaseTextureImpl_GetLOD(IWineD3DBaseTexture *iface);
976 extern DWORD WINAPI IWineD3DBaseTextureImpl_GetLevelCount(IWineD3DBaseTexture *iface);
977 extern HRESULT WINAPI IWineD3DBaseTextureImpl_SetAutoGenFilterType(IWineD3DBaseTexture *iface, D3DTEXTUREFILTERTYPE FilterType);
978 extern D3DTEXTUREFILTERTYPE WINAPI IWineD3DBaseTextureImpl_GetAutoGenFilterType(IWineD3DBaseTexture *iface);
979 extern void WINAPI IWineD3DBaseTextureImpl_GenerateMipSubLevels(IWineD3DBaseTexture *iface);
980 extern BOOL WINAPI IWineD3DBaseTextureImpl_SetDirty(IWineD3DBaseTexture *iface, BOOL);
981 extern BOOL WINAPI IWineD3DBaseTextureImpl_GetDirty(IWineD3DBaseTexture *iface);
982 extern HRESULT WINAPI IWineD3DBaseTextureImpl_BindTexture(IWineD3DBaseTexture *iface);
983 extern HRESULT WINAPI IWineD3DBaseTextureImpl_UnBindTexture(IWineD3DBaseTexture *iface);
984 /*** class static members ***/
985 void IWineD3DBaseTextureImpl_CleanUp(IWineD3DBaseTexture *iface);
987 /*****************************************************************************
988 * IDirect3DVertexShader implementation structure
990 typedef struct IWineD3DVertexShaderImpl {
992 const IWineD3DVertexShaderVtbl *lpVtbl;
993 DWORD ref; /* Note: Ref counting not required */
996 IWineD3DDeviceImpl *wineD3DDevice;
998 /* IWineD3DVertexShaderImpl*/
999 CONST DWORD *function;
1000 UINT functionLength;
1002 #if 0 /* needs reworking */
1005 /* run time datas */
1007 VSHADERINPUTDATA input;
1008 VSHADEROUTPUTDATA output;
1010 } IWineD3DVertexShaderImpl;
1011 extern const IWineD3DVertexShaderVtbl IWineD3DVertexShader_Vtbl;
1013 /*****************************************************************************
1014 * IDirect3DPixelShader implementation structure
1016 typedef struct IWineD3DPixelShaderImpl {
1018 const IWineD3DPixelShaderVtbl *lpVtbl;
1019 DWORD ref; /* Note: Ref counting not required */
1022 IWineD3DDeviceImpl *wineD3DDevice;
1025 /* IWineD3DPixelShaderImpl*/
1026 CONST DWORD *function;
1027 UINT functionLength;
1029 #if 0 /* needs reworking */
1030 UINT functionLength;
1032 /* run time datas */
1034 PSHADERINPUTDATA input;
1035 PSHADEROUTPUTDATA output;
1037 } IWineD3DPixelShaderImpl;
1039 extern const IWineD3DPixelShaderVtbl IWineD3DPixelShader_Vtbl;