ioctl 440F only returns non mapped drives (for now).
[wine] / dlls / wined3d / wined3d_private.h
1 /*
2  * Direct3D wine internal private include file
3  *
4  * Copyright 2002-2003 The wine-d3d team
5  * Copyright 2002-2003 Raphael Junqueira
6  * Copyright 2004 Jason Edmeades
7  * Copyright 2005 Oliver Stieber
8  *
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.
13  *
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.
18  *
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
22  */
23
24 #ifndef __WINE_WINED3D_PRIVATE_H
25 #define __WINE_WINED3D_PRIVATE_H
26
27 #include <stdarg.h>
28 #include <math.h>
29 #define NONAMELESSUNION
30 #define NONAMELESSSTRUCT
31 #define COBJMACROS
32 #include "windef.h"
33 #include "winbase.h"
34 #include "winreg.h"
35 #include "wingdi.h"
36 #include "winuser.h"
37 #include "wine/debug.h"
38 #include "wine/unicode.h"
39
40 #include "d3d9.h"
41 #include "d3d9types.h"
42 #include "wine/wined3d_interface.h"
43 #include "wine/wined3d_gl.h"
44
45 /* Device caps */
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
53
54 #define MAX_VSHADER_CONSTANTS 96
55 #define MAX_PSHADER_CONSTANTS 32
56
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
64
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];
71
72 typedef enum _WINELOOKUP {
73     WINELOOKUP_WARPPARAM = 0,
74     WINELOOKUP_MAGFILTER = 1,
75     MAX_LOOKUPS          = 2
76 } WINELOOKUP;
77
78 extern int minLookup[MAX_LOOKUPS];
79 extern int maxLookup[MAX_LOOKUPS];
80 extern DWORD *stateLookup[MAX_LOOKUPS];
81
82 extern DWORD minMipLookup[D3DTEXF_ANISOTROPIC + 1][D3DTEXF_LINEAR + 1];
83
84 /* NOTE: Make sure these are in the correct numerical order. (see /include/d3d9types.h typedef enum _D3DDECLTYPE) */
85 UINT static const glTypeLookup[D3DDECLTYPE_UNUSED][5] = {
86                                   {D3DDECLTYPE_FLOAT1,    1, GL_FLOAT           , GL_FALSE ,sizeof(float)},
87                                   {D3DDECLTYPE_FLOAT2,    2, GL_FLOAT           , GL_FALSE ,sizeof(float)},
88                                   {D3DDECLTYPE_FLOAT3,    3, GL_FLOAT           , GL_FALSE ,sizeof(float)},
89                                   {D3DDECLTYPE_FLOAT4,    4, GL_FLOAT           , GL_FALSE ,sizeof(float)},
90                                   {D3DDECLTYPE_D3DCOLOR,  4, GL_UNSIGNED_BYTE   , GL_TRUE  ,sizeof(BYTE)},
91                                   {D3DDECLTYPE_UBYTE4,    4, GL_UNSIGNED_BYTE   , GL_FALSE ,sizeof(BYTE)},
92                                   {D3DDECLTYPE_SHORT2,    2, GL_SHORT           , GL_FALSE ,sizeof(short int)},
93                                   {D3DDECLTYPE_SHORT4,    4, GL_SHORT           , GL_FALSE ,sizeof(short int)},
94                                   {D3DDECLTYPE_UBYTE4N,   4, GL_UNSIGNED_BYTE   , GL_FALSE ,sizeof(BYTE)},
95                                   {D3DDECLTYPE_SHORT2N,   2, GL_SHORT           , GL_FALSE ,sizeof(short int)},
96                                   {D3DDECLTYPE_SHORT4N,   4, GL_SHORT           , GL_FALSE ,sizeof(short int)},
97                                   {D3DDECLTYPE_USHORT2N,  2, GL_UNSIGNED_SHORT  , GL_FALSE ,sizeof(short int)},
98                                   {D3DDECLTYPE_USHORT4N,  4, GL_UNSIGNED_SHORT  , GL_FALSE ,sizeof(short int)},
99                                   {D3DDECLTYPE_UDEC3,     3, GL_UNSIGNED_SHORT  , GL_FALSE ,sizeof(short int)},
100                                   {D3DDECLTYPE_DEC3N,     3, GL_SHORT           , GL_FALSE ,sizeof(short int)},
101                                   {D3DDECLTYPE_FLOAT16_2, 2, GL_FLOAT           , GL_FALSE ,sizeof(short int)},
102                                   {D3DDECLTYPE_FLOAT16_4, 4, GL_FLOAT           , GL_FALSE ,sizeof(short int)}};
103
104 #define WINED3D_ATR_TYPE(_attribute)          glTypeLookup[sd->u.s._attribute.dwType][0]
105 #define WINED3D_ATR_SIZE(_attribute)          glTypeLookup[sd->u.s._attribute.dwType][1]
106 #define WINED3D_ATR_GLTYPE(_attribute)        glTypeLookup[sd->u.s._attribute.dwType][2]
107 #define WINED3D_ATR_NORMALIZED(_attribute)    glTypeLookup[sd->u.s._attribute.dwType][3]
108 #define WINED3D_ATR_TYPESIZE(_attribute)      glTypeLookup[sd->u.s._attribute.dwType][4]
109
110 /**
111  * Settings 
112  */
113 #define VS_NONE    0
114 #define VS_HW      1
115 #define VS_SW      2
116
117 #define PS_NONE    0
118 #define PS_HW      1
119
120 #define VBO_NONE   0
121 #define VBO_HW     1
122
123 #define NP2_NONE   0
124 #define NP2_REPACK 1
125
126 typedef struct wined3d_settings_s {
127 /* vertex and pixel shader modes */
128   int vs_mode;
129   int ps_mode;
130   int vbo_mode;
131 /* nonpower 2 function */
132   int nonpower2_mode;
133 } wined3d_settings_t;
134
135 extern wined3d_settings_t wined3d_settings;
136
137 /* X11 locking */
138
139 extern void (*wine_tsx11_lock_ptr)(void);
140 extern void (*wine_tsx11_unlock_ptr)(void);
141
142 /* As GLX relies on X, this is needed */
143 extern int num_lock;
144
145 #if 0
146 #define ENTER_GL() ++num_lock; if (num_lock > 1) FIXME("Recursive use of GL lock to: %d\n", num_lock); wine_tsx11_lock_ptr()
147 #define LEAVE_GL() if (num_lock != 1) FIXME("Recursive use of GL lock: %d\n", num_lock); --num_lock; wine_tsx11_unlock_ptr()
148 #else
149 #define ENTER_GL() wine_tsx11_lock_ptr()
150 #define LEAVE_GL() wine_tsx11_unlock_ptr()
151 #endif
152
153 /*****************************************************************************
154  * Defines
155  */
156
157 /* GL related defines */
158 /* ------------------ */
159 #define GL_SUPPORT(ExtName)           (GLINFO_LOCATION.supported[ExtName] != 0)
160 #define GL_LIMITS(ExtName)            (GLINFO_LOCATION.max_##ExtName)
161 #define GL_EXTCALL(FuncName)          (GLINFO_LOCATION.FuncName)
162 #define GL_VEND(_VendName)            (GLINFO_LOCATION.gl_vendor == VENDOR_##_VendName ? TRUE : FALSE)
163
164 #define D3DCOLOR_R(dw) (((float) (((dw) >> 16) & 0xFF)) / 255.0f)
165 #define D3DCOLOR_G(dw) (((float) (((dw) >>  8) & 0xFF)) / 255.0f)
166 #define D3DCOLOR_B(dw) (((float) (((dw) >>  0) & 0xFF)) / 255.0f)
167 #define D3DCOLOR_A(dw) (((float) (((dw) >> 24) & 0xFF)) / 255.0f)
168
169 #define D3DCOLORTOGLFLOAT4(dw, vec) \
170   (vec)[0] = D3DCOLOR_R(dw); \
171   (vec)[1] = D3DCOLOR_G(dw); \
172   (vec)[2] = D3DCOLOR_B(dw); \
173   (vec)[3] = D3DCOLOR_A(dw);
174   
175 /* Note: The following is purely to keep the source code as clear from #ifdefs as possible */
176 #if defined(GL_VERSION_1_3)
177 #define GLACTIVETEXTURE(textureNo)                          \
178             glActiveTexture(GL_TEXTURE0 + textureNo);       \
179             checkGLcall("glActiveTexture");      
180 #define GLCLIENTACTIVETEXTURE(textureNo)                    \
181             glClientActiveTexture(GL_TEXTURE0 + textureNo);
182 #define GLMULTITEXCOORD1F(a,b)                              \
183             glMultiTexCoord1f(GL_TEXTURE0 + a, b);
184 #define GLMULTITEXCOORD2F(a,b,c)                            \
185             glMultiTexCoord2f(GL_TEXTURE0 + a, b, c);
186 #define GLMULTITEXCOORD3F(a,b,c,d)                          \
187             glMultiTexCoord3f(GL_TEXTURE0 + a, b, c, d);
188 #define GLMULTITEXCOORD4F(a,b,c,d,e)                        \
189             glMultiTexCoord4f(GL_TEXTURE0 + a, b, c, d, e);
190 #define GLTEXTURECUBEMAP GL_TEXTURE_CUBE_MAP
191 #else 
192 #define GLACTIVETEXTURE(textureNo)                             \
193             glActiveTextureARB(GL_TEXTURE0_ARB + textureNo);   \
194             checkGLcall("glActiveTextureARB");
195 #define GLCLIENTACTIVETEXTURE(textureNo)                    \
196             glClientActiveTextureARB(GL_TEXTURE0_ARB + textureNo);
197 #define GLMULTITEXCOORD1F(a,b)                                 \
198             glMultiTexCoord1fARB(GL_TEXTURE0_ARB + a, b);
199 #define GLMULTITEXCOORD2F(a,b,c)                               \
200             glMultiTexCoord2fARB(GL_TEXTURE0_ARB + a, b, c);
201 #define GLMULTITEXCOORD3F(a,b,c,d)                             \
202             glMultiTexCoord3fARB(GL_TEXTURE0_ARB + a, b, c, d);
203 #define GLMULTITEXCOORD4F(a,b,c,d,e)                           \
204             glMultiTexCoord4fARB(GL_TEXTURE0_ARB + a, b, c, d, e);
205 #define GLTEXTURECUBEMAP GL_TEXTURE_CUBE_MAP_ARB
206 #endif
207
208 /* DirectX Device Limits */
209 /* --------------------- */
210 #define MAX_LEVELS  256  /* Maximum number of mipmap levels. Guessed at 256 */
211
212 #define MAX_STREAMS  16  /* Maximum possible streams - used for fixed size arrays
213                             See MaxStreams in MSDN under GetDeviceCaps */
214                          /* Maximum number of constants provided to the shaders */
215 #define HIGHEST_TRANSFORMSTATE 512 
216                          /* Highest value in D3DTRANSFORMSTATETYPE */
217 #define MAX_CLIPPLANES  D3DMAXUSERCLIPPLANES
218
219 #define MAX_PALETTES      256
220
221 /* Checking of API calls */
222 /* --------------------- */
223 #define checkGLcall(A) \
224 { \
225     GLint err = glGetError();   \
226     if (err != GL_NO_ERROR) { \
227        FIXME(">>>>>>>>>>>>>>>>> %x from %s @ %s / %d\n", err, A, __FILE__, __LINE__); \
228     } else { \
229        TRACE("%s call ok %s / %d\n", A, __FILE__, __LINE__); \
230     } \
231 }
232
233 /* Trace routines / diagnostics */
234 /* ---------------------------- */
235
236 /* Dump out a matrix and copy it */
237 #define conv_mat(mat,gl_mat)                                                                \
238 do {                                                                                        \
239     TRACE("%f %f %f %f\n", (mat)->u.s._11, (mat)->u.s._12, (mat)->u.s._13, (mat)->u.s._14); \
240     TRACE("%f %f %f %f\n", (mat)->u.s._21, (mat)->u.s._22, (mat)->u.s._23, (mat)->u.s._24); \
241     TRACE("%f %f %f %f\n", (mat)->u.s._31, (mat)->u.s._32, (mat)->u.s._33, (mat)->u.s._34); \
242     TRACE("%f %f %f %f\n", (mat)->u.s._41, (mat)->u.s._42, (mat)->u.s._43, (mat)->u.s._44); \
243     memcpy(gl_mat, (mat), 16 * sizeof(float));                                              \
244 } while (0)
245
246 /* Macro to dump out the current state of the light chain */
247 #define DUMP_LIGHT_CHAIN()                    \
248 {                                             \
249   PLIGHTINFOEL *el = This->stateBlock->lights;\
250   while (el) {                                \
251     TRACE("Light %p (glIndex %ld, d3dIndex %ld, enabled %d)\n", el, el->glIndex, el->OriginalIndex, el->lightEnabled);\
252     el = el->next;                            \
253   }                                           \
254 }
255
256 /* Trace vector and strided data information */
257 #define TRACE_VECTOR(name) TRACE( #name "=(%f, %f, %f, %f)\n", name.x, name.y, name.z, name.w);
258 #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);
259
260 /* Defines used for optimizations */
261
262 /*    Only reapply what is necessary */
263 #define REAPPLY_ALPHAOP  0x0001
264 #define REAPPLY_ALL      0xFFFF
265
266 /* Advance declaration of structures to satisfy compiler */
267 typedef struct IWineD3DStateBlockImpl IWineD3DStateBlockImpl;
268 typedef struct IWineD3DSurfaceImpl    IWineD3DSurfaceImpl;
269
270 /* Tracking */
271
272 /* TODO: Move some of this to the device */
273 long globalChangeGlRam(long glram);
274
275 /* Memory and object tracking */
276
277 /*Structure for holding information on all direct3d objects
278 useful for making sure tracking is ok and when release is called on a device!
279 and probably quite handy for debugging and dumping states out
280 */
281 typedef struct WineD3DGlobalStatistics {
282     int glsurfaceram; /* The aproximate amount of glTexture memory allocated for textures */
283 } WineD3DGlobalStatistics;
284
285 extern WineD3DGlobalStatistics* wineD3DGlobalStatistics;
286
287 /* Global variables */
288 extern const float identity[16];
289
290 /*****************************************************************************
291  * Compilable extra diagnostics
292  */
293
294 /* Trace information per-vertex: (extremely high amount of trace) */
295 #if 0 /* NOTE: Must be 0 in cvs */
296 # define VTRACE(A) TRACE A
297 #else 
298 # define VTRACE(A) 
299 #endif
300
301 /* Checking of per-vertex related GL calls */
302 #define vcheckGLcall(A) \
303 { \
304     GLint err = glGetError();   \
305     if (err != GL_NO_ERROR) { \
306        FIXME(">>>>>>>>>>>>>>>>> %x from %s @ %s / %d\n", err, A, __FILE__, __LINE__); \
307     } else { \
308        VTRACE(("%s call ok %s / %d\n", A, __FILE__, __LINE__)); \
309     } \
310 }
311
312 /* TODO: Confirm each of these works when wined3d move completed */
313 #if 0 /* NOTE: Must be 0 in cvs */
314   /* To avoid having to get gigabytes of trace, the following can be compiled in, and at the start
315      of each frame, a check is made for the existence of C:\D3DTRACE, and if if exists d3d trace
316      is enabled, and if it doesn't exists it is disabled.                                           */
317 # define FRAME_DEBUGGING
318   /*  Adding in the SINGLE_FRAME_DEBUGGING gives a trace of just what makes up a single frame, before
319       the file is deleted                                                                            */
320 # if 1 /* NOTE: Must be 1 in cvs, as this is mostly more useful than a trace from program start */
321 #  define SINGLE_FRAME_DEBUGGING
322 # endif  
323   /* The following, when enabled, lets you see the makeup of the frame, by drawprimitive calls.
324      It can only be enabled when FRAME_DEBUGGING is also enabled                               
325      The contents of the back buffer are written into /tmp/backbuffer_* after each primitive 
326      array is drawn.                                                                            */
327 # if 0 /* NOTE: Must be 0 in cvs, as this give a lot of ppm files when compiled in */                                                                                       
328 #  define SHOW_FRAME_MAKEUP 1
329 # endif  
330   /* The following, when enabled, lets you see the makeup of the all the textures used during each
331      of the drawprimitive calls. It can only be enabled when SHOW_FRAME_MAKEUP is also enabled.
332      The contents of the textures assigned to each stage are written into 
333      /tmp/texture_*_<Stage>.ppm after each primitive array is drawn.                            */
334 # if 0 /* NOTE: Must be 0 in cvs, as this give a lot of ppm files when compiled in */
335 #  define SHOW_TEXTURE_MAKEUP 0
336 # endif  
337 extern BOOL isOn;
338 extern BOOL isDumpingFrames;
339 extern LONG primCounter;
340 #endif
341
342 /*****************************************************************************
343  * Prototypes
344  */
345
346 /* Routine common to the draw primitive and draw indexed primitive routines */
347 void drawPrimitive(IWineD3DDevice *iface,
348                     int PrimitiveType,
349                     long NumPrimitives,
350                     /* for Indexed: */
351                     long  StartVertexIndex,
352                     UINT  numberOfVertices,
353                     long  StartIdx,
354                     short idxBytes,
355                     const void *idxData,
356                     int   minIndex);
357
358 /*****************************************************************************
359  * Structures required to draw primitives 
360  */
361
362 typedef struct Direct3DStridedData {
363     BYTE     *lpData;        /* Pointer to start of data               */
364     DWORD     dwStride;      /* Stride between occurances of this data */
365     DWORD     dwType;        /* Type (as in D3DVSDT_TYPE)              */
366 } Direct3DStridedData;
367
368 typedef struct Direct3DVertexStridedData {
369     union {
370         struct {
371              Direct3DStridedData  position;
372              Direct3DStridedData  blendWeights;
373              Direct3DStridedData  blendMatrixIndices;
374              Direct3DStridedData  normal;
375              Direct3DStridedData  pSize;
376              Direct3DStridedData  diffuse;
377              Direct3DStridedData  specular;
378              Direct3DStridedData  texCoords[MAX_TEXTURES];
379              Direct3DStridedData  position2; /* tween data */
380              Direct3DStridedData  normal2;   /* tween data */
381              Direct3DStridedData  tangent;
382              Direct3DStridedData  binormal;
383              Direct3DStridedData  tessFactor;
384              Direct3DStridedData  fog;
385              Direct3DStridedData  depth;
386              Direct3DStridedData  sample;
387         } s;
388         Direct3DStridedData input[16];  /* Indexed by constants in D3DVSDE_REGISTER */
389     } u;
390 } Direct3DVertexStridedData;
391
392 /*****************************************************************************
393  * Internal representation of a light
394  */
395 typedef struct PLIGHTINFOEL PLIGHTINFOEL;
396 struct PLIGHTINFOEL {
397     WINED3DLIGHT OriginalParms; /* Note D3D8LIGHT == D3D9LIGHT */
398     DWORD        OriginalIndex;
399     LONG         glIndex;
400     BOOL         lightEnabled;
401     BOOL         changed;
402     BOOL         enabledChanged;
403
404     /* Converted parms to speed up swapping lights */
405     float                         lightPosn[4];
406     float                         lightDirn[4];
407     float                         exponent;
408     float                         cutoff;
409
410     PLIGHTINFOEL *next;
411     PLIGHTINFOEL *prev;
412 };
413
414 /*****************************************************************************
415  * IWineD3D implementation structure
416  */
417 typedef struct IWineD3DImpl
418 {
419     /* IUnknown fields */
420     const IWineD3DVtbl     *lpVtbl;
421     LONG                    ref;     /* Note: Ref counting not required */
422
423     /* WineD3D Information */
424     IUnknown               *parent;
425     UINT                    dxVersion;
426
427     /* GL Information */
428     BOOL                    isGLInfoValid;
429     WineD3D_GL_Info         gl_info;
430 } IWineD3DImpl;
431
432 extern const IWineD3DVtbl IWineD3D_Vtbl;
433
434 typedef struct SwapChainList {
435     IWineD3DSwapChain         *swapchain;
436     struct SwapChainList      *next;
437 } SwapChainList;
438
439 /** Hacked out start of a context manager!! **/
440 typedef struct glContext {
441     int Width;
442     int Height;
443     int usedcount;
444     GLXContext context;
445
446     Drawable drawable;
447     IWineD3DSurface *pSurface;
448 #if 0 /* TODO: someway to represent the state of the context */
449     IWineD3DStateBlock *pStateBlock;
450 #endif
451 /* a few other things like format */
452 } glContext;
453
454 /* TODO: setup some flags in the regestry to enable, disable pbuffer support
455 (since it will break quite a few things until contexts are managed properly!) */
456 extern BOOL pbuffer_support;
457 /* allocate one pbuffer per surface */
458 extern BOOL pbuffer_per_surface;
459
460 /* Maximum number of contexts/pbuffers to keep in cache,
461 set to 100 because ATI's drivers don't support deleting pBuffers properly
462 this needs to be migrated to a list and some option availalbe for controle the cache size.
463 */
464 #define CONTEXT_CACHE 100
465
466 typedef struct ResourceList {
467     IWineD3DResource         *resource;
468     struct ResourceList      *next;
469 } ResourceList;
470
471 /*****************************************************************************
472  * IWineD3DDevice implementation structure
473  */
474 typedef struct IWineD3DDeviceImpl
475 {
476     /* IUnknown fields      */
477     const IWineD3DDeviceVtbl *lpVtbl;
478     LONG                    ref;     /* Note: Ref counting not required */
479
480     /* WineD3D Information  */
481     IUnknown               *parent;
482     IWineD3D               *wineD3D;
483
484     /* X and GL Information */
485     GLint                   maxConcurrentLights;
486
487     /* Optimization */
488     BOOL                    modelview_valid;
489     BOOL                    proj_valid;
490     BOOL                    view_ident;        /* true iff view matrix is identity                */
491     BOOL                    last_was_rhw;      /* true iff last draw_primitive was in xyzrhw mode */
492     GLenum                  tracking_parm;     /* Which source is tracking current colour         */
493     LONG                    tracking_color;    /* used iff GL_COLOR_MATERIAL was enabled          */
494 #define                         DISABLED_TRACKING  0  /* Disabled                                 */
495 #define                         IS_TRACKING        1  /* tracking_parm is tracking diffuse color  */
496 #define                         NEEDS_TRACKING     2  /* Tracking needs to be enabled when needed */
497 #define                         NEEDS_DISABLE      3  /* Tracking needs to be disabled when needed*/
498     UINT                    srcBlend;
499     UINT                    dstBlend;
500     UINT                    alphafunc;
501     UINT                    stencilfunc;
502     BOOL                    texture_shader_active;  /* TODO: Confirm use is correct */
503
504     /* State block related */
505     BOOL                    isRecordingState;
506     IWineD3DStateBlockImpl *stateBlock;
507     IWineD3DStateBlockImpl *updateStateBlock;
508
509     /* Internal use fields  */
510     D3DDEVICE_CREATION_PARAMETERS   createParms;
511     UINT                            adapterNo;
512     D3DDEVTYPE                      devType;
513
514     SwapChainList          *swapchains;
515
516     ResourceList           *resources; /* a linked list to track resources created by the device */
517
518     /* Render Target Support */
519     IWineD3DSurface        *depthStencilBuffer;
520
521     IWineD3DSurface        *renderTarget;
522     IWineD3DSurface        *stencilBufferTarget;
523
524     /* palettes texture management */
525     PALETTEENTRY            palettes[MAX_PALETTES][256];
526     UINT                    currentPalette;
527
528     /* For rendering to a texture using glCopyTexImage */
529     BOOL                    renderUpsideDown;
530
531     /* Cursor management */
532     BOOL                    bCursorVisible;
533     UINT                    xHotSpot;
534     UINT                    yHotSpot;
535     UINT                    xScreenSpace;
536     UINT                    yScreenSpace;
537
538     /* Textures for when no other textures are mapped */
539     UINT                          dummyTextureName[MAX_TEXTURES];
540
541     /* Debug stream management */
542     BOOL                     debug;
543
544     /* Device state management */
545     HRESULT                 state;
546
547     /* Screen buffer resources */
548     glContext contextCache[CONTEXT_CACHE];
549
550     /* A flag to check if endscene has been called before changing the render tartet */
551     BOOL sceneEnded;
552 } IWineD3DDeviceImpl;
553
554 extern const IWineD3DDeviceVtbl IWineD3DDevice_Vtbl;
555
556 /* Support for IWineD3DResource ::Set/Get/FreePrivateData. I don't think
557  * anybody uses it for much so a good implementation is optional. */
558 typedef struct PrivateData
559 {
560     struct PrivateData* next;
561
562     GUID tag;
563     DWORD flags; /* DDSPD_* */
564     DWORD uniqueness_value;
565
566     union
567     {
568         LPVOID data;
569         LPUNKNOWN object;
570     } ptr;
571
572     DWORD size;
573 } PrivateData;
574
575 /*****************************************************************************
576  * IWineD3DResource implementation structure
577  */
578 typedef struct IWineD3DResourceClass
579 {
580     /* IUnknown fields */
581     LONG                    ref;     /* Note: Ref counting not required */
582
583     /* WineD3DResource Information */
584     IUnknown               *parent;
585     D3DRESOURCETYPE         resourceType;
586     IWineD3DDeviceImpl     *wineD3DDevice;
587     D3DPOOL                 pool;
588     UINT                    size;
589     DWORD                   usage;
590     WINED3DFORMAT           format;
591     BYTE                   *allocatedMemory;
592     PrivateData            *privateData;
593
594 } IWineD3DResourceClass;
595
596 typedef struct IWineD3DResourceImpl
597 {
598     /* IUnknown & WineD3DResource Information     */
599     const IWineD3DResourceVtbl *lpVtbl;
600     IWineD3DResourceClass   resource;
601 } IWineD3DResourceImpl;
602
603
604 /*****************************************************************************
605  * IWineD3DVertexBuffer implementation structure (extends IWineD3DResourceImpl)
606  */
607 typedef struct IWineD3DVertexBufferImpl
608 {
609     /* IUnknown & WineD3DResource Information     */
610     const IWineD3DVertexBufferVtbl *lpVtbl;
611     IWineD3DResourceClass     resource;
612
613     /* WineD3DVertexBuffer specifics */
614     DWORD                     fvf;
615
616 } IWineD3DVertexBufferImpl;
617
618 extern const IWineD3DVertexBufferVtbl IWineD3DVertexBuffer_Vtbl;
619
620
621 /*****************************************************************************
622  * IWineD3DIndexBuffer implementation structure (extends IWineD3DResourceImpl)
623  */
624 typedef struct IWineD3DIndexBufferImpl
625 {
626     /* IUnknown & WineD3DResource Information     */
627     const IWineD3DIndexBufferVtbl *lpVtbl;
628     IWineD3DResourceClass     resource;
629
630     /* WineD3DVertexBuffer specifics */
631 } IWineD3DIndexBufferImpl;
632
633 extern const IWineD3DIndexBufferVtbl IWineD3DIndexBuffer_Vtbl;
634
635 /*****************************************************************************
636  * IWineD3DBaseTexture D3D- > openGL state map lookups
637  */
638 #define WINED3DFUNC_NOTSUPPORTED  -2
639 #define WINED3DFUNC_UNIMPLEMENTED -1
640
641 typedef enum winetexturestates {
642     WINED3DTEXSTA_ADDRESSU       = 0,
643     WINED3DTEXSTA_ADDRESSV       = 1,
644     WINED3DTEXSTA_ADDRESSW       = 2,
645     WINED3DTEXSTA_BORDERCOLOR    = 3,
646     WINED3DTEXSTA_MAGFILTER      = 4,
647     WINED3DTEXSTA_MINFILTER      = 5,
648     WINED3DTEXSTA_MIPFILTER      = 6,
649     WINED3DTEXSTA_MAXMIPLEVEL    = 7,
650     WINED3DTEXSTA_MAXANISOTROPY  = 8,
651     WINED3DTEXSTA_SRGBTEXTURE    = 9,
652     WINED3DTEXSTA_ELEMENTINDEX   = 10,
653     WINED3DTEXSTA_DMAPOFFSET     = 11,
654     WINED3DTEXSTA_TSSADDRESSW    = 12,
655     MAX_WINETEXTURESTATES        = 13,
656 } winetexturestates;
657
658 typedef struct Wined3dTextureStateMap {
659     CONST int state;
660     int function;
661 } Wined3dTextureStateMap;
662
663 /*****************************************************************************
664  * IWineD3DBaseTexture implementation structure (extends IWineD3DResourceImpl)
665  */
666 typedef struct IWineD3DBaseTextureClass
667 {
668     UINT                    levels;
669     BOOL                    dirty;
670     D3DFORMAT               format;
671     DWORD                   usage;
672     UINT                    textureName;
673     UINT                    LOD;
674     D3DTEXTUREFILTERTYPE    filterType;
675     DWORD                   states[MAX_WINETEXTURESTATES];
676
677 } IWineD3DBaseTextureClass;
678
679 typedef struct IWineD3DBaseTextureImpl
680 {
681     /* IUnknown & WineD3DResource Information     */
682     const IWineD3DBaseTextureVtbl *lpVtbl;
683     IWineD3DResourceClass     resource;
684     IWineD3DBaseTextureClass  baseTexture;
685
686 } IWineD3DBaseTextureImpl;
687
688 /*****************************************************************************
689  * IWineD3DTexture implementation structure (extends IWineD3DBaseTextureImpl)
690  */
691 typedef struct IWineD3DTextureImpl
692 {
693     /* IUnknown & WineD3DResource/WineD3DBaseTexture Information     */
694     const IWineD3DTextureVtbl *lpVtbl;
695     IWineD3DResourceClass     resource;
696     IWineD3DBaseTextureClass  baseTexture;
697
698     /* IWineD3DTexture */
699     IWineD3DSurface          *surfaces[MAX_LEVELS];
700     
701     UINT                      width;
702     UINT                      height;
703     float                     pow2scalingFactorX;
704     float                     pow2scalingFactorY;
705
706 } IWineD3DTextureImpl;
707
708 extern const IWineD3DTextureVtbl IWineD3DTexture_Vtbl;
709
710 /*****************************************************************************
711  * IWineD3DCubeTexture implementation structure (extends IWineD3DBaseTextureImpl)
712  */
713 typedef struct IWineD3DCubeTextureImpl
714 {
715     /* IUnknown & WineD3DResource/WineD3DBaseTexture Information     */
716     const IWineD3DCubeTextureVtbl *lpVtbl;
717     IWineD3DResourceClass     resource;
718     IWineD3DBaseTextureClass  baseTexture;
719
720     /* IWineD3DCubeTexture */
721     IWineD3DSurface          *surfaces[6][MAX_LEVELS];
722
723     UINT                      edgeLength;
724     float                     pow2scalingFactor;
725
726 } IWineD3DCubeTextureImpl;
727
728 extern const IWineD3DCubeTextureVtbl IWineD3DCubeTexture_Vtbl;
729
730 /*****************************************************************************
731  * IWineD3DVolume implementation structure (extends IUnknown)
732  */
733 typedef struct IWineD3DVolumeImpl
734 {
735     /* IUnknown & WineD3DResource fields */
736     const IWineD3DVolumeVtbl  *lpVtbl;
737     IWineD3DResourceClass      resource;
738
739     /* WineD3DVolume Information */
740     D3DVOLUME_DESC          currentDesc;
741     IUnknown               *container;
742     UINT                    bytesPerPixel;
743
744     BOOL                    lockable;
745     BOOL                    locked;
746     D3DBOX                  lockedBox;
747     D3DBOX                  dirtyBox;
748     BOOL                    dirty;
749
750
751 } IWineD3DVolumeImpl;
752
753 extern const IWineD3DVolumeVtbl IWineD3DVolume_Vtbl;
754
755 /*****************************************************************************
756  * IWineD3DVolumeTexture implementation structure (extends IWineD3DBaseTextureImpl)
757  */
758 typedef struct IWineD3DVolumeTextureImpl
759 {
760     /* IUnknown & WineD3DResource/WineD3DBaseTexture Information     */
761     const IWineD3DVolumeTextureVtbl *lpVtbl;
762     IWineD3DResourceClass     resource;
763     IWineD3DBaseTextureClass  baseTexture;
764
765     /* IWineD3DVolumeTexture */
766     IWineD3DVolume           *volumes[MAX_LEVELS];
767
768     UINT                      width;
769     UINT                      height;
770     UINT                      depth;
771 } IWineD3DVolumeTextureImpl;
772
773 extern const IWineD3DVolumeTextureVtbl IWineD3DVolumeTexture_Vtbl;
774
775 typedef struct _WINED3DSURFACET_DESC
776 {
777     D3DMULTISAMPLE_TYPE MultiSampleType;
778     DWORD               MultiSampleQuality;
779     UINT                Width;
780     UINT                Height;
781 } WINED3DSURFACET_DESC;
782
783 /*****************************************************************************
784  * IWineD3DSurface implementation structure
785  */
786 struct IWineD3DSurfaceImpl
787 {
788     /* IUnknown & IWineD3DResource Information     */
789     const IWineD3DSurfaceVtbl *lpVtbl;
790     IWineD3DResourceClass     resource;
791
792     /* IWineD3DSurface fields */
793     IUnknown                 *container;
794     WINED3DSURFACET_DESC      currentDesc;
795
796     UINT                      textureName;
797     UINT                      bytesPerPixel;
798
799     /* TODO: move this off into a management class(maybe!) */
800     BOOL                      nonpow2;
801
802     UINT                      pow2Width;
803     UINT                      pow2Height;
804     UINT                      pow2Size;
805
806 #if 0
807     /* precalculated x and y scalings for texture coords */
808     float                     pow2scalingFactorX; /* =  (Width  / pow2Width ) */
809     float                     pow2scalingFactorY; /* =  (Height / pow2Height) */
810 #endif
811
812     BOOL                      lockable;
813     BOOL                      discard;
814     BOOL                      locked;
815     BOOL                      activeLock;
816     
817     RECT                      lockedRect;
818     RECT                      dirtyRect;
819     BOOL                      Dirty;
820     
821     BOOL                      inTexture;
822     BOOL                      inPBuffer;
823
824     glDescriptor              glDescription;
825 };
826
827 extern const IWineD3DSurfaceVtbl IWineD3DSurface_Vtbl;
828
829 /*****************************************************************************
830  * IWineD3DVertexDeclaration implementation structure
831  */
832 typedef struct IWineD3DVertexDeclarationImpl {
833  /* IUnknown  Information     */
834   const IWineD3DVertexDeclarationVtbl *lpVtbl;
835   LONG                    ref;     /* Note: Ref counting not required */
836
837   IUnknown               *parent;
838   /** precomputed fvf if simple declaration */
839   IWineD3DDeviceImpl     *wineD3DDevice;
840   DWORD   fvf[MAX_STREAMS];
841   DWORD   allFVF;
842
843   /** dx8 compatible Declaration fields */
844   DWORD*  pDeclaration8;
845   DWORD   declaration8Length;
846
847   /** dx9+ */
848   D3DVERTEXELEMENT9* pDeclaration9;
849   UINT               declaration9NumElements;
850 } IWineD3DVertexDeclarationImpl;
851
852 extern const IWineD3DVertexDeclarationVtbl IWineD3DVertexDeclaration_Vtbl;
853
854 /*****************************************************************************
855  * IWineD3DStateBlock implementation structure
856  */
857
858 /* Internal state Block for Begin/End/Capture/Create/Apply info  */
859 /*   Note: Very long winded but gl Lists are not flexible enough */
860 /*   to resolve everything we need, so doing it manually for now */
861 typedef struct SAVEDSTATES {
862         BOOL                      indices;
863         BOOL                      material;
864         BOOL                      fvf;
865         BOOL                      streamSource[MAX_STREAMS];
866         BOOL                      streamFreq[MAX_STREAMS];
867         BOOL                      textures[MAX_TEXTURES];
868         BOOL                      transform[HIGHEST_TRANSFORMSTATE + 1];
869         BOOL                      viewport;
870         BOOL                      renderState[WINEHIGHEST_RENDER_STATE + 1];
871         BOOL                      textureState[MAX_TEXTURES][WINED3D_HIGHEST_TEXTURE_STATE + 1];
872         BOOL                      samplerState[MAX_SAMPLERS][WINED3D_HIGHEST_SAMPLER_STATE + 1];
873         BOOL                      clipplane[MAX_CLIPPLANES];
874         BOOL                      vertexDecl;
875         BOOL                      pixelShader;
876         BOOL                      pixelShaderConstants[MAX_PSHADER_CONSTANTS];
877         BOOL                      vertexShader;
878         BOOL                      vertexShaderConstants[MAX_VSHADER_CONSTANTS];
879 } SAVEDSTATES;
880
881 typedef enum {
882     WINESHADERCNST_FLOAT    = 0,
883     WINESHADERCNST_INTEGER  = 1,
884     WINESHADERCNST_BOOL     = 2
885 } WINESHADERCNST;
886
887 struct IWineD3DStateBlockImpl
888 {
889     /* IUnknown fields */
890     const IWineD3DStateBlockVtbl *lpVtbl;
891     LONG                      ref;     /* Note: Ref counting not required */
892
893     /* IWineD3DStateBlock information */
894     IUnknown                 *parent;
895     IWineD3DDeviceImpl       *wineD3DDevice;
896     WINED3DSTATEBLOCKTYPE     blockType;
897
898     /* Array indicating whether things have been set or changed */
899     SAVEDSTATES               changed;
900     SAVEDSTATES               set;
901
902     /* Drawing - Vertex Shader or FVF related */
903     DWORD                     fvf;
904     /* Vertex Shader Declaration */
905     IWineD3DVertexDeclaration *vertexDecl;
906
907     IWineD3DVertexShader      *vertexShader;
908
909     /* Vertex Shader Constants */
910     BOOL                       vertexShaderConstantB[MAX_VSHADER_CONSTANTS];
911     INT                        vertexShaderConstantI[MAX_VSHADER_CONSTANTS * 4];
912     float                      vertexShaderConstantF[MAX_VSHADER_CONSTANTS * 4];
913     WINESHADERCNST             vertexShaderConstantT[MAX_VSHADER_CONSTANTS]; /* TODO: Think about changing this to a char to possibly save a little memory */
914
915     BOOL                       softwareVertexProcessing;
916
917     /* Stream Source */
918     BOOL                      streamIsUP;
919     UINT                      streamStride[MAX_STREAMS];
920     UINT                      streamOffset[MAX_STREAMS];
921     IWineD3DVertexBuffer     *streamSource[MAX_STREAMS];
922     UINT                      streamFreq[MAX_STREAMS];
923     UINT                      streamFlags[MAX_STREAMS];     /*0 | D3DSTREAMSOURCE_INSTANCEDATA | D3DSTREAMSOURCE_INDEXEDDATA  */
924
925     /* Indices */
926     IWineD3DIndexBuffer*      pIndexData;
927     UINT                      baseVertexIndex; /* Note: only used for d3d8 */
928
929     /* Transform */
930     D3DMATRIX                 transforms[HIGHEST_TRANSFORMSTATE + 1];
931
932     /* Lights */
933     PLIGHTINFOEL             *lights; /* NOTE: active GL lights must be front of the chain */
934
935     /* Clipping */
936     double                    clipplane[MAX_CLIPPLANES][4];
937     WINED3DCLIPSTATUS         clip_status;
938
939     /* ViewPort */
940     WINED3DVIEWPORT           viewport;
941
942     /* Material */
943     WINED3DMATERIAL           material;
944
945     /* Pixel Shader */
946     IWineD3DPixelShader      *pixelShader;
947
948     /* Pixel Shader Constants */
949     BOOL                       pixelShaderConstantB[MAX_PSHADER_CONSTANTS];
950     INT                        pixelShaderConstantI[MAX_PSHADER_CONSTANTS * 4];
951     float                      pixelShaderConstantF[MAX_PSHADER_CONSTANTS * 4];
952     WINESHADERCNST             pixelShaderConstantT[MAX_PSHADER_CONSTANTS]; /* TODO: Think about changing this to a char to possibly save a little memory */
953
954     /* Indexed Vertex Blending */
955     D3DVERTEXBLENDFLAGS       vertex_blend;
956     FLOAT                     tween_factor;
957
958     /* RenderState */
959     DWORD                     renderState[WINEHIGHEST_RENDER_STATE + 1];
960
961     /* Texture */
962     IWineD3DBaseTexture      *textures[MAX_TEXTURES];
963     int                       textureDimensions[MAX_SAMPLERS];
964
965     /* Texture State Stage */
966     DWORD                     textureState[MAX_TEXTURES][WINED3D_HIGHEST_TEXTURE_STATE + 1];
967     /* Sampler States */
968     DWORD                     samplerState[MAX_SAMPLERS][WINED3D_HIGHEST_SAMPLER_STATE + 1];
969
970 };
971
972 extern const IWineD3DStateBlockVtbl IWineD3DStateBlock_Vtbl;
973
974 /*****************************************************************************
975  * IWineD3DQueryImpl implementation structure (extends IUnknown)
976  */
977 typedef struct IWineD3DQueryImpl
978 {
979     const IWineD3DQueryVtbl  *lpVtbl;
980     LONG                      ref;     /* Note: Ref counting not required */
981     
982     IUnknown                 *parent;
983     /*TODO: replace with iface usage */
984 #if 0
985     IWineD3DDevice         *wineD3DDevice;
986 #else
987     IWineD3DDeviceImpl       *wineD3DDevice;
988 #endif
989     /* IWineD3DQuery fields */
990
991     D3DQUERYTYPE              type;
992     /* TODO: Think about using a IUnknown instead of a void* */
993     void                     *extendedData;
994     
995   
996 } IWineD3DQueryImpl;
997
998 extern const IWineD3DQueryVtbl IWineD3DQuery_Vtbl;
999
1000 /* Datastructures for IWineD3DQueryImpl.extendedData */
1001 typedef struct  WineQueryOcclusionData {
1002        unsigned int queryId;
1003 } WineQueryOcclusionData;
1004
1005
1006 /*****************************************************************************
1007  * IWineD3DSwapChainImpl implementation structure (extends IUnknown)
1008  */
1009
1010 typedef struct IWineD3DSwapChainImpl
1011 {
1012     /*IUnknown part*/
1013     IWineD3DSwapChainVtbl    *lpVtbl;
1014     LONG                      ref;     /* Note: Ref counting not required */
1015
1016     IUnknown                 *parent;
1017     IWineD3DDeviceImpl       *wineD3DDevice;
1018
1019     /* IWineD3DSwapChain fields */
1020     IWineD3DSurface          *backBuffer;
1021     IWineD3DSurface          *frontBuffer;
1022     BOOL                      wantsDepthStencilBuffer;
1023     D3DPRESENT_PARAMETERS     presentParms;
1024
1025     /* TODO: move everything upto drawable off into a context manager
1026       and store the 'data' in the contextManagerData interface.
1027     IUnknown                  *contextManagerData;
1028     */
1029
1030     HWND                    win_handle;
1031     Window                  win;
1032     Display                *display;
1033
1034     GLXContext              glCtx;
1035     XVisualInfo            *visInfo;
1036     GLXContext              render_ctx;
1037     /* This has been left in device for now, but needs moving off into a rendertarget management class and separated out from swapchains and devices. */
1038     Drawable                drawable;
1039 } IWineD3DSwapChainImpl;
1040
1041 extern IWineD3DSwapChainVtbl IWineD3DSwapChain_Vtbl;
1042
1043 /*****************************************************************************
1044  * Utility function prototypes 
1045  */
1046
1047 /* Trace routines */
1048 const char* debug_d3dformat(WINED3DFORMAT fmt);
1049 const char* debug_d3ddevicetype(D3DDEVTYPE devtype);
1050 const char* debug_d3dresourcetype(D3DRESOURCETYPE res);
1051 const char* debug_d3dusage(DWORD usage);
1052 const char* debug_d3dprimitivetype(D3DPRIMITIVETYPE PrimitiveType);
1053 const char* debug_d3drenderstate(DWORD state);
1054 const char* debug_d3dtexturestate(DWORD state);
1055 const char* debug_d3dpool(D3DPOOL pool);
1056
1057 /* Routines for GL <-> D3D values */
1058 GLenum StencilOp(DWORD op);
1059 void   set_tex_op(IWineD3DDevice *iface, BOOL isAlpha, int Stage, D3DTEXTUREOP op, DWORD arg1, DWORD arg2, DWORD arg3);
1060 void   set_texture_matrix(const float *smat, DWORD flags, BOOL calculatedCoords);
1061 void   GetSrcAndOpFromValue(DWORD iValue, BOOL isAlphaArg, GLenum* source, GLenum* operand);
1062
1063 SHORT  D3DFmtGetBpp(IWineD3DDeviceImpl* This, D3DFORMAT fmt);
1064 GLenum D3DFmt2GLFmt(IWineD3DDeviceImpl* This, D3DFORMAT fmt);
1065 GLenum D3DFmt2GLType(IWineD3DDeviceImpl *This, D3DFORMAT fmt);
1066 GLint  D3DFmt2GLIntFmt(IWineD3DDeviceImpl* This, D3DFORMAT fmt);
1067
1068 int D3DFmtMakeGlCfg(D3DFORMAT BackBufferFormat, D3DFORMAT StencilBufferFormat, int *attribs, int* nAttribs, BOOL alternate);
1069
1070
1071 /*****************************************************************************
1072  * To enable calling of inherited functions, requires prototypes 
1073  *
1074  * Note: Only require classes which are subclassed, ie resource, basetexture, 
1075  */
1076     /*** IUnknown methods ***/
1077     extern HRESULT WINAPI IWineD3DResourceImpl_QueryInterface(IWineD3DResource *iface, REFIID riid, void** ppvObject);
1078     extern ULONG WINAPI IWineD3DResourceImpl_AddRef(IWineD3DResource *iface);
1079     extern ULONG WINAPI IWineD3DResourceImpl_Release(IWineD3DResource *iface);
1080     /*** IWineD3DResource methods ***/
1081     extern HRESULT WINAPI IWineD3DResourceImpl_GetParent(IWineD3DResource *iface, IUnknown **pParent);
1082     extern HRESULT WINAPI IWineD3DResourceImpl_GetDevice(IWineD3DResource *iface, IWineD3DDevice ** ppDevice);
1083     extern HRESULT WINAPI IWineD3DResourceImpl_SetPrivateData(IWineD3DResource *iface, REFGUID  refguid, CONST void * pData, DWORD  SizeOfData, DWORD  Flags);
1084     extern HRESULT WINAPI IWineD3DResourceImpl_GetPrivateData(IWineD3DResource *iface, REFGUID  refguid, void * pData, DWORD * pSizeOfData);
1085     extern HRESULT WINAPI IWineD3DResourceImpl_FreePrivateData(IWineD3DResource *iface, REFGUID  refguid);
1086     extern DWORD WINAPI IWineD3DResourceImpl_SetPriority(IWineD3DResource *iface, DWORD  PriorityNew);
1087     extern DWORD WINAPI IWineD3DResourceImpl_GetPriority(IWineD3DResource *iface);
1088     extern void WINAPI IWineD3DResourceImpl_PreLoad(IWineD3DResource *iface);
1089     extern D3DRESOURCETYPE WINAPI IWineD3DResourceImpl_GetType(IWineD3DResource *iface);
1090     /*** class static members ***/
1091     void IWineD3DResourceImpl_CleanUp(IWineD3DResource *iface);
1092
1093     /*** IUnknown methods ***/
1094     extern HRESULT WINAPI IWineD3DBaseTextureImpl_QueryInterface(IWineD3DBaseTexture *iface, REFIID riid, void** ppvObject);
1095     extern ULONG WINAPI IWineD3DBaseTextureImpl_AddRef(IWineD3DBaseTexture *iface);
1096     extern ULONG WINAPI IWineD3DBaseTextureImpl_Release(IWineD3DBaseTexture *iface);
1097     /*** IWineD3DResource methods ***/
1098     extern HRESULT WINAPI IWineD3DBaseTextureImpl_GetParent(IWineD3DBaseTexture *iface, IUnknown **pParent);
1099     extern HRESULT WINAPI IWineD3DBaseTextureImpl_GetDevice(IWineD3DBaseTexture *iface, IWineD3DDevice ** ppDevice);
1100     extern HRESULT WINAPI IWineD3DBaseTextureImpl_SetPrivateData(IWineD3DBaseTexture *iface, REFGUID  refguid, CONST void * pData, DWORD  SizeOfData, DWORD  Flags);
1101     extern HRESULT WINAPI IWineD3DBaseTextureImpl_GetPrivateData(IWineD3DBaseTexture *iface, REFGUID  refguid, void * pData, DWORD * pSizeOfData);
1102     extern HRESULT WINAPI IWineD3DBaseTextureImpl_FreePrivateData(IWineD3DBaseTexture *iface, REFGUID  refguid);
1103     extern DWORD WINAPI IWineD3DBaseTextureImpl_SetPriority(IWineD3DBaseTexture *iface, DWORD  PriorityNew);
1104     extern DWORD WINAPI IWineD3DBaseTextureImpl_GetPriority(IWineD3DBaseTexture *iface);
1105     extern void WINAPI IWineD3DBaseTextureImpl_PreLoad(IWineD3DBaseTexture *iface);
1106     extern D3DRESOURCETYPE WINAPI IWineD3DBaseTextureImpl_GetType(IWineD3DBaseTexture *iface);
1107     /*** IWineD3DBaseTexture methods ***/
1108     extern DWORD WINAPI IWineD3DBaseTextureImpl_SetLOD(IWineD3DBaseTexture *iface, DWORD LODNew);
1109     extern DWORD WINAPI IWineD3DBaseTextureImpl_GetLOD(IWineD3DBaseTexture *iface);
1110     extern DWORD WINAPI IWineD3DBaseTextureImpl_GetLevelCount(IWineD3DBaseTexture *iface);
1111     extern HRESULT WINAPI IWineD3DBaseTextureImpl_SetAutoGenFilterType(IWineD3DBaseTexture *iface, D3DTEXTUREFILTERTYPE FilterType);
1112     extern D3DTEXTUREFILTERTYPE WINAPI IWineD3DBaseTextureImpl_GetAutoGenFilterType(IWineD3DBaseTexture *iface);
1113     extern void WINAPI IWineD3DBaseTextureImpl_GenerateMipSubLevels(IWineD3DBaseTexture *iface);
1114     extern BOOL WINAPI IWineD3DBaseTextureImpl_SetDirty(IWineD3DBaseTexture *iface, BOOL);
1115     extern BOOL WINAPI IWineD3DBaseTextureImpl_GetDirty(IWineD3DBaseTexture *iface);
1116
1117     extern BYTE* WINAPI IWineD3DVertexBufferImpl_GetMemory(IWineD3DVertexBuffer* iface, DWORD iOffset);
1118     extern HRESULT WINAPI IWineD3DVertexBufferImpl_ReleaseMemory(IWineD3DVertexBuffer* iface);
1119     extern HRESULT WINAPI IWineD3DBaseTextureImpl_BindTexture(IWineD3DBaseTexture *iface);
1120     extern HRESULT WINAPI IWineD3DBaseTextureImpl_UnBindTexture(IWineD3DBaseTexture *iface);
1121     extern void WINAPI IWineD3DBaseTextureImpl_ApplyStateChanges(IWineD3DBaseTexture *iface, const DWORD textureStates[WINED3D_HIGHEST_TEXTURE_STATE + 1], const DWORD samplerStates[WINED3D_HIGHEST_SAMPLER_STATE + 1]);
1122     /*** class static members ***/
1123     void IWineD3DBaseTextureImpl_CleanUp(IWineD3DBaseTexture *iface);
1124
1125 /* An enum for the type of constants that are used... addressing causes
1126  * problems with being able to work out what's used and what's not.. so
1127  * maybe we'll have to rely on the server vertex shader const functions?
1128  */
1129 enum vsConstantsEnum {
1130     VS_CONSTANT_NOT_USED = 0,
1131     VS_CONSTANT_CONSTANT,
1132     VS_CONSTANT_INTEGER,
1133     VS_CONSTANT_BOOLEAN,
1134     VS_CONSTANT_FLOAT
1135 };
1136
1137 /*****************************************************************************
1138  * IDirect3DVertexShader implementation structure
1139  */
1140 typedef struct IWineD3DVertexShaderImpl {
1141     /* IUnknown parts*/   
1142     const IWineD3DVertexShaderVtbl *lpVtbl;
1143     LONG                        ref;     /* Note: Ref counting not required */
1144
1145     IUnknown                    *parent;
1146     IWineD3DDeviceImpl          *wineD3DDevice;
1147
1148     /* IWineD3DVertexShaderImpl */
1149     CONST DWORD                 *function;
1150     UINT                         functionLength;
1151
1152     DWORD usage;
1153     DWORD version;
1154
1155     /* vertex declaration array mapping */
1156     BOOL                        namedArrays;    /* don't map use named functions */
1157     BOOL                        declaredArrays; /* mapping requires */
1158     INT                         arrayUsageMap[WINED3DSHADERDECLUSAGE_MAX_USAGE];    /* lookup table for the maps */
1159     INT                         highestConstant;
1160     CHAR                        constantsUsedBitmap[256];
1161     /* FIXME: This needs to be populated with some flags of VS_CONSTANT_NOT_USED, VS_CONSTANT_CONSTANT, VS_CONSTANT_INTEGER, VS_CONSTANT_BOOLEAN, VS_CONSTANT_FLOAT, a half byte bitmap will be the best option, but I'll keep it as chards for siplicity */
1162     /* run time datas...  */
1163     VSHADERDATA* data;
1164     GLuint                      prgId;
1165 #if 0 /* needs reworking */
1166     /* run time datas */
1167     VSHADERINPUTDATA input;
1168     VSHADEROUTPUTDATA output;
1169 #endif
1170 } IWineD3DVertexShaderImpl;
1171 extern const IWineD3DVertexShaderVtbl IWineD3DVertexShader_Vtbl;
1172
1173 /*****************************************************************************
1174  * IDirect3DPixelShader implementation structure
1175  */
1176 typedef struct IWineD3DPixelShaderImpl {
1177     /* IUnknown parts */
1178     const IWineD3DPixelShaderVtbl *lpVtbl;
1179     LONG                        ref;     /* Note: Ref counting not required */
1180
1181     IUnknown                   *parent;
1182     IWineD3DDeviceImpl         *wineD3DDevice;
1183
1184     /* IWineD3DPixelShaderImpl */
1185     CONST DWORD                *function;
1186     UINT                        functionLength;
1187     DWORD                       version;
1188
1189     /* run time data */
1190     PSHADERDATA                *data;
1191
1192 #if 0 /* needs reworking */
1193     PSHADERINPUTDATA input;
1194     PSHADEROUTPUTDATA output;
1195 #endif
1196 } IWineD3DPixelShaderImpl;
1197
1198 extern const IWineD3DPixelShaderVtbl IWineD3DPixelShader_Vtbl;
1199 #endif