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