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