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
29 #define NONAMELESSUNION
30 #define NONAMELESSSTRUCT
37 #include "wine/debug.h"
38 #include "wine/unicode.h"
41 #include "d3d9types.h"
43 #include "wine/wined3d_interface.h"
44 #include "wine/wined3d_gl.h"
47 #define MAX_PALETTES 256
48 #define MAX_STREAMS 16
49 #define MAX_TEXTURES 8
50 #define MAX_SAMPLERS 16
51 #define MAX_ACTIVE_LIGHTS 8
52 #define MAX_CLIPPLANES D3DMAXUSERCLIPPLANES
53 #define MAX_LEVELS 256
55 #define MAX_VSHADER_CONSTANTS 96
56 #define MAX_PSHADER_CONSTANTS 32
58 /* Used for CreateStateBlock */
59 #define NUM_SAVEDPIXELSTATES_R 35
60 #define NUM_SAVEDPIXELSTATES_T 18
61 #define NUM_SAVEDPIXELSTATES_S 12
62 #define NUM_SAVEDVERTEXSTATES_R 31
63 #define NUM_SAVEDVERTEXSTATES_T 2
64 #define NUM_SAVEDVERTEXSTATES_S 1
66 extern const DWORD SavedPixelStates_R[NUM_SAVEDPIXELSTATES_R];
67 extern const DWORD SavedPixelStates_T[NUM_SAVEDPIXELSTATES_T];
68 extern const DWORD SavedPixelStates_S[NUM_SAVEDPIXELSTATES_S];
69 extern const DWORD SavedVertexStates_R[NUM_SAVEDVERTEXSTATES_R];
70 extern const DWORD SavedVertexStates_T[NUM_SAVEDVERTEXSTATES_T];
71 extern const DWORD SavedVertexStates_S[NUM_SAVEDVERTEXSTATES_S];
73 typedef enum _WINELOOKUP {
74 WINELOOKUP_WARPPARAM = 0,
75 WINELOOKUP_MAGFILTER = 1,
79 extern int minLookup[MAX_LOOKUPS];
80 extern int maxLookup[MAX_LOOKUPS];
81 extern DWORD *stateLookup[MAX_LOOKUPS];
83 extern DWORD minMipLookup[D3DTEXF_ANISOTROPIC + 1][D3DTEXF_LINEAR + 1];
85 typedef struct _WINED3DGLTYPE {
93 /* NOTE: Make sure these are in the correct numerical order. (see /include/d3d9types.h typedef enum _D3DDECLTYPE) */
94 WINED3DGLTYPE static const glTypeLookup[D3DDECLTYPE_UNUSED] = {
95 {D3DDECLTYPE_FLOAT1, 1, GL_FLOAT , GL_FALSE ,sizeof(float)},
96 {D3DDECLTYPE_FLOAT2, 2, GL_FLOAT , GL_FALSE ,sizeof(float)},
97 {D3DDECLTYPE_FLOAT3, 3, GL_FLOAT , GL_FALSE ,sizeof(float)},
98 {D3DDECLTYPE_FLOAT4, 4, GL_FLOAT , GL_FALSE ,sizeof(float)},
99 {D3DDECLTYPE_D3DCOLOR, 4, GL_UNSIGNED_BYTE , GL_TRUE ,sizeof(BYTE)},
100 {D3DDECLTYPE_UBYTE4, 4, GL_UNSIGNED_BYTE , GL_FALSE ,sizeof(BYTE)},
101 {D3DDECLTYPE_SHORT2, 2, GL_SHORT , GL_FALSE ,sizeof(short int)},
102 {D3DDECLTYPE_SHORT4, 4, GL_SHORT , GL_FALSE ,sizeof(short int)},
103 {D3DDECLTYPE_UBYTE4N, 4, GL_UNSIGNED_BYTE , GL_FALSE ,sizeof(BYTE)},
104 {D3DDECLTYPE_SHORT2N, 2, GL_SHORT , GL_FALSE ,sizeof(short int)},
105 {D3DDECLTYPE_SHORT4N, 4, GL_SHORT , GL_FALSE ,sizeof(short int)},
106 {D3DDECLTYPE_USHORT2N, 2, GL_UNSIGNED_SHORT , GL_FALSE ,sizeof(short int)},
107 {D3DDECLTYPE_USHORT4N, 4, GL_UNSIGNED_SHORT , GL_FALSE ,sizeof(short int)},
108 {D3DDECLTYPE_UDEC3, 3, GL_UNSIGNED_SHORT , GL_FALSE ,sizeof(short int)},
109 {D3DDECLTYPE_DEC3N, 3, GL_SHORT , GL_FALSE ,sizeof(short int)},
110 {D3DDECLTYPE_FLOAT16_2, 2, GL_FLOAT , GL_FALSE ,sizeof(short int)},
111 {D3DDECLTYPE_FLOAT16_4, 4, GL_FLOAT , GL_FALSE ,sizeof(short int)}};
113 #define WINED3D_ATR_TYPE(_attribute) glTypeLookup[sd->u.s._attribute.dwType].d3dType
114 #define WINED3D_ATR_SIZE(_attribute) glTypeLookup[sd->u.s._attribute.dwType].size
115 #define WINED3D_ATR_GLTYPE(_attribute) glTypeLookup[sd->u.s._attribute.dwType].glType
116 #define WINED3D_ATR_NORMALIZED(_attribute) glTypeLookup[sd->u.s._attribute.dwType].normalized
117 #define WINED3D_ATR_TYPESIZE(_attribute) glTypeLookup[sd->u.s._attribute.dwType].typesize
135 typedef struct wined3d_settings_s {
136 /* vertex and pixel shader modes */
140 /* nonpower 2 function */
142 } wined3d_settings_t;
144 extern wined3d_settings_t wined3d_settings;
148 extern void (*wine_tsx11_lock_ptr)(void);
149 extern void (*wine_tsx11_unlock_ptr)(void);
151 /* As GLX relies on X, this is needed */
155 #define ENTER_GL() ++num_lock; if (num_lock > 1) FIXME("Recursive use of GL lock to: %d\n", num_lock); wine_tsx11_lock_ptr()
156 #define LEAVE_GL() if (num_lock != 1) FIXME("Recursive use of GL lock: %d\n", num_lock); --num_lock; wine_tsx11_unlock_ptr()
158 #define ENTER_GL() wine_tsx11_lock_ptr()
159 #define LEAVE_GL() wine_tsx11_unlock_ptr()
162 /*****************************************************************************
166 /* GL related defines */
167 /* ------------------ */
168 #define GL_SUPPORT(ExtName) (GLINFO_LOCATION.supported[ExtName] != 0)
169 #define GL_LIMITS(ExtName) (GLINFO_LOCATION.max_##ExtName)
170 #define GL_EXTCALL(FuncName) (GLINFO_LOCATION.FuncName)
171 #define GL_VEND(_VendName) (GLINFO_LOCATION.gl_vendor == VENDOR_##_VendName ? TRUE : FALSE)
173 #define D3DCOLOR_B_R(dw) (((dw) >> 16) & 0xFF)
174 #define D3DCOLOR_B_G(dw) (((dw) >> 8) & 0xFF)
175 #define D3DCOLOR_B_B(dw) (((dw) >> 0) & 0xFF)
176 #define D3DCOLOR_B_A(dw) (((dw) >> 24) & 0xFF)
178 #define D3DCOLOR_R(dw) (((float) (((dw) >> 16) & 0xFF)) / 255.0f)
179 #define D3DCOLOR_G(dw) (((float) (((dw) >> 8) & 0xFF)) / 255.0f)
180 #define D3DCOLOR_B(dw) (((float) (((dw) >> 0) & 0xFF)) / 255.0f)
181 #define D3DCOLOR_A(dw) (((float) (((dw) >> 24) & 0xFF)) / 255.0f)
183 #define D3DCOLORTOGLFLOAT4(dw, vec) \
184 (vec)[0] = D3DCOLOR_R(dw); \
185 (vec)[1] = D3DCOLOR_G(dw); \
186 (vec)[2] = D3DCOLOR_B(dw); \
187 (vec)[3] = D3DCOLOR_A(dw);
189 /* Note: The following is purely to keep the source code as clear from #ifdefs as possible */
190 #if defined(GL_VERSION_1_3)
191 #define GLACTIVETEXTURE(textureNo) \
192 glActiveTexture(GL_TEXTURE0 + textureNo); \
193 checkGLcall("glActiveTexture");
194 #define GLCLIENTACTIVETEXTURE(textureNo) \
195 glClientActiveTexture(GL_TEXTURE0 + textureNo);
196 #define GLMULTITEXCOORD1F(a,b) \
197 glMultiTexCoord1f(GL_TEXTURE0 + a, b);
198 #define GLMULTITEXCOORD2F(a,b,c) \
199 glMultiTexCoord2f(GL_TEXTURE0 + a, b, c);
200 #define GLMULTITEXCOORD3F(a,b,c,d) \
201 glMultiTexCoord3f(GL_TEXTURE0 + a, b, c, d);
202 #define GLMULTITEXCOORD4F(a,b,c,d,e) \
203 glMultiTexCoord4f(GL_TEXTURE0 + a, b, c, d, e);
204 #define GLTEXTURECUBEMAP GL_TEXTURE_CUBE_MAP
206 #define GLACTIVETEXTURE(textureNo) \
207 glActiveTextureARB(GL_TEXTURE0_ARB + textureNo); \
208 checkGLcall("glActiveTextureARB");
209 #define GLCLIENTACTIVETEXTURE(textureNo) \
210 glClientActiveTextureARB(GL_TEXTURE0_ARB + textureNo);
211 #define GLMULTITEXCOORD1F(a,b) \
212 glMultiTexCoord1fARB(GL_TEXTURE0_ARB + a, b);
213 #define GLMULTITEXCOORD2F(a,b,c) \
214 glMultiTexCoord2fARB(GL_TEXTURE0_ARB + a, b, c);
215 #define GLMULTITEXCOORD3F(a,b,c,d) \
216 glMultiTexCoord3fARB(GL_TEXTURE0_ARB + a, b, c, d);
217 #define GLMULTITEXCOORD4F(a,b,c,d,e) \
218 glMultiTexCoord4fARB(GL_TEXTURE0_ARB + a, b, c, d, e);
219 #define GLTEXTURECUBEMAP GL_TEXTURE_CUBE_MAP_ARB
222 /* DirectX Device Limits */
223 /* --------------------- */
224 #define MAX_LEVELS 256 /* Maximum number of mipmap levels. Guessed at 256 */
226 #define MAX_STREAMS 16 /* Maximum possible streams - used for fixed size arrays
227 See MaxStreams in MSDN under GetDeviceCaps */
228 /* Maximum number of constants provided to the shaders */
229 #define HIGHEST_TRANSFORMSTATE 512
230 /* Highest value in D3DTRANSFORMSTATETYPE */
231 #define MAX_CLIPPLANES D3DMAXUSERCLIPPLANES
233 #define MAX_PALETTES 256
235 /* Checking of API calls */
236 /* --------------------- */
237 #define checkGLcall(A) \
239 GLint err = glGetError(); \
240 if (err == GL_NO_ERROR) { \
241 TRACE("%s call ok %s / %d\n", A, __FILE__, __LINE__); \
244 FIXME(">>>>>>>>>>>>>>>>> %x from %s @ %s / %d\n", \
245 err, A, __FILE__, __LINE__); \
246 err = glGetError(); \
247 } while (err != GL_NO_ERROR); \
250 /* Trace routines / diagnostics */
251 /* ---------------------------- */
253 /* Dump out a matrix and copy it */
254 #define conv_mat(mat,gl_mat) \
256 TRACE("%f %f %f %f\n", (mat)->u.s._11, (mat)->u.s._12, (mat)->u.s._13, (mat)->u.s._14); \
257 TRACE("%f %f %f %f\n", (mat)->u.s._21, (mat)->u.s._22, (mat)->u.s._23, (mat)->u.s._24); \
258 TRACE("%f %f %f %f\n", (mat)->u.s._31, (mat)->u.s._32, (mat)->u.s._33, (mat)->u.s._34); \
259 TRACE("%f %f %f %f\n", (mat)->u.s._41, (mat)->u.s._42, (mat)->u.s._43, (mat)->u.s._44); \
260 memcpy(gl_mat, (mat), 16 * sizeof(float)); \
263 /* Macro to dump out the current state of the light chain */
264 #define DUMP_LIGHT_CHAIN() \
266 PLIGHTINFOEL *el = This->stateBlock->lights;\
268 TRACE("Light %p (glIndex %ld, d3dIndex %ld, enabled %d)\n", el, el->glIndex, el->OriginalIndex, el->lightEnabled);\
273 /* Trace vector and strided data information */
274 #define TRACE_VECTOR(name) TRACE( #name "=(%f, %f, %f, %f)\n", name.x, name.y, name.z, name.w);
275 #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);
277 /* Defines used for optimizations */
279 /* Only reapply what is necessary */
280 #define REAPPLY_ALPHAOP 0x0001
281 #define REAPPLY_ALL 0xFFFF
283 /* Advance declaration of structures to satisfy compiler */
284 typedef struct IWineD3DStateBlockImpl IWineD3DStateBlockImpl;
285 typedef struct IWineD3DSurfaceImpl IWineD3DSurfaceImpl;
286 typedef struct IWineD3DPaletteImpl IWineD3DPaletteImpl;
290 /* TODO: Move some of this to the device */
291 long globalChangeGlRam(long glram);
293 /* Memory and object tracking */
295 /*Structure for holding information on all direct3d objects
296 useful for making sure tracking is ok and when release is called on a device!
297 and probably quite handy for debugging and dumping states out
299 typedef struct WineD3DGlobalStatistics {
300 int glsurfaceram; /* The aproximate amount of glTexture memory allocated for textures */
301 } WineD3DGlobalStatistics;
303 extern WineD3DGlobalStatistics* wineD3DGlobalStatistics;
305 /* Global variables */
306 extern const float identity[16];
308 /*****************************************************************************
309 * Compilable extra diagnostics
312 /* Trace information per-vertex: (extremely high amount of trace) */
313 #if 0 /* NOTE: Must be 0 in cvs */
314 # define VTRACE(A) TRACE A
319 /* Checking of per-vertex related GL calls */
320 /* --------------------- */
321 #define vcheckGLcall(A) \
323 GLint err = glGetError(); \
324 if (err == GL_NO_ERROR) { \
325 VTRACE(("%s call ok %s / %d\n", A, __FILE__, __LINE__)); \
328 FIXME(">>>>>>>>>>>>>>>>> %x from %s @ %s / %d\n", \
329 err, A, __FILE__, __LINE__); \
330 err = glGetError(); \
331 } while (err != GL_NO_ERROR); \
334 /* TODO: Confirm each of these works when wined3d move completed */
335 #if 0 /* NOTE: Must be 0 in cvs */
336 /* To avoid having to get gigabytes of trace, the following can be compiled in, and at the start
337 of each frame, a check is made for the existence of C:\D3DTRACE, and if if exists d3d trace
338 is enabled, and if it doesn't exists it is disabled. */
339 # define FRAME_DEBUGGING
340 /* Adding in the SINGLE_FRAME_DEBUGGING gives a trace of just what makes up a single frame, before
341 the file is deleted */
342 # if 1 /* NOTE: Must be 1 in cvs, as this is mostly more useful than a trace from program start */
343 # define SINGLE_FRAME_DEBUGGING
345 /* The following, when enabled, lets you see the makeup of the frame, by drawprimitive calls.
346 It can only be enabled when FRAME_DEBUGGING is also enabled
347 The contents of the back buffer are written into /tmp/backbuffer_* after each primitive
349 # if 0 /* NOTE: Must be 0 in cvs, as this give a lot of ppm files when compiled in */
350 # define SHOW_FRAME_MAKEUP 1
352 /* The following, when enabled, lets you see the makeup of the all the textures used during each
353 of the drawprimitive calls. It can only be enabled when SHOW_FRAME_MAKEUP is also enabled.
354 The contents of the textures assigned to each stage are written into
355 /tmp/texture_*_<Stage>.ppm after each primitive array is drawn. */
356 # if 0 /* NOTE: Must be 0 in cvs, as this give a lot of ppm files when compiled in */
357 # define SHOW_TEXTURE_MAKEUP 0
360 extern BOOL isDumpingFrames;
361 extern LONG primCounter;
364 /*****************************************************************************
368 /* Routine common to the draw primitive and draw indexed primitive routines */
369 void drawPrimitive(IWineD3DDevice *iface,
373 long StartVertexIndex,
374 UINT numberOfVertices,
379 WineDirect3DVertexStridedData *DrawPrimStrideData);
383 /* Routine to fill gl caps for swapchains and IWineD3D */
384 BOOL IWineD3DImpl_FillGLCaps(WineD3D_GL_Info *gl_info,
387 /*****************************************************************************
388 * Internal representation of a light
390 typedef struct PLIGHTINFOEL PLIGHTINFOEL;
391 struct PLIGHTINFOEL {
392 WINED3DLIGHT OriginalParms; /* Note D3D8LIGHT == D3D9LIGHT */
399 /* Converted parms to speed up swapping lights */
409 /*****************************************************************************
410 * IWineD3D implementation structure
412 typedef struct IWineD3DImpl
414 /* IUnknown fields */
415 const IWineD3DVtbl *lpVtbl;
416 LONG ref; /* Note: Ref counting not required */
418 /* WineD3D Information */
424 WineD3D_GL_Info gl_info;
427 extern const IWineD3DVtbl IWineD3D_Vtbl;
429 typedef struct SwapChainList {
430 IWineD3DSwapChain *swapchain;
431 struct SwapChainList *next;
434 /** Hacked out start of a context manager!! **/
435 typedef struct glContext {
442 IWineD3DSurface *pSurface;
443 #if 0 /* TODO: someway to represent the state of the context */
444 IWineD3DStateBlock *pStateBlock;
446 /* a few other things like format */
449 /* TODO: setup some flags in the regestry to enable, disable pbuffer support
450 (since it will break quite a few things until contexts are managed properly!) */
451 extern BOOL pbuffer_support;
452 /* allocate one pbuffer per surface */
453 extern BOOL pbuffer_per_surface;
455 /* Maximum number of contexts/pbuffers to keep in cache,
456 set to 100 because ATI's drivers don't support deleting pBuffers properly
457 this needs to be migrated to a list and some option availalbe for controle the cache size.
459 #define CONTEXT_CACHE 100
461 typedef struct ResourceList {
462 IWineD3DResource *resource;
463 struct ResourceList *next;
466 /* A helper function that dumps a resource list */
467 void dumpResources(ResourceList *resources);
469 /*****************************************************************************
470 * IWineD3DDevice implementation structure
472 typedef struct IWineD3DDeviceImpl
474 /* IUnknown fields */
475 const IWineD3DDeviceVtbl *lpVtbl;
476 LONG ref; /* Note: Ref counting not required */
478 /* WineD3D Information */
482 /* X and GL Information */
483 GLint maxConcurrentLights;
486 BOOL modelview_valid;
488 BOOL view_ident; /* true iff view matrix is identity */
489 BOOL last_was_rhw; /* true iff last draw_primitive was in xyzrhw mode */
490 BOOL viewport_changed; /* Was the viewport changed since the last draw? */
491 GLenum tracking_parm; /* Which source is tracking current colour */
492 LONG tracking_color; /* used iff GL_COLOR_MATERIAL was enabled */
493 #define DISABLED_TRACKING 0 /* Disabled */
494 #define IS_TRACKING 1 /* tracking_parm is tracking diffuse color */
495 #define NEEDS_TRACKING 2 /* Tracking needs to be enabled when needed */
496 #define NEEDS_DISABLE 3 /* Tracking needs to be disabled when needed*/
501 BOOL texture_shader_active; /* TODO: Confirm use is correct */
503 /* State block related */
504 BOOL isRecordingState;
505 IWineD3DStateBlockImpl *stateBlock;
506 IWineD3DStateBlockImpl *updateStateBlock;
508 /* Internal use fields */
509 WINED3DDEVICE_CREATION_PARAMETERS createParms;
513 SwapChainList *swapchains;
515 ResourceList *resources; /* a linked list to track resources created by the device */
517 /* Render Target Support */
518 IWineD3DSurface *depthStencilBuffer;
520 IWineD3DSurface *renderTarget;
521 IWineD3DSurface *stencilBufferTarget;
523 /* palettes texture management */
524 PALETTEENTRY palettes[MAX_PALETTES][256];
527 /* For rendering to a texture using glCopyTexImage */
528 BOOL renderUpsideDown;
530 /* Cursor management */
537 /* Textures for when no other textures are mapped */
538 UINT dummyTextureName[MAX_TEXTURES];
540 /* Debug stream management */
543 /* Device state management */
545 BOOL d3d_initialized;
547 /* Screen buffer resources */
548 glContext contextCache[CONTEXT_CACHE];
550 /* A flag to check if endscene has been called before changing the render tartet */
553 /* process vertex shaders using software or hardware */
554 BOOL softwareVertexProcessing;
556 /* DirectDraw stuff */
559 } IWineD3DDeviceImpl;
561 extern const IWineD3DDeviceVtbl IWineD3DDevice_Vtbl;
563 /* Support for IWineD3DResource ::Set/Get/FreePrivateData. I don't think
564 * anybody uses it for much so a good implementation is optional. */
565 typedef struct PrivateData
567 struct PrivateData* next;
570 DWORD flags; /* DDSPD_* */
571 DWORD uniqueness_value;
582 /*****************************************************************************
583 * IWineD3DResource implementation structure
585 typedef struct IWineD3DResourceClass
587 /* IUnknown fields */
588 LONG ref; /* Note: Ref counting not required */
590 /* WineD3DResource Information */
592 WINED3DRESOURCETYPE resourceType;
593 IWineD3DDeviceImpl *wineD3DDevice;
597 WINED3DFORMAT format;
598 BYTE *allocatedMemory;
599 PrivateData *privateData;
601 } IWineD3DResourceClass;
603 typedef struct IWineD3DResourceImpl
605 /* IUnknown & WineD3DResource Information */
606 const IWineD3DResourceVtbl *lpVtbl;
607 IWineD3DResourceClass resource;
608 } IWineD3DResourceImpl;
611 /*****************************************************************************
612 * IWineD3DVertexBuffer implementation structure (extends IWineD3DResourceImpl)
614 typedef struct IWineD3DVertexBufferImpl
616 /* IUnknown & WineD3DResource Information */
617 const IWineD3DVertexBufferVtbl *lpVtbl;
618 IWineD3DResourceClass resource;
620 /* WineD3DVertexBuffer specifics */
623 } IWineD3DVertexBufferImpl;
625 extern const IWineD3DVertexBufferVtbl IWineD3DVertexBuffer_Vtbl;
628 /*****************************************************************************
629 * IWineD3DIndexBuffer implementation structure (extends IWineD3DResourceImpl)
631 typedef struct IWineD3DIndexBufferImpl
633 /* IUnknown & WineD3DResource Information */
634 const IWineD3DIndexBufferVtbl *lpVtbl;
635 IWineD3DResourceClass resource;
637 /* WineD3DVertexBuffer specifics */
638 } IWineD3DIndexBufferImpl;
640 extern const IWineD3DIndexBufferVtbl IWineD3DIndexBuffer_Vtbl;
642 /*****************************************************************************
643 * IWineD3DBaseTexture D3D- > openGL state map lookups
645 #define WINED3DFUNC_NOTSUPPORTED -2
646 #define WINED3DFUNC_UNIMPLEMENTED -1
648 typedef enum winetexturestates {
649 WINED3DTEXSTA_ADDRESSU = 0,
650 WINED3DTEXSTA_ADDRESSV = 1,
651 WINED3DTEXSTA_ADDRESSW = 2,
652 WINED3DTEXSTA_BORDERCOLOR = 3,
653 WINED3DTEXSTA_MAGFILTER = 4,
654 WINED3DTEXSTA_MINFILTER = 5,
655 WINED3DTEXSTA_MIPFILTER = 6,
656 WINED3DTEXSTA_MAXMIPLEVEL = 7,
657 WINED3DTEXSTA_MAXANISOTROPY = 8,
658 WINED3DTEXSTA_SRGBTEXTURE = 9,
659 WINED3DTEXSTA_ELEMENTINDEX = 10,
660 WINED3DTEXSTA_DMAPOFFSET = 11,
661 WINED3DTEXSTA_TSSADDRESSW = 12,
662 MAX_WINETEXTURESTATES = 13,
665 typedef struct Wined3dTextureStateMap {
668 } Wined3dTextureStateMap;
670 /*****************************************************************************
671 * IWineD3DBaseTexture implementation structure (extends IWineD3DResourceImpl)
673 typedef struct IWineD3DBaseTextureClass
681 WINED3DTEXTUREFILTERTYPE filterType;
682 DWORD states[MAX_WINETEXTURESTATES];
684 } IWineD3DBaseTextureClass;
686 typedef struct IWineD3DBaseTextureImpl
688 /* IUnknown & WineD3DResource Information */
689 const IWineD3DBaseTextureVtbl *lpVtbl;
690 IWineD3DResourceClass resource;
691 IWineD3DBaseTextureClass baseTexture;
693 } IWineD3DBaseTextureImpl;
695 /*****************************************************************************
696 * IWineD3DTexture implementation structure (extends IWineD3DBaseTextureImpl)
698 typedef struct IWineD3DTextureImpl
700 /* IUnknown & WineD3DResource/WineD3DBaseTexture Information */
701 const IWineD3DTextureVtbl *lpVtbl;
702 IWineD3DResourceClass resource;
703 IWineD3DBaseTextureClass baseTexture;
705 /* IWineD3DTexture */
706 IWineD3DSurface *surfaces[MAX_LEVELS];
710 float pow2scalingFactorX;
711 float pow2scalingFactorY;
713 } IWineD3DTextureImpl;
715 extern const IWineD3DTextureVtbl IWineD3DTexture_Vtbl;
717 /*****************************************************************************
718 * IWineD3DCubeTexture implementation structure (extends IWineD3DBaseTextureImpl)
720 typedef struct IWineD3DCubeTextureImpl
722 /* IUnknown & WineD3DResource/WineD3DBaseTexture Information */
723 const IWineD3DCubeTextureVtbl *lpVtbl;
724 IWineD3DResourceClass resource;
725 IWineD3DBaseTextureClass baseTexture;
727 /* IWineD3DCubeTexture */
728 IWineD3DSurface *surfaces[6][MAX_LEVELS];
731 float pow2scalingFactor;
733 } IWineD3DCubeTextureImpl;
735 extern const IWineD3DCubeTextureVtbl IWineD3DCubeTexture_Vtbl;
737 /*****************************************************************************
738 * IWineD3DVolume implementation structure (extends IUnknown)
740 typedef struct IWineD3DVolumeImpl
742 /* IUnknown & WineD3DResource fields */
743 const IWineD3DVolumeVtbl *lpVtbl;
744 IWineD3DResourceClass resource;
746 /* WineD3DVolume Information */
747 D3DVOLUME_DESC currentDesc;
748 IWineD3DBase *container;
753 WINED3DBOX lockedBox;
758 } IWineD3DVolumeImpl;
760 extern const IWineD3DVolumeVtbl IWineD3DVolume_Vtbl;
762 /*****************************************************************************
763 * IWineD3DVolumeTexture implementation structure (extends IWineD3DBaseTextureImpl)
765 typedef struct IWineD3DVolumeTextureImpl
767 /* IUnknown & WineD3DResource/WineD3DBaseTexture Information */
768 const IWineD3DVolumeTextureVtbl *lpVtbl;
769 IWineD3DResourceClass resource;
770 IWineD3DBaseTextureClass baseTexture;
772 /* IWineD3DVolumeTexture */
773 IWineD3DVolume *volumes[MAX_LEVELS];
778 } IWineD3DVolumeTextureImpl;
780 extern const IWineD3DVolumeTextureVtbl IWineD3DVolumeTexture_Vtbl;
782 typedef struct _WINED3DSURFACET_DESC
784 WINED3DMULTISAMPLE_TYPE MultiSampleType;
785 DWORD MultiSampleQuality;
788 } WINED3DSURFACET_DESC;
790 /*****************************************************************************
791 * Structure for DIB Surfaces (GetDC and GDI surfaces)
793 typedef struct wineD3DSurface_DIB {
798 } wineD3DSurface_DIB;
800 /*****************************************************************************
801 * IWineD3DSurface implementation structure
803 struct IWineD3DSurfaceImpl
805 /* IUnknown & IWineD3DResource Information */
806 const IWineD3DSurfaceVtbl *lpVtbl;
807 IWineD3DResourceClass resource;
809 /* IWineD3DSurface fields */
810 IWineD3DBase *container;
811 WINED3DSURFACET_DESC currentDesc;
812 IWineD3DPaletteImpl *palette;
817 /* TODO: move this off into a management class(maybe!) */
825 /* precalculated x and y scalings for texture coords */
826 float pow2scalingFactorX; /* = (Width / pow2Width ) */
827 float pow2scalingFactorY; /* = (Height / pow2Height) */
833 glDescriptor glDescription;
836 wineD3DSurface_DIB dib;
839 /* Color keys for DDraw */
840 DDCOLORKEY DestBltCKey;
841 DDCOLORKEY DestOverlayCKey;
842 DDCOLORKEY SrcOverlayCKey;
843 DDCOLORKEY SrcBltCKey;
848 extern const IWineD3DSurfaceVtbl IWineD3DSurface_Vtbl;
851 #define SFLAG_OVERSIZE 0x0001 /* Surface is bigger than gl size, blts only */
852 #define SFLAG_CONVERTED 0x0002 /* Converted for color keying or Palettized */
853 #define SFLAG_DIBSECTION 0x0004 /* Has a DIB section attached for getdc */
854 #define SFLAG_DIRTY 0x0008 /* Surface was locked by the app */
855 #define SFLAG_LOCKABLE 0x0010 /* Surface can be locked */
856 #define SFLAG_DISCARD 0x0020 /* ??? */
857 #define SFLAG_LOCKED 0x0040 /* Surface is locked atm */
858 #define SFLAG_ACTIVELOCK 0x0080 /* Not locked, but surface memory is needed */
859 #define SFLAG_INTEXTURE 0x0100 /* ??? */
860 #define SFLAG_INPBUFFER 0x0200 /* ??? */
861 #define SFLAG_NONPOW2 0x0400 /* Surface sizes are not a power of 2 */
862 #define SFLAG_DYNLOCK 0x0800 /* Surface is often locked by the app */
863 #define SFLAG_DYNCHANGE 0x1800 /* Surface contents are changed very often, implies DYNLOCK */
864 #define SFLAG_DCINUSE 0x2000 /* Set between GetDC and ReleaseDC calls */
865 #define SFLAG_NEWDC 0x4000 /* To inform LockRect about a new dc */
866 #define SFLAG_LOST 0x8000 /* Surface lost flag for DDraw */
868 /* In some conditions the surface memory must not be freed:
869 * SFLAG_OVERSIZE: Not all data can be kept in GL
870 * SFLAG_CONVERTED: Converting the data back would take too long
871 * SFLAG_DIBSECTION: The dib code manages the memory
872 * SFLAG_DIRTY: GL surface isn't up to date
873 * SFLAG_LOCKED: The app requires access to the surface data
874 * SFLAG_ACTIVELOCK: Some wined3d code needs the memory
875 * SFLAG_DYNLOCK: Avoid freeing the data for performance
876 * SFLAG_DYNCHANGE: Same reason as DYNLOCK
878 #define SFLAG_DONOTFREE (SFLAG_OVERSIZE | \
887 /*****************************************************************************
888 * IWineD3DVertexDeclaration implementation structure
890 typedef struct IWineD3DVertexDeclarationImpl {
891 /* IUnknown Information */
892 const IWineD3DVertexDeclarationVtbl *lpVtbl;
893 LONG ref; /* Note: Ref counting not required */
896 /** precomputed fvf if simple declaration */
897 IWineD3DDeviceImpl *wineD3DDevice;
898 DWORD fvf[MAX_STREAMS];
901 /** dx8 compatible Declaration fields */
902 DWORD* pDeclaration8;
903 DWORD declaration8Length;
906 D3DVERTEXELEMENT9 *pDeclaration9;
907 UINT declaration9NumElements;
909 WINED3DVERTEXELEMENT *pDeclarationWine;
910 UINT declarationWNumElements;
914 } IWineD3DVertexDeclarationImpl;
916 extern const IWineD3DVertexDeclarationVtbl IWineD3DVertexDeclaration_Vtbl;
918 /*****************************************************************************
919 * IWineD3DStateBlock implementation structure
922 /* Internal state Block for Begin/End/Capture/Create/Apply info */
923 /* Note: Very long winded but gl Lists are not flexible enough */
924 /* to resolve everything we need, so doing it manually for now */
925 typedef struct SAVEDSTATES {
929 BOOL streamSource[MAX_STREAMS];
930 BOOL streamFreq[MAX_STREAMS];
931 BOOL textures[MAX_TEXTURES];
932 BOOL transform[HIGHEST_TRANSFORMSTATE + 1];
934 BOOL renderState[WINEHIGHEST_RENDER_STATE + 1];
935 BOOL textureState[MAX_TEXTURES][WINED3D_HIGHEST_TEXTURE_STATE + 1];
936 BOOL samplerState[MAX_SAMPLERS][WINED3D_HIGHEST_SAMPLER_STATE + 1];
937 BOOL clipplane[MAX_CLIPPLANES];
940 BOOL pixelShaderConstants[MAX_PSHADER_CONSTANTS];
942 BOOL vertexShaderConstants[MAX_VSHADER_CONSTANTS];
946 WINESHADERCNST_NONE = 0,
947 WINESHADERCNST_FLOAT = 1,
948 WINESHADERCNST_INTEGER = 2,
949 WINESHADERCNST_BOOL = 3
952 struct IWineD3DStateBlockImpl
954 /* IUnknown fields */
955 const IWineD3DStateBlockVtbl *lpVtbl;
956 LONG ref; /* Note: Ref counting not required */
958 /* IWineD3DStateBlock information */
960 IWineD3DDeviceImpl *wineD3DDevice;
961 WINED3DSTATEBLOCKTYPE blockType;
963 /* Array indicating whether things have been set or changed */
967 /* Drawing - Vertex Shader or FVF related */
969 /* Vertex Shader Declaration */
970 IWineD3DVertexDeclaration *vertexDecl;
972 IWineD3DVertexShader *vertexShader;
974 /* Vertex Shader Constants */
975 BOOL vertexShaderConstantB[MAX_VSHADER_CONSTANTS];
976 INT vertexShaderConstantI[MAX_VSHADER_CONSTANTS * 4];
977 float vertexShaderConstantF[MAX_VSHADER_CONSTANTS * 4];
978 WINESHADERCNST vertexShaderConstantT[MAX_VSHADER_CONSTANTS]; /* TODO: Think about changing this to a char to possibly save a little memory */
982 UINT streamStride[MAX_STREAMS];
983 UINT streamOffset[MAX_STREAMS];
984 IWineD3DVertexBuffer *streamSource[MAX_STREAMS];
985 UINT streamFreq[MAX_STREAMS];
986 UINT streamFlags[MAX_STREAMS]; /*0 | D3DSTREAMSOURCE_INSTANCEDATA | D3DSTREAMSOURCE_INDEXEDDATA */
989 IWineD3DIndexBuffer* pIndexData;
990 UINT baseVertexIndex; /* Note: only used for d3d8 */
993 D3DMATRIX transforms[HIGHEST_TRANSFORMSTATE + 1];
996 PLIGHTINFOEL *lights; /* NOTE: active GL lights must be front of the chain */
999 double clipplane[MAX_CLIPPLANES][4];
1000 WINED3DCLIPSTATUS clip_status;
1003 WINED3DVIEWPORT viewport;
1006 WINED3DMATERIAL material;
1009 IWineD3DPixelShader *pixelShader;
1011 /* Pixel Shader Constants */
1012 BOOL pixelShaderConstantB[MAX_PSHADER_CONSTANTS];
1013 INT pixelShaderConstantI[MAX_PSHADER_CONSTANTS * 4];
1014 float pixelShaderConstantF[MAX_PSHADER_CONSTANTS * 4];
1015 WINESHADERCNST pixelShaderConstantT[MAX_PSHADER_CONSTANTS]; /* TODO: Think about changing this to a char to possibly save a little memory */
1017 /* Indexed Vertex Blending */
1018 D3DVERTEXBLENDFLAGS vertex_blend;
1022 DWORD renderState[WINEHIGHEST_RENDER_STATE + 1];
1025 IWineD3DBaseTexture *textures[MAX_TEXTURES];
1026 int textureDimensions[MAX_SAMPLERS];
1028 /* Texture State Stage */
1029 DWORD textureState[MAX_TEXTURES][WINED3D_HIGHEST_TEXTURE_STATE + 1];
1030 /* Sampler States */
1031 DWORD samplerState[MAX_SAMPLERS][WINED3D_HIGHEST_SAMPLER_STATE + 1];
1035 extern const IWineD3DStateBlockVtbl IWineD3DStateBlock_Vtbl;
1037 /*****************************************************************************
1038 * IWineD3DQueryImpl implementation structure (extends IUnknown)
1040 typedef struct IWineD3DQueryImpl
1042 const IWineD3DQueryVtbl *lpVtbl;
1043 LONG ref; /* Note: Ref counting not required */
1046 /*TODO: replace with iface usage */
1048 IWineD3DDevice *wineD3DDevice;
1050 IWineD3DDeviceImpl *wineD3DDevice;
1052 /* IWineD3DQuery fields */
1055 /* TODO: Think about using a IUnknown instead of a void* */
1059 } IWineD3DQueryImpl;
1061 extern const IWineD3DQueryVtbl IWineD3DQuery_Vtbl;
1063 /* Datastructures for IWineD3DQueryImpl.extendedData */
1064 typedef struct WineQueryOcclusionData {
1065 unsigned int queryId;
1066 } WineQueryOcclusionData;
1069 /*****************************************************************************
1070 * IWineD3DSwapChainImpl implementation structure (extends IUnknown)
1073 typedef struct IWineD3DSwapChainImpl
1076 IWineD3DSwapChainVtbl *lpVtbl;
1077 LONG ref; /* Note: Ref counting not required */
1080 IWineD3DDeviceImpl *wineD3DDevice;
1082 /* IWineD3DSwapChain fields */
1083 IWineD3DSurface *backBuffer;
1084 IWineD3DSurface *frontBuffer;
1085 BOOL wantsDepthStencilBuffer;
1086 D3DPRESENT_PARAMETERS presentParms;
1088 /* TODO: move everything up to drawable off into a context manager
1089 and store the 'data' in the contextManagerData interface.
1090 IUnknown *contextManagerData;
1098 XVisualInfo *visInfo;
1099 GLXContext render_ctx;
1100 /* This has been left in device for now, but needs moving off into a rendertarget management class and separated out from swapchains and devices. */
1102 } IWineD3DSwapChainImpl;
1104 extern IWineD3DSwapChainVtbl IWineD3DSwapChain_Vtbl;
1106 /*****************************************************************************
1107 * Utility function prototypes
1110 /* Trace routines */
1111 const char* debug_d3dformat(WINED3DFORMAT fmt);
1112 const char* debug_d3ddevicetype(D3DDEVTYPE devtype);
1113 const char* debug_d3dresourcetype(WINED3DRESOURCETYPE res);
1114 const char* debug_d3dusage(DWORD usage);
1115 const char* debug_d3dprimitivetype(D3DPRIMITIVETYPE PrimitiveType);
1116 const char* debug_d3drenderstate(DWORD state);
1117 const char* debug_d3dtexturestate(DWORD state);
1118 const char* debug_d3dpool(WINED3DPOOL pool);
1120 /* Routines for GL <-> D3D values */
1121 GLenum StencilOp(DWORD op);
1122 void set_tex_op(IWineD3DDevice *iface, BOOL isAlpha, int Stage, D3DTEXTUREOP op, DWORD arg1, DWORD arg2, DWORD arg3);
1123 void set_texture_matrix(const float *smat, DWORD flags, BOOL calculatedCoords);
1124 void GetSrcAndOpFromValue(DWORD iValue, BOOL isAlphaArg, GLenum* source, GLenum* operand);
1126 SHORT D3DFmtGetBpp(IWineD3DDeviceImpl* This, D3DFORMAT fmt);
1127 GLenum D3DFmt2GLFmt(IWineD3DDeviceImpl* This, D3DFORMAT fmt);
1128 GLenum D3DFmt2GLType(IWineD3DDeviceImpl *This, D3DFORMAT fmt);
1129 GLint D3DFmt2GLIntFmt(IWineD3DDeviceImpl* This, D3DFORMAT fmt);
1131 int D3DFmtMakeGlCfg(D3DFORMAT BackBufferFormat, D3DFORMAT StencilBufferFormat, int *attribs, int* nAttribs, BOOL alternate);
1134 /*****************************************************************************
1135 * To enable calling of inherited functions, requires prototypes
1137 * Note: Only require classes which are subclassed, ie resource, basetexture,
1139 /*** IUnknown methods ***/
1140 extern HRESULT WINAPI IWineD3DResourceImpl_QueryInterface(IWineD3DResource *iface, REFIID riid, void** ppvObject);
1141 extern ULONG WINAPI IWineD3DResourceImpl_AddRef(IWineD3DResource *iface);
1142 extern ULONG WINAPI IWineD3DResourceImpl_Release(IWineD3DResource *iface);
1143 /*** IWineD3DResource methods ***/
1144 extern HRESULT WINAPI IWineD3DResourceImpl_GetParent(IWineD3DResource *iface, IUnknown **pParent);
1145 extern HRESULT WINAPI IWineD3DResourceImpl_GetDevice(IWineD3DResource *iface, IWineD3DDevice ** ppDevice);
1146 extern HRESULT WINAPI IWineD3DResourceImpl_SetPrivateData(IWineD3DResource *iface, REFGUID refguid, CONST void * pData, DWORD SizeOfData, DWORD Flags);
1147 extern HRESULT WINAPI IWineD3DResourceImpl_GetPrivateData(IWineD3DResource *iface, REFGUID refguid, void * pData, DWORD * pSizeOfData);
1148 extern HRESULT WINAPI IWineD3DResourceImpl_FreePrivateData(IWineD3DResource *iface, REFGUID refguid);
1149 extern DWORD WINAPI IWineD3DResourceImpl_SetPriority(IWineD3DResource *iface, DWORD PriorityNew);
1150 extern DWORD WINAPI IWineD3DResourceImpl_GetPriority(IWineD3DResource *iface);
1151 extern void WINAPI IWineD3DResourceImpl_PreLoad(IWineD3DResource *iface);
1152 extern WINED3DRESOURCETYPE WINAPI IWineD3DResourceImpl_GetType(IWineD3DResource *iface);
1153 /*** class static members ***/
1154 void IWineD3DResourceImpl_CleanUp(IWineD3DResource *iface);
1156 /*** IUnknown methods ***/
1157 extern HRESULT WINAPI IWineD3DBaseTextureImpl_QueryInterface(IWineD3DBaseTexture *iface, REFIID riid, void** ppvObject);
1158 extern ULONG WINAPI IWineD3DBaseTextureImpl_AddRef(IWineD3DBaseTexture *iface);
1159 extern ULONG WINAPI IWineD3DBaseTextureImpl_Release(IWineD3DBaseTexture *iface);
1160 /*** IWineD3DResource methods ***/
1161 extern HRESULT WINAPI IWineD3DBaseTextureImpl_GetParent(IWineD3DBaseTexture *iface, IUnknown **pParent);
1162 extern HRESULT WINAPI IWineD3DBaseTextureImpl_GetDevice(IWineD3DBaseTexture *iface, IWineD3DDevice ** ppDevice);
1163 extern HRESULT WINAPI IWineD3DBaseTextureImpl_SetPrivateData(IWineD3DBaseTexture *iface, REFGUID refguid, CONST void * pData, DWORD SizeOfData, DWORD Flags);
1164 extern HRESULT WINAPI IWineD3DBaseTextureImpl_GetPrivateData(IWineD3DBaseTexture *iface, REFGUID refguid, void * pData, DWORD * pSizeOfData);
1165 extern HRESULT WINAPI IWineD3DBaseTextureImpl_FreePrivateData(IWineD3DBaseTexture *iface, REFGUID refguid);
1166 extern DWORD WINAPI IWineD3DBaseTextureImpl_SetPriority(IWineD3DBaseTexture *iface, DWORD PriorityNew);
1167 extern DWORD WINAPI IWineD3DBaseTextureImpl_GetPriority(IWineD3DBaseTexture *iface);
1168 extern void WINAPI IWineD3DBaseTextureImpl_PreLoad(IWineD3DBaseTexture *iface);
1169 extern WINED3DRESOURCETYPE WINAPI IWineD3DBaseTextureImpl_GetType(IWineD3DBaseTexture *iface);
1170 /*** IWineD3DBaseTexture methods ***/
1171 extern DWORD WINAPI IWineD3DBaseTextureImpl_SetLOD(IWineD3DBaseTexture *iface, DWORD LODNew);
1172 extern DWORD WINAPI IWineD3DBaseTextureImpl_GetLOD(IWineD3DBaseTexture *iface);
1173 extern DWORD WINAPI IWineD3DBaseTextureImpl_GetLevelCount(IWineD3DBaseTexture *iface);
1174 extern HRESULT WINAPI IWineD3DBaseTextureImpl_SetAutoGenFilterType(IWineD3DBaseTexture *iface, WINED3DTEXTUREFILTERTYPE FilterType);
1175 extern WINED3DTEXTUREFILTERTYPE WINAPI IWineD3DBaseTextureImpl_GetAutoGenFilterType(IWineD3DBaseTexture *iface);
1176 extern void WINAPI IWineD3DBaseTextureImpl_GenerateMipSubLevels(IWineD3DBaseTexture *iface);
1177 extern BOOL WINAPI IWineD3DBaseTextureImpl_SetDirty(IWineD3DBaseTexture *iface, BOOL);
1178 extern BOOL WINAPI IWineD3DBaseTextureImpl_GetDirty(IWineD3DBaseTexture *iface);
1180 extern BYTE* WINAPI IWineD3DVertexBufferImpl_GetMemory(IWineD3DVertexBuffer* iface, DWORD iOffset);
1181 extern HRESULT WINAPI IWineD3DVertexBufferImpl_ReleaseMemory(IWineD3DVertexBuffer* iface);
1182 extern HRESULT WINAPI IWineD3DBaseTextureImpl_BindTexture(IWineD3DBaseTexture *iface);
1183 extern HRESULT WINAPI IWineD3DBaseTextureImpl_UnBindTexture(IWineD3DBaseTexture *iface);
1184 extern void WINAPI IWineD3DBaseTextureImpl_ApplyStateChanges(IWineD3DBaseTexture *iface, const DWORD textureStates[WINED3D_HIGHEST_TEXTURE_STATE + 1], const DWORD samplerStates[WINED3D_HIGHEST_SAMPLER_STATE + 1]);
1185 /*** class static members ***/
1186 void IWineD3DBaseTextureImpl_CleanUp(IWineD3DBaseTexture *iface);
1188 /* An enum for the type of constants that are used... addressing causes
1189 * problems with being able to work out what's used and what's not.. so
1190 * maybe we'll have to rely on the server vertex shader const functions?
1192 enum vsConstantsEnum {
1193 VS_CONSTANT_NOT_USED = 0,
1194 VS_CONSTANT_CONSTANT,
1195 VS_CONSTANT_INTEGER,
1196 VS_CONSTANT_BOOLEAN,
1200 struct SHADER_OPCODE_ARG;
1201 typedef void (*shader_fct_t)();
1202 typedef void (*SHADER_HANDLER) (struct SHADER_OPCODE_ARG*);
1204 #define SHADER_PGMSIZE 65535
1205 typedef struct SHADER_BUFFER {
1208 unsigned int lineNo;
1211 typedef struct SHADER_OPCODE {
1212 unsigned int opcode;
1215 CONST UINT num_params;
1216 shader_fct_t soft_fct;
1217 SHADER_HANDLER hw_fct;
1222 typedef struct SHADER_OPCODE_ARG {
1223 IWineD3DBaseShader* shader;
1224 CONST SHADER_OPCODE* opcode;
1227 SHADER_BUFFER* buffer;
1228 } SHADER_OPCODE_ARG;
1230 typedef struct SHADER_LIMITS {
1231 unsigned int temporary;
1232 unsigned int texture;
1233 unsigned int constant_int;
1234 unsigned int constant_float;
1235 unsigned int constant_bool;
1236 unsigned int address;
1239 /** Keeps track of details for TEX_M#x# shader opcodes which need to
1240 maintain state information between multiple codes */
1241 typedef struct SHADER_PARSE_STATE {
1242 unsigned int current_row;
1243 DWORD texcoord_w[2];
1244 } SHADER_PARSE_STATE;
1246 /* Base Shader utility functions.
1247 * (may move callers into the same file in the future) */
1248 extern int shader_addline(
1249 SHADER_BUFFER* buffer,
1250 const char* fmt, ...);
1252 extern const SHADER_OPCODE* shader_get_opcode(
1253 IWineD3DBaseShader *iface,
1256 /*****************************************************************************
1257 * IDirect3DBaseShader implementation structure
1259 typedef struct IWineD3DBaseShaderClass
1263 SHADER_LIMITS limits;
1264 SHADER_PARSE_STATE parse_state;
1265 CONST SHADER_OPCODE *shader_ins;
1266 CONST DWORD *function;
1267 UINT functionLength;
1269 } IWineD3DBaseShaderClass;
1271 typedef struct IWineD3DBaseShaderImpl {
1273 const IWineD3DBaseShaderVtbl *lpVtbl;
1276 /* IWineD3DBaseShader */
1277 IWineD3DBaseShaderClass baseShader;
1278 } IWineD3DBaseShaderImpl;
1280 extern void shader_get_registers_used(
1281 IWineD3DBaseShader *iface,
1282 CONST DWORD* pToken,
1286 extern void shader_program_dump_decl_usage(
1290 inline static int shader_get_regtype(const DWORD param) {
1291 return (((param & D3DSP_REGTYPE_MASK) >> D3DSP_REGTYPE_SHIFT) |
1292 ((param & D3DSP_REGTYPE_MASK2) >> D3DSP_REGTYPE_SHIFT2));
1295 /*****************************************************************************
1296 * IDirect3DVertexShader implementation structure
1298 typedef struct IWineD3DVertexShaderImpl {
1300 const IWineD3DVertexShaderVtbl *lpVtbl;
1301 LONG ref; /* Note: Ref counting not required */
1303 /* IWineD3DBaseShader */
1304 IWineD3DBaseShaderClass baseShader;
1306 /* IWineD3DVertexShaderImpl */
1308 IWineD3DDeviceImpl *wineD3DDevice;
1312 /* vertex declaration array mapping */
1313 BOOL namedArrays; /* don't map use named functions */
1314 BOOL declaredArrays; /* mapping requires */
1315 INT arrayUsageMap[WINED3DSHADERDECLUSAGE_MAX_USAGE]; /* lookup table for the maps */
1316 INT highestConstant;
1317 CHAR constantsUsedBitmap[256];
1318 /* 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 */
1319 /* run time datas... */
1321 IWineD3DVertexDeclaration *vertexDeclaration;
1322 #if 0 /* needs reworking */
1323 /* run time datas */
1324 VSHADERINPUTDATA input;
1325 VSHADEROUTPUTDATA output;
1327 } IWineD3DVertexShaderImpl;
1328 extern const SHADER_OPCODE IWineD3DVertexShaderImpl_shader_ins[];
1329 extern const IWineD3DVertexShaderVtbl IWineD3DVertexShader_Vtbl;
1331 /*****************************************************************************
1332 * IDirect3DPixelShader implementation structure
1334 typedef struct IWineD3DPixelShaderImpl {
1335 /* IUnknown parts */
1336 const IWineD3DPixelShaderVtbl *lpVtbl;
1337 LONG ref; /* Note: Ref counting not required */
1339 /* IWineD3DBaseShader */
1340 IWineD3DBaseShaderClass baseShader;
1342 /* IWineD3DPixelShaderImpl */
1344 IWineD3DDeviceImpl *wineD3DDevice;
1346 CHAR constants[WINED3D_PSHADER_MAX_CONSTANTS];
1351 #if 0 /* needs reworking */
1352 PSHADERINPUTDATA input;
1353 PSHADEROUTPUTDATA output;
1355 } IWineD3DPixelShaderImpl;
1357 extern const SHADER_OPCODE IWineD3DPixelShaderImpl_shader_ins[];
1358 extern const IWineD3DPixelShaderVtbl IWineD3DPixelShader_Vtbl;
1360 /*****************************************************************************
1361 * IWineD3DPalette implementation structure
1363 struct IWineD3DPaletteImpl {
1364 /* IUnknown parts */
1365 const IWineD3DPaletteVtbl *lpVtbl;
1369 IWineD3DDeviceImpl *wineD3DDevice;
1371 /* IWineD3DPalette */
1373 WORD palVersion; /*| */
1374 WORD palNumEntries; /*| LOGPALETTE */
1375 PALETTEENTRY palents[256]; /*| */
1376 /* This is to store the palette in 'screen format' */
1377 int screen_palents[256];
1381 extern const IWineD3DPaletteVtbl IWineD3DPalette_Vtbl;
1382 DWORD IWineD3DPaletteImpl_Size(DWORD dwFlags);
1384 /* DirectDraw utility functions */
1385 extern WINED3DFORMAT pixelformat_for_depth(DWORD depth);
1386 LONG get_bitmask_red(WINED3DFORMAT fmt);
1387 LONG get_bitmask_green(WINED3DFORMAT fmt);
1388 LONG get_bitmask_blue(WINED3DFORMAT fmt);
1389 LONG get_bitmask_alpha(WINED3DFORMAT fmt);