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