msi: Change an ERR to a WARN.
[wine.git] / dlls / wined3d / wined3d_private.h
blobb3dc283c7520464a8f899c7985d29722c25a62e5
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, 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 "ddraw.h"
43 #include "wine/wined3d_interface.h"
44 #include "wine/wined3d_gl.h"
45 #include "wine/list.h"
47 /* Device caps */
48 #define MAX_PALETTES 256
49 #define MAX_STREAMS 16
50 #define MAX_TEXTURES 8
51 #define MAX_SAMPLERS 16
52 #define MAX_ACTIVE_LIGHTS 8
53 #define MAX_CLIPPLANES D3DMAXUSERCLIPPLANES
54 #define MAX_LEVELS 256
56 #define MAX_CONST_I 16
57 #define MAX_CONST_B 16
59 /* Used for CreateStateBlock */
60 #define NUM_SAVEDPIXELSTATES_R 35
61 #define NUM_SAVEDPIXELSTATES_T 18
62 #define NUM_SAVEDPIXELSTATES_S 12
63 #define NUM_SAVEDVERTEXSTATES_R 31
64 #define NUM_SAVEDVERTEXSTATES_T 2
65 #define NUM_SAVEDVERTEXSTATES_S 1
67 extern const DWORD SavedPixelStates_R[NUM_SAVEDPIXELSTATES_R];
68 extern const DWORD SavedPixelStates_T[NUM_SAVEDPIXELSTATES_T];
69 extern const DWORD SavedPixelStates_S[NUM_SAVEDPIXELSTATES_S];
70 extern const DWORD SavedVertexStates_R[NUM_SAVEDVERTEXSTATES_R];
71 extern const DWORD SavedVertexStates_T[NUM_SAVEDVERTEXSTATES_T];
72 extern const DWORD SavedVertexStates_S[NUM_SAVEDVERTEXSTATES_S];
74 typedef enum _WINELOOKUP {
75 WINELOOKUP_WARPPARAM = 0,
76 WINELOOKUP_MAGFILTER = 1,
77 MAX_LOOKUPS = 2
78 } WINELOOKUP;
80 extern int minLookup[MAX_LOOKUPS];
81 extern int maxLookup[MAX_LOOKUPS];
82 extern DWORD *stateLookup[MAX_LOOKUPS];
84 extern DWORD minMipLookup[D3DTEXF_ANISOTROPIC + 1][D3DTEXF_LINEAR + 1];
86 typedef struct _WINED3DGLTYPE {
87 int d3dType;
88 GLint size;
89 GLenum glType;
90 GLboolean normalized;
91 int typesize;
92 } WINED3DGLTYPE;
94 /* NOTE: Make sure these are in the correct numerical order. (see /include/d3d9types.h typedef enum _D3DDECLTYPE) */
95 static WINED3DGLTYPE const glTypeLookup[D3DDECLTYPE_UNUSED] = {
96 {D3DDECLTYPE_FLOAT1, 1, GL_FLOAT , GL_FALSE ,sizeof(float)},
97 {D3DDECLTYPE_FLOAT2, 2, GL_FLOAT , GL_FALSE ,sizeof(float)},
98 {D3DDECLTYPE_FLOAT3, 3, GL_FLOAT , GL_FALSE ,sizeof(float)},
99 {D3DDECLTYPE_FLOAT4, 4, GL_FLOAT , GL_FALSE ,sizeof(float)},
100 {D3DDECLTYPE_D3DCOLOR, 4, GL_UNSIGNED_BYTE , GL_TRUE ,sizeof(BYTE)},
101 {D3DDECLTYPE_UBYTE4, 4, GL_UNSIGNED_BYTE , GL_FALSE ,sizeof(BYTE)},
102 {D3DDECLTYPE_SHORT2, 2, GL_SHORT , GL_FALSE ,sizeof(short int)},
103 {D3DDECLTYPE_SHORT4, 4, GL_SHORT , GL_FALSE ,sizeof(short int)},
104 {D3DDECLTYPE_UBYTE4N, 4, GL_UNSIGNED_BYTE , GL_FALSE ,sizeof(BYTE)},
105 {D3DDECLTYPE_SHORT2N, 2, GL_SHORT , GL_FALSE ,sizeof(short int)},
106 {D3DDECLTYPE_SHORT4N, 4, GL_SHORT , GL_FALSE ,sizeof(short int)},
107 {D3DDECLTYPE_USHORT2N, 2, GL_UNSIGNED_SHORT , GL_FALSE ,sizeof(short int)},
108 {D3DDECLTYPE_USHORT4N, 4, GL_UNSIGNED_SHORT , GL_FALSE ,sizeof(short int)},
109 {D3DDECLTYPE_UDEC3, 3, GL_UNSIGNED_SHORT , GL_FALSE ,sizeof(short int)},
110 {D3DDECLTYPE_DEC3N, 3, GL_SHORT , GL_FALSE ,sizeof(short int)},
111 {D3DDECLTYPE_FLOAT16_2, 2, GL_FLOAT , GL_FALSE ,sizeof(short int)},
112 {D3DDECLTYPE_FLOAT16_4, 4, GL_FLOAT , GL_FALSE ,sizeof(short int)}};
114 #define WINED3D_ATR_TYPE(type) glTypeLookup[type].d3dType
115 #define WINED3D_ATR_SIZE(type) glTypeLookup[type].size
116 #define WINED3D_ATR_GLTYPE(type) glTypeLookup[type].glType
117 #define WINED3D_ATR_NORMALIZED(type) glTypeLookup[type].normalized
118 #define WINED3D_ATR_TYPESIZE(type) glTypeLookup[type].typesize
121 * Settings
123 #define VS_NONE 0
124 #define VS_HW 1
125 #define VS_SW 2
127 #define PS_NONE 0
128 #define PS_HW 1
130 #define VBO_NONE 0
131 #define VBO_HW 1
133 #define NP2_NONE 0
134 #define NP2_REPACK 1
136 #define SHADER_SW 0
137 #define SHADER_ARB 1
138 #define SHADER_GLSL 2
139 #define SHADER_NONE 3
141 #define RTL_DISABLE -1
142 #define RTL_AUTO 0
143 #define RTL_READDRAW 1
144 #define RTL_READTEX 2
145 #define RTL_TEXDRAW 3
146 #define RTL_TEXTEX 4
148 typedef struct wined3d_settings_s {
149 /* vertex and pixel shader modes */
150 int vs_mode;
151 int ps_mode;
152 int vbo_mode;
153 /* Ideally, we don't want the user to have to request GLSL. If the hardware supports GLSL,
154 we should use it. However, until it's fully implemented, we'll leave it as a registry
155 setting for developers. */
156 BOOL glslRequested;
157 int vs_selected_mode;
158 int ps_selected_mode;
159 /* nonpower 2 function */
160 int nonpower2_mode;
161 int rendertargetlock_mode;
162 } wined3d_settings_t;
164 extern wined3d_settings_t wined3d_settings;
166 /* X11 locking */
168 extern void (*wine_tsx11_lock_ptr)(void);
169 extern void (*wine_tsx11_unlock_ptr)(void);
171 /* As GLX relies on X, this is needed */
172 extern int num_lock;
174 #if 0
175 #define ENTER_GL() ++num_lock; if (num_lock > 1) FIXME("Recursive use of GL lock to: %d\n", num_lock); wine_tsx11_lock_ptr()
176 #define LEAVE_GL() if (num_lock != 1) FIXME("Recursive use of GL lock: %d\n", num_lock); --num_lock; wine_tsx11_unlock_ptr()
177 #else
178 #define ENTER_GL() wine_tsx11_lock_ptr()
179 #define LEAVE_GL() wine_tsx11_unlock_ptr()
180 #endif
182 /*****************************************************************************
183 * Defines
186 /* GL related defines */
187 /* ------------------ */
188 #define GL_SUPPORT(ExtName) (GLINFO_LOCATION.supported[ExtName] != 0)
189 #define GL_LIMITS(ExtName) (GLINFO_LOCATION.max_##ExtName)
190 #define GL_EXTCALL(FuncName) (GLINFO_LOCATION.FuncName)
191 #define GL_VEND(_VendName) (GLINFO_LOCATION.gl_vendor == VENDOR_##_VendName ? TRUE : FALSE)
193 #define D3DCOLOR_B_R(dw) (((dw) >> 16) & 0xFF)
194 #define D3DCOLOR_B_G(dw) (((dw) >> 8) & 0xFF)
195 #define D3DCOLOR_B_B(dw) (((dw) >> 0) & 0xFF)
196 #define D3DCOLOR_B_A(dw) (((dw) >> 24) & 0xFF)
198 #define D3DCOLOR_R(dw) (((float) (((dw) >> 16) & 0xFF)) / 255.0f)
199 #define D3DCOLOR_G(dw) (((float) (((dw) >> 8) & 0xFF)) / 255.0f)
200 #define D3DCOLOR_B(dw) (((float) (((dw) >> 0) & 0xFF)) / 255.0f)
201 #define D3DCOLOR_A(dw) (((float) (((dw) >> 24) & 0xFF)) / 255.0f)
203 #define D3DCOLORTOGLFLOAT4(dw, vec) \
204 (vec)[0] = D3DCOLOR_R(dw); \
205 (vec)[1] = D3DCOLOR_G(dw); \
206 (vec)[2] = D3DCOLOR_B(dw); \
207 (vec)[3] = D3DCOLOR_A(dw);
209 #define GLTEXTURECUBEMAP GL_TEXTURE_CUBE_MAP_ARB
211 /* DirectX Device Limits */
212 /* --------------------- */
213 #define MAX_LEVELS 256 /* Maximum number of mipmap levels. Guessed at 256 */
215 #define MAX_STREAMS 16 /* Maximum possible streams - used for fixed size arrays
216 See MaxStreams in MSDN under GetDeviceCaps */
217 /* Maximum number of constants provided to the shaders */
218 #define HIGHEST_TRANSFORMSTATE 512
219 /* Highest value in D3DTRANSFORMSTATETYPE */
220 #define MAX_CLIPPLANES D3DMAXUSERCLIPPLANES
222 #define MAX_PALETTES 256
224 /* Checking of API calls */
225 /* --------------------- */
226 #define checkGLcall(A) \
228 GLint err = glGetError(); \
229 if (err == GL_NO_ERROR) { \
230 TRACE("%s call ok %s / %d\n", A, __FILE__, __LINE__); \
232 } else do { \
233 FIXME(">>>>>>>>>>>>>>>>> %x from %s @ %s / %d\n", \
234 err, A, __FILE__, __LINE__); \
235 err = glGetError(); \
236 } while (err != GL_NO_ERROR); \
239 /* Trace routines / diagnostics */
240 /* ---------------------------- */
242 /* Dump out a matrix and copy it */
243 #define conv_mat(mat,gl_mat) \
244 do { \
245 TRACE("%f %f %f %f\n", (mat)->u.s._11, (mat)->u.s._12, (mat)->u.s._13, (mat)->u.s._14); \
246 TRACE("%f %f %f %f\n", (mat)->u.s._21, (mat)->u.s._22, (mat)->u.s._23, (mat)->u.s._24); \
247 TRACE("%f %f %f %f\n", (mat)->u.s._31, (mat)->u.s._32, (mat)->u.s._33, (mat)->u.s._34); \
248 TRACE("%f %f %f %f\n", (mat)->u.s._41, (mat)->u.s._42, (mat)->u.s._43, (mat)->u.s._44); \
249 memcpy(gl_mat, (mat), 16 * sizeof(float)); \
250 } while (0)
252 /* Macro to dump out the current state of the light chain */
253 #define DUMP_LIGHT_CHAIN() \
255 PLIGHTINFOEL *el = This->stateBlock->lights;\
256 while (el) { \
257 TRACE("Light %p (glIndex %ld, d3dIndex %ld, enabled %d)\n", el, el->glIndex, el->OriginalIndex, el->lightEnabled);\
258 el = el->next; \
262 /* Trace vector and strided data information */
263 #define TRACE_VECTOR(name) TRACE( #name "=(%f, %f, %f, %f)\n", name.x, name.y, name.z, name.w);
264 #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);
266 /* Defines used for optimizations */
268 /* Only reapply what is necessary */
269 #define REAPPLY_ALPHAOP 0x0001
270 #define REAPPLY_ALL 0xFFFF
272 /* Advance declaration of structures to satisfy compiler */
273 typedef struct IWineD3DStateBlockImpl IWineD3DStateBlockImpl;
274 typedef struct IWineD3DSurfaceImpl IWineD3DSurfaceImpl;
275 typedef struct IWineD3DPaletteImpl IWineD3DPaletteImpl;
277 /* Tracking */
279 /* TODO: Move some of this to the device */
280 long globalChangeGlRam(long glram);
282 /* Memory and object tracking */
284 /*Structure for holding information on all direct3d objects
285 useful for making sure tracking is ok and when release is called on a device!
286 and probably quite handy for debugging and dumping states out
288 typedef struct WineD3DGlobalStatistics {
289 int glsurfaceram; /* The aproximate amount of glTexture memory allocated for textures */
290 } WineD3DGlobalStatistics;
292 extern WineD3DGlobalStatistics* wineD3DGlobalStatistics;
294 /* Global variables */
295 extern const float identity[16];
297 /*****************************************************************************
298 * Compilable extra diagnostics
301 /* Trace information per-vertex: (extremely high amount of trace) */
302 #if 0 /* NOTE: Must be 0 in cvs */
303 # define VTRACE(A) TRACE A
304 #else
305 # define VTRACE(A)
306 #endif
308 /* Checking of per-vertex related GL calls */
309 /* --------------------- */
310 #define vcheckGLcall(A) \
312 GLint err = glGetError(); \
313 if (err == GL_NO_ERROR) { \
314 VTRACE(("%s call ok %s / %d\n", A, __FILE__, __LINE__)); \
316 } else do { \
317 FIXME(">>>>>>>>>>>>>>>>> %x from %s @ %s / %d\n", \
318 err, A, __FILE__, __LINE__); \
319 err = glGetError(); \
320 } while (err != GL_NO_ERROR); \
323 /* TODO: Confirm each of these works when wined3d move completed */
324 #if 0 /* NOTE: Must be 0 in cvs */
325 /* To avoid having to get gigabytes of trace, the following can be compiled in, and at the start
326 of each frame, a check is made for the existence of C:\D3DTRACE, and if if exists d3d trace
327 is enabled, and if it doesn't exists it is disabled. */
328 # define FRAME_DEBUGGING
329 /* Adding in the SINGLE_FRAME_DEBUGGING gives a trace of just what makes up a single frame, before
330 the file is deleted */
331 # if 1 /* NOTE: Must be 1 in cvs, as this is mostly more useful than a trace from program start */
332 # define SINGLE_FRAME_DEBUGGING
333 # endif
334 /* The following, when enabled, lets you see the makeup of the frame, by drawprimitive calls.
335 It can only be enabled when FRAME_DEBUGGING is also enabled
336 The contents of the back buffer are written into /tmp/backbuffer_* after each primitive
337 array is drawn. */
338 # if 0 /* NOTE: Must be 0 in cvs, as this give a lot of ppm files when compiled in */
339 # define SHOW_FRAME_MAKEUP 1
340 # endif
341 /* The following, when enabled, lets you see the makeup of the all the textures used during each
342 of the drawprimitive calls. It can only be enabled when SHOW_FRAME_MAKEUP is also enabled.
343 The contents of the textures assigned to each stage are written into
344 /tmp/texture_*_<Stage>.ppm after each primitive array is drawn. */
345 # if 0 /* NOTE: Must be 0 in cvs, as this give a lot of ppm files when compiled in */
346 # define SHOW_TEXTURE_MAKEUP 0
347 # endif
348 extern BOOL isOn;
349 extern BOOL isDumpingFrames;
350 extern LONG primCounter;
351 #endif
353 /*****************************************************************************
354 * Prototypes
357 /* Routine common to the draw primitive and draw indexed primitive routines */
358 void drawPrimitive(IWineD3DDevice *iface,
359 int PrimitiveType,
360 long NumPrimitives,
361 /* for Indexed: */
362 long StartVertexIndex,
363 UINT numberOfVertices,
364 long StartIdx,
365 short idxBytes,
366 const void *idxData,
367 int minIndex,
368 WineDirect3DVertexStridedData *DrawPrimStrideData);
370 void primitiveConvertToStridedData(IWineD3DDevice *iface, WineDirect3DVertexStridedData *strided, LONG BaseVertexIndex, BOOL *fixup);
372 void primitiveDeclarationConvertToStridedData(
373 IWineD3DDevice *iface,
374 BOOL useVertexShaderFunction,
375 WineDirect3DVertexStridedData *strided,
376 LONG BaseVertexIndex,
377 BOOL *fixup);
379 void primitiveConvertFVFtoOffset(DWORD thisFVF,
380 DWORD stride,
381 BYTE *data,
382 WineDirect3DVertexStridedData *strided,
383 GLint streamVBO);
385 DWORD get_flexible_vertex_size(DWORD d3dvtVertexType);
387 #define eps 1e-8
389 #define GET_TEXCOORD_SIZE_FROM_FVF(d3dvtVertexType, tex_num) \
390 (((((d3dvtVertexType) >> (16 + (2 * (tex_num)))) + 1) & 0x03) + 1)
392 /* Routine to fill gl caps for swapchains and IWineD3D */
393 BOOL IWineD3DImpl_FillGLCaps(IWineD3D *iface, Display* display);
395 /*****************************************************************************
396 * Internal representation of a light
398 typedef struct PLIGHTINFOEL PLIGHTINFOEL;
399 struct PLIGHTINFOEL {
400 WINED3DLIGHT OriginalParms; /* Note D3D8LIGHT == D3D9LIGHT */
401 DWORD OriginalIndex;
402 LONG glIndex;
403 BOOL lightEnabled;
404 BOOL changed;
405 BOOL enabledChanged;
407 /* Converted parms to speed up swapping lights */
408 float lightPosn[4];
409 float lightDirn[4];
410 float exponent;
411 float cutoff;
413 PLIGHTINFOEL *next;
414 PLIGHTINFOEL *prev;
417 /* The default light parameters */
418 extern const WINED3DLIGHT WINED3D_default_light;
420 /*****************************************************************************
421 * IWineD3D implementation structure
423 typedef struct IWineD3DImpl
425 /* IUnknown fields */
426 const IWineD3DVtbl *lpVtbl;
427 LONG ref; /* Note: Ref counting not required */
429 /* WineD3D Information */
430 IUnknown *parent;
431 UINT dxVersion;
433 /* GL Information */
434 BOOL isGLInfoValid;
435 WineD3D_GL_Info gl_info;
436 } IWineD3DImpl;
438 extern const IWineD3DVtbl IWineD3D_Vtbl;
440 /** Hacked out start of a context manager!! **/
441 typedef struct glContext {
442 int Width;
443 int Height;
444 int usedcount;
445 GLXContext context;
447 Drawable drawable;
448 IWineD3DSurface *pSurface;
449 #if 0 /* TODO: someway to represent the state of the context */
450 IWineD3DStateBlock *pStateBlock;
451 #endif
452 /* a few other things like format */
453 } glContext;
455 /* TODO: setup some flags in the regestry to enable, disable pbuffer support
456 (since it will break quite a few things until contexts are managed properly!) */
457 extern BOOL pbuffer_support;
458 /* allocate one pbuffer per surface */
459 extern BOOL pbuffer_per_surface;
461 /* Maximum number of contexts/pbuffers to keep in cache,
462 set to 100 because ATI's drivers don't support deleting pBuffers properly
463 this needs to be migrated to a list and some option availalbe for controle the cache size.
465 #define CONTEXT_CACHE 100
467 typedef struct ResourceList {
468 IWineD3DResource *resource;
469 struct ResourceList *next;
470 } ResourceList;
472 /* A helper function that dumps a resource list */
473 void dumpResources(ResourceList *resources);
475 /*****************************************************************************
476 * IWineD3DDevice implementation structure
478 typedef struct IWineD3DDeviceImpl
480 /* IUnknown fields */
481 const IWineD3DDeviceVtbl *lpVtbl;
482 LONG ref; /* Note: Ref counting not required */
484 /* WineD3D Information */
485 IUnknown *parent;
486 IWineD3D *wineD3D;
488 /* X and GL Information */
489 GLint maxConcurrentLights;
491 /* Optimization */
492 BOOL modelview_valid;
493 BOOL proj_valid;
494 BOOL view_ident; /* true iff view matrix is identity */
495 BOOL last_was_rhw; /* true iff last draw_primitive was in xyzrhw mode */
496 BOOL viewport_changed; /* Was the viewport changed since the last draw? */
497 GLenum tracking_parm; /* Which source is tracking current colour */
498 LONG tracking_color; /* used iff GL_COLOR_MATERIAL was enabled */
499 #define DISABLED_TRACKING 0 /* Disabled */
500 #define IS_TRACKING 1 /* tracking_parm is tracking diffuse color */
501 #define NEEDS_TRACKING 2 /* Tracking needs to be enabled when needed */
502 #define NEEDS_DISABLE 3 /* Tracking needs to be disabled when needed*/
503 UINT srcBlend;
504 UINT dstBlend;
505 UINT alphafunc;
506 BOOL texture_shader_active; /* TODO: Confirm use is correct */
507 BOOL last_was_notclipped;
509 /* State block related */
510 BOOL isRecordingState;
511 IWineD3DStateBlockImpl *stateBlock;
512 IWineD3DStateBlockImpl *updateStateBlock;
514 /* Internal use fields */
515 WINED3DDEVICE_CREATION_PARAMETERS createParms;
516 UINT adapterNo;
517 D3DDEVTYPE devType;
519 IWineD3DSwapChain **swapchains;
520 uint NumberOfSwapChains;
522 ResourceList *resources; /* a linked list to track resources created by the device */
524 /* Render Target Support */
525 IWineD3DSurface *depthStencilBuffer;
527 IWineD3DSurface *renderTarget;
528 IWineD3DSurface *stencilBufferTarget;
530 /* palettes texture management */
531 PALETTEENTRY palettes[MAX_PALETTES][256];
532 UINT currentPalette;
534 /* For rendering to a texture using glCopyTexImage */
535 BOOL renderUpsideDown;
537 /* Cursor management */
538 BOOL bCursorVisible;
539 UINT xHotSpot;
540 UINT yHotSpot;
541 UINT xScreenSpace;
542 UINT yScreenSpace;
543 UINT cursorWidth, cursorHeight;
544 GLuint cursorTexture;
546 /* Textures for when no other textures are mapped */
547 UINT dummyTextureName[MAX_TEXTURES];
549 /* Debug stream management */
550 BOOL debug;
552 /* Device state management */
553 HRESULT state;
554 BOOL d3d_initialized;
556 /* Screen buffer resources */
557 glContext contextCache[CONTEXT_CACHE];
559 /* A flag to check if endscene has been called before changing the render tartet */
560 BOOL sceneEnded;
562 /* process vertex shaders using software or hardware */
563 BOOL softwareVertexProcessing;
565 /* DirectDraw stuff */
566 HWND ddraw_window;
567 IWineD3DSurface *ddraw_primary;
568 DWORD ddraw_width, ddraw_height;
569 WINED3DFORMAT ddraw_format;
571 /* List of GLSL shader programs and their associated vertex & pixel shaders */
572 struct list glsl_shader_progs;
574 } IWineD3DDeviceImpl;
576 extern const IWineD3DDeviceVtbl IWineD3DDevice_Vtbl;
578 /* Support for IWineD3DResource ::Set/Get/FreePrivateData. I don't think
579 * anybody uses it for much so a good implementation is optional. */
580 typedef struct PrivateData
582 struct PrivateData* next;
584 GUID tag;
585 DWORD flags; /* DDSPD_* */
586 DWORD uniqueness_value;
588 union
590 LPVOID data;
591 LPUNKNOWN object;
592 } ptr;
594 DWORD size;
595 } PrivateData;
597 void d3ddevice_set_ortho(IWineD3DDeviceImpl *This);
599 /*****************************************************************************
600 * IWineD3DResource implementation structure
602 typedef struct IWineD3DResourceClass
604 /* IUnknown fields */
605 LONG ref; /* Note: Ref counting not required */
607 /* WineD3DResource Information */
608 IUnknown *parent;
609 WINED3DRESOURCETYPE resourceType;
610 IWineD3DDeviceImpl *wineD3DDevice;
611 WINED3DPOOL pool;
612 UINT size;
613 DWORD usage;
614 WINED3DFORMAT format;
615 BYTE *allocatedMemory;
616 PrivateData *privateData;
618 } IWineD3DResourceClass;
620 typedef struct IWineD3DResourceImpl
622 /* IUnknown & WineD3DResource Information */
623 const IWineD3DResourceVtbl *lpVtbl;
624 IWineD3DResourceClass resource;
625 } IWineD3DResourceImpl;
628 /*****************************************************************************
629 * IWineD3DVertexBuffer implementation structure (extends IWineD3DResourceImpl)
631 typedef struct IWineD3DVertexBufferImpl
633 /* IUnknown & WineD3DResource Information */
634 const IWineD3DVertexBufferVtbl *lpVtbl;
635 IWineD3DResourceClass resource;
637 /* WineD3DVertexBuffer specifics */
638 DWORD fvf;
640 /* Vertex buffer object support */
641 GLuint vbo;
642 BYTE Flags;
643 UINT stream;
645 UINT dirtystart, dirtyend;
646 LONG lockcount;
648 /* Last description of the buffer */
649 WineDirect3DVertexStridedData strided;
650 } IWineD3DVertexBufferImpl;
652 extern const IWineD3DVertexBufferVtbl IWineD3DVertexBuffer_Vtbl;
654 #define VBFLAG_LOAD 0x01 /* Data is written from allocatedMemory to the VBO */
655 #define VBFLAG_OPTIMIZED 0x02 /* Optimize has been called for the VB */
656 #define VBFLAG_DIRTY 0x04 /* Buffer data has been modified */
657 #define VBFLAG_STREAM 0x08 /* The vertex buffer is in a stream */
658 #define VBFLAG_HASDESC 0x10 /* A vertex description has been found */
659 #define VBFLAG_VBOCREATEFAIL 0x20 /* An attempt to create a vbo has failed */
661 /*****************************************************************************
662 * IWineD3DIndexBuffer implementation structure (extends IWineD3DResourceImpl)
664 typedef struct IWineD3DIndexBufferImpl
666 /* IUnknown & WineD3DResource Information */
667 const IWineD3DIndexBufferVtbl *lpVtbl;
668 IWineD3DResourceClass resource;
670 /* WineD3DVertexBuffer specifics */
671 } IWineD3DIndexBufferImpl;
673 extern const IWineD3DIndexBufferVtbl IWineD3DIndexBuffer_Vtbl;
675 /*****************************************************************************
676 * IWineD3DBaseTexture D3D- > openGL state map lookups
678 #define WINED3DFUNC_NOTSUPPORTED -2
679 #define WINED3DFUNC_UNIMPLEMENTED -1
681 typedef enum winetexturestates {
682 WINED3DTEXSTA_ADDRESSU = 0,
683 WINED3DTEXSTA_ADDRESSV = 1,
684 WINED3DTEXSTA_ADDRESSW = 2,
685 WINED3DTEXSTA_BORDERCOLOR = 3,
686 WINED3DTEXSTA_MAGFILTER = 4,
687 WINED3DTEXSTA_MINFILTER = 5,
688 WINED3DTEXSTA_MIPFILTER = 6,
689 WINED3DTEXSTA_MAXMIPLEVEL = 7,
690 WINED3DTEXSTA_MAXANISOTROPY = 8,
691 WINED3DTEXSTA_SRGBTEXTURE = 9,
692 WINED3DTEXSTA_ELEMENTINDEX = 10,
693 WINED3DTEXSTA_DMAPOFFSET = 11,
694 WINED3DTEXSTA_TSSADDRESSW = 12,
695 MAX_WINETEXTURESTATES = 13,
696 } winetexturestates;
698 typedef struct Wined3dTextureStateMap {
699 CONST int state;
700 int function;
701 } Wined3dTextureStateMap;
703 /*****************************************************************************
704 * IWineD3DBaseTexture implementation structure (extends IWineD3DResourceImpl)
706 typedef struct IWineD3DBaseTextureClass
708 UINT levels;
709 BOOL dirty;
710 D3DFORMAT format;
711 DWORD usage;
712 UINT textureName;
713 UINT LOD;
714 WINED3DTEXTUREFILTERTYPE filterType;
715 DWORD states[MAX_WINETEXTURESTATES];
717 } IWineD3DBaseTextureClass;
719 typedef struct IWineD3DBaseTextureImpl
721 /* IUnknown & WineD3DResource Information */
722 const IWineD3DBaseTextureVtbl *lpVtbl;
723 IWineD3DResourceClass resource;
724 IWineD3DBaseTextureClass baseTexture;
726 } IWineD3DBaseTextureImpl;
728 /*****************************************************************************
729 * IWineD3DTexture implementation structure (extends IWineD3DBaseTextureImpl)
731 typedef struct IWineD3DTextureImpl
733 /* IUnknown & WineD3DResource/WineD3DBaseTexture Information */
734 const IWineD3DTextureVtbl *lpVtbl;
735 IWineD3DResourceClass resource;
736 IWineD3DBaseTextureClass baseTexture;
738 /* IWineD3DTexture */
739 IWineD3DSurface *surfaces[MAX_LEVELS];
741 UINT width;
742 UINT height;
743 float pow2scalingFactorX;
744 float pow2scalingFactorY;
746 } IWineD3DTextureImpl;
748 extern const IWineD3DTextureVtbl IWineD3DTexture_Vtbl;
750 /*****************************************************************************
751 * IWineD3DCubeTexture implementation structure (extends IWineD3DBaseTextureImpl)
753 typedef struct IWineD3DCubeTextureImpl
755 /* IUnknown & WineD3DResource/WineD3DBaseTexture Information */
756 const IWineD3DCubeTextureVtbl *lpVtbl;
757 IWineD3DResourceClass resource;
758 IWineD3DBaseTextureClass baseTexture;
760 /* IWineD3DCubeTexture */
761 IWineD3DSurface *surfaces[6][MAX_LEVELS];
763 UINT edgeLength;
764 float pow2scalingFactor;
766 } IWineD3DCubeTextureImpl;
768 extern const IWineD3DCubeTextureVtbl IWineD3DCubeTexture_Vtbl;
770 typedef struct _WINED3DVOLUMET_DESC
772 UINT Width;
773 UINT Height;
774 UINT Depth;
775 } WINED3DVOLUMET_DESC;
777 /*****************************************************************************
778 * IWineD3DVolume implementation structure (extends IUnknown)
780 typedef struct IWineD3DVolumeImpl
782 /* IUnknown & WineD3DResource fields */
783 const IWineD3DVolumeVtbl *lpVtbl;
784 IWineD3DResourceClass resource;
786 /* WineD3DVolume Information */
787 WINED3DVOLUMET_DESC currentDesc;
788 IWineD3DBase *container;
789 UINT bytesPerPixel;
791 BOOL lockable;
792 BOOL locked;
793 WINED3DBOX lockedBox;
794 WINED3DBOX dirtyBox;
795 BOOL dirty;
798 } IWineD3DVolumeImpl;
800 extern const IWineD3DVolumeVtbl IWineD3DVolume_Vtbl;
802 /*****************************************************************************
803 * IWineD3DVolumeTexture implementation structure (extends IWineD3DBaseTextureImpl)
805 typedef struct IWineD3DVolumeTextureImpl
807 /* IUnknown & WineD3DResource/WineD3DBaseTexture Information */
808 const IWineD3DVolumeTextureVtbl *lpVtbl;
809 IWineD3DResourceClass resource;
810 IWineD3DBaseTextureClass baseTexture;
812 /* IWineD3DVolumeTexture */
813 IWineD3DVolume *volumes[MAX_LEVELS];
815 UINT width;
816 UINT height;
817 UINT depth;
818 } IWineD3DVolumeTextureImpl;
820 extern const IWineD3DVolumeTextureVtbl IWineD3DVolumeTexture_Vtbl;
822 typedef struct _WINED3DSURFACET_DESC
824 WINED3DMULTISAMPLE_TYPE MultiSampleType;
825 DWORD MultiSampleQuality;
826 UINT Width;
827 UINT Height;
828 } WINED3DSURFACET_DESC;
830 /*****************************************************************************
831 * Structure for DIB Surfaces (GetDC and GDI surfaces)
833 typedef struct wineD3DSurface_DIB {
834 HBITMAP DIBsection;
835 void* bitmap_data;
836 HGDIOBJ holdbitmap;
837 BOOL client_memory;
838 } wineD3DSurface_DIB;
840 /*****************************************************************************
841 * IWineD3DSurface implementation structure
843 struct IWineD3DSurfaceImpl
845 /* IUnknown & IWineD3DResource Information */
846 const IWineD3DSurfaceVtbl *lpVtbl;
847 IWineD3DResourceClass resource;
849 /* IWineD3DSurface fields */
850 IWineD3DBase *container;
851 WINED3DSURFACET_DESC currentDesc;
852 IWineD3DPaletteImpl *palette;
854 UINT textureName;
855 UINT bytesPerPixel;
857 /* TODO: move this off into a management class(maybe!) */
858 DWORD Flags;
860 UINT pow2Width;
861 UINT pow2Height;
862 UINT pow2Size;
864 /* Oversized texture */
865 RECT glRect;
867 #if 0
868 /* precalculated x and y scalings for texture coords */
869 float pow2scalingFactorX; /* = (Width / pow2Width ) */
870 float pow2scalingFactorY; /* = (Height / pow2Height) */
871 #endif
873 RECT lockedRect;
874 RECT dirtyRect;
876 glDescriptor glDescription;
878 /* For GetDC */
879 wineD3DSurface_DIB dib;
880 HDC hDC;
882 /* Color keys for DDraw */
883 DDCOLORKEY DestBltCKey;
884 DDCOLORKEY DestOverlayCKey;
885 DDCOLORKEY SrcOverlayCKey;
886 DDCOLORKEY SrcBltCKey;
887 DWORD CKeyFlags;
889 DDCOLORKEY glCKey;
892 extern const IWineD3DSurfaceVtbl IWineD3DSurface_Vtbl;
893 extern const IWineD3DSurfaceVtbl IWineGDISurface_Vtbl;
895 /* Predeclare the shared Surface functions */
896 HRESULT WINAPI IWineD3DSurfaceImpl_QueryInterface(IWineD3DSurface *iface, REFIID riid, LPVOID *ppobj);
897 ULONG WINAPI IWineD3DSurfaceImpl_AddRef(IWineD3DSurface *iface);
898 ULONG WINAPI IWineD3DSurfaceImpl_Release(IWineD3DSurface *iface);
899 HRESULT WINAPI IWineD3DSurfaceImpl_GetParent(IWineD3DSurface *iface, IUnknown **pParent);
900 HRESULT WINAPI IWineD3DSurfaceImpl_GetDevice(IWineD3DSurface *iface, IWineD3DDevice** ppDevice);
901 HRESULT WINAPI IWineD3DSurfaceImpl_SetPrivateData(IWineD3DSurface *iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags);
902 HRESULT WINAPI IWineD3DSurfaceImpl_GetPrivateData(IWineD3DSurface *iface, REFGUID refguid, void* pData, DWORD* pSizeOfData);
903 HRESULT WINAPI IWineD3DSurfaceImpl_FreePrivateData(IWineD3DSurface *iface, REFGUID refguid);
904 DWORD WINAPI IWineD3DSurfaceImpl_SetPriority(IWineD3DSurface *iface, DWORD PriorityNew);
905 DWORD WINAPI IWineD3DSurfaceImpl_GetPriority(IWineD3DSurface *iface);
906 void WINAPI IWineD3DSurfaceImpl_PreLoad(IWineD3DSurface *iface);
907 WINED3DRESOURCETYPE WINAPI IWineD3DSurfaceImpl_GetType(IWineD3DSurface *iface);
908 HRESULT WINAPI IWineD3DSurfaceImpl_GetContainerParent(IWineD3DSurface* iface, IUnknown **ppContainerParent);
909 HRESULT WINAPI IWineD3DSurfaceImpl_GetContainer(IWineD3DSurface* iface, REFIID riid, void** ppContainer);
910 HRESULT WINAPI IWineD3DSurfaceImpl_GetDesc(IWineD3DSurface *iface, WINED3DSURFACE_DESC *pDesc);
911 HRESULT WINAPI IWineD3DSurfaceImpl_GetBltStatus(IWineD3DSurface *iface, DWORD Flags);
912 HRESULT WINAPI IWineD3DSurfaceImpl_GetFlipStatus(IWineD3DSurface *iface, DWORD Flags);
913 HRESULT WINAPI IWineD3DSurfaceImpl_IsLost(IWineD3DSurface *iface);
914 HRESULT WINAPI IWineD3DSurfaceImpl_Restore(IWineD3DSurface *iface);
915 HRESULT WINAPI IWineD3DSurfaceImpl_SetPixelFormat(IWineD3DSurface *iface, WINED3DFORMAT Format, BYTE *Surface, DWORD Size);
916 HRESULT WINAPI IWineD3DSurfaceImpl_GetPalette(IWineD3DSurface *iface, IWineD3DPalette **Pal);
917 HRESULT WINAPI IWineD3DSurfaceImpl_SetPalette(IWineD3DSurface *iface, IWineD3DPalette *Pal);
918 HRESULT WINAPI IWineD3DSurfaceImpl_SetColorKey(IWineD3DSurface *iface, DWORD Flags, DDCOLORKEY *CKey);
919 HRESULT WINAPI IWineD3DSurfaceImpl_CleanDirtyRect(IWineD3DSurface *iface);
920 extern HRESULT WINAPI IWineD3DSurfaceImpl_AddDirtyRect(IWineD3DSurface *iface, CONST RECT* pDirtyRect);
921 HRESULT WINAPI IWineD3DSurfaceImpl_SetContainer(IWineD3DSurface *iface, IWineD3DBase *container);
922 HRESULT WINAPI IWineD3DSurfaceImpl_SetPBufferState(IWineD3DSurface *iface, BOOL inPBuffer, BOOL inTexture);
923 void WINAPI IWineD3DSurfaceImpl_SetGlTextureDesc(IWineD3DSurface *iface, UINT textureName, int target);
924 void WINAPI IWineD3DSurfaceImpl_GetGlDesc(IWineD3DSurface *iface, glDescriptor **glDescription);
925 const void *WINAPI IWineD3DSurfaceImpl_GetData(IWineD3DSurface *iface);
926 HRESULT WINAPI IWineD3DSurfaceImpl_SetFormat(IWineD3DSurface *iface, WINED3DFORMAT format);
927 HRESULT WINAPI IWineGDISurfaceImpl_Blt(IWineD3DSurface *iface, RECT *DestRect, IWineD3DSurface *SrcSurface, RECT *SrcRect, DWORD Flags, DDBLTFX *DDBltFx);
928 HRESULT WINAPI IWineGDISurfaceImpl_BltFast(IWineD3DSurface *iface, DWORD dstx, DWORD dsty, IWineD3DSurface *Source, RECT *rsrc, DWORD trans);
929 HRESULT WINAPI IWineD3DSurfaceImpl_SetPalette(IWineD3DSurface *iface, IWineD3DPalette *Pal);
930 HRESULT WINAPI IWineD3DSurfaceImpl_GetDC(IWineD3DSurface *iface, HDC *pHDC);
931 HRESULT WINAPI IWineD3DSurfaceImpl_ReleaseDC(IWineD3DSurface *iface, HDC hDC);
932 DWORD WINAPI IWineD3DSurfaceImpl_GetPitch(IWineD3DSurface *iface);
933 HRESULT WINAPI IWineD3DSurfaceImpl_RealizePalette(IWineD3DSurface *iface);
934 HRESULT WINAPI IWineD3DSurfaceImpl_SetMem(IWineD3DSurface *iface, void *Mem);
936 /* Surface flags: */
937 #define SFLAG_OVERSIZE 0x00000001 /* Surface is bigger than gl size, blts only */
938 #define SFLAG_CONVERTED 0x00000002 /* Converted for color keying or Palettized */
939 #define SFLAG_DIBSECTION 0x00000004 /* Has a DIB section attached for getdc */
940 #define SFLAG_DIRTY 0x00000008 /* Surface was locked by the app */
941 #define SFLAG_LOCKABLE 0x00000010 /* Surface can be locked */
942 #define SFLAG_DISCARD 0x00000020 /* ??? */
943 #define SFLAG_LOCKED 0x00000040 /* Surface is locked atm */
944 #define SFLAG_ACTIVELOCK 0x00000080 /* Not locked, but surface memory is needed */
945 #define SFLAG_INTEXTURE 0x00000100 /* ??? */
946 #define SFLAG_INPBUFFER 0x00000200 /* ??? */
947 #define SFLAG_NONPOW2 0x00000400 /* Surface sizes are not a power of 2 */
948 #define SFLAG_DYNLOCK 0x00000800 /* Surface is often locked by the app */
949 #define SFLAG_DYNCHANGE 0x00001800 /* Surface contents are changed very often, implies DYNLOCK */
950 #define SFLAG_DCINUSE 0x00002000 /* Set between GetDC and ReleaseDC calls */
951 #define SFLAG_GLDIRTY 0x00004000 /* The opengl texture is more up to date than the surface mem */
952 #define SFLAG_LOST 0x00008000 /* Surface lost flag for DDraw */
953 #define SFLAG_FORCELOAD 0x00010000 /* To force PreLoading of a scratch cursor */
954 #define SFLAG_USERPTR 0x00020000 /* The application allocated the memory for this surface */
955 #define SFLAG_GLCKEY 0x00040000 /* The gl texture was created with a color key */
957 /* In some conditions the surface memory must not be freed:
958 * SFLAG_OVERSIZE: Not all data can be kept in GL
959 * SFLAG_CONVERTED: Converting the data back would take too long
960 * SFLAG_DIBSECTION: The dib code manages the memory
961 * SFLAG_DIRTY: GL surface isn't up to date
962 * SFLAG_LOCKED: The app requires access to the surface data
963 * SFLAG_ACTIVELOCK: Some wined3d code needs the memory
964 * SFLAG_DYNLOCK: Avoid freeing the data for performance
965 * SFLAG_DYNCHANGE: Same reason as DYNLOCK
967 #define SFLAG_DONOTFREE (SFLAG_OVERSIZE | \
968 SFLAG_CONVERTED | \
969 SFLAG_DIBSECTION | \
970 SFLAG_DIRTY | \
971 SFLAG_LOCKED | \
972 SFLAG_ACTIVELOCK | \
973 SFLAG_DYNLOCK | \
974 SFLAG_DYNCHANGE | \
975 SFLAG_USERPTR)
977 BOOL CalculateTexRect(IWineD3DSurfaceImpl *This, RECT *Rect, float glTexCoord[4]);
979 /*****************************************************************************
980 * IWineD3DVertexDeclaration implementation structure
982 typedef struct IWineD3DVertexDeclarationImpl {
983 /* IUnknown Information */
984 const IWineD3DVertexDeclarationVtbl *lpVtbl;
985 LONG ref; /* Note: Ref counting not required */
987 IUnknown *parent;
988 /** precomputed fvf if simple declaration */
989 IWineD3DDeviceImpl *wineD3DDevice;
990 DWORD fvf[MAX_STREAMS];
991 DWORD allFVF;
993 /** dx8 compatible Declaration fields */
994 DWORD* pDeclaration8;
995 DWORD declaration8Length;
997 /** dx9+ */
998 D3DVERTEXELEMENT9 *pDeclaration9;
999 UINT declaration9NumElements;
1001 WINED3DVERTEXELEMENT *pDeclarationWine;
1002 UINT declarationWNumElements;
1004 float *constants;
1006 } IWineD3DVertexDeclarationImpl;
1008 extern const IWineD3DVertexDeclarationVtbl IWineD3DVertexDeclaration_Vtbl;
1010 /*****************************************************************************
1011 * IWineD3DStateBlock implementation structure
1014 /* Internal state Block for Begin/End/Capture/Create/Apply info */
1015 /* Note: Very long winded but gl Lists are not flexible enough */
1016 /* to resolve everything we need, so doing it manually for now */
1017 typedef struct SAVEDSTATES {
1018 BOOL indices;
1019 BOOL material;
1020 BOOL fvf;
1021 BOOL streamSource[MAX_STREAMS];
1022 BOOL streamFreq[MAX_STREAMS];
1023 BOOL textures[MAX_SAMPLERS];
1024 BOOL transform[HIGHEST_TRANSFORMSTATE + 1];
1025 BOOL viewport;
1026 BOOL renderState[WINEHIGHEST_RENDER_STATE + 1];
1027 BOOL textureState[MAX_TEXTURES][WINED3D_HIGHEST_TEXTURE_STATE + 1];
1028 BOOL samplerState[MAX_SAMPLERS][WINED3D_HIGHEST_SAMPLER_STATE + 1];
1029 BOOL clipplane[MAX_CLIPPLANES];
1030 BOOL vertexDecl;
1031 BOOL pixelShader;
1032 BOOL pixelShaderConstantsB[MAX_CONST_B];
1033 BOOL pixelShaderConstantsI[MAX_CONST_I];
1034 BOOL *pixelShaderConstantsF;
1035 BOOL vertexShader;
1036 BOOL vertexShaderConstantsB[MAX_CONST_B];
1037 BOOL vertexShaderConstantsI[MAX_CONST_I];
1038 BOOL *vertexShaderConstantsF;
1039 } SAVEDSTATES;
1041 struct IWineD3DStateBlockImpl
1043 /* IUnknown fields */
1044 const IWineD3DStateBlockVtbl *lpVtbl;
1045 LONG ref; /* Note: Ref counting not required */
1047 /* IWineD3DStateBlock information */
1048 IUnknown *parent;
1049 IWineD3DDeviceImpl *wineD3DDevice;
1050 WINED3DSTATEBLOCKTYPE blockType;
1052 /* Array indicating whether things have been set or changed */
1053 SAVEDSTATES changed;
1054 SAVEDSTATES set;
1056 /* Drawing - Vertex Shader or FVF related */
1057 DWORD fvf;
1058 /* Vertex Shader Declaration */
1059 IWineD3DVertexDeclaration *vertexDecl;
1061 IWineD3DVertexShader *vertexShader;
1063 /* Vertex Shader Constants */
1064 BOOL vertexShaderConstantB[MAX_CONST_B];
1065 INT vertexShaderConstantI[MAX_CONST_I * 4];
1066 float *vertexShaderConstantF;
1068 /* Stream Source */
1069 BOOL streamIsUP;
1070 UINT streamStride[MAX_STREAMS];
1071 UINT streamOffset[MAX_STREAMS];
1072 IWineD3DVertexBuffer *streamSource[MAX_STREAMS];
1073 UINT streamFreq[MAX_STREAMS];
1074 UINT streamFlags[MAX_STREAMS]; /*0 | D3DSTREAMSOURCE_INSTANCEDATA | D3DSTREAMSOURCE_INDEXEDDATA */
1076 /* Indices */
1077 IWineD3DIndexBuffer* pIndexData;
1078 UINT baseVertexIndex; /* Note: only used for d3d8 */
1080 /* Transform */
1081 D3DMATRIX transforms[HIGHEST_TRANSFORMSTATE + 1];
1083 /* Lights */
1084 PLIGHTINFOEL *lights; /* NOTE: active GL lights must be front of the chain */
1086 /* Clipping */
1087 double clipplane[MAX_CLIPPLANES][4];
1088 WINED3DCLIPSTATUS clip_status;
1090 /* ViewPort */
1091 WINED3DVIEWPORT viewport;
1093 /* Material */
1094 WINED3DMATERIAL material;
1096 /* Pixel Shader */
1097 IWineD3DPixelShader *pixelShader;
1099 /* Pixel Shader Constants */
1100 BOOL pixelShaderConstantB[MAX_CONST_B];
1101 INT pixelShaderConstantI[MAX_CONST_I * 4];
1102 float *pixelShaderConstantF;
1104 /* Indexed Vertex Blending */
1105 D3DVERTEXBLENDFLAGS vertex_blend;
1106 FLOAT tween_factor;
1108 /* RenderState */
1109 DWORD renderState[WINEHIGHEST_RENDER_STATE + 1];
1111 /* Texture */
1112 IWineD3DBaseTexture *textures[MAX_SAMPLERS];
1113 int textureDimensions[MAX_SAMPLERS];
1115 /* Texture State Stage */
1116 DWORD textureState[MAX_TEXTURES][WINED3D_HIGHEST_TEXTURE_STATE + 1];
1117 /* Sampler States */
1118 DWORD samplerState[MAX_SAMPLERS][WINED3D_HIGHEST_SAMPLER_STATE + 1];
1120 /* Current GLSL Shader Program */
1121 GLhandleARB shaderPrgId;
1124 extern void stateblock_savedstates_set(
1125 IWineD3DStateBlock* iface,
1126 SAVEDSTATES* states,
1127 BOOL value);
1129 extern void stateblock_savedstates_copy(
1130 IWineD3DStateBlock* iface,
1131 SAVEDSTATES* dest,
1132 SAVEDSTATES* source);
1134 extern void stateblock_copy(
1135 IWineD3DStateBlock* destination,
1136 IWineD3DStateBlock* source);
1138 extern const IWineD3DStateBlockVtbl IWineD3DStateBlock_Vtbl;
1140 /*****************************************************************************
1141 * IWineD3DQueryImpl implementation structure (extends IUnknown)
1143 typedef struct IWineD3DQueryImpl
1145 const IWineD3DQueryVtbl *lpVtbl;
1146 LONG ref; /* Note: Ref counting not required */
1148 IUnknown *parent;
1149 /*TODO: replace with iface usage */
1150 #if 0
1151 IWineD3DDevice *wineD3DDevice;
1152 #else
1153 IWineD3DDeviceImpl *wineD3DDevice;
1154 #endif
1155 /* IWineD3DQuery fields */
1157 D3DQUERYTYPE type;
1158 /* TODO: Think about using a IUnknown instead of a void* */
1159 void *extendedData;
1162 } IWineD3DQueryImpl;
1164 extern const IWineD3DQueryVtbl IWineD3DQuery_Vtbl;
1166 /* Datastructures for IWineD3DQueryImpl.extendedData */
1167 typedef struct WineQueryOcclusionData {
1168 GLuint queryId;
1169 } WineQueryOcclusionData;
1172 /*****************************************************************************
1173 * IWineD3DSwapChainImpl implementation structure (extends IUnknown)
1176 typedef struct IWineD3DSwapChainImpl
1178 /*IUnknown part*/
1179 IWineD3DSwapChainVtbl *lpVtbl;
1180 LONG ref; /* Note: Ref counting not required */
1182 IUnknown *parent;
1183 IWineD3DDeviceImpl *wineD3DDevice;
1185 /* IWineD3DSwapChain fields */
1186 IWineD3DSurface **backBuffer;
1187 IWineD3DSurface *frontBuffer;
1188 BOOL wantsDepthStencilBuffer;
1189 D3DPRESENT_PARAMETERS presentParms;
1191 /* TODO: move everything up to drawable off into a context manager
1192 and store the 'data' in the contextManagerData interface.
1193 IUnknown *contextManagerData;
1196 HWND win_handle;
1197 Window win;
1198 Display *display;
1200 GLXContext glCtx;
1201 XVisualInfo *visInfo;
1202 GLXContext render_ctx;
1203 /* This has been left in device for now, but needs moving off into a rendertarget management class and separated out from swapchains and devices. */
1204 Drawable drawable;
1205 } IWineD3DSwapChainImpl;
1207 extern IWineD3DSwapChainVtbl IWineD3DSwapChain_Vtbl;
1209 /*****************************************************************************
1210 * Utility function prototypes
1213 /* Trace routines */
1214 const char* debug_d3dformat(WINED3DFORMAT fmt);
1215 const char* debug_d3ddevicetype(D3DDEVTYPE devtype);
1216 const char* debug_d3dresourcetype(WINED3DRESOURCETYPE res);
1217 const char* debug_d3dusage(DWORD usage);
1218 const char* debug_d3dusagequery(DWORD usagequery);
1219 const char* debug_d3ddeclusage(BYTE usage);
1220 const char* debug_d3dprimitivetype(D3DPRIMITIVETYPE PrimitiveType);
1221 const char* debug_d3drenderstate(DWORD state);
1222 const char* debug_d3dsamplerstate(DWORD state);
1223 const char* debug_d3dtexturestate(DWORD state);
1224 const char* debug_d3dtstype(WINED3DTRANSFORMSTATETYPE tstype);
1225 const char* debug_d3dpool(WINED3DPOOL pool);
1227 /* Routines for GL <-> D3D values */
1228 GLenum StencilOp(DWORD op);
1229 GLenum StencilFunc(DWORD func);
1230 void set_tex_op(IWineD3DDevice *iface, BOOL isAlpha, int Stage, D3DTEXTUREOP op, DWORD arg1, DWORD arg2, DWORD arg3);
1231 void set_tex_op_nvrc(IWineD3DDevice *iface, BOOL is_alpha, int stage, D3DTEXTUREOP op, DWORD arg1, DWORD arg2, DWORD arg3, INT texture_idx);
1232 void set_texture_matrix(const float *smat, DWORD flags, BOOL calculatedCoords);
1234 int D3DFmtMakeGlCfg(D3DFORMAT BackBufferFormat, D3DFORMAT StencilBufferFormat, int *attribs, int* nAttribs, BOOL alternate);
1236 /* Math utils */
1237 void multiply_matrix(D3DMATRIX *dest, D3DMATRIX *src1, D3DMATRIX *src2);
1239 /*****************************************************************************
1240 * To enable calling of inherited functions, requires prototypes
1242 * Note: Only require classes which are subclassed, ie resource, basetexture,
1244 /*** IUnknown methods ***/
1245 extern HRESULT WINAPI IWineD3DResourceImpl_QueryInterface(IWineD3DResource *iface, REFIID riid, void** ppvObject);
1246 extern ULONG WINAPI IWineD3DResourceImpl_AddRef(IWineD3DResource *iface);
1247 extern ULONG WINAPI IWineD3DResourceImpl_Release(IWineD3DResource *iface);
1248 /*** IWineD3DResource methods ***/
1249 extern HRESULT WINAPI IWineD3DResourceImpl_GetParent(IWineD3DResource *iface, IUnknown **pParent);
1250 extern HRESULT WINAPI IWineD3DResourceImpl_GetDevice(IWineD3DResource *iface, IWineD3DDevice ** ppDevice);
1251 extern HRESULT WINAPI IWineD3DResourceImpl_SetPrivateData(IWineD3DResource *iface, REFGUID refguid, CONST void * pData, DWORD SizeOfData, DWORD Flags);
1252 extern HRESULT WINAPI IWineD3DResourceImpl_GetPrivateData(IWineD3DResource *iface, REFGUID refguid, void * pData, DWORD * pSizeOfData);
1253 extern HRESULT WINAPI IWineD3DResourceImpl_FreePrivateData(IWineD3DResource *iface, REFGUID refguid);
1254 extern DWORD WINAPI IWineD3DResourceImpl_SetPriority(IWineD3DResource *iface, DWORD PriorityNew);
1255 extern DWORD WINAPI IWineD3DResourceImpl_GetPriority(IWineD3DResource *iface);
1256 extern void WINAPI IWineD3DResourceImpl_PreLoad(IWineD3DResource *iface);
1257 extern WINED3DRESOURCETYPE WINAPI IWineD3DResourceImpl_GetType(IWineD3DResource *iface);
1258 /*** class static members ***/
1259 void IWineD3DResourceImpl_CleanUp(IWineD3DResource *iface);
1261 /*** IUnknown methods ***/
1262 extern HRESULT WINAPI IWineD3DBaseTextureImpl_QueryInterface(IWineD3DBaseTexture *iface, REFIID riid, void** ppvObject);
1263 extern ULONG WINAPI IWineD3DBaseTextureImpl_AddRef(IWineD3DBaseTexture *iface);
1264 extern ULONG WINAPI IWineD3DBaseTextureImpl_Release(IWineD3DBaseTexture *iface);
1265 /*** IWineD3DResource methods ***/
1266 extern HRESULT WINAPI IWineD3DBaseTextureImpl_GetParent(IWineD3DBaseTexture *iface, IUnknown **pParent);
1267 extern HRESULT WINAPI IWineD3DBaseTextureImpl_GetDevice(IWineD3DBaseTexture *iface, IWineD3DDevice ** ppDevice);
1268 extern HRESULT WINAPI IWineD3DBaseTextureImpl_SetPrivateData(IWineD3DBaseTexture *iface, REFGUID refguid, CONST void * pData, DWORD SizeOfData, DWORD Flags);
1269 extern HRESULT WINAPI IWineD3DBaseTextureImpl_GetPrivateData(IWineD3DBaseTexture *iface, REFGUID refguid, void * pData, DWORD * pSizeOfData);
1270 extern HRESULT WINAPI IWineD3DBaseTextureImpl_FreePrivateData(IWineD3DBaseTexture *iface, REFGUID refguid);
1271 extern DWORD WINAPI IWineD3DBaseTextureImpl_SetPriority(IWineD3DBaseTexture *iface, DWORD PriorityNew);
1272 extern DWORD WINAPI IWineD3DBaseTextureImpl_GetPriority(IWineD3DBaseTexture *iface);
1273 extern void WINAPI IWineD3DBaseTextureImpl_PreLoad(IWineD3DBaseTexture *iface);
1274 extern WINED3DRESOURCETYPE WINAPI IWineD3DBaseTextureImpl_GetType(IWineD3DBaseTexture *iface);
1275 /*** IWineD3DBaseTexture methods ***/
1276 extern DWORD WINAPI IWineD3DBaseTextureImpl_SetLOD(IWineD3DBaseTexture *iface, DWORD LODNew);
1277 extern DWORD WINAPI IWineD3DBaseTextureImpl_GetLOD(IWineD3DBaseTexture *iface);
1278 extern DWORD WINAPI IWineD3DBaseTextureImpl_GetLevelCount(IWineD3DBaseTexture *iface);
1279 extern HRESULT WINAPI IWineD3DBaseTextureImpl_SetAutoGenFilterType(IWineD3DBaseTexture *iface, WINED3DTEXTUREFILTERTYPE FilterType);
1280 extern WINED3DTEXTUREFILTERTYPE WINAPI IWineD3DBaseTextureImpl_GetAutoGenFilterType(IWineD3DBaseTexture *iface);
1281 extern void WINAPI IWineD3DBaseTextureImpl_GenerateMipSubLevels(IWineD3DBaseTexture *iface);
1282 extern BOOL WINAPI IWineD3DBaseTextureImpl_SetDirty(IWineD3DBaseTexture *iface, BOOL);
1283 extern BOOL WINAPI IWineD3DBaseTextureImpl_GetDirty(IWineD3DBaseTexture *iface);
1285 extern BYTE* WINAPI IWineD3DVertexBufferImpl_GetMemory(IWineD3DVertexBuffer* iface, DWORD iOffset, GLint *vbo);
1286 extern HRESULT WINAPI IWineD3DVertexBufferImpl_ReleaseMemory(IWineD3DVertexBuffer* iface);
1287 extern HRESULT WINAPI IWineD3DBaseTextureImpl_BindTexture(IWineD3DBaseTexture *iface);
1288 extern HRESULT WINAPI IWineD3DBaseTextureImpl_UnBindTexture(IWineD3DBaseTexture *iface);
1289 extern void WINAPI IWineD3DBaseTextureImpl_ApplyStateChanges(IWineD3DBaseTexture *iface, const DWORD textureStates[WINED3D_HIGHEST_TEXTURE_STATE + 1], const DWORD samplerStates[WINED3D_HIGHEST_SAMPLER_STATE + 1]);
1290 /*** class static members ***/
1291 void IWineD3DBaseTextureImpl_CleanUp(IWineD3DBaseTexture *iface);
1293 struct SHADER_OPCODE_ARG;
1294 typedef void (*shader_fct_t)();
1295 typedef void (*SHADER_HANDLER) (struct SHADER_OPCODE_ARG*);
1297 /* Struct to maintain a list of GLSL shader programs and their associated pixel and
1298 * vertex shaders. A list of this type is maintained on the DeviceImpl, and is only
1299 * used if the user is using GLSL shaders. */
1300 struct glsl_shader_prog_link {
1301 struct list entry;
1302 GLhandleARB programId;
1303 IWineD3DVertexShader* vertexShader;
1304 IWineD3DPixelShader* pixelShader;
1307 /* TODO: Make this dynamic, based on shader limits ? */
1308 #define MAX_REG_ADDR 1
1309 #define MAX_REG_TEMP 32
1310 #define MAX_REG_TEXCRD 8
1311 #define MAX_REG_INPUT 12
1312 #define MAX_REG_OUTPUT 12
1313 #define MAX_ATTRIBS 16
1314 #define MAX_CONST_I 16
1315 #define MAX_CONST_B 16
1317 /* FIXME: This needs to go up to 2048 for
1318 * Shader model 3 according to msdn (and for software shaders) */
1319 #define MAX_LABELS 16
1321 typedef struct semantic {
1322 DWORD usage;
1323 DWORD reg;
1324 } semantic;
1326 typedef struct local_constant {
1327 struct list entry;
1328 unsigned int idx;
1329 DWORD value[4];
1330 } local_constant;
1332 typedef struct shader_reg_maps {
1334 char texcoord[MAX_REG_TEXCRD]; /* pixel < 3.0 */
1335 char temporary[MAX_REG_TEMP]; /* pixel, vertex */
1336 char address[MAX_REG_ADDR]; /* vertex */
1337 char packed_input[MAX_REG_INPUT]; /* pshader >= 3.0 */
1338 char packed_output[MAX_REG_OUTPUT]; /* vertex >= 3.0 */
1339 char attributes[MAX_ATTRIBS]; /* vertex */
1340 char labels[MAX_LABELS]; /* pixel, vertex */
1342 /* Sampler usage tokens
1343 * Use 0 as default (bit 31 is always 1 on a valid token) */
1344 DWORD samplers[MAX_SAMPLERS];
1346 /* Whether or not a loop is used in this shader */
1347 char loop;
1349 /* Whether or not this shader uses fog */
1350 char fog;
1352 } shader_reg_maps;
1354 #define SHADER_PGMSIZE 65535
1355 typedef struct SHADER_BUFFER {
1356 char* buffer;
1357 unsigned int bsize;
1358 unsigned int lineNo;
1359 } SHADER_BUFFER;
1361 /* Undocumented opcode controls */
1362 #define INST_CONTROLS_SHIFT 16
1363 #define INST_CONTROLS_MASK 0x00ff0000
1365 typedef enum COMPARISON_TYPE {
1366 COMPARISON_GT = 1,
1367 COMPARISON_EQ = 2,
1368 COMPARISON_GE = 3,
1369 COMPARISON_LT = 4,
1370 COMPARISON_NE = 5,
1371 COMPARISON_LE = 6
1372 } COMPARISON_TYPE;
1374 typedef struct SHADER_OPCODE {
1375 unsigned int opcode;
1376 const char* name;
1377 const char* glname;
1378 char dst_token;
1379 CONST UINT num_params;
1380 shader_fct_t soft_fct;
1381 SHADER_HANDLER hw_fct;
1382 SHADER_HANDLER hw_glsl_fct;
1383 DWORD min_version;
1384 DWORD max_version;
1385 } SHADER_OPCODE;
1387 typedef struct SHADER_OPCODE_ARG {
1388 IWineD3DBaseShader* shader;
1389 shader_reg_maps* reg_maps;
1390 CONST SHADER_OPCODE* opcode;
1391 DWORD opcode_token;
1392 DWORD dst;
1393 DWORD dst_addr;
1394 DWORD predicate;
1395 DWORD src[4];
1396 DWORD src_addr[4];
1397 SHADER_BUFFER* buffer;
1398 } SHADER_OPCODE_ARG;
1400 typedef struct SHADER_LIMITS {
1401 unsigned int temporary;
1402 unsigned int texcoord;
1403 unsigned int sampler;
1404 unsigned int constant_int;
1405 unsigned int constant_float;
1406 unsigned int constant_bool;
1407 unsigned int address;
1408 unsigned int packed_output;
1409 unsigned int packed_input;
1410 unsigned int attributes;
1411 unsigned int label;
1412 } SHADER_LIMITS;
1414 /** Keeps track of details for TEX_M#x# shader opcodes which need to
1415 maintain state information between multiple codes */
1416 typedef struct SHADER_PARSE_STATE {
1417 unsigned int current_row;
1418 DWORD texcoord_w[2];
1419 } SHADER_PARSE_STATE;
1421 /* Base Shader utility functions.
1422 * (may move callers into the same file in the future) */
1423 extern int shader_addline(
1424 SHADER_BUFFER* buffer,
1425 const char* fmt, ...);
1427 extern const SHADER_OPCODE* shader_get_opcode(
1428 IWineD3DBaseShader *iface,
1429 const DWORD code);
1431 extern void shader_delete_constant_list(
1432 struct list* clist);
1434 /* Vertex shader utility functions */
1435 extern BOOL vshader_get_input(
1436 IWineD3DVertexShader* iface,
1437 BYTE usage_req, BYTE usage_idx_req,
1438 unsigned int* regnum);
1440 extern BOOL vshader_input_is_color(
1441 IWineD3DVertexShader* iface,
1442 unsigned int regnum);
1444 extern HRESULT allocate_shader_constants(IWineD3DStateBlockImpl* object);
1446 /* ARB_[vertex/fragment]_program helper functions */
1447 extern void shader_arb_load_constants(
1448 IWineD3DStateBlock* iface,
1449 char usePixelShader,
1450 char useVertexShader);
1452 /* ARB shader program Prototypes */
1453 extern void shader_hw_def(SHADER_OPCODE_ARG *arg);
1455 /* ARB pixel shader prototypes */
1456 extern void pshader_hw_cnd(SHADER_OPCODE_ARG* arg);
1457 extern void pshader_hw_cmp(SHADER_OPCODE_ARG* arg);
1458 extern void pshader_hw_map2gl(SHADER_OPCODE_ARG* arg);
1459 extern void pshader_hw_tex(SHADER_OPCODE_ARG* arg);
1460 extern void pshader_hw_texcoord(SHADER_OPCODE_ARG* arg);
1461 extern void pshader_hw_texreg2ar(SHADER_OPCODE_ARG* arg);
1462 extern void pshader_hw_texreg2gb(SHADER_OPCODE_ARG* arg);
1463 extern void pshader_hw_texbem(SHADER_OPCODE_ARG* arg);
1464 extern void pshader_hw_texm3x2pad(SHADER_OPCODE_ARG* arg);
1465 extern void pshader_hw_texm3x2tex(SHADER_OPCODE_ARG* arg);
1466 extern void pshader_hw_texm3x3pad(SHADER_OPCODE_ARG* arg);
1467 extern void pshader_hw_texm3x3tex(SHADER_OPCODE_ARG* arg);
1468 extern void pshader_hw_texm3x3spec(SHADER_OPCODE_ARG* arg);
1469 extern void pshader_hw_texm3x3vspec(SHADER_OPCODE_ARG* arg);
1471 /* ARB vertex shader prototypes */
1472 extern void vshader_hw_map2gl(SHADER_OPCODE_ARG* arg);
1473 extern void vshader_hw_mnxn(SHADER_OPCODE_ARG* arg);
1475 /* GLSL helper functions */
1476 extern void set_glsl_shader_program(IWineD3DDevice *iface);
1477 extern void shader_glsl_add_instruction_modifiers(SHADER_OPCODE_ARG *arg);
1478 extern void shader_glsl_load_constants(
1479 IWineD3DStateBlock* iface,
1480 char usePixelShader,
1481 char useVertexShader);
1483 /** The following translate DirectX pixel/vertex shader opcodes to GLSL lines */
1484 extern void shader_glsl_map2gl(SHADER_OPCODE_ARG* arg);
1485 extern void shader_glsl_arith(SHADER_OPCODE_ARG* arg);
1486 extern void shader_glsl_mov(SHADER_OPCODE_ARG* arg);
1487 extern void shader_glsl_mad(SHADER_OPCODE_ARG* arg);
1488 extern void shader_glsl_mnxn(SHADER_OPCODE_ARG* arg);
1489 extern void shader_glsl_lrp(SHADER_OPCODE_ARG* arg);
1490 extern void shader_glsl_dot(SHADER_OPCODE_ARG* arg);
1491 extern void shader_glsl_rcp(SHADER_OPCODE_ARG* arg);
1492 extern void shader_glsl_cnd(SHADER_OPCODE_ARG* arg);
1493 extern void shader_glsl_compare(SHADER_OPCODE_ARG* arg);
1494 extern void shader_glsl_def(SHADER_OPCODE_ARG* arg);
1495 extern void shader_glsl_defi(SHADER_OPCODE_ARG* arg);
1496 extern void shader_glsl_defb(SHADER_OPCODE_ARG* arg);
1497 extern void shader_glsl_expp(SHADER_OPCODE_ARG* arg);
1498 extern void shader_glsl_cmp(SHADER_OPCODE_ARG* arg);
1499 extern void shader_glsl_lit(SHADER_OPCODE_ARG* arg);
1500 extern void shader_glsl_dst(SHADER_OPCODE_ARG* arg);
1501 extern void shader_glsl_sincos(SHADER_OPCODE_ARG* arg);
1502 extern void shader_glsl_loop(SHADER_OPCODE_ARG* arg);
1503 extern void shader_glsl_end(SHADER_OPCODE_ARG* arg);
1504 extern void shader_glsl_if(SHADER_OPCODE_ARG* arg);
1505 extern void shader_glsl_ifc(SHADER_OPCODE_ARG* arg);
1506 extern void shader_glsl_else(SHADER_OPCODE_ARG* arg);
1507 extern void shader_glsl_break(SHADER_OPCODE_ARG* arg);
1508 extern void shader_glsl_breakc(SHADER_OPCODE_ARG* arg);
1509 extern void shader_glsl_rep(SHADER_OPCODE_ARG* arg);
1510 extern void shader_glsl_call(SHADER_OPCODE_ARG* arg);
1511 extern void shader_glsl_callnz(SHADER_OPCODE_ARG* arg);
1512 extern void shader_glsl_label(SHADER_OPCODE_ARG* arg);
1514 /** GLSL Pixel Shader Prototypes */
1515 extern void pshader_glsl_tex(SHADER_OPCODE_ARG* arg);
1516 extern void pshader_glsl_texcoord(SHADER_OPCODE_ARG* arg);
1517 extern void pshader_glsl_texdp3tex(SHADER_OPCODE_ARG* arg);
1518 extern void pshader_glsl_texdp3(SHADER_OPCODE_ARG* arg);
1519 extern void pshader_glsl_texdepth(SHADER_OPCODE_ARG* arg);
1520 extern void pshader_glsl_texm3x2depth(SHADER_OPCODE_ARG* arg);
1521 extern void pshader_glsl_texm3x2pad(SHADER_OPCODE_ARG* arg);
1522 extern void pshader_glsl_texm3x2tex(SHADER_OPCODE_ARG* arg);
1523 extern void pshader_glsl_texm3x3(SHADER_OPCODE_ARG* arg);
1524 extern void pshader_glsl_texm3x3pad(SHADER_OPCODE_ARG* arg);
1525 extern void pshader_glsl_texm3x3tex(SHADER_OPCODE_ARG* arg);
1526 extern void pshader_glsl_texm3x3spec(SHADER_OPCODE_ARG* arg);
1527 extern void pshader_glsl_texm3x3vspec(SHADER_OPCODE_ARG* arg);
1528 extern void pshader_glsl_texkill(SHADER_OPCODE_ARG* arg);
1529 extern void pshader_glsl_texbem(SHADER_OPCODE_ARG* arg);
1530 extern void pshader_glsl_texreg2ar(SHADER_OPCODE_ARG* arg);
1531 extern void pshader_glsl_texreg2gb(SHADER_OPCODE_ARG* arg);
1532 extern void pshader_glsl_texreg2rgb(SHADER_OPCODE_ARG* arg);
1533 extern void pshader_glsl_dp2add(SHADER_OPCODE_ARG* arg);
1534 extern void pshader_glsl_input_pack(
1535 SHADER_BUFFER* buffer,
1536 semantic* semantics_out);
1538 /** GLSL Vertex Shader Prototypes */
1539 extern void vshader_glsl_output_unpack(
1540 SHADER_BUFFER* buffer,
1541 semantic* semantics_out);
1543 /*****************************************************************************
1544 * IDirect3DBaseShader implementation structure
1546 typedef struct IWineD3DBaseShaderClass
1548 DWORD hex_version;
1549 SHADER_LIMITS limits;
1550 SHADER_PARSE_STATE parse_state;
1551 CONST SHADER_OPCODE *shader_ins;
1552 CONST DWORD *function;
1553 UINT functionLength;
1554 GLuint prgId;
1556 /* Type of shader backend */
1557 int shader_mode;
1559 /* Immediate constants (override global ones) */
1560 struct list constantsB;
1561 struct list constantsF;
1562 struct list constantsI;
1564 } IWineD3DBaseShaderClass;
1566 typedef struct IWineD3DBaseShaderImpl {
1567 /* IUnknown */
1568 const IWineD3DBaseShaderVtbl *lpVtbl;
1569 LONG ref;
1571 /* IWineD3DBaseShader */
1572 IWineD3DBaseShaderClass baseShader;
1573 } IWineD3DBaseShaderImpl;
1575 extern HRESULT shader_get_registers_used(
1576 IWineD3DBaseShader *iface,
1577 shader_reg_maps* reg_maps,
1578 semantic* semantics_in,
1579 semantic* semantics_out,
1580 CONST DWORD* pToken);
1582 extern void shader_generate_glsl_declarations(
1583 IWineD3DBaseShader *iface,
1584 shader_reg_maps* reg_maps,
1585 SHADER_BUFFER* buffer,
1586 WineD3D_GL_Info* gl_info);
1588 extern void shader_generate_arb_declarations(
1589 IWineD3DBaseShader *iface,
1590 shader_reg_maps* reg_maps,
1591 SHADER_BUFFER* buffer,
1592 WineD3D_GL_Info* gl_info);
1594 extern void shader_generate_main(
1595 IWineD3DBaseShader *iface,
1596 SHADER_BUFFER* buffer,
1597 shader_reg_maps* reg_maps,
1598 CONST DWORD* pFunction);
1600 extern void shader_dump_ins_modifiers(
1601 const DWORD output);
1603 extern void shader_dump_param(
1604 IWineD3DBaseShader *iface,
1605 const DWORD param,
1606 const DWORD addr_token,
1607 int input);
1609 extern void shader_trace_init(
1610 IWineD3DBaseShader *iface,
1611 const DWORD* pFunction);
1613 extern int shader_get_param(
1614 IWineD3DBaseShader* iface,
1615 const DWORD* pToken,
1616 DWORD* param,
1617 DWORD* addr_token);
1619 extern int shader_skip_unrecognized(
1620 IWineD3DBaseShader* iface,
1621 const DWORD* pToken);
1623 extern void print_glsl_info_log(
1624 WineD3D_GL_Info *gl_info,
1625 GLhandleARB obj);
1627 inline static int shader_get_regtype(const DWORD param) {
1628 return (((param & D3DSP_REGTYPE_MASK) >> D3DSP_REGTYPE_SHIFT) |
1629 ((param & D3DSP_REGTYPE_MASK2) >> D3DSP_REGTYPE_SHIFT2));
1632 extern unsigned int shader_get_float_offset(const DWORD reg);
1634 inline static BOOL shader_is_pshader_version(DWORD token) {
1635 return 0xFFFF0000 == (token & 0xFFFF0000);
1638 inline static BOOL shader_is_vshader_version(DWORD token) {
1639 return 0xFFFE0000 == (token & 0xFFFF0000);
1642 inline static BOOL shader_is_comment(DWORD token) {
1643 return D3DSIO_COMMENT == (token & D3DSI_OPCODE_MASK);
1646 /*****************************************************************************
1647 * IDirect3DVertexShader implementation structure
1649 typedef struct IWineD3DVertexShaderImpl {
1650 /* IUnknown parts*/
1651 const IWineD3DVertexShaderVtbl *lpVtbl;
1652 LONG ref; /* Note: Ref counting not required */
1654 /* IWineD3DBaseShader */
1655 IWineD3DBaseShaderClass baseShader;
1657 /* IWineD3DVertexShaderImpl */
1658 IUnknown *parent;
1659 IWineD3DDeviceImpl *wineD3DDevice;
1661 char usesFog;
1662 DWORD usage;
1664 /* Vertex shader input and output semantics */
1665 semantic semantics_in [MAX_ATTRIBS];
1666 semantic semantics_out [MAX_REG_OUTPUT];
1668 /* run time datas... */
1669 VSHADERDATA *data;
1670 IWineD3DVertexDeclaration *vertexDeclaration;
1671 #if 0 /* needs reworking */
1672 /* run time datas */
1673 VSHADERINPUTDATA input;
1674 VSHADEROUTPUTDATA output;
1675 #endif
1676 } IWineD3DVertexShaderImpl;
1677 extern const SHADER_OPCODE IWineD3DVertexShaderImpl_shader_ins[];
1678 extern const IWineD3DVertexShaderVtbl IWineD3DVertexShader_Vtbl;
1680 /*****************************************************************************
1681 * IDirect3DPixelShader implementation structure
1683 typedef struct IWineD3DPixelShaderImpl {
1684 /* IUnknown parts */
1685 const IWineD3DPixelShaderVtbl *lpVtbl;
1686 LONG ref; /* Note: Ref counting not required */
1688 /* IWineD3DBaseShader */
1689 IWineD3DBaseShaderClass baseShader;
1691 /* IWineD3DPixelShaderImpl */
1692 IUnknown *parent;
1693 IWineD3DDeviceImpl *wineD3DDevice;
1695 /* Pixel shader input semantics */
1696 semantic semantics_in [MAX_REG_INPUT];
1698 /* run time data */
1699 PSHADERDATA *data;
1701 #if 0 /* needs reworking */
1702 PSHADERINPUTDATA input;
1703 PSHADEROUTPUTDATA output;
1704 #endif
1705 } IWineD3DPixelShaderImpl;
1707 extern const SHADER_OPCODE IWineD3DPixelShaderImpl_shader_ins[];
1708 extern const IWineD3DPixelShaderVtbl IWineD3DPixelShader_Vtbl;
1710 /*****************************************************************************
1711 * IWineD3DPalette implementation structure
1713 struct IWineD3DPaletteImpl {
1714 /* IUnknown parts */
1715 const IWineD3DPaletteVtbl *lpVtbl;
1716 LONG ref;
1718 IUnknown *parent;
1719 IWineD3DDeviceImpl *wineD3DDevice;
1721 /* IWineD3DPalette */
1722 HPALETTE hpal;
1723 WORD palVersion; /*| */
1724 WORD palNumEntries; /*| LOGPALETTE */
1725 PALETTEENTRY palents[256]; /*| */
1726 /* This is to store the palette in 'screen format' */
1727 int screen_palents[256];
1728 DWORD Flags;
1731 extern const IWineD3DPaletteVtbl IWineD3DPalette_Vtbl;
1732 DWORD IWineD3DPaletteImpl_Size(DWORD dwFlags);
1734 /* DirectDraw utility functions */
1735 extern WINED3DFORMAT pixelformat_for_depth(DWORD depth);
1737 /*****************************************************************************
1738 * Pixel format management
1740 typedef struct {
1741 WINED3DFORMAT format;
1742 DWORD alphaMask, redMask, greenMask, blueMask;
1743 UINT bpp;
1744 BOOL isFourcc;
1745 GLint glInternal, glFormat, glType;
1746 } PixelFormatDesc;
1748 const PixelFormatDesc *getFormatDescEntry(WINED3DFORMAT fmt);
1749 #endif