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
29 #define NONAMELESSUNION
30 #define NONAMELESSSTRUCT
37 #include "wine/debug.h"
38 #include "wine/unicode.h"
41 #include "d3d9types.h"
42 #include "wined3d_private_types.h"
44 #include "wine/wined3d_interface.h"
45 #include "wine/wined3d_gl.h"
46 #include "wine/list.h"
49 #define MAX_PALETTES 256
50 #define MAX_STREAMS 16
51 #define MAX_TEXTURES 8
52 #define MAX_SAMPLERS 16
53 #define MAX_ACTIVE_LIGHTS 8
54 #define MAX_CLIPPLANES WINED3DMAXUSERCLIPPLANES
55 #define MAX_LEVELS 256
57 #define MAX_CONST_I 16
58 #define MAX_CONST_B 16
60 /* Used for CreateStateBlock */
61 #define NUM_SAVEDPIXELSTATES_R 35
62 #define NUM_SAVEDPIXELSTATES_T 18
63 #define NUM_SAVEDPIXELSTATES_S 12
64 #define NUM_SAVEDVERTEXSTATES_R 31
65 #define NUM_SAVEDVERTEXSTATES_T 2
66 #define NUM_SAVEDVERTEXSTATES_S 1
68 extern const DWORD SavedPixelStates_R[NUM_SAVEDPIXELSTATES_R];
69 extern const DWORD SavedPixelStates_T[NUM_SAVEDPIXELSTATES_T];
70 extern const DWORD SavedPixelStates_S[NUM_SAVEDPIXELSTATES_S];
71 extern const DWORD SavedVertexStates_R[NUM_SAVEDVERTEXSTATES_R];
72 extern const DWORD SavedVertexStates_T[NUM_SAVEDVERTEXSTATES_T];
73 extern const DWORD SavedVertexStates_S[NUM_SAVEDVERTEXSTATES_S];
75 typedef enum _WINELOOKUP {
76 WINELOOKUP_WARPPARAM = 0,
77 WINELOOKUP_MAGFILTER = 1,
81 extern int minLookup[MAX_LOOKUPS];
82 extern int maxLookup[MAX_LOOKUPS];
83 extern DWORD *stateLookup[MAX_LOOKUPS];
85 extern DWORD minMipLookup[WINED3DTEXF_ANISOTROPIC + 1][WINED3DTEXF_LINEAR + 1];
87 typedef struct _WINED3DGLTYPE {
95 /* NOTE: Make sure these are in the correct numerical order. (see /include/wined3d_types.h) */
96 static WINED3DGLTYPE const glTypeLookup[WINED3DDECLTYPE_UNUSED] = {
97 {WINED3DDECLTYPE_FLOAT1, 1, GL_FLOAT , GL_FALSE ,sizeof(float)},
98 {WINED3DDECLTYPE_FLOAT2, 2, GL_FLOAT , GL_FALSE ,sizeof(float)},
99 {WINED3DDECLTYPE_FLOAT3, 3, GL_FLOAT , GL_FALSE ,sizeof(float)},
100 {WINED3DDECLTYPE_FLOAT4, 4, GL_FLOAT , GL_FALSE ,sizeof(float)},
101 {WINED3DDECLTYPE_D3DCOLOR, 4, GL_UNSIGNED_BYTE , GL_TRUE ,sizeof(BYTE)},
102 {WINED3DDECLTYPE_UBYTE4, 4, GL_UNSIGNED_BYTE , GL_FALSE ,sizeof(BYTE)},
103 {WINED3DDECLTYPE_SHORT2, 2, GL_SHORT , GL_FALSE ,sizeof(short int)},
104 {WINED3DDECLTYPE_SHORT4, 4, GL_SHORT , GL_FALSE ,sizeof(short int)},
105 {WINED3DDECLTYPE_UBYTE4N, 4, GL_UNSIGNED_BYTE , GL_FALSE ,sizeof(BYTE)},
106 {WINED3DDECLTYPE_SHORT2N, 2, GL_SHORT , GL_FALSE ,sizeof(short int)},
107 {WINED3DDECLTYPE_SHORT4N, 4, GL_SHORT , GL_FALSE ,sizeof(short int)},
108 {WINED3DDECLTYPE_USHORT2N, 2, GL_UNSIGNED_SHORT , GL_FALSE ,sizeof(short int)},
109 {WINED3DDECLTYPE_USHORT4N, 4, GL_UNSIGNED_SHORT , GL_FALSE ,sizeof(short int)},
110 {WINED3DDECLTYPE_UDEC3, 3, GL_UNSIGNED_SHORT , GL_FALSE ,sizeof(short int)},
111 {WINED3DDECLTYPE_DEC3N, 3, GL_SHORT , GL_FALSE ,sizeof(short int)},
112 {WINED3DDECLTYPE_FLOAT16_2, 2, GL_FLOAT , GL_FALSE ,sizeof(short int)},
113 {WINED3DDECLTYPE_FLOAT16_4, 4, GL_FLOAT , GL_FALSE ,sizeof(short int)}};
115 #define WINED3D_ATR_TYPE(type) glTypeLookup[type].d3dType
116 #define WINED3D_ATR_SIZE(type) glTypeLookup[type].size
117 #define WINED3D_ATR_GLTYPE(type) glTypeLookup[type].glType
118 #define WINED3D_ATR_NORMALIZED(type) glTypeLookup[type].normalized
119 #define WINED3D_ATR_TYPESIZE(type) glTypeLookup[type].typesize
138 #define ORM_BACKBUFFER 0
139 #define ORM_PBUFFER 1
144 #define SHADER_GLSL 2
145 #define SHADER_NONE 3
147 #define RTL_DISABLE -1
149 #define RTL_READDRAW 1
150 #define RTL_READTEX 2
151 #define RTL_TEXDRAW 3
154 /* NOTE: When adding fields to this structure, make sure to update the default
155 * values in wined3d_main.c as well. */
156 typedef struct wined3d_settings_s {
157 /* vertex and pixel shader modes */
161 /* Ideally, we don't want the user to have to request GLSL. If the hardware supports GLSL,
162 we should use it. However, until it's fully implemented, we'll leave it as a registry
163 setting for developers. */
165 /* nonpower 2 function */
167 int offscreen_rendering_mode;
168 int rendertargetlock_mode;
169 /* Memory tracking and object counting */
170 unsigned int emulated_textureram;
171 } wined3d_settings_t;
173 extern wined3d_settings_t wined3d_settings;
175 /* Shader backends */
178 void (*shader_select)(IWineD3DDevice *iface, BOOL usePS, BOOL useVS);
179 void (*shader_select_depth_blt)(IWineD3DDevice *iface);
180 void (*shader_load_constants)(IWineD3DDevice *iface, char usePS, char useVS);
181 void (*shader_cleanup)(BOOL usePS, BOOL useVS);
184 extern const shader_backend_t glsl_shader_backend;
185 extern const shader_backend_t arb_program_shader_backend;
186 extern const shader_backend_t none_shader_backend;
190 extern void (*wine_tsx11_lock_ptr)(void);
191 extern void (*wine_tsx11_unlock_ptr)(void);
193 /* As GLX relies on X, this is needed */
197 #define ENTER_GL() ++num_lock; if (num_lock > 1) FIXME("Recursive use of GL lock to: %d\n", num_lock); wine_tsx11_lock_ptr()
198 #define LEAVE_GL() if (num_lock != 1) FIXME("Recursive use of GL lock: %d\n", num_lock); --num_lock; wine_tsx11_unlock_ptr()
200 #define ENTER_GL() wine_tsx11_lock_ptr()
201 #define LEAVE_GL() wine_tsx11_unlock_ptr()
204 /*****************************************************************************
208 /* GL related defines */
209 /* ------------------ */
210 #define GL_SUPPORT(ExtName) (GLINFO_LOCATION.supported[ExtName] != 0)
211 #define GL_LIMITS(ExtName) (GLINFO_LOCATION.max_##ExtName)
212 #define GL_EXTCALL(FuncName) (GLINFO_LOCATION.FuncName)
213 #define GL_VEND(_VendName) (GLINFO_LOCATION.gl_vendor == VENDOR_##_VendName ? TRUE : FALSE)
215 #define D3DCOLOR_B_R(dw) (((dw) >> 16) & 0xFF)
216 #define D3DCOLOR_B_G(dw) (((dw) >> 8) & 0xFF)
217 #define D3DCOLOR_B_B(dw) (((dw) >> 0) & 0xFF)
218 #define D3DCOLOR_B_A(dw) (((dw) >> 24) & 0xFF)
220 #define D3DCOLOR_R(dw) (((float) (((dw) >> 16) & 0xFF)) / 255.0f)
221 #define D3DCOLOR_G(dw) (((float) (((dw) >> 8) & 0xFF)) / 255.0f)
222 #define D3DCOLOR_B(dw) (((float) (((dw) >> 0) & 0xFF)) / 255.0f)
223 #define D3DCOLOR_A(dw) (((float) (((dw) >> 24) & 0xFF)) / 255.0f)
225 #define D3DCOLORTOGLFLOAT4(dw, vec) \
226 (vec)[0] = D3DCOLOR_R(dw); \
227 (vec)[1] = D3DCOLOR_G(dw); \
228 (vec)[2] = D3DCOLOR_B(dw); \
229 (vec)[3] = D3DCOLOR_A(dw);
231 /* DirectX Device Limits */
232 /* --------------------- */
233 #define MAX_LEVELS 256 /* Maximum number of mipmap levels. Guessed at 256 */
235 #define MAX_STREAMS 16 /* Maximum possible streams - used for fixed size arrays
236 See MaxStreams in MSDN under GetDeviceCaps */
237 /* Maximum number of constants provided to the shaders */
238 #define HIGHEST_TRANSFORMSTATE 512
239 /* Highest value in WINED3DTRANSFORMSTATETYPE */
240 #define MAX_PALETTES 256
242 /* Checking of API calls */
243 /* --------------------- */
244 #define checkGLcall(A) \
246 GLint err = glGetError(); \
247 if (err == GL_NO_ERROR) { \
248 TRACE("%s call ok %s / %d\n", A, __FILE__, __LINE__); \
251 FIXME(">>>>>>>>>>>>>>>>> %x from %s @ %s / %d\n", \
252 err, A, __FILE__, __LINE__); \
253 err = glGetError(); \
254 } while (err != GL_NO_ERROR); \
257 /* Trace routines / diagnostics */
258 /* ---------------------------- */
260 /* Dump out a matrix and copy it */
261 #define conv_mat(mat,gl_mat) \
263 TRACE("%f %f %f %f\n", (mat)->u.s._11, (mat)->u.s._12, (mat)->u.s._13, (mat)->u.s._14); \
264 TRACE("%f %f %f %f\n", (mat)->u.s._21, (mat)->u.s._22, (mat)->u.s._23, (mat)->u.s._24); \
265 TRACE("%f %f %f %f\n", (mat)->u.s._31, (mat)->u.s._32, (mat)->u.s._33, (mat)->u.s._34); \
266 TRACE("%f %f %f %f\n", (mat)->u.s._41, (mat)->u.s._42, (mat)->u.s._43, (mat)->u.s._44); \
267 memcpy(gl_mat, (mat), 16 * sizeof(float)); \
270 /* Macro to dump out the current state of the light chain */
271 #define DUMP_LIGHT_CHAIN() \
273 PLIGHTINFOEL *el = This->stateBlock->lights;\
275 TRACE("Light %p (glIndex %ld, d3dIndex %ld, enabled %d)\n", el, el->glIndex, el->OriginalIndex, el->lightEnabled);\
280 /* Trace vector and strided data information */
281 #define TRACE_VECTOR(name) TRACE( #name "=(%f, %f, %f, %f)\n", name.x, name.y, name.z, name.w);
282 #define TRACE_STRIDED(sd,name) TRACE( #name "=(data:%p, stride:%d, type:%d)\n", sd->u.s.name.lpData, sd->u.s.name.dwStride, sd->u.s.name.dwType);
284 /* Defines used for optimizations */
286 /* Only reapply what is necessary */
287 #define REAPPLY_ALPHAOP 0x0001
288 #define REAPPLY_ALL 0xFFFF
290 /* Advance declaration of structures to satisfy compiler */
291 typedef struct IWineD3DStateBlockImpl IWineD3DStateBlockImpl;
292 typedef struct IWineD3DSurfaceImpl IWineD3DSurfaceImpl;
293 typedef struct IWineD3DPaletteImpl IWineD3DPaletteImpl;
297 /* TODO: Move some of this to the device */
298 long globalChangeGlRam(long glram);
300 /* Memory and object tracking */
302 /*Structure for holding information on all direct3d objects
303 useful for making sure tracking is ok and when release is called on a device!
304 and probably quite handy for debugging and dumping states out
306 typedef struct WineD3DGlobalStatistics {
307 int glsurfaceram; /* The aproximate amount of glTexture memory allocated for textures */
308 } WineD3DGlobalStatistics;
310 extern WineD3DGlobalStatistics* wineD3DGlobalStatistics;
312 /* Global variables */
313 extern const float identity[16];
315 /*****************************************************************************
316 * Compilable extra diagnostics
319 /* Trace information per-vertex: (extremely high amount of trace) */
320 #if 0 /* NOTE: Must be 0 in cvs */
321 # define VTRACE(A) TRACE A
326 /* Checking of per-vertex related GL calls */
327 /* --------------------- */
328 #define vcheckGLcall(A) \
330 GLint err = glGetError(); \
331 if (err == GL_NO_ERROR) { \
332 VTRACE(("%s call ok %s / %d\n", A, __FILE__, __LINE__)); \
335 FIXME(">>>>>>>>>>>>>>>>> %x from %s @ %s / %d\n", \
336 err, A, __FILE__, __LINE__); \
337 err = glGetError(); \
338 } while (err != GL_NO_ERROR); \
341 /* TODO: Confirm each of these works when wined3d move completed */
342 #if 0 /* NOTE: Must be 0 in cvs */
343 /* To avoid having to get gigabytes of trace, the following can be compiled in, and at the start
344 of each frame, a check is made for the existence of C:\D3DTRACE, and if it exists d3d trace
345 is enabled, and if it doesn't exist it is disabled. */
346 # define FRAME_DEBUGGING
347 /* Adding in the SINGLE_FRAME_DEBUGGING gives a trace of just what makes up a single frame, before
348 the file is deleted */
349 # if 1 /* NOTE: Must be 1 in cvs, as this is mostly more useful than a trace from program start */
350 # define SINGLE_FRAME_DEBUGGING
352 /* The following, when enabled, lets you see the makeup of the frame, by drawprimitive calls.
353 It can only be enabled when FRAME_DEBUGGING is also enabled
354 The contents of the back buffer are written into /tmp/backbuffer_* after each primitive
356 # if 0 /* NOTE: Must be 0 in cvs, as this give a lot of ppm files when compiled in */
357 # define SHOW_FRAME_MAKEUP 1
359 /* The following, when enabled, lets you see the makeup of the all the textures used during each
360 of the drawprimitive calls. It can only be enabled when SHOW_FRAME_MAKEUP is also enabled.
361 The contents of the textures assigned to each stage are written into
362 /tmp/texture_*_<Stage>.ppm after each primitive array is drawn. */
363 # if 0 /* NOTE: Must be 0 in cvs, as this give a lot of ppm files when compiled in */
364 # define SHOW_TEXTURE_MAKEUP 0
367 extern BOOL isDumpingFrames;
368 extern LONG primCounter;
371 /*****************************************************************************
375 /* Routine common to the draw primitive and draw indexed primitive routines */
376 void drawPrimitive(IWineD3DDevice *iface,
380 long StartVertexIndex,
381 UINT numberOfVertices,
386 WineDirect3DVertexStridedData *DrawPrimStrideData);
388 void primitiveConvertToStridedData(IWineD3DDevice *iface, WineDirect3DVertexStridedData *strided, LONG BaseVertexIndex, BOOL *fixup);
390 void primitiveDeclarationConvertToStridedData(
391 IWineD3DDevice *iface,
392 BOOL useVertexShaderFunction,
393 WineDirect3DVertexStridedData *strided,
394 LONG BaseVertexIndex,
397 void primitiveConvertFVFtoOffset(DWORD thisFVF,
400 WineDirect3DVertexStridedData *strided,
403 DWORD get_flexible_vertex_size(DWORD d3dvtVertexType);
407 #define GET_TEXCOORD_SIZE_FROM_FVF(d3dvtVertexType, tex_num) \
408 (((((d3dvtVertexType) >> (16 + (2 * (tex_num)))) + 1) & 0x03) + 1)
410 /* Routines and structures related to state management */
411 typedef void (*APPLYSTATEFUNC)(DWORD state, IWineD3DStateBlockImpl *stateblock);
413 #define STATE_RENDER(a) (a)
414 #define STATE_IS_RENDER(a) ((a) >= STATE_RENDER(1) && (a) <= STATE_RENDER(WINEHIGHEST_RENDER_STATE))
418 DWORD representative;
419 APPLYSTATEFUNC apply;
422 /* Global state table */
423 extern const struct StateEntry StateTable[];
425 /* Routine to fill gl caps for swapchains and IWineD3D */
426 BOOL IWineD3DImpl_FillGLCaps(IWineD3D *iface, Display* display);
428 /* Macros for doing basic GPU detection based on opengl capabilities */
429 #define WINE_D3D6_CAPABLE(gl_info) (gl_info->supported[ARB_MULTITEXTURE])
430 #define WINE_D3D7_CAPABLE(gl_info) (gl_info->supported[ARB_TEXTURE_COMPRESSION] && gl_info->supported[ARB_TEXTURE_CUBE_MAP] && gl_info->supported[ARB_TEXTURE_ENV_DOT3])
431 #define WINE_D3D8_CAPABLE(gl_info) WINE_D3D7_CAPABLE(gl_info) && (gl_info->supported[ARB_MULTISAMPLE] && gl_info->supported[ARB_TEXTURE_BORDER_CLAMP])
432 #define WINE_D3D9_CAPABLE(gl_info) WINE_D3D8_CAPABLE(gl_info) && (gl_info->supported[ARB_FRAGMENT_PROGRAM] && gl_info->supported[ARB_VERTEX_SHADER])
434 /* Default callbacks for implicit object destruction */
435 extern ULONG WINAPI D3DCB_DefaultDestroySurface(IWineD3DSurface *pSurface);
437 extern ULONG WINAPI D3DCB_DefaultDestroyVolume(IWineD3DVolume *pSurface);
439 /*****************************************************************************
440 * Internal representation of a light
442 typedef struct PLIGHTINFOEL PLIGHTINFOEL;
443 struct PLIGHTINFOEL {
444 WINED3DLIGHT OriginalParms; /* Note D3D8LIGHT == D3D9LIGHT */
451 /* Converted parms to speed up swapping lights */
461 /* The default light parameters */
462 extern const WINED3DLIGHT WINED3D_default_light;
464 /*****************************************************************************
465 * IWineD3D implementation structure
467 typedef struct IWineD3DImpl
469 /* IUnknown fields */
470 const IWineD3DVtbl *lpVtbl;
471 LONG ref; /* Note: Ref counting not required */
473 /* WineD3D Information */
479 WineD3D_GL_Info gl_info;
482 extern const IWineD3DVtbl IWineD3D_Vtbl;
484 /** Hacked out start of a context manager!! **/
485 typedef struct glContext {
492 IWineD3DSurface *pSurface;
493 #if 0 /* TODO: someway to represent the state of the context */
494 IWineD3DStateBlock *pStateBlock;
496 /* a few other things like format */
499 /* TODO: setup some flags in the regestry to enable, disable pbuffer support
500 (since it will break quite a few things until contexts are managed properly!) */
501 extern BOOL pbuffer_support;
502 /* allocate one pbuffer per surface */
503 extern BOOL pbuffer_per_surface;
505 /* Maximum number of contexts/pbuffers to keep in cache,
506 set to 100 because ATI's drivers don't support deleting pBuffers properly
507 this needs to be migrated to a list and some option availalbe for controle the cache size.
509 #define CONTEXT_CACHE 100
511 typedef struct ResourceList {
512 IWineD3DResource *resource;
513 struct ResourceList *next;
516 /* A helper function that dumps a resource list */
517 void dumpResources(ResourceList *resources);
519 /*****************************************************************************
520 * IWineD3DDevice implementation structure
522 typedef struct IWineD3DDeviceImpl
524 /* IUnknown fields */
525 const IWineD3DDeviceVtbl *lpVtbl;
526 LONG ref; /* Note: Ref counting not required */
528 /* WineD3D Information */
532 /* X and GL Information */
533 GLint maxConcurrentLights;
535 /* Selected capabilities */
536 int vs_selected_mode;
537 int ps_selected_mode;
538 const shader_backend_t *shader_backend;
541 BOOL modelview_valid;
543 BOOL view_ident; /* true iff view matrix is identity */
544 BOOL last_was_rhw; /* true iff last draw_primitive was in xyzrhw mode */
545 BOOL viewport_changed; /* Was the viewport changed since the last draw? */
546 GLenum tracking_parm; /* Which source is tracking current colour */
547 LONG tracking_color; /* used iff GL_COLOR_MATERIAL was enabled */
548 #define DISABLED_TRACKING 0 /* Disabled */
549 #define IS_TRACKING 1 /* tracking_parm is tracking diffuse color */
550 #define NEEDS_TRACKING 2 /* Tracking needs to be enabled when needed */
551 #define NEEDS_DISABLE 3 /* Tracking needs to be disabled when needed*/
555 BOOL texture_shader_active; /* TODO: Confirm use is correct */
556 BOOL last_was_notclipped;
559 /* State block related */
560 BOOL isRecordingState;
561 IWineD3DStateBlockImpl *stateBlock;
562 IWineD3DStateBlockImpl *updateStateBlock;
564 /* Internal use fields */
565 WINED3DDEVICE_CREATION_PARAMETERS createParms;
567 WINED3DDEVTYPE devType;
569 IWineD3DSwapChain **swapchains;
570 uint NumberOfSwapChains;
572 ResourceList *resources; /* a linked list to track resources created by the device */
574 /* Render Target Support */
575 IWineD3DSurface *depthStencilBuffer;
577 IWineD3DSurface *renderTarget;
578 IWineD3DSurface *stencilBufferTarget;
580 /* palettes texture management */
581 PALETTEENTRY palettes[MAX_PALETTES][256];
584 /* For rendering to a texture using glCopyTexImage */
585 BOOL render_offscreen;
586 WINED3D_DEPTHCOPYSTATE depth_copy_state;
589 /* Cursor management */
595 UINT cursorWidth, cursorHeight;
596 GLuint cursorTexture;
598 /* Textures for when no other textures are mapped */
599 UINT dummyTextureName[MAX_TEXTURES];
601 /* Debug stream management */
604 /* Device state management */
606 BOOL d3d_initialized;
608 /* Screen buffer resources */
609 glContext contextCache[CONTEXT_CACHE];
611 /* A flag to check if endscene has been called before changing the render tartet */
614 /* process vertex shaders using software or hardware */
615 BOOL softwareVertexProcessing;
617 /* DirectDraw stuff */
619 IWineD3DSurface *ddraw_primary;
620 DWORD ddraw_width, ddraw_height;
621 WINED3DFORMAT ddraw_format;
622 BOOL ddraw_fullscreen;
624 /* List of GLSL shader programs and their associated vertex & pixel shaders */
625 struct list glsl_shader_progs;
628 /* Final position fixup constant */
630 } IWineD3DDeviceImpl;
632 extern const IWineD3DDeviceVtbl IWineD3DDevice_Vtbl;
634 /* Support for IWineD3DResource ::Set/Get/FreePrivateData. I don't think
635 * anybody uses it for much so a good implementation is optional. */
636 typedef struct PrivateData
638 struct PrivateData* next;
641 DWORD flags; /* DDSPD_* */
642 DWORD uniqueness_value;
653 void d3ddevice_set_ortho(IWineD3DDeviceImpl *This);
655 /*****************************************************************************
656 * IWineD3DResource implementation structure
658 typedef struct IWineD3DResourceClass
660 /* IUnknown fields */
661 LONG ref; /* Note: Ref counting not required */
663 /* WineD3DResource Information */
665 WINED3DRESOURCETYPE resourceType;
666 IWineD3DDeviceImpl *wineD3DDevice;
670 WINED3DFORMAT format;
671 BYTE *allocatedMemory;
672 PrivateData *privateData;
674 } IWineD3DResourceClass;
676 typedef struct IWineD3DResourceImpl
678 /* IUnknown & WineD3DResource Information */
679 const IWineD3DResourceVtbl *lpVtbl;
680 IWineD3DResourceClass resource;
681 } IWineD3DResourceImpl;
684 /*****************************************************************************
685 * IWineD3DVertexBuffer implementation structure (extends IWineD3DResourceImpl)
687 typedef struct IWineD3DVertexBufferImpl
689 /* IUnknown & WineD3DResource Information */
690 const IWineD3DVertexBufferVtbl *lpVtbl;
691 IWineD3DResourceClass resource;
693 /* WineD3DVertexBuffer specifics */
696 /* Vertex buffer object support */
701 UINT dirtystart, dirtyend;
704 LONG declChanges, draws;
705 /* Last description of the buffer */
706 WineDirect3DVertexStridedData strided;
707 } IWineD3DVertexBufferImpl;
709 extern const IWineD3DVertexBufferVtbl IWineD3DVertexBuffer_Vtbl;
711 #define VBFLAG_LOAD 0x01 /* Data is written from allocatedMemory to the VBO */
712 #define VBFLAG_OPTIMIZED 0x02 /* Optimize has been called for the VB */
713 #define VBFLAG_DIRTY 0x04 /* Buffer data has been modified */
714 #define VBFLAG_STREAM 0x08 /* The vertex buffer is in a stream */
715 #define VBFLAG_HASDESC 0x10 /* A vertex description has been found */
716 #define VBFLAG_VBOCREATEFAIL 0x20 /* An attempt to create a vbo has failed */
718 /*****************************************************************************
719 * IWineD3DIndexBuffer implementation structure (extends IWineD3DResourceImpl)
721 typedef struct IWineD3DIndexBufferImpl
723 /* IUnknown & WineD3DResource Information */
724 const IWineD3DIndexBufferVtbl *lpVtbl;
725 IWineD3DResourceClass resource;
727 /* WineD3DVertexBuffer specifics */
728 } IWineD3DIndexBufferImpl;
730 extern const IWineD3DIndexBufferVtbl IWineD3DIndexBuffer_Vtbl;
732 /*****************************************************************************
733 * IWineD3DBaseTexture D3D- > openGL state map lookups
735 #define WINED3DFUNC_NOTSUPPORTED -2
736 #define WINED3DFUNC_UNIMPLEMENTED -1
738 typedef enum winetexturestates {
739 WINED3DTEXSTA_ADDRESSU = 0,
740 WINED3DTEXSTA_ADDRESSV = 1,
741 WINED3DTEXSTA_ADDRESSW = 2,
742 WINED3DTEXSTA_BORDERCOLOR = 3,
743 WINED3DTEXSTA_MAGFILTER = 4,
744 WINED3DTEXSTA_MINFILTER = 5,
745 WINED3DTEXSTA_MIPFILTER = 6,
746 WINED3DTEXSTA_MAXMIPLEVEL = 7,
747 WINED3DTEXSTA_MAXANISOTROPY = 8,
748 WINED3DTEXSTA_SRGBTEXTURE = 9,
749 WINED3DTEXSTA_ELEMENTINDEX = 10,
750 WINED3DTEXSTA_DMAPOFFSET = 11,
751 WINED3DTEXSTA_TSSADDRESSW = 12,
752 MAX_WINETEXTURESTATES = 13,
755 typedef struct Wined3dTextureStateMap {
758 } Wined3dTextureStateMap;
760 /*****************************************************************************
761 * IWineD3DBaseTexture implementation structure (extends IWineD3DResourceImpl)
763 typedef struct IWineD3DBaseTextureClass
767 WINED3DFORMAT format;
771 WINED3DTEXTUREFILTERTYPE filterType;
772 DWORD states[MAX_WINETEXTURESTATES];
774 } IWineD3DBaseTextureClass;
776 typedef struct IWineD3DBaseTextureImpl
778 /* IUnknown & WineD3DResource Information */
779 const IWineD3DBaseTextureVtbl *lpVtbl;
780 IWineD3DResourceClass resource;
781 IWineD3DBaseTextureClass baseTexture;
783 } IWineD3DBaseTextureImpl;
785 /*****************************************************************************
786 * IWineD3DTexture implementation structure (extends IWineD3DBaseTextureImpl)
788 typedef struct IWineD3DTextureImpl
790 /* IUnknown & WineD3DResource/WineD3DBaseTexture Information */
791 const IWineD3DTextureVtbl *lpVtbl;
792 IWineD3DResourceClass resource;
793 IWineD3DBaseTextureClass baseTexture;
795 /* IWineD3DTexture */
796 IWineD3DSurface *surfaces[MAX_LEVELS];
800 float pow2scalingFactorX;
801 float pow2scalingFactorY;
803 } IWineD3DTextureImpl;
805 extern const IWineD3DTextureVtbl IWineD3DTexture_Vtbl;
807 /*****************************************************************************
808 * IWineD3DCubeTexture implementation structure (extends IWineD3DBaseTextureImpl)
810 typedef struct IWineD3DCubeTextureImpl
812 /* IUnknown & WineD3DResource/WineD3DBaseTexture Information */
813 const IWineD3DCubeTextureVtbl *lpVtbl;
814 IWineD3DResourceClass resource;
815 IWineD3DBaseTextureClass baseTexture;
817 /* IWineD3DCubeTexture */
818 IWineD3DSurface *surfaces[6][MAX_LEVELS];
821 float pow2scalingFactor;
823 } IWineD3DCubeTextureImpl;
825 extern const IWineD3DCubeTextureVtbl IWineD3DCubeTexture_Vtbl;
827 typedef struct _WINED3DVOLUMET_DESC
832 } WINED3DVOLUMET_DESC;
834 /*****************************************************************************
835 * IWineD3DVolume implementation structure (extends IUnknown)
837 typedef struct IWineD3DVolumeImpl
839 /* IUnknown & WineD3DResource fields */
840 const IWineD3DVolumeVtbl *lpVtbl;
841 IWineD3DResourceClass resource;
843 /* WineD3DVolume Information */
844 WINED3DVOLUMET_DESC currentDesc;
845 IWineD3DBase *container;
850 WINED3DBOX lockedBox;
855 } IWineD3DVolumeImpl;
857 extern const IWineD3DVolumeVtbl IWineD3DVolume_Vtbl;
859 /*****************************************************************************
860 * IWineD3DVolumeTexture implementation structure (extends IWineD3DBaseTextureImpl)
862 typedef struct IWineD3DVolumeTextureImpl
864 /* IUnknown & WineD3DResource/WineD3DBaseTexture Information */
865 const IWineD3DVolumeTextureVtbl *lpVtbl;
866 IWineD3DResourceClass resource;
867 IWineD3DBaseTextureClass baseTexture;
869 /* IWineD3DVolumeTexture */
870 IWineD3DVolume *volumes[MAX_LEVELS];
875 } IWineD3DVolumeTextureImpl;
877 extern const IWineD3DVolumeTextureVtbl IWineD3DVolumeTexture_Vtbl;
879 typedef struct _WINED3DSURFACET_DESC
881 WINED3DMULTISAMPLE_TYPE MultiSampleType;
882 DWORD MultiSampleQuality;
885 } WINED3DSURFACET_DESC;
887 /*****************************************************************************
888 * Structure for DIB Surfaces (GetDC and GDI surfaces)
890 typedef struct wineD3DSurface_DIB {
895 } wineD3DSurface_DIB;
897 /*****************************************************************************
898 * IWineD3DSurface implementation structure
900 struct IWineD3DSurfaceImpl
902 /* IUnknown & IWineD3DResource Information */
903 const IWineD3DSurfaceVtbl *lpVtbl;
904 IWineD3DResourceClass resource;
906 /* IWineD3DSurface fields */
907 IWineD3DBase *container;
908 WINED3DSURFACET_DESC currentDesc;
909 IWineD3DPaletteImpl *palette;
913 /* TODO: move this off into a management class(maybe!) */
920 /* Oversized texture */
924 /* precalculated x and y scalings for texture coords */
925 float pow2scalingFactorX; /* = (Width / pow2Width ) */
926 float pow2scalingFactorY; /* = (Height / pow2Height) */
932 glDescriptor glDescription;
935 wineD3DSurface_DIB dib;
938 /* Color keys for DDraw */
939 DDCOLORKEY DestBltCKey;
940 DDCOLORKEY DestOverlayCKey;
941 DDCOLORKEY SrcOverlayCKey;
942 DDCOLORKEY SrcBltCKey;
948 extern const IWineD3DSurfaceVtbl IWineD3DSurface_Vtbl;
949 extern const IWineD3DSurfaceVtbl IWineGDISurface_Vtbl;
951 /* Predeclare the shared Surface functions */
952 HRESULT WINAPI IWineD3DSurfaceImpl_QueryInterface(IWineD3DSurface *iface, REFIID riid, LPVOID *ppobj);
953 ULONG WINAPI IWineD3DSurfaceImpl_AddRef(IWineD3DSurface *iface);
954 ULONG WINAPI IWineD3DSurfaceImpl_Release(IWineD3DSurface *iface);
955 HRESULT WINAPI IWineD3DSurfaceImpl_GetParent(IWineD3DSurface *iface, IUnknown **pParent);
956 HRESULT WINAPI IWineD3DSurfaceImpl_GetDevice(IWineD3DSurface *iface, IWineD3DDevice** ppDevice);
957 HRESULT WINAPI IWineD3DSurfaceImpl_SetPrivateData(IWineD3DSurface *iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags);
958 HRESULT WINAPI IWineD3DSurfaceImpl_GetPrivateData(IWineD3DSurface *iface, REFGUID refguid, void* pData, DWORD* pSizeOfData);
959 HRESULT WINAPI IWineD3DSurfaceImpl_FreePrivateData(IWineD3DSurface *iface, REFGUID refguid);
960 DWORD WINAPI IWineD3DSurfaceImpl_SetPriority(IWineD3DSurface *iface, DWORD PriorityNew);
961 DWORD WINAPI IWineD3DSurfaceImpl_GetPriority(IWineD3DSurface *iface);
962 void WINAPI IWineD3DSurfaceImpl_PreLoad(IWineD3DSurface *iface);
963 WINED3DRESOURCETYPE WINAPI IWineD3DSurfaceImpl_GetType(IWineD3DSurface *iface);
964 HRESULT WINAPI IWineD3DSurfaceImpl_GetContainerParent(IWineD3DSurface* iface, IUnknown **ppContainerParent);
965 HRESULT WINAPI IWineD3DSurfaceImpl_GetContainer(IWineD3DSurface* iface, REFIID riid, void** ppContainer);
966 HRESULT WINAPI IWineD3DSurfaceImpl_GetDesc(IWineD3DSurface *iface, WINED3DSURFACE_DESC *pDesc);
967 HRESULT WINAPI IWineD3DSurfaceImpl_GetBltStatus(IWineD3DSurface *iface, DWORD Flags);
968 HRESULT WINAPI IWineD3DSurfaceImpl_GetFlipStatus(IWineD3DSurface *iface, DWORD Flags);
969 HRESULT WINAPI IWineD3DSurfaceImpl_IsLost(IWineD3DSurface *iface);
970 HRESULT WINAPI IWineD3DSurfaceImpl_Restore(IWineD3DSurface *iface);
971 HRESULT WINAPI IWineD3DSurfaceImpl_SetPixelFormat(IWineD3DSurface *iface, WINED3DFORMAT Format, BYTE *Surface, DWORD Size);
972 HRESULT WINAPI IWineD3DSurfaceImpl_GetPalette(IWineD3DSurface *iface, IWineD3DPalette **Pal);
973 HRESULT WINAPI IWineD3DSurfaceImpl_SetPalette(IWineD3DSurface *iface, IWineD3DPalette *Pal);
974 HRESULT WINAPI IWineD3DSurfaceImpl_SetColorKey(IWineD3DSurface *iface, DWORD Flags, DDCOLORKEY *CKey);
975 HRESULT WINAPI IWineD3DSurfaceImpl_CleanDirtyRect(IWineD3DSurface *iface);
976 extern HRESULT WINAPI IWineD3DSurfaceImpl_AddDirtyRect(IWineD3DSurface *iface, CONST RECT* pDirtyRect);
977 HRESULT WINAPI IWineD3DSurfaceImpl_SetContainer(IWineD3DSurface *iface, IWineD3DBase *container);
978 HRESULT WINAPI IWineD3DSurfaceImpl_SetPBufferState(IWineD3DSurface *iface, BOOL inPBuffer, BOOL inTexture);
979 void WINAPI IWineD3DSurfaceImpl_SetGlTextureDesc(IWineD3DSurface *iface, UINT textureName, int target);
980 void WINAPI IWineD3DSurfaceImpl_GetGlDesc(IWineD3DSurface *iface, glDescriptor **glDescription);
981 const void *WINAPI IWineD3DSurfaceImpl_GetData(IWineD3DSurface *iface);
982 HRESULT WINAPI IWineD3DSurfaceImpl_SetFormat(IWineD3DSurface *iface, WINED3DFORMAT format);
983 HRESULT WINAPI IWineGDISurfaceImpl_Blt(IWineD3DSurface *iface, RECT *DestRect, IWineD3DSurface *SrcSurface, RECT *SrcRect, DWORD Flags, DDBLTFX *DDBltFx);
984 HRESULT WINAPI IWineGDISurfaceImpl_BltFast(IWineD3DSurface *iface, DWORD dstx, DWORD dsty, IWineD3DSurface *Source, RECT *rsrc, DWORD trans);
985 HRESULT WINAPI IWineD3DSurfaceImpl_SetPalette(IWineD3DSurface *iface, IWineD3DPalette *Pal);
986 HRESULT WINAPI IWineD3DSurfaceImpl_GetDC(IWineD3DSurface *iface, HDC *pHDC);
987 HRESULT WINAPI IWineD3DSurfaceImpl_ReleaseDC(IWineD3DSurface *iface, HDC hDC);
988 DWORD WINAPI IWineD3DSurfaceImpl_GetPitch(IWineD3DSurface *iface);
989 HRESULT WINAPI IWineD3DSurfaceImpl_RealizePalette(IWineD3DSurface *iface);
990 HRESULT WINAPI IWineD3DSurfaceImpl_SetMem(IWineD3DSurface *iface, void *Mem);
991 HRESULT WINAPI IWineD3DSurfaceImpl_SetOverlayPosition(IWineD3DSurface *iface, LONG X, LONG Y);
992 HRESULT WINAPI IWineD3DSurfaceImpl_GetOverlayPosition(IWineD3DSurface *iface, LONG *X, LONG *Y);
993 HRESULT WINAPI IWineD3DSurfaceImpl_UpdateOverlayZOrder(IWineD3DSurface *iface, DWORD Flags, IWineD3DSurface *Ref);
994 HRESULT WINAPI IWineD3DSurfaceImpl_UpdateOverlay(IWineD3DSurface *iface, RECT *SrcRect, IWineD3DSurface *DstSurface, RECT *DstRect, DWORD Flags, WINEDDOVERLAYFX *FX);
997 #define SFLAG_OVERSIZE 0x00000001 /* Surface is bigger than gl size, blts only */
998 #define SFLAG_CONVERTED 0x00000002 /* Converted for color keying or Palettized */
999 #define SFLAG_DIBSECTION 0x00000004 /* Has a DIB section attached for getdc */
1000 #define SFLAG_DIRTY 0x00000008 /* Surface was locked by the app */
1001 #define SFLAG_LOCKABLE 0x00000010 /* Surface can be locked */
1002 #define SFLAG_DISCARD 0x00000020 /* ??? */
1003 #define SFLAG_LOCKED 0x00000040 /* Surface is locked atm */
1004 #define SFLAG_ACTIVELOCK 0x00000080 /* Not locked, but surface memory is needed */
1005 #define SFLAG_INTEXTURE 0x00000100 /* ??? */
1006 #define SFLAG_INPBUFFER 0x00000200 /* ??? */
1007 #define SFLAG_NONPOW2 0x00000400 /* Surface sizes are not a power of 2 */
1008 #define SFLAG_DYNLOCK 0x00000800 /* Surface is often locked by the app */
1009 #define SFLAG_DYNCHANGE 0x00001800 /* Surface contents are changed very often, implies DYNLOCK */
1010 #define SFLAG_DCINUSE 0x00002000 /* Set between GetDC and ReleaseDC calls */
1011 #define SFLAG_GLDIRTY 0x00004000 /* The opengl texture is more up to date than the surface mem */
1012 #define SFLAG_LOST 0x00008000 /* Surface lost flag for DDraw */
1013 #define SFLAG_FORCELOAD 0x00010000 /* To force PreLoading of a scratch cursor */
1014 #define SFLAG_USERPTR 0x00020000 /* The application allocated the memory for this surface */
1015 #define SFLAG_GLCKEY 0x00040000 /* The gl texture was created with a color key */
1017 /* In some conditions the surface memory must not be freed:
1018 * SFLAG_OVERSIZE: Not all data can be kept in GL
1019 * SFLAG_CONVERTED: Converting the data back would take too long
1020 * SFLAG_DIBSECTION: The dib code manages the memory
1021 * SFLAG_DIRTY: GL surface isn't up to date
1022 * SFLAG_LOCKED: The app requires access to the surface data
1023 * SFLAG_ACTIVELOCK: Some wined3d code needs the memory
1024 * SFLAG_DYNLOCK: Avoid freeing the data for performance
1025 * SFLAG_DYNCHANGE: Same reason as DYNLOCK
1027 #define SFLAG_DONOTFREE (SFLAG_OVERSIZE | \
1029 SFLAG_DIBSECTION | \
1032 SFLAG_ACTIVELOCK | \
1037 BOOL CalculateTexRect(IWineD3DSurfaceImpl *This, RECT *Rect, float glTexCoord[4]);
1039 /* Alignment of the pitch */
1040 #define SURFACE_ALIGNMENT 4
1042 /*****************************************************************************
1043 * IWineD3DVertexDeclaration implementation structure
1045 typedef struct IWineD3DVertexDeclarationImpl {
1046 /* IUnknown Information */
1047 const IWineD3DVertexDeclarationVtbl *lpVtbl;
1048 LONG ref; /* Note: Ref counting not required */
1051 /** precomputed fvf if simple declaration */
1052 IWineD3DDeviceImpl *wineD3DDevice;
1053 DWORD fvf[MAX_STREAMS];
1056 /** dx8 compatible Declaration fields */
1057 DWORD* pDeclaration8;
1058 DWORD declaration8Length;
1061 D3DVERTEXELEMENT9 *pDeclaration9;
1062 UINT declaration9NumElements;
1064 WINED3DVERTEXELEMENT *pDeclarationWine;
1065 UINT declarationWNumElements;
1069 } IWineD3DVertexDeclarationImpl;
1071 extern const IWineD3DVertexDeclarationVtbl IWineD3DVertexDeclaration_Vtbl;
1073 /*****************************************************************************
1074 * IWineD3DStateBlock implementation structure
1077 /* Internal state Block for Begin/End/Capture/Create/Apply info */
1078 /* Note: Very long winded but gl Lists are not flexible enough */
1079 /* to resolve everything we need, so doing it manually for now */
1080 typedef struct SAVEDSTATES {
1084 BOOL streamSource[MAX_STREAMS];
1085 BOOL streamFreq[MAX_STREAMS];
1086 BOOL textures[MAX_SAMPLERS];
1087 BOOL transform[HIGHEST_TRANSFORMSTATE + 1];
1089 BOOL renderState[WINEHIGHEST_RENDER_STATE + 1];
1090 BOOL textureState[MAX_TEXTURES][WINED3D_HIGHEST_TEXTURE_STATE + 1];
1091 BOOL samplerState[MAX_SAMPLERS][WINED3D_HIGHEST_SAMPLER_STATE + 1];
1092 BOOL clipplane[MAX_CLIPPLANES];
1095 BOOL pixelShaderConstantsB[MAX_CONST_B];
1096 BOOL pixelShaderConstantsI[MAX_CONST_I];
1097 BOOL *pixelShaderConstantsF;
1099 BOOL vertexShaderConstantsB[MAX_CONST_B];
1100 BOOL vertexShaderConstantsI[MAX_CONST_I];
1101 BOOL *vertexShaderConstantsF;
1109 struct IWineD3DStateBlockImpl
1111 /* IUnknown fields */
1112 const IWineD3DStateBlockVtbl *lpVtbl;
1113 LONG ref; /* Note: Ref counting not required */
1115 /* IWineD3DStateBlock information */
1117 IWineD3DDeviceImpl *wineD3DDevice;
1118 WINED3DSTATEBLOCKTYPE blockType;
1120 /* Array indicating whether things have been set or changed */
1121 SAVEDSTATES changed;
1123 struct list set_vconstantsF;
1124 struct list set_pconstantsF;
1126 /* Drawing - Vertex Shader or FVF related */
1128 /* Vertex Shader Declaration */
1129 IWineD3DVertexDeclaration *vertexDecl;
1131 IWineD3DVertexShader *vertexShader;
1133 /* Vertex Shader Constants */
1134 BOOL vertexShaderConstantB[MAX_CONST_B];
1135 INT vertexShaderConstantI[MAX_CONST_I * 4];
1136 float *vertexShaderConstantF;
1140 UINT streamStride[MAX_STREAMS];
1141 UINT streamOffset[MAX_STREAMS];
1142 IWineD3DVertexBuffer *streamSource[MAX_STREAMS];
1143 UINT streamFreq[MAX_STREAMS];
1144 UINT streamFlags[MAX_STREAMS]; /*0 | WINED3DSTREAMSOURCE_INSTANCEDATA | WINED3DSTREAMSOURCE_INDEXEDDATA */
1147 IWineD3DIndexBuffer* pIndexData;
1148 UINT baseVertexIndex; /* Note: only used for d3d8 */
1151 WINED3DMATRIX transforms[HIGHEST_TRANSFORMSTATE + 1];
1154 PLIGHTINFOEL *lights; /* NOTE: active GL lights must be front of the chain */
1157 double clipplane[MAX_CLIPPLANES][4];
1158 WINED3DCLIPSTATUS clip_status;
1161 WINED3DVIEWPORT viewport;
1164 WINED3DMATERIAL material;
1167 IWineD3DPixelShader *pixelShader;
1169 /* Pixel Shader Constants */
1170 BOOL pixelShaderConstantB[MAX_CONST_B];
1171 INT pixelShaderConstantI[MAX_CONST_I * 4];
1172 float *pixelShaderConstantF;
1175 DWORD renderState[WINEHIGHEST_RENDER_STATE + 1];
1178 IWineD3DBaseTexture *textures[MAX_SAMPLERS];
1179 int textureDimensions[MAX_SAMPLERS];
1181 /* Texture State Stage */
1182 DWORD textureState[MAX_TEXTURES][WINED3D_HIGHEST_TEXTURE_STATE + 1];
1183 /* Sampler States */
1184 DWORD samplerState[MAX_SAMPLERS][WINED3D_HIGHEST_SAMPLER_STATE + 1];
1186 /* Current GLSL Shader Program */
1187 struct glsl_shader_prog_link *glsl_program;
1190 extern void stateblock_savedstates_set(
1191 IWineD3DStateBlock* iface,
1192 SAVEDSTATES* states,
1195 extern void stateblock_savedstates_copy(
1196 IWineD3DStateBlock* iface,
1198 SAVEDSTATES* source);
1200 extern void stateblock_copy(
1201 IWineD3DStateBlock* destination,
1202 IWineD3DStateBlock* source);
1204 extern const IWineD3DStateBlockVtbl IWineD3DStateBlock_Vtbl;
1206 /*****************************************************************************
1207 * IWineD3DQueryImpl implementation structure (extends IUnknown)
1209 typedef struct IWineD3DQueryImpl
1211 const IWineD3DQueryVtbl *lpVtbl;
1212 LONG ref; /* Note: Ref counting not required */
1215 /*TODO: replace with iface usage */
1217 IWineD3DDevice *wineD3DDevice;
1219 IWineD3DDeviceImpl *wineD3DDevice;
1222 /* IWineD3DQuery fields */
1223 WINED3DQUERYTYPE type;
1224 /* TODO: Think about using a IUnknown instead of a void* */
1228 } IWineD3DQueryImpl;
1230 extern const IWineD3DQueryVtbl IWineD3DQuery_Vtbl;
1232 /* Datastructures for IWineD3DQueryImpl.extendedData */
1233 typedef struct WineQueryOcclusionData {
1235 } WineQueryOcclusionData;
1238 /*****************************************************************************
1239 * IWineD3DSwapChainImpl implementation structure (extends IUnknown)
1242 typedef struct IWineD3DSwapChainImpl
1245 IWineD3DSwapChainVtbl *lpVtbl;
1246 LONG ref; /* Note: Ref counting not required */
1249 IWineD3DDeviceImpl *wineD3DDevice;
1251 /* IWineD3DSwapChain fields */
1252 IWineD3DSurface **backBuffer;
1253 IWineD3DSurface *frontBuffer;
1254 BOOL wantsDepthStencilBuffer;
1255 D3DPRESENT_PARAMETERS presentParms;
1256 DWORD orig_width, orig_height;
1258 /* TODO: move everything up to drawable off into a context manager
1259 and store the 'data' in the contextManagerData interface.
1260 IUnknown *contextManagerData;
1268 XVisualInfo *visInfo;
1269 GLXContext render_ctx;
1270 /* This has been left in device for now, but needs moving off into a rendertarget management class and separated out from swapchains and devices. */
1272 } IWineD3DSwapChainImpl;
1274 extern IWineD3DSwapChainVtbl IWineD3DSwapChain_Vtbl;
1276 /*****************************************************************************
1277 * Utility function prototypes
1280 /* Trace routines */
1281 const char* debug_d3dformat(WINED3DFORMAT fmt);
1282 const char* debug_d3ddevicetype(WINED3DDEVTYPE devtype);
1283 const char* debug_d3dresourcetype(WINED3DRESOURCETYPE res);
1284 const char* debug_d3dusage(DWORD usage);
1285 const char* debug_d3dusagequery(DWORD usagequery);
1286 const char* debug_d3ddeclmethod(WINED3DDECLMETHOD method);
1287 const char* debug_d3ddecltype(WINED3DDECLTYPE type);
1288 const char* debug_d3ddeclusage(BYTE usage);
1289 const char* debug_d3dprimitivetype(WINED3DPRIMITIVETYPE PrimitiveType);
1290 const char* debug_d3drenderstate(DWORD state);
1291 const char* debug_d3dsamplerstate(DWORD state);
1292 const char* debug_d3dtexturestate(DWORD state);
1293 const char* debug_d3dtstype(WINED3DTRANSFORMSTATETYPE tstype);
1294 const char* debug_d3dpool(WINED3DPOOL pool);
1296 /* Routines for GL <-> D3D values */
1297 GLenum StencilOp(DWORD op);
1298 GLenum CompareFunc(DWORD func);
1299 void set_tex_op(IWineD3DDevice *iface, BOOL isAlpha, int Stage, WINED3DTEXTUREOP op, DWORD arg1, DWORD arg2, DWORD arg3);
1300 void set_tex_op_nvrc(IWineD3DDevice *iface, BOOL is_alpha, int stage, WINED3DTEXTUREOP op, DWORD arg1, DWORD arg2, DWORD arg3, INT texture_idx);
1301 void set_texture_matrix(const float *smat, DWORD flags, BOOL calculatedCoords);
1303 int D3DFmtMakeGlCfg(WINED3DFORMAT BackBufferFormat, WINED3DFORMAT StencilBufferFormat, int *attribs, int* nAttribs, BOOL alternate);
1306 void multiply_matrix(WINED3DMATRIX *dest, const WINED3DMATRIX *src1, const WINED3DMATRIX *src2);
1308 /*****************************************************************************
1309 * To enable calling of inherited functions, requires prototypes
1311 * Note: Only require classes which are subclassed, ie resource, basetexture,
1313 /*** IUnknown methods ***/
1314 extern HRESULT WINAPI IWineD3DResourceImpl_QueryInterface(IWineD3DResource *iface, REFIID riid, void** ppvObject);
1315 extern ULONG WINAPI IWineD3DResourceImpl_AddRef(IWineD3DResource *iface);
1316 extern ULONG WINAPI IWineD3DResourceImpl_Release(IWineD3DResource *iface);
1317 /*** IWineD3DResource methods ***/
1318 extern HRESULT WINAPI IWineD3DResourceImpl_GetParent(IWineD3DResource *iface, IUnknown **pParent);
1319 extern HRESULT WINAPI IWineD3DResourceImpl_GetDevice(IWineD3DResource *iface, IWineD3DDevice ** ppDevice);
1320 extern HRESULT WINAPI IWineD3DResourceImpl_SetPrivateData(IWineD3DResource *iface, REFGUID refguid, CONST void * pData, DWORD SizeOfData, DWORD Flags);
1321 extern HRESULT WINAPI IWineD3DResourceImpl_GetPrivateData(IWineD3DResource *iface, REFGUID refguid, void * pData, DWORD * pSizeOfData);
1322 extern HRESULT WINAPI IWineD3DResourceImpl_FreePrivateData(IWineD3DResource *iface, REFGUID refguid);
1323 extern DWORD WINAPI IWineD3DResourceImpl_SetPriority(IWineD3DResource *iface, DWORD PriorityNew);
1324 extern DWORD WINAPI IWineD3DResourceImpl_GetPriority(IWineD3DResource *iface);
1325 extern void WINAPI IWineD3DResourceImpl_PreLoad(IWineD3DResource *iface);
1326 extern WINED3DRESOURCETYPE WINAPI IWineD3DResourceImpl_GetType(IWineD3DResource *iface);
1327 /*** class static members ***/
1328 void IWineD3DResourceImpl_CleanUp(IWineD3DResource *iface);
1330 /*** IUnknown methods ***/
1331 extern HRESULT WINAPI IWineD3DBaseTextureImpl_QueryInterface(IWineD3DBaseTexture *iface, REFIID riid, void** ppvObject);
1332 extern ULONG WINAPI IWineD3DBaseTextureImpl_AddRef(IWineD3DBaseTexture *iface);
1333 extern ULONG WINAPI IWineD3DBaseTextureImpl_Release(IWineD3DBaseTexture *iface);
1334 /*** IWineD3DResource methods ***/
1335 extern HRESULT WINAPI IWineD3DBaseTextureImpl_GetParent(IWineD3DBaseTexture *iface, IUnknown **pParent);
1336 extern HRESULT WINAPI IWineD3DBaseTextureImpl_GetDevice(IWineD3DBaseTexture *iface, IWineD3DDevice ** ppDevice);
1337 extern HRESULT WINAPI IWineD3DBaseTextureImpl_SetPrivateData(IWineD3DBaseTexture *iface, REFGUID refguid, CONST void * pData, DWORD SizeOfData, DWORD Flags);
1338 extern HRESULT WINAPI IWineD3DBaseTextureImpl_GetPrivateData(IWineD3DBaseTexture *iface, REFGUID refguid, void * pData, DWORD * pSizeOfData);
1339 extern HRESULT WINAPI IWineD3DBaseTextureImpl_FreePrivateData(IWineD3DBaseTexture *iface, REFGUID refguid);
1340 extern DWORD WINAPI IWineD3DBaseTextureImpl_SetPriority(IWineD3DBaseTexture *iface, DWORD PriorityNew);
1341 extern DWORD WINAPI IWineD3DBaseTextureImpl_GetPriority(IWineD3DBaseTexture *iface);
1342 extern void WINAPI IWineD3DBaseTextureImpl_PreLoad(IWineD3DBaseTexture *iface);
1343 extern WINED3DRESOURCETYPE WINAPI IWineD3DBaseTextureImpl_GetType(IWineD3DBaseTexture *iface);
1344 /*** IWineD3DBaseTexture methods ***/
1345 extern DWORD WINAPI IWineD3DBaseTextureImpl_SetLOD(IWineD3DBaseTexture *iface, DWORD LODNew);
1346 extern DWORD WINAPI IWineD3DBaseTextureImpl_GetLOD(IWineD3DBaseTexture *iface);
1347 extern DWORD WINAPI IWineD3DBaseTextureImpl_GetLevelCount(IWineD3DBaseTexture *iface);
1348 extern HRESULT WINAPI IWineD3DBaseTextureImpl_SetAutoGenFilterType(IWineD3DBaseTexture *iface, WINED3DTEXTUREFILTERTYPE FilterType);
1349 extern WINED3DTEXTUREFILTERTYPE WINAPI IWineD3DBaseTextureImpl_GetAutoGenFilterType(IWineD3DBaseTexture *iface);
1350 extern void WINAPI IWineD3DBaseTextureImpl_GenerateMipSubLevels(IWineD3DBaseTexture *iface);
1351 extern BOOL WINAPI IWineD3DBaseTextureImpl_SetDirty(IWineD3DBaseTexture *iface, BOOL);
1352 extern BOOL WINAPI IWineD3DBaseTextureImpl_GetDirty(IWineD3DBaseTexture *iface);
1354 extern BYTE* WINAPI IWineD3DVertexBufferImpl_GetMemory(IWineD3DVertexBuffer* iface, DWORD iOffset, GLint *vbo);
1355 extern HRESULT WINAPI IWineD3DVertexBufferImpl_ReleaseMemory(IWineD3DVertexBuffer* iface);
1356 extern HRESULT WINAPI IWineD3DBaseTextureImpl_BindTexture(IWineD3DBaseTexture *iface);
1357 extern HRESULT WINAPI IWineD3DBaseTextureImpl_UnBindTexture(IWineD3DBaseTexture *iface);
1358 extern void WINAPI IWineD3DBaseTextureImpl_ApplyStateChanges(IWineD3DBaseTexture *iface, const DWORD textureStates[WINED3D_HIGHEST_TEXTURE_STATE + 1], const DWORD samplerStates[WINED3D_HIGHEST_SAMPLER_STATE + 1]);
1359 /*** class static members ***/
1360 void IWineD3DBaseTextureImpl_CleanUp(IWineD3DBaseTexture *iface);
1362 struct SHADER_OPCODE_ARG;
1363 typedef void (*shader_fct_t)();
1364 typedef void (*SHADER_HANDLER) (struct SHADER_OPCODE_ARG*);
1366 /* Struct to maintain a list of GLSL shader programs and their associated pixel and
1367 * vertex shaders. A list of this type is maintained on the DeviceImpl, and is only
1368 * used if the user is using GLSL shaders. */
1369 struct glsl_shader_prog_link {
1371 GLhandleARB programId;
1372 GLhandleARB *vuniformF_locations;
1373 GLhandleARB *puniformF_locations;
1374 IWineD3DVertexShader* vertexShader;
1375 IWineD3DPixelShader* pixelShader;
1378 /* TODO: Make this dynamic, based on shader limits ? */
1379 #define MAX_REG_ADDR 1
1380 #define MAX_REG_TEMP 32
1381 #define MAX_REG_TEXCRD 8
1382 #define MAX_REG_INPUT 12
1383 #define MAX_REG_OUTPUT 12
1384 #define MAX_ATTRIBS 16
1385 #define MAX_CONST_I 16
1386 #define MAX_CONST_B 16
1388 /* FIXME: This needs to go up to 2048 for
1389 * Shader model 3 according to msdn (and for software shaders) */
1390 #define MAX_LABELS 16
1392 typedef struct semantic {
1397 typedef struct local_constant {
1403 typedef struct shader_reg_maps {
1405 char texcoord[MAX_REG_TEXCRD]; /* pixel < 3.0 */
1406 char temporary[MAX_REG_TEMP]; /* pixel, vertex */
1407 char address[MAX_REG_ADDR]; /* vertex */
1408 char packed_input[MAX_REG_INPUT]; /* pshader >= 3.0 */
1409 char packed_output[MAX_REG_OUTPUT]; /* vertex >= 3.0 */
1410 char attributes[MAX_ATTRIBS]; /* vertex */
1411 char labels[MAX_LABELS]; /* pixel, vertex */
1413 /* Sampler usage tokens
1414 * Use 0 as default (bit 31 is always 1 on a valid token) */
1415 DWORD samplers[MAX_SAMPLERS];
1417 /* Whether or not a loop is used in this shader */
1420 /* Whether or not this shader uses fog */
1425 #define SHADER_PGMSIZE 65535
1426 typedef struct SHADER_BUFFER {
1429 unsigned int lineNo;
1432 /* Undocumented opcode controls */
1433 #define INST_CONTROLS_SHIFT 16
1434 #define INST_CONTROLS_MASK 0x00ff0000
1436 typedef enum COMPARISON_TYPE {
1445 typedef struct SHADER_OPCODE {
1446 unsigned int opcode;
1450 CONST UINT num_params;
1451 shader_fct_t soft_fct;
1452 SHADER_HANDLER hw_fct;
1453 SHADER_HANDLER hw_glsl_fct;
1458 typedef struct SHADER_OPCODE_ARG {
1459 IWineD3DBaseShader* shader;
1460 shader_reg_maps* reg_maps;
1461 CONST SHADER_OPCODE* opcode;
1468 SHADER_BUFFER* buffer;
1469 } SHADER_OPCODE_ARG;
1471 typedef struct SHADER_LIMITS {
1472 unsigned int temporary;
1473 unsigned int texcoord;
1474 unsigned int sampler;
1475 unsigned int constant_int;
1476 unsigned int constant_float;
1477 unsigned int constant_bool;
1478 unsigned int address;
1479 unsigned int packed_output;
1480 unsigned int packed_input;
1481 unsigned int attributes;
1485 /** Keeps track of details for TEX_M#x# shader opcodes which need to
1486 maintain state information between multiple codes */
1487 typedef struct SHADER_PARSE_STATE {
1488 unsigned int current_row;
1489 DWORD texcoord_w[2];
1490 } SHADER_PARSE_STATE;
1492 /* Base Shader utility functions.
1493 * (may move callers into the same file in the future) */
1494 extern int shader_addline(
1495 SHADER_BUFFER* buffer,
1496 const char* fmt, ...);
1498 extern const SHADER_OPCODE* shader_get_opcode(
1499 IWineD3DBaseShader *iface,
1502 extern void shader_delete_constant_list(
1503 struct list* clist);
1505 /* Vertex shader utility functions */
1506 extern BOOL vshader_get_input(
1507 IWineD3DVertexShader* iface,
1508 BYTE usage_req, BYTE usage_idx_req,
1509 unsigned int* regnum);
1511 extern BOOL vshader_input_is_color(
1512 IWineD3DVertexShader* iface,
1513 unsigned int regnum);
1515 extern HRESULT allocate_shader_constants(IWineD3DStateBlockImpl* object);
1517 /* ARB_[vertex/fragment]_program helper functions */
1518 extern void shader_arb_load_constants(
1519 IWineD3DDevice* device,
1520 char usePixelShader,
1521 char useVertexShader);
1523 /* ARB shader program Prototypes */
1524 extern void shader_hw_def(SHADER_OPCODE_ARG *arg);
1526 /* ARB pixel shader prototypes */
1527 extern void pshader_hw_cnd(SHADER_OPCODE_ARG* arg);
1528 extern void pshader_hw_cmp(SHADER_OPCODE_ARG* arg);
1529 extern void pshader_hw_map2gl(SHADER_OPCODE_ARG* arg);
1530 extern void pshader_hw_tex(SHADER_OPCODE_ARG* arg);
1531 extern void pshader_hw_texcoord(SHADER_OPCODE_ARG* arg);
1532 extern void pshader_hw_texreg2ar(SHADER_OPCODE_ARG* arg);
1533 extern void pshader_hw_texreg2gb(SHADER_OPCODE_ARG* arg);
1534 extern void pshader_hw_texbem(SHADER_OPCODE_ARG* arg);
1535 extern void pshader_hw_texm3x2pad(SHADER_OPCODE_ARG* arg);
1536 extern void pshader_hw_texm3x2tex(SHADER_OPCODE_ARG* arg);
1537 extern void pshader_hw_texm3x3pad(SHADER_OPCODE_ARG* arg);
1538 extern void pshader_hw_texm3x3tex(SHADER_OPCODE_ARG* arg);
1539 extern void pshader_hw_texm3x3spec(SHADER_OPCODE_ARG* arg);
1540 extern void pshader_hw_texm3x3vspec(SHADER_OPCODE_ARG* arg);
1542 /* ARB vertex shader prototypes */
1543 extern void vshader_hw_map2gl(SHADER_OPCODE_ARG* arg);
1544 extern void vshader_hw_mnxn(SHADER_OPCODE_ARG* arg);
1546 /* GLSL helper functions */
1547 extern void set_glsl_shader_program(IWineD3DDevice *iface);
1548 extern void shader_glsl_add_instruction_modifiers(SHADER_OPCODE_ARG *arg);
1549 extern void shader_glsl_load_constants(
1550 IWineD3DDevice* device,
1551 char usePixelShader,
1552 char useVertexShader);
1554 /** The following translate DirectX pixel/vertex shader opcodes to GLSL lines */
1555 extern void shader_glsl_map2gl(SHADER_OPCODE_ARG* arg);
1556 extern void shader_glsl_arith(SHADER_OPCODE_ARG* arg);
1557 extern void shader_glsl_mov(SHADER_OPCODE_ARG* arg);
1558 extern void shader_glsl_mad(SHADER_OPCODE_ARG* arg);
1559 extern void shader_glsl_mnxn(SHADER_OPCODE_ARG* arg);
1560 extern void shader_glsl_lrp(SHADER_OPCODE_ARG* arg);
1561 extern void shader_glsl_dot(SHADER_OPCODE_ARG* arg);
1562 extern void shader_glsl_rcp(SHADER_OPCODE_ARG* arg);
1563 extern void shader_glsl_cnd(SHADER_OPCODE_ARG* arg);
1564 extern void shader_glsl_compare(SHADER_OPCODE_ARG* arg);
1565 extern void shader_glsl_def(SHADER_OPCODE_ARG* arg);
1566 extern void shader_glsl_defi(SHADER_OPCODE_ARG* arg);
1567 extern void shader_glsl_defb(SHADER_OPCODE_ARG* arg);
1568 extern void shader_glsl_expp(SHADER_OPCODE_ARG* arg);
1569 extern void shader_glsl_cmp(SHADER_OPCODE_ARG* arg);
1570 extern void shader_glsl_lit(SHADER_OPCODE_ARG* arg);
1571 extern void shader_glsl_dst(SHADER_OPCODE_ARG* arg);
1572 extern void shader_glsl_sincos(SHADER_OPCODE_ARG* arg);
1573 extern void shader_glsl_loop(SHADER_OPCODE_ARG* arg);
1574 extern void shader_glsl_end(SHADER_OPCODE_ARG* arg);
1575 extern void shader_glsl_if(SHADER_OPCODE_ARG* arg);
1576 extern void shader_glsl_ifc(SHADER_OPCODE_ARG* arg);
1577 extern void shader_glsl_else(SHADER_OPCODE_ARG* arg);
1578 extern void shader_glsl_break(SHADER_OPCODE_ARG* arg);
1579 extern void shader_glsl_breakc(SHADER_OPCODE_ARG* arg);
1580 extern void shader_glsl_rep(SHADER_OPCODE_ARG* arg);
1581 extern void shader_glsl_call(SHADER_OPCODE_ARG* arg);
1582 extern void shader_glsl_callnz(SHADER_OPCODE_ARG* arg);
1583 extern void shader_glsl_label(SHADER_OPCODE_ARG* arg);
1585 /** GLSL Pixel Shader Prototypes */
1586 extern void pshader_glsl_tex(SHADER_OPCODE_ARG* arg);
1587 extern void pshader_glsl_texcoord(SHADER_OPCODE_ARG* arg);
1588 extern void pshader_glsl_texdp3tex(SHADER_OPCODE_ARG* arg);
1589 extern void pshader_glsl_texdp3(SHADER_OPCODE_ARG* arg);
1590 extern void pshader_glsl_texdepth(SHADER_OPCODE_ARG* arg);
1591 extern void pshader_glsl_texm3x2depth(SHADER_OPCODE_ARG* arg);
1592 extern void pshader_glsl_texm3x2pad(SHADER_OPCODE_ARG* arg);
1593 extern void pshader_glsl_texm3x2tex(SHADER_OPCODE_ARG* arg);
1594 extern void pshader_glsl_texm3x3(SHADER_OPCODE_ARG* arg);
1595 extern void pshader_glsl_texm3x3pad(SHADER_OPCODE_ARG* arg);
1596 extern void pshader_glsl_texm3x3tex(SHADER_OPCODE_ARG* arg);
1597 extern void pshader_glsl_texm3x3spec(SHADER_OPCODE_ARG* arg);
1598 extern void pshader_glsl_texm3x3vspec(SHADER_OPCODE_ARG* arg);
1599 extern void pshader_glsl_texkill(SHADER_OPCODE_ARG* arg);
1600 extern void pshader_glsl_texbem(SHADER_OPCODE_ARG* arg);
1601 extern void pshader_glsl_texreg2ar(SHADER_OPCODE_ARG* arg);
1602 extern void pshader_glsl_texreg2gb(SHADER_OPCODE_ARG* arg);
1603 extern void pshader_glsl_texreg2rgb(SHADER_OPCODE_ARG* arg);
1604 extern void pshader_glsl_dp2add(SHADER_OPCODE_ARG* arg);
1605 extern void pshader_glsl_input_pack(
1606 SHADER_BUFFER* buffer,
1607 semantic* semantics_out);
1609 /** GLSL Vertex Shader Prototypes */
1610 extern void vshader_glsl_output_unpack(
1611 SHADER_BUFFER* buffer,
1612 semantic* semantics_out);
1614 /*****************************************************************************
1615 * IDirect3DBaseShader implementation structure
1617 typedef struct IWineD3DBaseShaderClass
1620 SHADER_LIMITS limits;
1621 SHADER_PARSE_STATE parse_state;
1622 CONST SHADER_OPCODE *shader_ins;
1623 CONST DWORD *function;
1624 UINT functionLength;
1628 /* Type of shader backend */
1631 /* Immediate constants (override global ones) */
1632 struct list constantsB;
1633 struct list constantsF;
1634 struct list constantsI;
1635 shader_reg_maps reg_maps;
1637 /* Pointer to the parent device */
1638 IWineD3DDevice *device;
1640 } IWineD3DBaseShaderClass;
1642 typedef struct IWineD3DBaseShaderImpl {
1644 const IWineD3DBaseShaderVtbl *lpVtbl;
1647 /* IWineD3DBaseShader */
1648 IWineD3DBaseShaderClass baseShader;
1649 } IWineD3DBaseShaderImpl;
1651 extern HRESULT shader_get_registers_used(
1652 IWineD3DBaseShader *iface,
1653 shader_reg_maps* reg_maps,
1654 semantic* semantics_in,
1655 semantic* semantics_out,
1656 CONST DWORD* pToken,
1657 IWineD3DStateBlockImpl *stateBlock);
1659 extern void shader_generate_glsl_declarations(
1660 IWineD3DBaseShader *iface,
1661 shader_reg_maps* reg_maps,
1662 SHADER_BUFFER* buffer,
1663 WineD3D_GL_Info* gl_info);
1665 extern void shader_generate_arb_declarations(
1666 IWineD3DBaseShader *iface,
1667 shader_reg_maps* reg_maps,
1668 SHADER_BUFFER* buffer,
1669 WineD3D_GL_Info* gl_info);
1671 extern void shader_generate_main(
1672 IWineD3DBaseShader *iface,
1673 SHADER_BUFFER* buffer,
1674 shader_reg_maps* reg_maps,
1675 CONST DWORD* pFunction);
1677 extern void shader_dump_ins_modifiers(
1678 const DWORD output);
1680 extern void shader_dump_param(
1681 IWineD3DBaseShader *iface,
1683 const DWORD addr_token,
1686 extern void shader_trace_init(
1687 IWineD3DBaseShader *iface,
1688 const DWORD* pFunction);
1690 extern int shader_get_param(
1691 IWineD3DBaseShader* iface,
1692 const DWORD* pToken,
1696 extern int shader_skip_unrecognized(
1697 IWineD3DBaseShader* iface,
1698 const DWORD* pToken);
1700 extern void print_glsl_info_log(
1701 WineD3D_GL_Info *gl_info,
1704 inline static int shader_get_regtype(const DWORD param) {
1705 return (((param & WINED3DSP_REGTYPE_MASK) >> WINED3DSP_REGTYPE_SHIFT) |
1706 ((param & WINED3DSP_REGTYPE_MASK2) >> WINED3DSP_REGTYPE_SHIFT2));
1709 extern unsigned int shader_get_float_offset(const DWORD reg);
1711 inline static BOOL shader_is_pshader_version(DWORD token) {
1712 return 0xFFFF0000 == (token & 0xFFFF0000);
1715 inline static BOOL shader_is_vshader_version(DWORD token) {
1716 return 0xFFFE0000 == (token & 0xFFFF0000);
1719 inline static BOOL shader_is_comment(DWORD token) {
1720 return WINED3DSIO_COMMENT == (token & WINED3DSI_OPCODE_MASK);
1723 /* Internally used shader constants. Applications can use constants 0 to GL_LIMITS(vshader_constantsF) - 1,
1724 * so upload them above that
1726 #define ARB_SHADER_PRIVCONST_BASE GL_LIMITS(vshader_constantsF)
1727 #define ARB_SHADER_PRIVCONST_POS ARB_SHADER_PRIVCONST_BASE + 0
1729 /*****************************************************************************
1730 * IDirect3DVertexShader implementation structure
1732 typedef struct IWineD3DVertexShaderImpl {
1734 const IWineD3DVertexShaderVtbl *lpVtbl;
1735 LONG ref; /* Note: Ref counting not required */
1737 /* IWineD3DBaseShader */
1738 IWineD3DBaseShaderClass baseShader;
1740 /* IWineD3DVertexShaderImpl */
1746 /* Vertex shader input and output semantics */
1747 semantic semantics_in [MAX_ATTRIBS];
1748 semantic semantics_out [MAX_REG_OUTPUT];
1750 /* run time datas... */
1752 IWineD3DVertexDeclaration *vertexDeclaration;
1753 #if 0 /* needs reworking */
1754 /* run time datas */
1755 VSHADERINPUTDATA input;
1756 VSHADEROUTPUTDATA output;
1758 } IWineD3DVertexShaderImpl;
1759 extern const SHADER_OPCODE IWineD3DVertexShaderImpl_shader_ins[];
1760 extern const IWineD3DVertexShaderVtbl IWineD3DVertexShader_Vtbl;
1762 /*****************************************************************************
1763 * IDirect3DPixelShader implementation structure
1765 typedef struct IWineD3DPixelShaderImpl {
1766 /* IUnknown parts */
1767 const IWineD3DPixelShaderVtbl *lpVtbl;
1768 LONG ref; /* Note: Ref counting not required */
1770 /* IWineD3DBaseShader */
1771 IWineD3DBaseShaderClass baseShader;
1773 /* IWineD3DPixelShaderImpl */
1776 /* Pixel shader input semantics */
1777 semantic semantics_in [MAX_REG_INPUT];
1782 #if 0 /* needs reworking */
1783 PSHADERINPUTDATA input;
1784 PSHADEROUTPUTDATA output;
1786 } IWineD3DPixelShaderImpl;
1788 extern const SHADER_OPCODE IWineD3DPixelShaderImpl_shader_ins[];
1789 extern const IWineD3DPixelShaderVtbl IWineD3DPixelShader_Vtbl;
1791 /*****************************************************************************
1792 * IWineD3DPalette implementation structure
1794 struct IWineD3DPaletteImpl {
1795 /* IUnknown parts */
1796 const IWineD3DPaletteVtbl *lpVtbl;
1800 IWineD3DDeviceImpl *wineD3DDevice;
1802 /* IWineD3DPalette */
1804 WORD palVersion; /*| */
1805 WORD palNumEntries; /*| LOGPALETTE */
1806 PALETTEENTRY palents[256]; /*| */
1807 /* This is to store the palette in 'screen format' */
1808 int screen_palents[256];
1812 extern const IWineD3DPaletteVtbl IWineD3DPalette_Vtbl;
1813 DWORD IWineD3DPaletteImpl_Size(DWORD dwFlags);
1815 /* DirectDraw utility functions */
1816 extern WINED3DFORMAT pixelformat_for_depth(DWORD depth);
1818 /*****************************************************************************
1819 * Pixel format management
1822 WINED3DFORMAT format;
1823 DWORD alphaMask, redMask, greenMask, blueMask;
1826 GLint glInternal, glFormat, glType;
1829 const PixelFormatDesc *getFormatDescEntry(WINED3DFORMAT fmt);