Raphael Junqueira | 0196861 | 2003-11-14 03:50:35 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Direct3D wine internal private include file |
| 3 | * |
| 4 | * Copyright 2002-2003 The wine-d3d team |
| 5 | * Copyright 2002-2003 Raphael Junqueira |
Jason Edmeades | 24ab49e | 2004-09-23 04:34:27 +0000 | [diff] [blame] | 6 | * Copyright 2004 Jason Edmeades |
Raphael Junqueira | 0196861 | 2003-11-14 03:50:35 +0000 | [diff] [blame] | 7 | * |
| 8 | * This library is free software; you can redistribute it and/or |
| 9 | * modify it under the terms of the GNU Lesser General Public |
| 10 | * License as published by the Free Software Foundation; either |
| 11 | * version 2.1 of the License, or (at your option) any later version. |
| 12 | * |
| 13 | * This library is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 16 | * Lesser General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU Lesser General Public |
| 19 | * License along with this library; if not, write to the Free Software |
| 20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 21 | */ |
| 22 | |
| 23 | #ifndef __WINE_WINED3D_PRIVATE_H |
| 24 | #define __WINE_WINED3D_PRIVATE_H |
| 25 | |
| 26 | #include <stdarg.h> |
Jason Edmeades | 0a944ae | 2004-11-29 17:53:42 +0000 | [diff] [blame] | 27 | #include <math.h> |
Jason Edmeades | 24ab49e | 2004-09-23 04:34:27 +0000 | [diff] [blame] | 28 | #define NONAMELESSUNION |
| 29 | #define NONAMELESSSTRUCT |
Jason Edmeades | 289562e | 2004-11-23 13:52:46 +0000 | [diff] [blame] | 30 | #define COBJMACROS |
Raphael Junqueira | 0196861 | 2003-11-14 03:50:35 +0000 | [diff] [blame] | 31 | #include "windef.h" |
| 32 | #include "winbase.h" |
Jason Edmeades | 24ab49e | 2004-09-23 04:34:27 +0000 | [diff] [blame] | 33 | #include "winreg.h" |
Raphael Junqueira | 0196861 | 2003-11-14 03:50:35 +0000 | [diff] [blame] | 34 | #include "wingdi.h" |
| 35 | #include "winuser.h" |
| 36 | #include "wine/debug.h" |
Jason Edmeades | b9e2bed | 2004-10-08 20:52:33 +0000 | [diff] [blame] | 37 | #include "wine/unicode.h" |
Raphael Junqueira | 0196861 | 2003-11-14 03:50:35 +0000 | [diff] [blame] | 38 | |
Jason Edmeades | 24ab49e | 2004-09-23 04:34:27 +0000 | [diff] [blame] | 39 | #include "d3d9.h" |
| 40 | #include "d3d9types.h" |
Raphael Junqueira | 0196861 | 2003-11-14 03:50:35 +0000 | [diff] [blame] | 41 | #include "wine/wined3d_interface.h" |
Jason Edmeades | c3421ea | 2004-09-29 21:26:47 +0000 | [diff] [blame] | 42 | #include "wine/wined3d_gl.h" |
Raphael Junqueira | 0196861 | 2003-11-14 03:50:35 +0000 | [diff] [blame] | 43 | |
Jason Edmeades | 24ab49e | 2004-09-23 04:34:27 +0000 | [diff] [blame] | 44 | extern int vs_mode; |
| 45 | #define VS_NONE 0 |
| 46 | #define VS_HW 1 |
| 47 | #define VS_SW 2 |
Raphael Junqueira | 0196861 | 2003-11-14 03:50:35 +0000 | [diff] [blame] | 48 | |
Jason Edmeades | 24ab49e | 2004-09-23 04:34:27 +0000 | [diff] [blame] | 49 | extern int ps_mode; |
| 50 | #define PS_NONE 0 |
| 51 | #define PS_HW 1 |
| 52 | |
Jason Edmeades | c3421ea | 2004-09-29 21:26:47 +0000 | [diff] [blame] | 53 | /* X11 locking */ |
| 54 | |
| 55 | extern void (*wine_tsx11_lock_ptr)(void); |
| 56 | extern void (*wine_tsx11_unlock_ptr)(void); |
| 57 | |
| 58 | /* As GLX relies on X, this is needed */ |
| 59 | extern int num_lock; |
| 60 | |
| 61 | #if 0 |
| 62 | #define ENTER_GL() ++num_lock; if (num_lock > 1) FIXME("Recursive use of GL lock to: %d\n", num_lock); wine_tsx11_lock_ptr() |
| 63 | #define LEAVE_GL() if (num_lock != 1) FIXME("Recursive use of GL lock: %d\n", num_lock); --num_lock; wine_tsx11_unlock_ptr() |
| 64 | #else |
| 65 | #define ENTER_GL() wine_tsx11_lock_ptr() |
| 66 | #define LEAVE_GL() wine_tsx11_unlock_ptr() |
| 67 | #endif |
| 68 | |
| 69 | /***************************************************************************** |
| 70 | * Defines |
| 71 | */ |
Jason Edmeades | 2003c7a | 2004-12-13 13:35:38 +0000 | [diff] [blame] | 72 | |
| 73 | /* GL related defines */ |
| 74 | /* ------------------ */ |
Jason Edmeades | eba27af | 2004-11-28 15:04:41 +0000 | [diff] [blame] | 75 | #define GL_SUPPORT(ExtName) (GLINFO_LOCATION.supported[ExtName] != 0) |
| 76 | #define GL_LIMITS(ExtName) (GLINFO_LOCATION.max_##ExtName) |
Jason Edmeades | f738c14 | 2004-12-09 11:42:34 +0000 | [diff] [blame] | 77 | #define GL_EXTCALL(FuncName) (GLINFO_LOCATION.FuncName) |
Jason Edmeades | b519893 | 2004-10-06 00:05:29 +0000 | [diff] [blame] | 78 | |
Jason Edmeades | 2003c7a | 2004-12-13 13:35:38 +0000 | [diff] [blame] | 79 | #define D3DCOLOR_R(dw) (((float) (((dw) >> 16) & 0xFF)) / 255.0f) |
| 80 | #define D3DCOLOR_G(dw) (((float) (((dw) >> 8) & 0xFF)) / 255.0f) |
| 81 | #define D3DCOLOR_B(dw) (((float) (((dw) >> 0) & 0xFF)) / 255.0f) |
| 82 | #define D3DCOLOR_A(dw) (((float) (((dw) >> 24) & 0xFF)) / 255.0f) |
| 83 | |
| 84 | #define D3DCOLORTOGLFLOAT4(dw, vec) \ |
| 85 | (vec)[0] = D3DCOLOR_R(dw); \ |
| 86 | (vec)[1] = D3DCOLOR_G(dw); \ |
| 87 | (vec)[2] = D3DCOLOR_B(dw); \ |
| 88 | (vec)[3] = D3DCOLOR_A(dw); |
| 89 | |
| 90 | /* Note: The following is purely to keep the source code as clear from #ifdefs as possible */ |
| 91 | #if defined(GL_VERSION_1_3) |
Jason Edmeades | c4de952 | 2004-12-14 11:54:27 +0000 | [diff] [blame] | 92 | #define GLACTIVETEXTURE(textureNo) \ |
| 93 | glActiveTexture(GL_TEXTURE0 + textureNo); \ |
Jason Edmeades | 2003c7a | 2004-12-13 13:35:38 +0000 | [diff] [blame] | 94 | checkGLcall("glActiveTexture"); |
Jason Edmeades | c4de952 | 2004-12-14 11:54:27 +0000 | [diff] [blame] | 95 | #define GLMULTITEXCOORD1F(a,b) \ |
| 96 | glMultiTexCoord1f(GL_TEXTURE0 + a, b); |
| 97 | #define GLMULTITEXCOORD2F(a,b,c) \ |
| 98 | glMultiTexCoord2f(GL_TEXTURE0 + a, b, c); |
| 99 | #define GLMULTITEXCOORD3F(a,b,c,d) \ |
| 100 | glMultiTexCoord3f(GL_TEXTURE0 + a, b, c, d); |
| 101 | #define GLMULTITEXCOORD4F(a,b,c,d,e) \ |
| 102 | glMultiTexCoord4f(GL_TEXTURE0 + a, b, c, d, e); |
Jason Edmeades | 2003c7a | 2004-12-13 13:35:38 +0000 | [diff] [blame] | 103 | #else |
Jason Edmeades | c4de952 | 2004-12-14 11:54:27 +0000 | [diff] [blame] | 104 | #define GLACTIVETEXTURE(textureNo) \ |
| 105 | glActiveTextureARB(GL_TEXTURE0_ARB + textureNo); \ |
Jason Edmeades | 2003c7a | 2004-12-13 13:35:38 +0000 | [diff] [blame] | 106 | checkGLcall("glActiveTextureARB"); |
Jason Edmeades | c4de952 | 2004-12-14 11:54:27 +0000 | [diff] [blame] | 107 | #define GLMULTITEXCOORD1F(a,b) \ |
Raphael Junqueira | 66cae0d | 2004-12-17 19:07:44 +0000 | [diff] [blame] | 108 | glMultiTexCoord1fARB(GL_TEXTURE0_ARB + a, b); |
Jason Edmeades | c4de952 | 2004-12-14 11:54:27 +0000 | [diff] [blame] | 109 | #define GLMULTITEXCOORD2F(a,b,c) \ |
Raphael Junqueira | 66cae0d | 2004-12-17 19:07:44 +0000 | [diff] [blame] | 110 | glMultiTexCoord2fARB(GL_TEXTURE0_ARB + a, b, c); |
Jason Edmeades | c4de952 | 2004-12-14 11:54:27 +0000 | [diff] [blame] | 111 | #define GLMULTITEXCOORD3F(a,b,c,d) \ |
Raphael Junqueira | 66cae0d | 2004-12-17 19:07:44 +0000 | [diff] [blame] | 112 | glMultiTexCoord3fARB(GL_TEXTURE0_ARB + a, b, c, d); |
Jason Edmeades | c4de952 | 2004-12-14 11:54:27 +0000 | [diff] [blame] | 113 | #define GLMULTITEXCOORD4F(a,b,c,d,e) \ |
Raphael Junqueira | 66cae0d | 2004-12-17 19:07:44 +0000 | [diff] [blame] | 114 | glMultiTexCoord4fARB(GL_TEXTURE0_ARB + a, b, c, d, e); |
Jason Edmeades | 2003c7a | 2004-12-13 13:35:38 +0000 | [diff] [blame] | 115 | #endif |
| 116 | |
| 117 | /* DirectX Device Limits */ |
| 118 | /* --------------------- */ |
Jason Edmeades | b519893 | 2004-10-06 00:05:29 +0000 | [diff] [blame] | 119 | #define MAX_STREAMS 16 /* Maximum possible streams - used for fixed size arrays |
| 120 | See MaxStreams in MSDN under GetDeviceCaps */ |
Jason Edmeades | eba27af | 2004-11-28 15:04:41 +0000 | [diff] [blame] | 121 | #define HIGHEST_TRANSFORMSTATE 512 |
| 122 | /* Highest value in D3DTRANSFORMSTATETYPE */ |
Jason Edmeades | 2003c7a | 2004-12-13 13:35:38 +0000 | [diff] [blame] | 123 | #define HIGHEST_RENDER_STATE 209 |
| 124 | /* Highest D3DRS_ value */ |
| 125 | #define HIGHEST_TEXTURE_STATE 32 |
| 126 | /* Highest D3DTSS_ value */ |
Jason Edmeades | b519893 | 2004-10-06 00:05:29 +0000 | [diff] [blame] | 127 | #define WINED3D_VSHADER_MAX_CONSTANTS 96 |
| 128 | /* Maximum number of constants provided to the shaders */ |
Jason Edmeades | 0a944ae | 2004-11-29 17:53:42 +0000 | [diff] [blame] | 129 | #define MAX_CLIPPLANES D3DMAXUSERCLIPPLANES |
Jason Edmeades | b519893 | 2004-10-06 00:05:29 +0000 | [diff] [blame] | 130 | |
Jason Edmeades | 4142785 | 2005-01-09 17:37:02 +0000 | [diff] [blame^] | 131 | #define MAX_PALETTES 256 |
| 132 | |
Jason Edmeades | 2003c7a | 2004-12-13 13:35:38 +0000 | [diff] [blame] | 133 | /* Checking of API calls */ |
| 134 | /* --------------------- */ |
Jason Edmeades | b9e2bed | 2004-10-08 20:52:33 +0000 | [diff] [blame] | 135 | #define checkGLcall(A) \ |
| 136 | { \ |
| 137 | GLint err = glGetError(); \ |
| 138 | if (err != GL_NO_ERROR) { \ |
| 139 | FIXME(">>>>>>>>>>>>>>>>> %x from %s @ %s / %d\n", err, A, __FILE__, __LINE__); \ |
| 140 | } else { \ |
| 141 | TRACE("%s call ok %s / %d\n", A, __FILE__, __LINE__); \ |
| 142 | } \ |
| 143 | } |
| 144 | |
Jason Edmeades | 2003c7a | 2004-12-13 13:35:38 +0000 | [diff] [blame] | 145 | /* Trace routines / diagnostics */ |
| 146 | /* ---------------------------- */ |
| 147 | |
| 148 | /* Dump out a matrix and copy it */ |
Jason Edmeades | eba27af | 2004-11-28 15:04:41 +0000 | [diff] [blame] | 149 | #define conv_mat(mat,gl_mat) \ |
| 150 | do { \ |
| 151 | TRACE("%f %f %f %f\n", (mat)->u.s._11, (mat)->u.s._12, (mat)->u.s._13, (mat)->u.s._14); \ |
| 152 | TRACE("%f %f %f %f\n", (mat)->u.s._21, (mat)->u.s._22, (mat)->u.s._23, (mat)->u.s._24); \ |
| 153 | TRACE("%f %f %f %f\n", (mat)->u.s._31, (mat)->u.s._32, (mat)->u.s._33, (mat)->u.s._34); \ |
| 154 | TRACE("%f %f %f %f\n", (mat)->u.s._41, (mat)->u.s._42, (mat)->u.s._43, (mat)->u.s._44); \ |
| 155 | memcpy(gl_mat, (mat), 16 * sizeof(float)); \ |
| 156 | } while (0) |
| 157 | |
Jason Edmeades | 0a944ae | 2004-11-29 17:53:42 +0000 | [diff] [blame] | 158 | /* Macro to dump out the current state of the light chain */ |
| 159 | #define DUMP_LIGHT_CHAIN() \ |
| 160 | { \ |
| 161 | PLIGHTINFOEL *el = This->stateBlock->lights;\ |
| 162 | while (el) { \ |
| 163 | TRACE("Light %p (glIndex %ld, d3dIndex %ld, enabled %d)\n", el, el->glIndex, el->OriginalIndex, el->lightEnabled);\ |
| 164 | el = el->next; \ |
| 165 | } \ |
| 166 | } |
| 167 | |
Jason Edmeades | 2003c7a | 2004-12-13 13:35:38 +0000 | [diff] [blame] | 168 | /* Trace vector and strided data information */ |
Jason Edmeades | f738c14 | 2004-12-09 11:42:34 +0000 | [diff] [blame] | 169 | #define TRACE_VECTOR(name) TRACE( #name "=(%f, %f, %f, %f)\n", name.x, name.y, name.z, name.w); |
| 170 | #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); |
| 171 | |
Jason Edmeades | 2003c7a | 2004-12-13 13:35:38 +0000 | [diff] [blame] | 172 | /* Defines used for optimizations */ |
| 173 | |
| 174 | /* Only reapply what is necessary */ |
| 175 | #define REAPPLY_ALPHAOP 0x0001 |
| 176 | #define REAPPLY_ALL 0xFFFF |
| 177 | |
| 178 | /* Advance declaration of structures to satisfy compiler */ |
Jason Edmeades | 447d5ed | 2004-10-21 20:59:12 +0000 | [diff] [blame] | 179 | typedef struct IWineD3DStateBlockImpl IWineD3DStateBlockImpl; |
Jason Edmeades | 4142785 | 2005-01-09 17:37:02 +0000 | [diff] [blame^] | 180 | typedef struct IWineD3DSurfaceImpl IWineD3DSurfaceImpl; |
Jason Edmeades | 447d5ed | 2004-10-21 20:59:12 +0000 | [diff] [blame] | 181 | |
Jason Edmeades | 2003c7a | 2004-12-13 13:35:38 +0000 | [diff] [blame] | 182 | /* Global variables */ |
Jason Edmeades | eba27af | 2004-11-28 15:04:41 +0000 | [diff] [blame] | 183 | extern const float identity[16]; |
| 184 | |
Jason Edmeades | 24ab49e | 2004-09-23 04:34:27 +0000 | [diff] [blame] | 185 | /***************************************************************************** |
Jason Edmeades | f738c14 | 2004-12-09 11:42:34 +0000 | [diff] [blame] | 186 | * Compilable extra diagnostics |
| 187 | */ |
| 188 | |
| 189 | /* Trace information per-vertex: (extremely high amount of trace) */ |
| 190 | #if 0 /* NOTE: Must be 0 in cvs */ |
| 191 | # define VTRACE(A) TRACE A |
| 192 | #else |
| 193 | # define VTRACE(A) |
| 194 | #endif |
| 195 | |
| 196 | /* Checking of per-vertex related GL calls */ |
| 197 | #define vcheckGLcall(A) \ |
| 198 | { \ |
| 199 | GLint err = glGetError(); \ |
| 200 | if (err != GL_NO_ERROR) { \ |
| 201 | FIXME(">>>>>>>>>>>>>>>>> %x from %s @ %s / %d\n", err, A, __FILE__, __LINE__); \ |
| 202 | } else { \ |
| 203 | VTRACE(("%s call ok %s / %d\n", A, __FILE__, __LINE__)); \ |
| 204 | } \ |
| 205 | } |
| 206 | |
Jason Edmeades | c4de952 | 2004-12-14 11:54:27 +0000 | [diff] [blame] | 207 | /* TODO: Confirm each of these works when wined3d move completed */ |
| 208 | #if 0 /* NOTE: Must be 0 in cvs */ |
| 209 | /* To avoid having to get gigabytes of trace, the following can be compiled in, and at the start |
| 210 | of each frame, a check is made for the existence of C:\D3DTRACE, and if if exists d3d trace |
| 211 | is enabled, and if it doesn't exists it is disabled. */ |
| 212 | # define FRAME_DEBUGGING |
| 213 | /* Adding in the SINGLE_FRAME_DEBUGGING gives a trace of just what makes up a single frame, before |
| 214 | the file is deleted */ |
| 215 | # if 1 /* NOTE: Must be 1 in cvs, as this is mostly more useful than a trace from program start */ |
| 216 | # define SINGLE_FRAME_DEBUGGING |
| 217 | # endif |
| 218 | /* The following, when enabled, lets you see the makeup of the frame, by drawprimitive calls. |
| 219 | It can only be enabled when FRAME_DEBUGGING is also enabled |
| 220 | The contents of the back buffer are written into /tmp/backbuffer_* after each primitive |
| 221 | array is drawn. */ |
| 222 | # if 0 /* NOTE: Must be 0 in cvs, as this give a lot of ppm files when compiled in */ |
| 223 | # define SHOW_FRAME_MAKEUP 1 |
| 224 | # endif |
| 225 | /* The following, when enabled, lets you see the makeup of the all the textures used during each |
| 226 | of the drawprimitive calls. It can only be enabled when SHOW_FRAME_MAKEUP is also enabled. |
| 227 | The contents of the textures assigned to each stage are written into |
| 228 | /tmp/texture_*_<Stage>.ppm after each primitive array is drawn. */ |
| 229 | # if 0 /* NOTE: Must be 0 in cvs, as this give a lot of ppm files when compiled in */ |
| 230 | # define SHOW_TEXTURE_MAKEUP 0 |
| 231 | # endif |
| 232 | extern BOOL isOn; |
| 233 | extern BOOL isDumpingFrames; |
| 234 | extern LONG primCounter; |
| 235 | #endif |
| 236 | |
Jason Edmeades | f738c14 | 2004-12-09 11:42:34 +0000 | [diff] [blame] | 237 | /***************************************************************************** |
| 238 | * Prototypes |
| 239 | */ |
| 240 | |
| 241 | /* Routine common to the draw primitive and draw indexed primitive routines */ |
| 242 | void drawPrimitive(IWineD3DDevice *iface, |
| 243 | int PrimitiveType, |
| 244 | long NumPrimitives, |
| 245 | |
| 246 | /* for Indexed: */ |
| 247 | long StartVertexIndex, |
| 248 | long StartIdx, |
| 249 | short idxBytes, |
| 250 | const void *idxData, |
| 251 | int minIndex); |
| 252 | |
| 253 | /***************************************************************************** |
| 254 | * Structures required to draw primitives |
| 255 | */ |
| 256 | |
| 257 | typedef struct Direct3DStridedData { |
| 258 | BYTE *lpData; /* Pointer to start of data */ |
| 259 | DWORD dwStride; /* Stride between occurances of this data */ |
| 260 | DWORD dwType; /* Type (as in D3DVSDT_TYPE) */ |
| 261 | } Direct3DStridedData; |
| 262 | |
| 263 | typedef struct Direct3DVertexStridedData { |
| 264 | union { |
| 265 | struct { |
| 266 | Direct3DStridedData position; |
| 267 | Direct3DStridedData blendWeights; |
| 268 | Direct3DStridedData blendMatrixIndices; |
| 269 | Direct3DStridedData normal; |
| 270 | Direct3DStridedData pSize; |
| 271 | Direct3DStridedData diffuse; |
| 272 | Direct3DStridedData specular; |
| 273 | Direct3DStridedData texCoords[8]; |
| 274 | } s; |
| 275 | Direct3DStridedData input[16]; /* Indexed by constants in D3DVSDE_REGISTER */ |
| 276 | } u; |
| 277 | } Direct3DVertexStridedData; |
| 278 | |
| 279 | /***************************************************************************** |
Jason Edmeades | 0a944ae | 2004-11-29 17:53:42 +0000 | [diff] [blame] | 280 | * Internal representation of a light |
| 281 | */ |
| 282 | typedef struct PLIGHTINFOEL PLIGHTINFOEL; |
| 283 | struct PLIGHTINFOEL { |
| 284 | WINED3DLIGHT OriginalParms; /* Note D3D8LIGHT == D3D9LIGHT */ |
| 285 | DWORD OriginalIndex; |
| 286 | LONG glIndex; |
| 287 | BOOL lightEnabled; |
| 288 | BOOL changed; |
| 289 | BOOL enabledChanged; |
| 290 | |
| 291 | /* Converted parms to speed up swapping lights */ |
| 292 | float lightPosn[4]; |
| 293 | float lightDirn[4]; |
| 294 | float exponent; |
| 295 | float cutoff; |
| 296 | |
| 297 | PLIGHTINFOEL *next; |
| 298 | PLIGHTINFOEL *prev; |
| 299 | }; |
| 300 | |
| 301 | /***************************************************************************** |
Jason Edmeades | 24ab49e | 2004-09-23 04:34:27 +0000 | [diff] [blame] | 302 | * IWineD3D implementation structure |
| 303 | */ |
| 304 | typedef struct IWineD3DImpl |
| 305 | { |
| 306 | /* IUnknown fields */ |
| 307 | IWineD3DVtbl *lpVtbl; |
| 308 | DWORD ref; /* Note: Ref counting not required */ |
| 309 | |
| 310 | /* WineD3D Information */ |
Jason Edmeades | 289562e | 2004-11-23 13:52:46 +0000 | [diff] [blame] | 311 | IUnknown *parent; |
Jason Edmeades | 24ab49e | 2004-09-23 04:34:27 +0000 | [diff] [blame] | 312 | UINT dxVersion; |
Jason Edmeades | c3421ea | 2004-09-29 21:26:47 +0000 | [diff] [blame] | 313 | |
| 314 | /* GL Information */ |
| 315 | BOOL isGLInfoValid; |
| 316 | WineD3D_GL_Info gl_info; |
Jason Edmeades | 24ab49e | 2004-09-23 04:34:27 +0000 | [diff] [blame] | 317 | } IWineD3DImpl; |
| 318 | |
| 319 | extern IWineD3DVtbl IWineD3D_Vtbl; |
| 320 | |
Jason Edmeades | ac490fa | 2004-10-07 04:22:21 +0000 | [diff] [blame] | 321 | /***************************************************************************** |
| 322 | * IWineD3DDevice implementation structure |
| 323 | */ |
| 324 | typedef struct IWineD3DDeviceImpl |
| 325 | { |
Jason Edmeades | b9e2bed | 2004-10-08 20:52:33 +0000 | [diff] [blame] | 326 | /* IUnknown fields */ |
Jason Edmeades | ac490fa | 2004-10-07 04:22:21 +0000 | [diff] [blame] | 327 | IWineD3DDeviceVtbl *lpVtbl; |
| 328 | DWORD ref; /* Note: Ref counting not required */ |
| 329 | |
Jason Edmeades | b9e2bed | 2004-10-08 20:52:33 +0000 | [diff] [blame] | 330 | /* WineD3D Information */ |
Jason Edmeades | 289562e | 2004-11-23 13:52:46 +0000 | [diff] [blame] | 331 | IUnknown *parent; /* TODO - to be a new interface eventually */ |
Jason Edmeades | eba27af | 2004-11-28 15:04:41 +0000 | [diff] [blame] | 332 | IWineD3D *wineD3D; |
Jason Edmeades | ac490fa | 2004-10-07 04:22:21 +0000 | [diff] [blame] | 333 | |
Jason Edmeades | b9e2bed | 2004-10-08 20:52:33 +0000 | [diff] [blame] | 334 | /* X and GL Information */ |
| 335 | HWND win_handle; |
| 336 | Window win; |
| 337 | Display *display; |
| 338 | GLXContext glCtx; |
| 339 | XVisualInfo *visInfo; |
| 340 | GLXContext render_ctx; |
| 341 | Drawable drawable; |
| 342 | GLint maxConcurrentLights; |
| 343 | |
| 344 | /* Optimization */ |
| 345 | BOOL modelview_valid; |
| 346 | BOOL proj_valid; |
| 347 | BOOL view_ident; /* true iff view matrix is identity */ |
| 348 | BOOL last_was_rhw; /* true iff last draw_primitive was in xyzrhw mode */ |
Jason Edmeades | f738c14 | 2004-12-09 11:42:34 +0000 | [diff] [blame] | 349 | GLenum tracking_parm; /* Which source is tracking current colour */ |
| 350 | LONG tracking_color; /* used iff GL_COLOR_MATERIAL was enabled */ |
| 351 | #define DISABLED_TRACKING 0 /* Disabled */ |
| 352 | #define IS_TRACKING 1 /* tracking_parm is tracking diffuse color */ |
| 353 | #define NEEDS_TRACKING 2 /* Tracking needs to be enabled when needed */ |
| 354 | #define NEEDS_DISABLE 3 /* Tracking needs to be disabled when needed*/ |
Jason Edmeades | 2003c7a | 2004-12-13 13:35:38 +0000 | [diff] [blame] | 355 | UINT srcBlend; |
| 356 | UINT dstBlend; |
| 357 | UINT alphafunc; |
| 358 | UINT stencilfunc; |
| 359 | BOOL texture_shader_active; /* TODO: Confirm use is correct */ |
Jason Edmeades | b9e2bed | 2004-10-08 20:52:33 +0000 | [diff] [blame] | 360 | |
Jason Edmeades | 447d5ed | 2004-10-21 20:59:12 +0000 | [diff] [blame] | 361 | /* State block related */ |
| 362 | BOOL isRecordingState; |
| 363 | IWineD3DStateBlockImpl *stateBlock; |
| 364 | IWineD3DStateBlockImpl *updateStateBlock; |
| 365 | |
Jason Edmeades | b9e2bed | 2004-10-08 20:52:33 +0000 | [diff] [blame] | 366 | /* Internal use fields */ |
| 367 | D3DDEVICE_CREATION_PARAMETERS createParms; |
| 368 | D3DPRESENT_PARAMETERS presentParms; |
| 369 | UINT adapterNo; |
| 370 | D3DDEVTYPE devType; |
| 371 | |
Jason Edmeades | 4142785 | 2005-01-09 17:37:02 +0000 | [diff] [blame^] | 372 | /* Render Target Support */ |
| 373 | IWineD3DSurfaceImpl *frontBuffer; |
| 374 | IWineD3DSurfaceImpl *backBuffer; |
| 375 | IWineD3DSurfaceImpl *depthStencilBuffer; |
| 376 | |
| 377 | IWineD3DSurfaceImpl *renderTarget; |
| 378 | IWineD3DSurfaceImpl *stencilBufferTarget; |
| 379 | |
| 380 | /* palettes texture management */ |
| 381 | PALETTEENTRY palettes[MAX_PALETTES][256]; |
| 382 | UINT currentPalette; |
| 383 | |
Jason Edmeades | f738c14 | 2004-12-09 11:42:34 +0000 | [diff] [blame] | 384 | /* For rendering to a texture using glCopyTexImage */ |
| 385 | BOOL renderUpsideDown; |
| 386 | |
Jason Edmeades | 2003c7a | 2004-12-13 13:35:38 +0000 | [diff] [blame] | 387 | /* Textures for when no other textures are mapped */ |
| 388 | UINT dummyTextureName[8]; |
| 389 | |
Jason Edmeades | ac490fa | 2004-10-07 04:22:21 +0000 | [diff] [blame] | 390 | } IWineD3DDeviceImpl; |
| 391 | |
| 392 | extern IWineD3DDeviceVtbl IWineD3DDevice_Vtbl; |
| 393 | |
Jason Edmeades | db7a505 | 2004-10-14 00:32:04 +0000 | [diff] [blame] | 394 | /***************************************************************************** |
| 395 | * IWineD3DResource implementation structure |
| 396 | */ |
| 397 | typedef struct IWineD3DResourceClass |
| 398 | { |
| 399 | /* IUnknown fields */ |
| 400 | DWORD ref; /* Note: Ref counting not required */ |
| 401 | |
| 402 | /* WineD3DResource Information */ |
Jason Edmeades | 289562e | 2004-11-23 13:52:46 +0000 | [diff] [blame] | 403 | IUnknown *parent; |
Jason Edmeades | db7a505 | 2004-10-14 00:32:04 +0000 | [diff] [blame] | 404 | D3DRESOURCETYPE resourceType; |
Jason Edmeades | 4142785 | 2005-01-09 17:37:02 +0000 | [diff] [blame^] | 405 | IWineD3DDeviceImpl *wineD3DDevice; |
Jason Edmeades | db7a505 | 2004-10-14 00:32:04 +0000 | [diff] [blame] | 406 | |
| 407 | } IWineD3DResourceClass; |
| 408 | |
| 409 | typedef struct IWineD3DResourceImpl |
| 410 | { |
| 411 | /* IUnknown & WineD3DResource Information */ |
| 412 | IWineD3DResourceVtbl *lpVtbl; |
| 413 | IWineD3DResourceClass resource; |
Jason Edmeades | db7a505 | 2004-10-14 00:32:04 +0000 | [diff] [blame] | 414 | } IWineD3DResourceImpl; |
| 415 | |
| 416 | extern IWineD3DResourceVtbl IWineD3DResource_Vtbl; |
| 417 | |
| 418 | /***************************************************************************** |
| 419 | * IWineD3DVertexBuffer implementation structure (extends IWineD3DResourceImpl) |
| 420 | */ |
| 421 | typedef struct IWineD3DVertexBufferImpl |
| 422 | { |
| 423 | /* IUnknown & WineD3DResource Information */ |
| 424 | IWineD3DVertexBufferVtbl *lpVtbl; |
| 425 | IWineD3DResourceClass resource; |
| 426 | |
| 427 | /* WineD3DVertexBuffer specifics */ |
| 428 | BYTE *allocatedMemory; |
| 429 | D3DVERTEXBUFFER_DESC currentDesc; |
| 430 | |
| 431 | } IWineD3DVertexBufferImpl; |
| 432 | |
| 433 | extern IWineD3DVertexBufferVtbl IWineD3DVertexBuffer_Vtbl; |
| 434 | |
Jason Edmeades | 447d5ed | 2004-10-21 20:59:12 +0000 | [diff] [blame] | 435 | /***************************************************************************** |
Jason Edmeades | 73e8baf | 2004-11-24 18:13:41 +0000 | [diff] [blame] | 436 | * IWineD3DIndexBuffer implementation structure (extends IWineD3DResourceImpl) |
| 437 | */ |
| 438 | typedef struct IWineD3DIndexBufferImpl |
| 439 | { |
| 440 | /* IUnknown & WineD3DResource Information */ |
| 441 | IWineD3DIndexBufferVtbl *lpVtbl; |
| 442 | IWineD3DResourceClass resource; |
| 443 | |
| 444 | /* WineD3DVertexBuffer specifics */ |
| 445 | BYTE *allocatedMemory; |
| 446 | D3DINDEXBUFFER_DESC currentDesc; |
| 447 | |
| 448 | } IWineD3DIndexBufferImpl; |
| 449 | |
| 450 | extern IWineD3DIndexBufferVtbl IWineD3DIndexBuffer_Vtbl; |
| 451 | |
| 452 | /***************************************************************************** |
Jason Edmeades | 819b0e1 | 2004-12-07 14:29:12 +0000 | [diff] [blame] | 453 | * IWineD3DBaseTexture implementation structure (extends IWineD3DResourceImpl) |
| 454 | */ |
| 455 | typedef struct IWineD3DBaseTextureClass |
| 456 | { |
| 457 | UINT levels; |
Jason Edmeades | 4142785 | 2005-01-09 17:37:02 +0000 | [diff] [blame^] | 458 | BOOL dirty; |
Jason Edmeades | 819b0e1 | 2004-12-07 14:29:12 +0000 | [diff] [blame] | 459 | |
| 460 | } IWineD3DBaseTextureClass; |
| 461 | |
| 462 | typedef struct IWineD3DBaseTextureImpl |
| 463 | { |
| 464 | /* IUnknown & WineD3DResource Information */ |
| 465 | IWineD3DIndexBufferVtbl *lpVtbl; |
| 466 | IWineD3DResourceClass resource; |
| 467 | IWineD3DBaseTextureClass baseTexture; |
| 468 | |
| 469 | } IWineD3DBaseTextureImpl; |
| 470 | |
| 471 | extern IWineD3DBaseTextureVtbl IWineD3DBaseTexture_Vtbl; |
| 472 | |
| 473 | /***************************************************************************** |
Jason Edmeades | 4142785 | 2005-01-09 17:37:02 +0000 | [diff] [blame^] | 474 | * IWineD3DSurface implementation structure |
| 475 | */ |
| 476 | struct IWineD3DSurfaceImpl |
| 477 | { |
| 478 | /* IUnknown & IWineD3DResource Information */ |
| 479 | IWineD3DSurfaceVtbl *lpVtbl; |
| 480 | IWineD3DResourceClass resource; |
| 481 | |
| 482 | /* IWineD3DSurface fields */ |
| 483 | IUnknown *container; |
| 484 | D3DSURFACE_DESC currentDesc; |
| 485 | BYTE *allocatedMemory; |
| 486 | |
| 487 | UINT textureName; |
| 488 | UINT bytesPerPixel; |
| 489 | |
| 490 | BOOL lockable; |
| 491 | BOOL locked; |
| 492 | RECT lockedRect; |
| 493 | RECT dirtyRect; |
| 494 | BOOL Dirty; |
| 495 | BOOL inTexture; |
| 496 | BOOL inPBuffer; |
| 497 | }; |
| 498 | |
| 499 | extern IWineD3DSurfaceVtbl IWineD3DSurface_Vtbl; |
| 500 | |
| 501 | /***************************************************************************** |
Jason Edmeades | 447d5ed | 2004-10-21 20:59:12 +0000 | [diff] [blame] | 502 | * IWineD3DStateBlock implementation structure |
| 503 | */ |
| 504 | |
| 505 | /* Internal state Block for Begin/End/Capture/Create/Apply info */ |
| 506 | /* Note: Very long winded but gl Lists are not flexible enough */ |
| 507 | /* to resolve everything we need, so doing it manually for now */ |
| 508 | typedef struct SAVEDSTATES { |
Jason Edmeades | f738c14 | 2004-12-09 11:42:34 +0000 | [diff] [blame] | 509 | BOOL indices; |
Jason Edmeades | 0a944ae | 2004-11-29 17:53:42 +0000 | [diff] [blame] | 510 | BOOL material; |
Jason Edmeades | 447d5ed | 2004-10-21 20:59:12 +0000 | [diff] [blame] | 511 | BOOL fvf; |
Jason Edmeades | 289562e | 2004-11-23 13:52:46 +0000 | [diff] [blame] | 512 | BOOL stream_source[MAX_STREAMS]; |
Jason Edmeades | f738c14 | 2004-12-09 11:42:34 +0000 | [diff] [blame] | 513 | BOOL textures[8]; |
Jason Edmeades | eba27af | 2004-11-28 15:04:41 +0000 | [diff] [blame] | 514 | BOOL transform[HIGHEST_TRANSFORMSTATE]; |
Jason Edmeades | f738c14 | 2004-12-09 11:42:34 +0000 | [diff] [blame] | 515 | BOOL viewport; |
Jason Edmeades | 2003c7a | 2004-12-13 13:35:38 +0000 | [diff] [blame] | 516 | BOOL renderState[HIGHEST_RENDER_STATE]; |
| 517 | BOOL textureState[8][HIGHEST_TEXTURE_STATE]; |
Jason Edmeades | 0a944ae | 2004-11-29 17:53:42 +0000 | [diff] [blame] | 518 | BOOL clipplane[MAX_CLIPPLANES]; |
Jason Edmeades | 447d5ed | 2004-10-21 20:59:12 +0000 | [diff] [blame] | 519 | } SAVEDSTATES; |
| 520 | |
| 521 | struct IWineD3DStateBlockImpl |
| 522 | { |
| 523 | /* IUnknown fields */ |
| 524 | IWineD3DStateBlockVtbl *lpVtbl; |
| 525 | DWORD ref; /* Note: Ref counting not required */ |
| 526 | |
| 527 | /* IWineD3DStateBlock information */ |
Jason Edmeades | 289562e | 2004-11-23 13:52:46 +0000 | [diff] [blame] | 528 | IUnknown *parent; |
Jason Edmeades | 4142785 | 2005-01-09 17:37:02 +0000 | [diff] [blame^] | 529 | IWineD3DDeviceImpl *wineD3DDevice; |
Jason Edmeades | 447d5ed | 2004-10-21 20:59:12 +0000 | [diff] [blame] | 530 | D3DSTATEBLOCKTYPE blockType; |
| 531 | |
| 532 | /* Array indicating whether things have been set or changed */ |
| 533 | SAVEDSTATES changed; |
| 534 | SAVEDSTATES set; |
| 535 | |
| 536 | /* Drawing - Vertex Shader or FVF related */ |
| 537 | DWORD fvf; |
Jason Edmeades | f738c14 | 2004-12-09 11:42:34 +0000 | [diff] [blame] | 538 | void *vertexShader; /* TODO: Replace void * with IWineD3DVertexShader * */ |
| 539 | BOOL streamIsUP; |
Jason Edmeades | 447d5ed | 2004-10-21 20:59:12 +0000 | [diff] [blame] | 540 | |
Jason Edmeades | 289562e | 2004-11-23 13:52:46 +0000 | [diff] [blame] | 541 | /* Stream Source */ |
| 542 | UINT stream_stride[MAX_STREAMS]; |
| 543 | UINT stream_offset[MAX_STREAMS]; |
| 544 | IWineD3DVertexBuffer *stream_source[MAX_STREAMS]; |
Jason Edmeades | eba27af | 2004-11-28 15:04:41 +0000 | [diff] [blame] | 545 | |
Jason Edmeades | f738c14 | 2004-12-09 11:42:34 +0000 | [diff] [blame] | 546 | /* Indices */ |
| 547 | IWineD3DIndexBuffer* pIndexData; |
| 548 | UINT baseVertexIndex; /* Note: only used for d3d8 */ |
| 549 | |
Jason Edmeades | eba27af | 2004-11-28 15:04:41 +0000 | [diff] [blame] | 550 | /* Transform */ |
| 551 | D3DMATRIX transforms[HIGHEST_TRANSFORMSTATE]; |
| 552 | |
Jason Edmeades | 0a944ae | 2004-11-29 17:53:42 +0000 | [diff] [blame] | 553 | /* Lights */ |
| 554 | PLIGHTINFOEL *lights; /* NOTE: active GL lights must be front of the chain */ |
| 555 | |
| 556 | /* Clipping */ |
| 557 | double clipplane[MAX_CLIPPLANES][4]; |
| 558 | WINED3DCLIPSTATUS clip_status; |
| 559 | |
Jason Edmeades | f738c14 | 2004-12-09 11:42:34 +0000 | [diff] [blame] | 560 | /* ViewPort */ |
| 561 | WINED3DVIEWPORT viewport; |
| 562 | |
Jason Edmeades | 0a944ae | 2004-11-29 17:53:42 +0000 | [diff] [blame] | 563 | /* Material */ |
| 564 | WINED3DMATERIAL material; |
| 565 | |
Jason Edmeades | 2003c7a | 2004-12-13 13:35:38 +0000 | [diff] [blame] | 566 | /* Indexed Vertex Blending */ |
| 567 | D3DVERTEXBLENDFLAGS vertex_blend; |
| 568 | FLOAT tween_factor; |
| 569 | |
| 570 | /* RenderState */ |
| 571 | DWORD renderState[HIGHEST_RENDER_STATE]; |
| 572 | |
Jason Edmeades | f738c14 | 2004-12-09 11:42:34 +0000 | [diff] [blame] | 573 | /* Texture */ |
| 574 | IWineD3DBaseTexture *textures[8]; |
| 575 | int textureDimensions[8]; |
Jason Edmeades | 2003c7a | 2004-12-13 13:35:38 +0000 | [diff] [blame] | 576 | |
| 577 | /* Texture State Stage */ |
| 578 | DWORD textureState[8][HIGHEST_TEXTURE_STATE]; |
| 579 | |
Jason Edmeades | 447d5ed | 2004-10-21 20:59:12 +0000 | [diff] [blame] | 580 | }; |
| 581 | |
| 582 | extern IWineD3DStateBlockVtbl IWineD3DStateBlock_Vtbl; |
| 583 | |
| 584 | /***************************************************************************** |
| 585 | * Utility function prototypes |
| 586 | */ |
Jason Edmeades | 2003c7a | 2004-12-13 13:35:38 +0000 | [diff] [blame] | 587 | |
| 588 | /* Trace routines */ |
Jason Edmeades | ae5a436 | 2004-09-28 02:12:12 +0000 | [diff] [blame] | 589 | const char* debug_d3dformat(D3DFORMAT fmt); |
Jason Edmeades | c579fa6 | 2004-10-05 02:14:06 +0000 | [diff] [blame] | 590 | const char* debug_d3ddevicetype(D3DDEVTYPE devtype); |
| 591 | const char* debug_d3dresourcetype(D3DRESOURCETYPE res); |
| 592 | const char* debug_d3dusage(DWORD usage); |
Jason Edmeades | f738c14 | 2004-12-09 11:42:34 +0000 | [diff] [blame] | 593 | const char* debug_d3dprimitivetype(D3DPRIMITIVETYPE PrimitiveType); |
Jason Edmeades | 2003c7a | 2004-12-13 13:35:38 +0000 | [diff] [blame] | 594 | const char* debug_d3drenderstate(DWORD state); |
| 595 | const char* debug_d3dtexturestate(DWORD state); |
| 596 | |
| 597 | /* Routines for GL <-> D3D values */ |
| 598 | GLenum StencilOp(DWORD op); |
| 599 | void set_tex_op(IWineD3DDevice *iface, BOOL isAlpha, int Stage, D3DTEXTUREOP op, DWORD arg1, DWORD arg2, DWORD arg3); |
| 600 | void set_texture_matrix(const float *smat, DWORD flags); |
| 601 | void GetSrcAndOpFromValue(DWORD iValue, BOOL isAlphaArg, GLenum* source, GLenum* operand); |
Jason Edmeades | ae5a436 | 2004-09-28 02:12:12 +0000 | [diff] [blame] | 602 | |
Jason Edmeades | 4142785 | 2005-01-09 17:37:02 +0000 | [diff] [blame^] | 603 | SHORT D3DFmtGetBpp(IWineD3DDeviceImpl* This, D3DFORMAT fmt); |
| 604 | GLenum D3DFmt2GLFmt(IWineD3DDeviceImpl* This, D3DFORMAT fmt); |
| 605 | GLenum D3DFmt2GLType(IWineD3DDeviceImpl *This, D3DFORMAT fmt); |
| 606 | GLint D3DFmt2GLIntFmt(IWineD3DDeviceImpl* This, D3DFORMAT fmt); |
| 607 | |
| 608 | |
Jason Edmeades | 24ab49e | 2004-09-23 04:34:27 +0000 | [diff] [blame] | 609 | #if 0 /* Needs fixing during rework */ |
Raphael Junqueira | 0196861 | 2003-11-14 03:50:35 +0000 | [diff] [blame] | 610 | /***************************************************************************** |
| 611 | * IDirect3DVertexShaderDeclaration implementation structure |
| 612 | */ |
| 613 | struct IDirect3DVertexShaderDeclarationImpl { |
| 614 | /* The device */ |
| 615 | /*IDirect3DDeviceImpl* device;*/ |
| 616 | |
| 617 | /** precomputed fvf if simple declaration */ |
| 618 | DWORD fvf[MAX_STREAMS]; |
| 619 | DWORD allFVF; |
| 620 | |
| 621 | /** dx8 compatible Declaration fields */ |
| 622 | DWORD* pDeclaration8; |
| 623 | DWORD declaration8Length; |
| 624 | }; |
| 625 | |
| 626 | |
| 627 | /***************************************************************************** |
| 628 | * IDirect3DVertexShader implementation structure |
| 629 | */ |
| 630 | struct IDirect3DVertexShaderImpl { |
| 631 | /* The device */ |
| 632 | /*IDirect3DDeviceImpl* device;*/ |
| 633 | |
| 634 | DWORD* function; |
| 635 | UINT functionLength; |
| 636 | DWORD usage; |
| 637 | DWORD version; |
| 638 | /* run time datas */ |
| 639 | VSHADERDATA* data; |
| 640 | VSHADERINPUTDATA input; |
| 641 | VSHADEROUTPUTDATA output; |
| 642 | }; |
| 643 | |
| 644 | |
| 645 | /***************************************************************************** |
| 646 | * IDirect3DPixelShader implementation structure |
| 647 | */ |
| 648 | struct IDirect3DPixelShaderImpl { |
| 649 | /* The device */ |
| 650 | /*IDirect3DDeviceImpl* device;*/ |
| 651 | |
| 652 | DWORD* function; |
| 653 | UINT functionLength; |
| 654 | DWORD version; |
| 655 | /* run time datas */ |
| 656 | PSHADERDATA* data; |
| 657 | PSHADERINPUTDATA input; |
| 658 | PSHADEROUTPUTDATA output; |
| 659 | }; |
| 660 | |
Jason Edmeades | 24ab49e | 2004-09-23 04:34:27 +0000 | [diff] [blame] | 661 | #endif /* Needs fixing during rework */ |
Raphael Junqueira | 0196861 | 2003-11-14 03:50:35 +0000 | [diff] [blame] | 662 | #endif |