- Timestamp:
- Dec 5, 2010 1:50:36 PM (14 years ago)
- Location:
- trunk/src/VBox
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/GuestHost/OpenGL/include/cr_glstate.h
r34107 r34725 234 234 DECLEXPORT(void) STATE_APIENTRY crStateSetSharedContext(CRContext *pCtx); 235 235 DECLEXPORT(GLboolean) STATE_APIENTRY crStateContextIsShared(CRContext *pCtx); 236 237 DECLEXPORT(void) STATE_APIENTRY crStateQueryHWState(); 236 238 #ifdef __cplusplus 237 239 } -
trunk/src/VBox/GuestHost/OpenGL/state_tracker/state_buffer.txt
r15532 r34725 3 3 # 4 4 # See the file LICENSE.txt for information on redistributing this software. 5 #-:enable:*glAble able[2]; 6 #-:enable:*able[0] = diff_api.Disable; 7 #-:enable:*able[1] = diff_api.Enable; 8 #-:enable:*able[to->depthTest](GL_DEPTH_TEST); 9 #-:enable:*FILLDIRTY(b->enable); 10 #-:enable:*FILLDIRTY(b->dirty); 11 #+:enable:depthTest:GL_DEPTH_TEST 5 12 :enable:depthTest:GL_DEPTH_TEST 6 13 :enable:blend:GL_BLEND -
trunk/src/VBox/GuestHost/OpenGL/state_tracker/state_lists.c
r15532 r34725 13 13 void crStateListsDestroy(CRContext *ctx) 14 14 { 15 15 /* nothing - dlists are in shared state */ 16 16 } 17 17 18 18 void crStateListsInit(CRContext *ctx) 19 19 { 20 CRListsState *l = &ctx->lists; 21 CRStateBits *sb = GetCurrentBits(); 22 CRListsBits *lb = &(sb->lists); 23 24 l->newEnd = GL_FALSE; 25 l->mode = 0; 26 l->currentIndex = 0; 27 l->base = 0; 28 29 RESET(lb->base, ctx->bitid); 30 RESET(lb->dirty, ctx->bitid); 20 CRListsState *l = &ctx->lists; 21 CRStateBits *sb = GetCurrentBits(); 22 CRListsBits *lb = &(sb->lists); 23 24 l->newEnd = GL_FALSE; 25 l->mode = 0; 26 l->currentIndex = 0; 27 l->base = 0; 28 29 RESET(lb->base, ctx->bitid); 30 RESET(lb->dirty, ctx->bitid); 31 } 32 33 /*#define CRSTATE_DEBUG_QUERY_HW_STATE*/ 34 35 #ifndef CRSTATE_DEBUG_QUERY_HW_STATE 36 # define CRSTATE_SET_CAP(state, value, format) g->state=value 37 # define CR_STATE_SETTEX_MSG(state, st, hw) 38 # define CR_STATE_SETMAT_MSG(state, st, hw) 39 #else 40 # define CRSTATE_SET_CAP(state, value, format) \ 41 if (g->state!=value) { \ 42 crDebug("crStateQueryHWState fixed %s from "format" to "format, #state, g->state, value); \ 43 g->state=value; \ 44 } 45 # define CR_STATE_SETTEX_MSG(state, st, hw) crDebug("crStateQueryHWState fixed %s from %i to %i", state, st, hw) 46 # define CR_STATE_SETMAT_MSG(state, st, hw) \ 47 { \ 48 crDebug("crStateQueryHWState fixed %s", state); \ 49 crDebug("st: [%f, %f, %f, %f] [%f, %f, %f, %f] [%f, %f, %f, %f] [%f, %f, %f, %f]", \ 50 st[0], st[1], st[2], st[3], st[4], st[5], st[6], st[7], \ 51 st[8], st[9], st[10], st[11], st[12], st[13], st[14], st[15]); \ 52 crDebug("hw: [%f, %f, %f, %f] [%f, %f, %f, %f] [%f, %f, %f, %f] [%f, %f, %f, %f]", \ 53 hw[0], hw[1], hw[2], hw[3], hw[4], hw[5], hw[6], hw[7], \ 54 hw[8], hw[9], hw[10], hw[11], hw[12], hw[13], hw[14], hw[15]); \ 55 } 56 #endif 57 58 #define CRSTATE_SET_ENABLED(state, cap) CRSTATE_SET_CAP(state, diff_api.IsEnabled(cap), "%u") 59 60 #define CRSTATE_SET_ENUM(state, cap) {GLenum _e=g->state; diff_api.GetIntegerv(cap, &_e); CRSTATE_SET_CAP(state, _e, "%#x");} 61 #define CRSTATE_SET_FLOAT(state, cap) {GLfloat _f=g->state; diff_api.GetFloatv(cap, &_f); CRSTATE_SET_CAP(state, _f, "%f");} 62 #define CRSTATE_SET_INT(state, cap) {GLint _i=g->state; diff_api.GetIntegerv(cap, &_i); CRSTATE_SET_CAP(state, _i, "%i");} 63 #define CRSTATE_SET_BOOL(state, cap) {GLboolean _b=g->state; diff_api.GetBooleanv(cap, &_b); CRSTATE_SET_CAP(state, _b, "%u");} 64 65 #define CRSTATE_SET_COLORF(state, cap) \ 66 { \ 67 GLfloat value[4]; \ 68 value[0]=g->state.r; \ 69 value[1]=g->state.g; \ 70 value[2]=g->state.b; \ 71 value[3]=g->state.a; \ 72 diff_api.GetFloatv(cap, &value[0]); \ 73 CRSTATE_SET_CAP(state.r, value[0], "%f"); \ 74 CRSTATE_SET_CAP(state.g, value[1], "%f"); \ 75 CRSTATE_SET_CAP(state.b, value[2], "%f"); \ 76 CRSTATE_SET_CAP(state.a, value[3], "%f"); \ 77 } 78 79 #define CRSTATE_SET_TEXTURE(state, cap, target) \ 80 { \ 81 GLint _stex, _hwtex; \ 82 _stex = _hwtex = crStateGetTextureObjHWID(g->state); \ 83 diff_api.GetIntegerv(cap, &_hwtex); \ 84 if (_stex!=_hwtex) \ 85 { \ 86 CR_STATE_SETTEX_MSG(#state, _stex, _hwtex); \ 87 crStateBindTexture(target, crStateTextureHWIDtoID(_hwtex)); \ 88 } \ 89 } 90 91 #define _CRSTATE_SET_4F_RGBA(state, p1, p2, func) \ 92 { \ 93 GLfloat value[4]; \ 94 value[0]=g->state.r; \ 95 value[1]=g->state.g; \ 96 value[2]=g->state.b; \ 97 value[3]=g->state.a; \ 98 diff_api.func(p1, p2, &value[0]); \ 99 CRSTATE_SET_CAP(state.r, value[0], "%f"); \ 100 CRSTATE_SET_CAP(state.g, value[1], "%f"); \ 101 CRSTATE_SET_CAP(state.b, value[2], "%f"); \ 102 CRSTATE_SET_CAP(state.a, value[3], "%f"); \ 103 } 104 105 #define _CRSTATE_SET_4F_XYZW(state, p1, p2, func) \ 106 { \ 107 GLfloat value[4]; \ 108 value[0]=g->state.x; \ 109 value[1]=g->state.y; \ 110 value[2]=g->state.z; \ 111 value[3]=g->state.w; \ 112 diff_api.func(p1, p2, &value[0]); \ 113 CRSTATE_SET_CAP(state.x, value[0], "%f"); \ 114 CRSTATE_SET_CAP(state.y, value[1], "%f"); \ 115 CRSTATE_SET_CAP(state.z, value[2], "%f"); \ 116 CRSTATE_SET_CAP(state.w, value[3], "%f"); \ 117 } 118 119 #define CRSTATE_SET_TEXGEN_4F(state, coord, pname) _CRSTATE_SET_4F_XYZW(state, coord, pname, GetTexGenfv) 120 #define CRSTATE_SET_TEXGEN_I(state, coord, pname) {GLint _i=g->state; diff_api.GetTexGeniv(coord, pname, &_i); CRSTATE_SET_CAP(state, _i, "%i");} 121 122 #define CRSTATE_SET_TEXENV_I(state, target, pname) {GLint _i=g->state; diff_api.GetTexEnviv(target, pname, &_i); CRSTATE_SET_CAP(state, _i, "%i");} 123 #define CRSTATE_SET_TEXENV_F(state, target, pname) {GLfloat _f=g->state; diff_api.GetTexEnvfv(target, pname, &_f); CRSTATE_SET_CAP(state, _f, "%f");} 124 #define CRSTATE_SET_TEXENV_COLOR(state, target, pname) _CRSTATE_SET_4F_RGBA(state, target, pname, GetTexEnvfv) 125 126 #define CRSTATE_SET_MATERIAL_COLOR(state, face, pname) _CRSTATE_SET_4F_RGBA(state, face, pname, GetMaterialfv) 127 #define CRSTATE_SET_MATERIAL_F(state, face, pname) {GLfloat _f=g->state; diff_api.GetMaterialfv(face, pname, &_f); CRSTATE_SET_CAP(state, _f, "%f");} 128 129 #define CRSTATE_SET_LIGHT_COLOR(state, light, pname) _CRSTATE_SET_4F_RGBA(state, light, pname, GetLightfv) 130 #define CRSTATE_SET_LIGHT_F(state, light, pname) {GLfloat _f=g->state; diff_api.GetLightfv(light, pname, &_f); CRSTATE_SET_CAP(state, _f, "%f");} 131 #define CRSTATE_SET_LIGHT_4F(state, light, pname) _CRSTATE_SET_4F_XYZW(state, light, pname, GetLightfv) 132 #define CRSTATE_SET_LIGHT_3F(state, light, pname) \ 133 { \ 134 GLfloat value[3]; \ 135 value[0]=g->state.x; \ 136 value[1]=g->state.y; \ 137 value[2]=g->state.z; \ 138 diff_api.GetLightfv(light, pname, &value[0]); \ 139 CRSTATE_SET_CAP(state.x, value[0], "%f"); \ 140 CRSTATE_SET_CAP(state.y, value[1], "%f"); \ 141 CRSTATE_SET_CAP(state.z, value[2], "%f"); \ 142 } 143 144 #define CRSTATE_SET_CLIPPLANE_4D(state, plane) \ 145 { \ 146 GLdouble value[4]; \ 147 value[0]=g->state.x; \ 148 value[1]=g->state.y; \ 149 value[2]=g->state.z; \ 150 value[3]=g->state.w; \ 151 diff_api.GetClipPlane(plane, &value[0]); \ 152 CRSTATE_SET_CAP(state.x, value[0], "%G"); \ 153 CRSTATE_SET_CAP(state.y, value[1], "%G"); \ 154 CRSTATE_SET_CAP(state.z, value[2], "%G"); \ 155 CRSTATE_SET_CAP(state.w, value[3], "%G"); \ 156 } 157 158 #define CRSTATE_SET_MATRIX(state, cap) \ 159 { \ 160 GLfloat f[16], sm[16]; \ 161 crMatrixGetFloats(&f[0], g->state); \ 162 crMemcpy(&sm[0], &f[0], 16*sizeof(GLfloat)); \ 163 diff_api.GetFloatv(cap, &f[0]); \ 164 if (crMemcmp(&f[0], &sm[0], 16*sizeof(GLfloat))) \ 165 { \ 166 CR_STATE_SETMAT_MSG(#state, sm, f); \ 167 crMatrixInitFromFloats(g->state, &f[0]); \ 168 } \ 169 } 170 171 void STATE_APIENTRY crStateQueryHWState() 172 { 173 CRContext *g = GetCurrentContext(); 174 CRStateBits *sb = GetCurrentBits(); 175 CRbitvalue *bitID=g->bitid, *negbitID=g->neg_bitid; 176 177 if (CHECKDIRTY(sb->buffer.dirty, negbitID)) 178 { 179 if (CHECKDIRTY(sb->buffer.enable, negbitID)) 180 { 181 CRSTATE_SET_ENABLED(buffer.depthTest, GL_DEPTH_TEST); 182 CRSTATE_SET_ENABLED(buffer.blend, GL_BLEND); 183 CRSTATE_SET_ENABLED(buffer.alphaTest, GL_ALPHA_TEST); 184 CRSTATE_SET_ENABLED(buffer.logicOp, GL_COLOR_LOGIC_OP); 185 CRSTATE_SET_ENABLED(buffer.indexLogicOp, GL_INDEX_LOGIC_OP); 186 CRSTATE_SET_ENABLED(buffer.dither, GL_DITHER); 187 } 188 189 if (CHECKDIRTY(sb->buffer.alphaFunc, negbitID)) 190 { 191 CRSTATE_SET_ENUM(buffer.alphaTestFunc, GL_ALPHA_TEST_FUNC); 192 CRSTATE_SET_FLOAT(buffer.alphaTestRef, GL_ALPHA_TEST_REF); 193 } 194 195 if (CHECKDIRTY(sb->buffer.depthFunc, negbitID)) 196 { 197 CRSTATE_SET_ENUM(buffer.depthFunc, GL_DEPTH_FUNC); 198 } 199 200 if (CHECKDIRTY(sb->buffer.blendFunc, negbitID)) 201 { 202 CRSTATE_SET_ENUM(buffer.blendSrcRGB, GL_BLEND_SRC); 203 CRSTATE_SET_ENUM(buffer.blendDstRGB, GL_BLEND_DST); 204 } 205 206 if (CHECKDIRTY(sb->buffer.logicOp, negbitID)) 207 { 208 CRSTATE_SET_ENUM(buffer.logicOpMode, GL_LOGIC_OP_MODE); 209 } 210 211 /* seems to always match previous .logicOp 212 if (CHECKDIRTY(sb->buffer.indexLogicOp, negbitID)) 213 { 214 CRSTATE_SET_ENUM(buffer.logicOpMode, GL_LOGIC_OP_MODE); 215 } 216 */ 217 218 if (CHECKDIRTY(sb->buffer.drawBuffer, negbitID)) 219 { 220 CRSTATE_SET_ENUM(buffer.drawBuffer, GL_DRAW_BUFFER); 221 } 222 223 if (CHECKDIRTY(sb->buffer.readBuffer, negbitID)) 224 { 225 CRSTATE_SET_ENUM(buffer.readBuffer, GL_READ_BUFFER); 226 } 227 228 if (CHECKDIRTY(sb->buffer.indexMask, negbitID)) 229 { 230 CRSTATE_SET_INT(buffer.indexWriteMask, GL_INDEX_WRITEMASK); 231 } 232 233 if (CHECKDIRTY(sb->buffer.colorWriteMask, negbitID)) 234 { 235 GLboolean value[4]; 236 value[0]=g->buffer.colorWriteMask.r; 237 value[1]=g->buffer.colorWriteMask.g; 238 value[2]=g->buffer.colorWriteMask.b; 239 value[3]=g->buffer.colorWriteMask.a; 240 diff_api.GetBooleanv(GL_COLOR_WRITEMASK, &value[0]); 241 242 CRSTATE_SET_CAP(buffer.colorWriteMask.r, value[0], "%u"); 243 CRSTATE_SET_CAP(buffer.colorWriteMask.g, value[1], "%u"); 244 CRSTATE_SET_CAP(buffer.colorWriteMask.b, value[2], "%u"); 245 CRSTATE_SET_CAP(buffer.colorWriteMask.a, value[3], "%u"); 246 } 247 248 if (CHECKDIRTY(sb->buffer.clearColor, negbitID)) 249 { 250 CRSTATE_SET_COLORF(buffer.colorClearValue, GL_COLOR_CLEAR_VALUE); 251 } 252 253 if (CHECKDIRTY(sb->buffer.clearIndex, negbitID)) 254 { 255 CRSTATE_SET_FLOAT(buffer.indexClearValue, GL_INDEX_CLEAR_VALUE); 256 } 257 258 if (CHECKDIRTY(sb->buffer.clearDepth, negbitID)) 259 { 260 CRSTATE_SET_FLOAT(buffer.depthClearValue, GL_DEPTH_CLEAR_VALUE); 261 } 262 263 if (CHECKDIRTY(sb->buffer.clearAccum, negbitID)) 264 { 265 CRSTATE_SET_COLORF(buffer.accumClearValue, GL_ACCUM_CLEAR_VALUE); 266 } 267 268 if (CHECKDIRTY(sb->buffer.depthMask, negbitID)) 269 { 270 CRSTATE_SET_BOOL(buffer.depthMask, GL_DEPTH_WRITEMASK); 271 } 272 273 #ifdef CR_EXT_blend_color 274 if (CHECKDIRTY(sb->buffer.blendColor, negbitID)) 275 { 276 CRSTATE_SET_COLORF(buffer.blendColor, GL_BLEND_COLOR); 277 } 278 #endif 279 #if defined(CR_EXT_blend_minmax) || defined(CR_EXT_blend_subtract) || defined(CR_EXT_blend_logic_op) 280 if (CHECKDIRTY(sb->buffer.blendEquation, negbitID)) 281 { 282 CRSTATE_SET_ENUM(buffer.blendEquation, GL_BLEND_EQUATION_EXT); 283 } 284 #endif 285 #if defined(CR_EXT_blend_func_separate) 286 if (CHECKDIRTY(sb->buffer.blendFuncSeparate, negbitID)) 287 { 288 CRSTATE_SET_ENUM(buffer.blendSrcRGB, GL_BLEND_SRC_RGB_EXT); 289 CRSTATE_SET_ENUM(buffer.blendDstRGB, GL_BLEND_DST_RGB_EXT); 290 CRSTATE_SET_ENUM(buffer.blendSrcA, GL_BLEND_SRC_ALPHA_EXT); 291 CRSTATE_SET_ENUM(buffer.blendDstA, GL_BLEND_DST_ALPHA_EXT); 292 } 293 #endif 294 } 295 296 if (CHECKDIRTY(sb->stencil.dirty, negbitID)) 297 { 298 if (CHECKDIRTY(sb->stencil.enable, negbitID)) 299 { 300 CRSTATE_SET_ENABLED(stencil.stencilTest, GL_STENCIL_TEST); 301 } 302 303 if (CHECKDIRTY(sb->stencil.func, negbitID)) 304 { 305 CRSTATE_SET_ENUM(stencil.func, GL_STENCIL_FUNC); 306 CRSTATE_SET_INT(stencil.ref, GL_STENCIL_REF); 307 CRSTATE_SET_INT(stencil.mask, GL_STENCIL_VALUE_MASK); 308 } 309 310 if (CHECKDIRTY(sb->stencil.op, negbitID)) 311 { 312 CRSTATE_SET_ENUM(stencil.fail, GL_STENCIL_FAIL); 313 CRSTATE_SET_ENUM(stencil.passDepthFail, GL_STENCIL_PASS_DEPTH_FAIL); 314 CRSTATE_SET_ENUM(stencil.passDepthPass, GL_STENCIL_PASS_DEPTH_PASS); 315 } 316 317 if (CHECKDIRTY(sb->stencil.clearValue, negbitID)) 318 { 319 CRSTATE_SET_INT(stencil.clearValue, GL_STENCIL_CLEAR_VALUE); 320 } 321 322 if (CHECKDIRTY(sb->stencil.writeMask, negbitID)) 323 { 324 CRSTATE_SET_INT(stencil.writeMask, GL_STENCIL_WRITEMASK); 325 } 326 } 327 328 if (CHECKDIRTY(sb->texture.dirty, negbitID)) 329 { 330 unsigned int i, activeUnit = g->texture.curTextureUnit; 331 332 for (i=0; i<g->limits.maxTextureUnits; ++i) 333 { 334 if (CHECKDIRTY(sb->texture.enable[i], negbitID)) 335 { 336 if (i!=activeUnit) 337 { 338 diff_api.ActiveTextureARB(i + GL_TEXTURE0_ARB); 339 activeUnit=i; 340 } 341 CRSTATE_SET_ENABLED(texture.unit[i].enabled1D, GL_TEXTURE_1D); 342 CRSTATE_SET_ENABLED(texture.unit[i].enabled2D, GL_TEXTURE_2D); 343 #ifdef CR_OPENGL_VERSION_1_2 344 CRSTATE_SET_ENABLED(texture.unit[i].enabled3D, GL_TEXTURE_3D); 345 #endif 346 #ifdef CR_ARB_texture_cube_map 347 if (g->extensions.ARB_texture_cube_map) 348 { 349 CRSTATE_SET_ENABLED(texture.unit[i].enabledCubeMap, GL_TEXTURE_CUBE_MAP_ARB); 350 } 351 #endif 352 #ifdef CR_NV_texture_rectangle 353 if (g->extensions.NV_texture_rectangle) 354 { 355 CRSTATE_SET_ENABLED(texture.unit[i].enabledRect, GL_TEXTURE_RECTANGLE_NV); 356 } 357 #endif 358 359 CRSTATE_SET_ENABLED(texture.unit[i].textureGen.s, GL_TEXTURE_GEN_S); 360 CRSTATE_SET_ENABLED(texture.unit[i].textureGen.t, GL_TEXTURE_GEN_T); 361 CRSTATE_SET_ENABLED(texture.unit[i].textureGen.r, GL_TEXTURE_GEN_R); 362 CRSTATE_SET_ENABLED(texture.unit[i].textureGen.q, GL_TEXTURE_GEN_Q); 363 } 364 365 if (CHECKDIRTY(sb->texture.current[i], negbitID)) 366 { 367 if (i!=activeUnit) 368 { 369 diff_api.ActiveTextureARB(i + GL_TEXTURE0_ARB); 370 activeUnit=i; 371 } 372 373 CRSTATE_SET_TEXTURE(texture.unit[i].currentTexture1D, GL_TEXTURE_BINDING_1D, GL_TEXTURE_1D); 374 CRSTATE_SET_TEXTURE(texture.unit[i].currentTexture2D, GL_TEXTURE_BINDING_2D, GL_TEXTURE_2D); 375 #ifdef CR_OPENGL_VERSION_1_2 376 CRSTATE_SET_TEXTURE(texture.unit[i].currentTexture3D, GL_TEXTURE_BINDING_3D, GL_TEXTURE_3D); 377 #endif 378 #ifdef CR_ARB_texture_cube_map 379 if (g->extensions.ARB_texture_cube_map) 380 { 381 CRSTATE_SET_TEXTURE(texture.unit[i].currentTextureCubeMap, GL_TEXTURE_BINDING_CUBE_MAP_ARB, GL_TEXTURE_CUBE_MAP_ARB); 382 } 383 #endif 384 #ifdef CR_NV_texture_rectangle 385 if (g->extensions.NV_texture_rectangle) 386 { 387 CRSTATE_SET_TEXTURE(texture.unit[i].currentTextureRect, GL_TEXTURE_BINDING_RECTANGLE_NV, GL_TEXTURE_RECTANGLE_NV); 388 } 389 #endif 390 } 391 392 if (CHECKDIRTY(sb->texture.objGen[i], negbitID)) 393 { 394 if (i!=activeUnit) 395 { 396 diff_api.ActiveTextureARB(i + GL_TEXTURE0_ARB); 397 activeUnit=i; 398 } 399 400 CRSTATE_SET_TEXGEN_4F(texture.unit[i].objSCoeff, GL_S, GL_OBJECT_PLANE); 401 CRSTATE_SET_TEXGEN_4F(texture.unit[i].objTCoeff, GL_T, GL_OBJECT_PLANE); 402 CRSTATE_SET_TEXGEN_4F(texture.unit[i].objRCoeff, GL_R, GL_OBJECT_PLANE); 403 CRSTATE_SET_TEXGEN_4F(texture.unit[i].objQCoeff, GL_Q, GL_OBJECT_PLANE); 404 } 405 406 if (CHECKDIRTY(sb->texture.eyeGen[i], negbitID)) 407 { 408 if (i!=activeUnit) 409 { 410 diff_api.ActiveTextureARB(i + GL_TEXTURE0_ARB); 411 activeUnit=i; 412 } 413 414 CRSTATE_SET_TEXGEN_4F(texture.unit[i].eyeSCoeff, GL_S, GL_EYE_PLANE); 415 CRSTATE_SET_TEXGEN_4F(texture.unit[i].eyeTCoeff, GL_T, GL_EYE_PLANE); 416 CRSTATE_SET_TEXGEN_4F(texture.unit[i].eyeRCoeff, GL_R, GL_EYE_PLANE); 417 CRSTATE_SET_TEXGEN_4F(texture.unit[i].eyeQCoeff, GL_Q, GL_EYE_PLANE); 418 } 419 420 if (CHECKDIRTY(sb->texture.genMode[i], negbitID)) 421 { 422 if (i!=activeUnit) 423 { 424 diff_api.ActiveTextureARB(i + GL_TEXTURE0_ARB); 425 activeUnit=i; 426 } 427 428 CRSTATE_SET_TEXGEN_I(texture.unit[i].gen.s, GL_S, GL_TEXTURE_GEN_MODE); 429 CRSTATE_SET_TEXGEN_I(texture.unit[i].gen.t, GL_T, GL_TEXTURE_GEN_MODE); 430 CRSTATE_SET_TEXGEN_I(texture.unit[i].gen.r, GL_R, GL_TEXTURE_GEN_MODE); 431 CRSTATE_SET_TEXGEN_I(texture.unit[i].gen.q, GL_Q, GL_TEXTURE_GEN_MODE); 432 } 433 434 if (CHECKDIRTY(sb->texture.envBit[i], negbitID)) 435 { 436 if (i!=activeUnit) 437 { 438 diff_api.ActiveTextureARB(i + GL_TEXTURE0_ARB); 439 activeUnit=i; 440 } 441 442 CRSTATE_SET_TEXENV_I(texture.unit[i].envMode, GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE); 443 CRSTATE_SET_TEXENV_COLOR(texture.unit[i].envColor, GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR); 444 CRSTATE_SET_TEXENV_I(texture.unit[i].combineModeRGB, GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB); 445 CRSTATE_SET_TEXENV_I(texture.unit[i].combineModeA, GL_TEXTURE_ENV, GL_COMBINE_ALPHA_ARB); 446 CRSTATE_SET_TEXENV_I(texture.unit[i].combineSourceRGB[0], GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB); 447 CRSTATE_SET_TEXENV_I(texture.unit[i].combineSourceRGB[1], GL_TEXTURE_ENV, GL_SOURCE1_RGB_ARB); 448 CRSTATE_SET_TEXENV_I(texture.unit[i].combineSourceRGB[2], GL_TEXTURE_ENV, GL_SOURCE2_RGB_ARB); 449 CRSTATE_SET_TEXENV_I(texture.unit[i].combineSourceA[0], GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_ARB); 450 CRSTATE_SET_TEXENV_I(texture.unit[i].combineSourceA[1], GL_TEXTURE_ENV, GL_SOURCE1_ALPHA_ARB); 451 CRSTATE_SET_TEXENV_I(texture.unit[i].combineSourceA[2], GL_TEXTURE_ENV, GL_SOURCE2_ALPHA_ARB); 452 CRSTATE_SET_TEXENV_I(texture.unit[i].combineOperandRGB[0], GL_TEXTURE_ENV, GL_OPERAND0_RGB_ARB); 453 CRSTATE_SET_TEXENV_I(texture.unit[i].combineOperandRGB[1], GL_TEXTURE_ENV, GL_OPERAND1_RGB_ARB); 454 CRSTATE_SET_TEXENV_I(texture.unit[i].combineOperandRGB[2], GL_TEXTURE_ENV, GL_OPERAND2_RGB_ARB); 455 CRSTATE_SET_TEXENV_I(texture.unit[i].combineOperandA[0], GL_TEXTURE_ENV, GL_OPERAND0_ALPHA_ARB); 456 CRSTATE_SET_TEXENV_I(texture.unit[i].combineOperandA[1], GL_TEXTURE_ENV, GL_OPERAND1_ALPHA_ARB); 457 CRSTATE_SET_TEXENV_I(texture.unit[i].combineOperandA[2], GL_TEXTURE_ENV, GL_OPERAND2_ALPHA_ARB); 458 CRSTATE_SET_TEXENV_F(texture.unit[i].combineScaleRGB, GL_TEXTURE_ENV, GL_RGB_SCALE_ARB); 459 CRSTATE_SET_TEXENV_F(texture.unit[i].combineScaleA, GL_TEXTURE_ENV, GL_ALPHA_SCALE); 460 } 461 } 462 if (activeUnit!=g->texture.curTextureUnit) 463 { 464 diff_api.ActiveTextureARB(g->texture.curTextureUnit + GL_TEXTURE0_ARB); 465 } 466 } 467 468 if (CHECKDIRTY(sb->lighting.dirty, negbitID)) 469 { 470 int i; 471 472 if (CHECKDIRTY(sb->lighting.enable, negbitID)) 473 { 474 CRSTATE_SET_ENABLED(lighting.lighting, GL_LIGHTING); 475 CRSTATE_SET_ENABLED(lighting.colorMaterial, GL_COLOR_MATERIAL); 476 CRSTATE_SET_ENABLED(lighting.colorSumEXT, GL_COLOR_SUM_EXT); 477 } 478 479 if (CHECKDIRTY(sb->lighting.shadeModel, negbitID)) 480 { 481 CRSTATE_SET_ENUM(lighting.shadeModel, GL_SHADE_MODEL); 482 } 483 484 if (CHECKDIRTY(sb->lighting.colorMaterial, negbitID)) 485 { 486 CRSTATE_SET_ENUM(lighting.colorMaterialFace, GL_COLOR_MATERIAL_FACE); 487 CRSTATE_SET_ENUM(lighting.colorMaterialMode, GL_COLOR_MATERIAL_PARAMETER); 488 } 489 490 if (CHECKDIRTY(sb->lighting.lightModel, negbitID)) 491 { 492 CRSTATE_SET_COLORF(lighting.lightModelAmbient, GL_LIGHT_MODEL_AMBIENT); 493 CRSTATE_SET_BOOL(lighting.lightModelLocalViewer, GL_LIGHT_MODEL_LOCAL_VIEWER); 494 CRSTATE_SET_BOOL(lighting.lightModelTwoSide, GL_LIGHT_MODEL_TWO_SIDE); 495 CRSTATE_SET_ENUM(lighting.lightModelColorControlEXT, GL_LIGHT_MODEL_COLOR_CONTROL); 496 } 497 498 if (CHECKDIRTY(sb->lighting.material, negbitID)) 499 { 500 CRSTATE_SET_MATERIAL_COLOR(lighting.ambient[0], GL_FRONT, GL_AMBIENT); 501 CRSTATE_SET_MATERIAL_COLOR(lighting.ambient[1], GL_BACK, GL_AMBIENT); 502 CRSTATE_SET_MATERIAL_COLOR(lighting.diffuse[0], GL_FRONT, GL_AMBIENT); 503 CRSTATE_SET_MATERIAL_COLOR(lighting.diffuse[1], GL_BACK, GL_AMBIENT); 504 CRSTATE_SET_MATERIAL_COLOR(lighting.specular[0], GL_FRONT, GL_AMBIENT); 505 CRSTATE_SET_MATERIAL_COLOR(lighting.specular[1], GL_BACK, GL_AMBIENT); 506 CRSTATE_SET_MATERIAL_COLOR(lighting.emission[0], GL_FRONT, GL_AMBIENT); 507 CRSTATE_SET_MATERIAL_COLOR(lighting.emission[1], GL_BACK, GL_AMBIENT); 508 CRSTATE_SET_MATERIAL_F(lighting.shininess[0], GL_FRONT, GL_SHININESS); 509 CRSTATE_SET_MATERIAL_F(lighting.shininess[1], GL_BACK, GL_SHININESS); 510 } 511 512 for (i=0; i<CR_MAX_LIGHTS; ++i) 513 { 514 if (CHECKDIRTY(sb->lighting.light[i].dirty, negbitID)) 515 { 516 if (CHECKDIRTY(sb->lighting.light[i].enable, negbitID)) 517 { 518 CRSTATE_SET_ENABLED(lighting.light[i].enable, GL_LIGHT0+i); 519 } 520 521 if (CHECKDIRTY(sb->lighting.light[i].ambient, negbitID)) 522 { 523 CRSTATE_SET_LIGHT_COLOR(lighting.light[i].ambient, GL_LIGHT0+i, GL_AMBIENT); 524 } 525 526 if (CHECKDIRTY(sb->lighting.light[i].diffuse, negbitID)) 527 { 528 CRSTATE_SET_LIGHT_COLOR(lighting.light[i].diffuse, GL_LIGHT0+i, GL_DIFFUSE); 529 } 530 531 if (CHECKDIRTY(sb->lighting.light[i].specular, negbitID)) 532 { 533 CRSTATE_SET_LIGHT_COLOR(lighting.light[i].specular, GL_LIGHT0+i, GL_SPECULAR); 534 } 535 536 if (CHECKDIRTY(sb->lighting.light[i].position, negbitID)) 537 { 538 CRSTATE_SET_LIGHT_4F(lighting.light[i].position, GL_LIGHT0+i, GL_POSITION); 539 } 540 541 if (CHECKDIRTY(sb->lighting.light[i].attenuation, negbitID)) 542 { 543 CRSTATE_SET_LIGHT_F(lighting.light[i].constantAttenuation, GL_LIGHT0+i, GL_CONSTANT_ATTENUATION); 544 CRSTATE_SET_LIGHT_F(lighting.light[i].linearAttenuation, GL_LIGHT0+i, GL_LINEAR_ATTENUATION); 545 CRSTATE_SET_LIGHT_F(lighting.light[i].quadraticAttenuation, GL_LIGHT0+i, GL_QUADRATIC_ATTENUATION); 546 } 547 548 if (CHECKDIRTY(sb->lighting.light[i].spot, negbitID)) 549 { 550 CRSTATE_SET_LIGHT_3F(lighting.light[i].spotDirection, GL_LIGHT0+i, GL_SPOT_DIRECTION); 551 CRSTATE_SET_LIGHT_F(lighting.light[i].spotExponent, GL_LIGHT0+i, GL_SPOT_EXPONENT); 552 CRSTATE_SET_LIGHT_F(lighting.light[i].spotCutoff, GL_LIGHT0+i, GL_SPOT_CUTOFF); 553 } 554 } 555 } 556 } 557 558 559 if (CHECKDIRTY(sb->transform.dirty, negbitID)) 560 { 561 if (CHECKDIRTY(sb->transform.enable, negbitID)) 562 { 563 CRSTATE_SET_ENABLED(transform.normalize, GL_NORMALIZE); 564 #ifdef CR_OPENGL_VERSION_1_2 565 CRSTATE_SET_ENABLED(transform.rescaleNormals, GL_RESCALE_NORMAL); 566 #endif 567 #ifdef CR_IBM_rasterpos_clip 568 CRSTATE_SET_ENABLED(transform.rasterPositionUnclipped, GL_RASTER_POSITION_UNCLIPPED_IBM); 569 #endif 570 } 571 572 if (CHECKDIRTY(sb->transform.clipPlane, negbitID)) 573 { 574 int i; 575 for (i=0; i<CR_MAX_CLIP_PLANES; i++) 576 { 577 CRSTATE_SET_CLIPPLANE_4D(transform.clipPlane[i], GL_CLIP_PLANE0+i); 578 } 579 } 580 581 if (CHECKDIRTY(sb->transform.modelviewMatrix, negbitID)) 582 { 583 CRSTATE_SET_MATRIX(transform.modelViewStack.top, GL_MODELVIEW_MATRIX); 584 } 585 586 if (CHECKDIRTY(sb->transform.projectionMatrix, negbitID)) 587 { 588 CRSTATE_SET_MATRIX(transform.projectionStack.top, GL_PROJECTION_MATRIX); 589 } 590 591 if (CHECKDIRTY(sb->transform.textureMatrix, negbitID)) 592 { 593 unsigned int i; 594 for (i=0; i<g->limits.maxTextureUnits; i++) 595 { 596 diff_api.ActiveTextureARB(GL_TEXTURE0_ARB+i); 597 CRSTATE_SET_MATRIX(transform.textureStack[i].top, GL_TEXTURE_MATRIX); 598 } 599 diff_api.ActiveTextureARB(g->texture.curTextureUnit + GL_TEXTURE0_ARB); 600 } 601 602 if (CHECKDIRTY(sb->transform.colorMatrix, negbitID)) 603 { 604 CRSTATE_SET_MATRIX(transform.colorStack.top, GL_COLOR_MATRIX); 605 } 606 607 if (CHECKDIRTY(sb->transform.matrixMode, negbitID)) 608 { 609 CRSTATE_SET_ENUM(transform.matrixMode, GL_MATRIX_MODE); 610 } 611 } 612 613 if (CHECKDIRTY(sb->viewport.dirty, negbitID)) 614 { 615 if (CHECKDIRTY(sb->viewport.enable, negbitID)) 616 { 617 CRSTATE_SET_ENABLED(viewport.scissorTest, GL_SCISSOR_TEST); 618 } 619 620 if (CHECKDIRTY(sb->viewport.s_dims, negbitID)) 621 { 622 GLint value[4]; 623 value[0] = g->viewport.scissorX; 624 value[1] = g->viewport.scissorY; 625 value[2] = g->viewport.scissorW; 626 value[3] = g->viewport.scissorH; 627 diff_api.GetIntegerv(GL_SCISSOR_BOX, &value[0]); 628 CRSTATE_SET_CAP(viewport.scissorX, value[0], "%i"); 629 CRSTATE_SET_CAP(viewport.scissorY, value[1], "%i"); 630 CRSTATE_SET_CAP(viewport.scissorW, value[2], "%i"); 631 CRSTATE_SET_CAP(viewport.scissorH, value[3], "%i"); 632 } 633 634 if (CHECKDIRTY(sb->viewport.v_dims, negbitID)) 635 { 636 GLint value[4]; 637 value[0] = g->viewport.viewportX; 638 value[1] = g->viewport.viewportY; 639 value[2] = g->viewport.viewportW; 640 value[3] = g->viewport.viewportH; 641 diff_api.GetIntegerv(GL_VIEWPORT, &value[0]); 642 CRSTATE_SET_CAP(viewport.viewportX, value[0], "%i"); 643 CRSTATE_SET_CAP(viewport.viewportY, value[1], "%i"); 644 CRSTATE_SET_CAP(viewport.viewportW, value[2], "%i"); 645 CRSTATE_SET_CAP(viewport.viewportH, value[3], "%i"); 646 } 647 648 if (CHECKDIRTY(sb->viewport.depth, negbitID)) 649 { 650 GLfloat value[2]; 651 value[0] = g->viewport.nearClip; 652 value[1] = g->viewport.farClip; 653 diff_api.GetFloatv(GL_DEPTH_RANGE, &value[0]); 654 CRSTATE_SET_CAP(viewport.nearClip, value[0], "%f"); 655 CRSTATE_SET_CAP(viewport.farClip, value[1], "%f"); 656 } 657 } 658 659 if (CHECKDIRTY(sb->eval.dirty, negbitID)) 660 { 661 int i; 662 const int gleval_sizes[] = {4, 1, 3, 1, 2, 3, 4, 3, 4}; 663 664 if (CHECKDIRTY(sb->eval.enable, negbitID)) 665 { 666 CRSTATE_SET_ENABLED(eval.autoNormal, GL_AUTO_NORMAL); 667 } 668 669 for (i=0; i<GLEVAL_TOT; i++) 670 { 671 if (CHECKDIRTY(sb->eval.enable1D[i], negbitID)) 672 { 673 CRSTATE_SET_ENABLED(eval.enable1D[i], i + GL_MAP1_COLOR_4); 674 } 675 676 if (CHECKDIRTY(sb->eval.enable2D[i], negbitID)) 677 { 678 CRSTATE_SET_ENABLED(eval.enable2D[i], i + GL_MAP2_COLOR_4); 679 } 680 681 if (CHECKDIRTY(sb->eval.eval1D[i], negbitID) && g->eval.enable1D[i]) 682 { 683 GLfloat *coeffs=NULL; 684 GLint order; 685 GLfloat uval[2]; 686 order = g->eval.eval1D[i].order; 687 uval[0] = g->eval.eval1D[i].u1; 688 uval[1] = g->eval.eval1D[i].u2; 689 diff_api.GetMapiv(i + GL_MAP1_COLOR_4, GL_ORDER, &order); 690 diff_api.GetMapfv(i + GL_MAP1_COLOR_4, GL_DOMAIN, &uval[0]); 691 if (order>0) 692 { 693 coeffs = crAlloc(order * gleval_sizes[i] * sizeof(GLfloat)); 694 if (!coeffs) 695 { 696 crWarning("crStateQueryHWState: out of memory, at eval1D[%i]", i); 697 continue; 698 } 699 diff_api.GetMapfv(i + GL_MAP1_COLOR_4, GL_COEFF, coeffs); 700 } 701 702 CRSTATE_SET_CAP(eval.eval1D[i].order, order, "%i"); 703 CRSTATE_SET_CAP(eval.eval1D[i].u1, uval[0], "%f"); 704 CRSTATE_SET_CAP(eval.eval1D[i].u2, uval[1], "%f"); 705 if (g->eval.eval1D[i].coeff) 706 { 707 crFree(g->eval.eval1D[i].coeff); 708 } 709 g->eval.eval1D[i].coeff = coeffs; 710 711 if (uval[0]!=uval[1]) 712 { 713 g->eval.eval1D[i].du = 1.0f / (uval[0] - uval[1]); 714 } 715 } 716 717 if (CHECKDIRTY(sb->eval.eval2D[i], negbitID) && g->eval.enable2D[i]) 718 { 719 GLfloat *coeffs=NULL; 720 GLint order[2]; 721 GLfloat uval[4]; 722 order[0] = g->eval.eval2D[i].uorder; 723 order[1] = g->eval.eval2D[i].vorder; 724 uval[0] = g->eval.eval2D[i].u1; 725 uval[1] = g->eval.eval2D[i].u2; 726 uval[2] = g->eval.eval2D[i].v1; 727 uval[3] = g->eval.eval2D[i].v2; 728 diff_api.GetMapiv(i + GL_MAP2_COLOR_4, GL_ORDER, &order[0]); 729 diff_api.GetMapfv(i + GL_MAP2_COLOR_4, GL_DOMAIN, &uval[0]); 730 if (order[0]>0 && order[1]>0) 731 { 732 coeffs = crAlloc(order[0] * order[1] * gleval_sizes[i] * sizeof(GLfloat)); 733 if (!coeffs) 734 { 735 crWarning("crStateQueryHWState: out of memory, at eval2D[%i]", i); 736 continue; 737 } 738 diff_api.GetMapfv(i + GL_MAP1_COLOR_4, GL_COEFF, coeffs); 739 } 740 CRSTATE_SET_CAP(eval.eval2D[i].uorder, order[0], "%i"); 741 CRSTATE_SET_CAP(eval.eval2D[i].vorder, order[1], "%i"); 742 CRSTATE_SET_CAP(eval.eval2D[i].u1, uval[0], "%f"); 743 CRSTATE_SET_CAP(eval.eval2D[i].u2, uval[1], "%f"); 744 CRSTATE_SET_CAP(eval.eval2D[i].v1, uval[2], "%f"); 745 CRSTATE_SET_CAP(eval.eval2D[i].v2, uval[3], "%f"); 746 if (g->eval.eval2D[i].coeff) 747 { 748 crFree(g->eval.eval2D[i].coeff); 749 } 750 g->eval.eval2D[i].coeff = coeffs; 751 752 if (uval[0]!=uval[1]) 753 { 754 g->eval.eval2D[i].du = 1.0f / (uval[0] - uval[1]); 755 } 756 if (uval[2]!=uval[3]) 757 { 758 g->eval.eval2D[i].dv = 1.0f / (uval[2] - uval[3]); 759 } 760 } 761 } 762 763 if (CHECKDIRTY(sb->eval.grid1D, negbitID)) 764 { 765 GLfloat value[2]; 766 CRSTATE_SET_INT(eval.un1D, GL_MAP1_GRID_SEGMENTS); 767 value[0] = g->eval.u11D; 768 value[1] = g->eval.u21D; 769 diff_api.GetFloatv(GL_MAP1_GRID_DOMAIN, &value[0]); 770 CRSTATE_SET_CAP(eval.u11D, value[0], "%f"); 771 CRSTATE_SET_CAP(eval.u21D, value[1], "%f"); 772 } 773 774 if (CHECKDIRTY(sb->eval.grid2D, negbitID)) 775 { 776 GLint iv[2]; 777 GLfloat value[4]; 778 iv[0] = g->eval.un2D; 779 iv[1] = g->eval.vn2D; 780 diff_api.GetIntegerv(GL_MAP1_GRID_SEGMENTS, &iv[0]); 781 CRSTATE_SET_CAP(eval.un2D, iv[0], "%i"); 782 CRSTATE_SET_CAP(eval.vn2D, iv[1], "%i"); 783 value[0] = g->eval.u12D; 784 value[1] = g->eval.u22D; 785 value[2] = g->eval.v12D; 786 value[3] = g->eval.v22D; 787 diff_api.GetFloatv(GL_MAP2_GRID_DOMAIN, &value[0]); 788 CRSTATE_SET_CAP(eval.u12D, value[0], "%f"); 789 CRSTATE_SET_CAP(eval.u22D, value[1], "%f"); 790 CRSTATE_SET_CAP(eval.v12D, value[2], "%f"); 791 CRSTATE_SET_CAP(eval.v22D, value[3], "%f"); 792 } 793 } 794 795 if (CHECKDIRTY(sb->fog.dirty, negbitID)) 796 { 797 if (CHECKDIRTY(sb->fog.enable, negbitID)) 798 { 799 CRSTATE_SET_ENABLED(fog.enable, GL_FOG); 800 } 801 802 if (CHECKDIRTY(sb->fog.color, negbitID)) 803 { 804 CRSTATE_SET_COLORF(fog.color, GL_FOG_COLOR); 805 } 806 807 if (CHECKDIRTY(sb->fog.index, negbitID)) 808 { 809 CRSTATE_SET_INT(fog.index, GL_FOG_INDEX); 810 } 811 812 if (CHECKDIRTY(sb->fog.density, negbitID)) 813 { 814 CRSTATE_SET_FLOAT(fog.density, GL_FOG_DENSITY); 815 } 816 817 if (CHECKDIRTY(sb->fog.start, negbitID)) 818 { 819 CRSTATE_SET_FLOAT(fog.start, GL_FOG_START); 820 } 821 822 if (CHECKDIRTY(sb->fog.end, negbitID)) 823 { 824 CRSTATE_SET_FLOAT(fog.end, GL_FOG_END); 825 } 826 827 if (CHECKDIRTY(sb->fog.mode, negbitID)) 828 { 829 CRSTATE_SET_INT(fog.mode, GL_FOG_MODE); 830 } 831 832 #ifdef CR_NV_fog_distance 833 if (CHECKDIRTY(sb->fog.fogDistanceMode, negbitID)) 834 { 835 CRSTATE_SET_ENUM(fog.fogDistanceMode, GL_FOG_DISTANCE_MODE_NV); 836 } 837 #endif 838 #ifdef CR_EXT_fog_coord 839 if (CHECKDIRTY(sb->fog.fogCoordinateSource, negbitID)) 840 { 841 CRSTATE_SET_ENUM(fog.fogCoordinateSource, GL_FOG_COORDINATE_SOURCE_EXT); 842 } 843 #endif 844 } 845 846 if (CHECKDIRTY(sb->hint.dirty, negbitID)) 847 { 848 if (CHECKDIRTY(sb->hint.perspectiveCorrection, negbitID)) 849 { 850 CRSTATE_SET_ENUM(hint.perspectiveCorrection, GL_PERSPECTIVE_CORRECTION_HINT); 851 } 852 853 if (CHECKDIRTY(sb->hint.pointSmooth, negbitID)) 854 { 855 CRSTATE_SET_ENUM(hint.pointSmooth, GL_POINT_SMOOTH_HINT); 856 } 857 858 if (CHECKDIRTY(sb->hint.lineSmooth, negbitID)) 859 { 860 CRSTATE_SET_ENUM(hint.lineSmooth, GL_LINE_SMOOTH_HINT); 861 } 862 863 if (CHECKDIRTY(sb->hint.polygonSmooth, negbitID)) 864 { 865 CRSTATE_SET_ENUM(hint.polygonSmooth, GL_POINT_SMOOTH_HINT); 866 } 867 868 if (CHECKDIRTY(sb->hint.fog, negbitID)) 869 { 870 CRSTATE_SET_ENUM(hint.fog, GL_FOG_HINT); 871 } 872 873 #ifdef CR_EXT_clip_volume_hint 874 if (CHECKDIRTY(sb->hint.clipVolumeClipping, negbitID)) 875 { 876 CRSTATE_SET_ENUM(hint.clipVolumeClipping, GL_CLIP_VOLUME_CLIPPING_HINT_EXT); 877 } 878 #endif 879 #ifdef CR_ARB_texture_compression 880 if (CHECKDIRTY(sb->hint.textureCompression, negbitID)) 881 { 882 CRSTATE_SET_ENUM(hint.textureCompression, GL_TEXTURE_COMPRESSION_HINT_ARB); 883 } 884 #endif 885 #ifdef CR_SGIS_generate_mipmap 886 if (CHECKDIRTY(sb->hint.generateMipmap, negbitID)) 887 { 888 CRSTATE_SET_ENUM(hint.generateMipmap, GL_GENERATE_MIPMAP_HINT_SGIS); 889 } 890 #endif 891 } 892 893 if (CHECKDIRTY(sb->line.dirty, negbitID)) 894 { 895 if (CHECKDIRTY(sb->line.enable, negbitID)) 896 { 897 CRSTATE_SET_ENABLED(line.lineSmooth, GL_LINE_SMOOTH); 898 CRSTATE_SET_ENABLED(line.lineStipple, GL_LINE_STIPPLE); 899 } 900 901 if (CHECKDIRTY(sb->line.width, negbitID)) 902 { 903 CRSTATE_SET_FLOAT(line.width, GL_LINE_WIDTH); 904 } 905 906 if (CHECKDIRTY(sb->line.stipple, negbitID)) 907 { 908 CRSTATE_SET_INT(line.repeat, GL_LINE_STIPPLE_REPEAT); 909 CRSTATE_SET_INT(line.pattern, GL_LINE_STIPPLE_PATTERN); 910 } 911 } 912 913 if (CHECKDIRTY(sb->multisample.dirty, negbitID)) 914 { 915 if (CHECKDIRTY(sb->multisample.enable, negbitID)) 916 { 917 CRSTATE_SET_ENABLED(multisample.enabled, GL_MULTISAMPLE_ARB); 918 CRSTATE_SET_ENABLED(multisample.sampleAlphaToCoverage, GL_SAMPLE_ALPHA_TO_COVERAGE_ARB); 919 CRSTATE_SET_ENABLED(multisample.sampleAlphaToOne, GL_SAMPLE_ALPHA_TO_ONE_ARB); 920 CRSTATE_SET_ENABLED(multisample.sampleCoverage, GL_SAMPLE_COVERAGE_ARB); 921 } 922 923 if (CHECKDIRTY(sb->multisample.sampleCoverageValue, negbitID)) 924 { 925 CRSTATE_SET_FLOAT(multisample.sampleCoverageValue, GL_SAMPLE_COVERAGE_VALUE_ARB) 926 CRSTATE_SET_BOOL(multisample.sampleCoverageInvert, GL_SAMPLE_COVERAGE_INVERT_ARB) 927 } 928 } 929 930 if (CHECKDIRTY(sb->point.dirty, negbitID)) 931 { 932 if (CHECKDIRTY(sb->point.enableSmooth, negbitID)) 933 { 934 CRSTATE_SET_ENABLED(point.pointSmooth, GL_POINT_SMOOTH); 935 } 936 937 if (CHECKDIRTY(sb->point.size, negbitID)) 938 { 939 CRSTATE_SET_FLOAT(point.pointSize, GL_POINT_SIZE); 940 } 941 942 #ifdef CR_ARB_point_parameters 943 if (CHECKDIRTY(sb->point.minSize, negbitID)) 944 { 945 CRSTATE_SET_FLOAT(point.minSize, GL_POINT_SIZE_MIN_ARB); 946 } 947 948 if (CHECKDIRTY(sb->point.maxSize, negbitID)) 949 { 950 CRSTATE_SET_FLOAT(point.maxSize, GL_POINT_SIZE_MAX_ARB); 951 } 952 953 if (CHECKDIRTY(sb->point.fadeThresholdSize, negbitID)) 954 { 955 CRSTATE_SET_FLOAT(point.fadeThresholdSize, GL_POINT_FADE_THRESHOLD_SIZE_ARB); 956 } 957 958 if (CHECKDIRTY(sb->point.distanceAttenuation, negbitID)) 959 { 960 GLfloat value[3]; 961 value[0] = g->point.distanceAttenuation[0]; 962 value[1] = g->point.distanceAttenuation[1]; 963 value[2] = g->point.distanceAttenuation[2]; 964 diff_api.GetFloatv(GL_POINT_DISTANCE_ATTENUATION, &value[0]); 965 CRSTATE_SET_CAP(point.distanceAttenuation[0], value[0], "%f"); 966 CRSTATE_SET_CAP(point.distanceAttenuation[1], value[1], "%f"); 967 CRSTATE_SET_CAP(point.distanceAttenuation[2], value[2], "%f"); 968 } 969 #endif 970 #ifdef CR_ARB_point_sprite 971 if (CHECKDIRTY(sb->point.enableSprite, negbitID)) 972 { 973 CRSTATE_SET_ENABLED(point.pointSprite, GL_POINT_SPRITE_ARB); 974 } 975 976 { 977 unsigned int i, activeUnit = g->texture.curTextureUnit; 978 for (i=0; i<g->limits.maxTextureUnits; ++i) 979 { 980 if (CHECKDIRTY(sb->point.coordReplacement[i], negbitID)) 981 { 982 GLint val=g->point.coordReplacement[i]; 983 if (activeUnit!=i) 984 { 985 diff_api.ActiveTextureARB(i + GL_TEXTURE0_ARB); 986 activeUnit=i; 987 } 988 diff_api.GetTexEnviv(GL_POINT_SPRITE_ARB, GL_COORD_REPLACE_ARB, &val); 989 CRSTATE_SET_CAP(point.coordReplacement[i], val, "%i"); 990 } 991 } 992 993 if (activeUnit!=g->texture.curTextureUnit) 994 { 995 diff_api.ActiveTextureARB(g->texture.curTextureUnit + GL_TEXTURE0_ARB); 996 } 997 } 998 #endif 999 } 1000 1001 if (CHECKDIRTY(sb->polygon.dirty, negbitID)) 1002 { 1003 if (CHECKDIRTY(sb->polygon.enable, negbitID)) 1004 { 1005 CRSTATE_SET_ENABLED(polygon.polygonSmooth, GL_POLYGON_SMOOTH); 1006 CRSTATE_SET_ENABLED(polygon.polygonOffsetFill, GL_POLYGON_OFFSET_FILL); 1007 CRSTATE_SET_ENABLED(polygon.polygonOffsetLine, GL_POLYGON_OFFSET_LINE); 1008 CRSTATE_SET_ENABLED(polygon.polygonOffsetPoint, GL_POLYGON_OFFSET_POINT); 1009 CRSTATE_SET_ENABLED(polygon.polygonStipple, GL_POLYGON_STIPPLE); 1010 CRSTATE_SET_ENABLED(polygon.cullFace, GL_CULL_FACE); 1011 } 1012 1013 if (CHECKDIRTY(sb->polygon.offset, negbitID)) 1014 { 1015 CRSTATE_SET_FLOAT(polygon.offsetFactor, GL_POLYGON_OFFSET_FACTOR); 1016 CRSTATE_SET_FLOAT(polygon.offsetUnits, GL_POLYGON_OFFSET_UNITS); 1017 } 1018 1019 if (CHECKDIRTY(sb->polygon.mode, negbitID)) 1020 { 1021 GLint val[2]; 1022 CRSTATE_SET_ENUM(polygon.frontFace, GL_FRONT_FACE); 1023 CRSTATE_SET_ENUM(polygon.cullFaceMode, GL_CULL_FACE_MODE); 1024 val[0] = g->polygon.frontMode; 1025 val[1] = g->polygon.backMode; 1026 diff_api.GetIntegerv(GL_POLYGON_MODE, &val[0]); 1027 CRSTATE_SET_CAP(polygon.frontMode, val[0], "%#x"); 1028 CRSTATE_SET_CAP(polygon.backMode, val[1], "%#x"); 1029 1030 1031 } 1032 1033 if (CHECKDIRTY(sb->polygon.stipple, negbitID)) 1034 { 1035 GLint stipple[32]; 1036 crMemcpy(&stipple[0], &g->polygon.stipple[0], sizeof(stipple)); 1037 diff_api.GetPolygonStipple((GLubyte*) &stipple[0]); 1038 if (crMemcmp(&stipple[0], &g->polygon.stipple[0], sizeof(stipple))) 1039 { 1040 #ifdef CRSTATE_DEBUG_QUERY_HW_STATE 1041 { 1042 crDebug("crStateQueryHWState fixed polygon.stipple"); 1043 } 1044 #endif 1045 crMemcpy(&g->polygon.stipple[0], &stipple[0], sizeof(stipple)); 1046 } 1047 } 1048 } 31 1049 } 32 1050 33 1051 void STATE_APIENTRY crStateNewList (GLuint list, GLenum mode) 34 1052 { 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 1053 CRContext *g = GetCurrentContext(); 1054 CRListsState *l = &(g->lists); 1055 1056 if (g->current.inBeginEnd) 1057 { 1058 crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "glNewList called in Begin/End"); 1059 return; 1060 } 1061 1062 if (list == 0) 1063 { 1064 crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, "glNewList(list=0)"); 1065 return; 1066 } 1067 1068 if (l->currentIndex) 1069 { 1070 /* already building a list */ 1071 crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "glNewList called inside display list"); 1072 return; 1073 } 1074 1075 if (mode != GL_COMPILE && mode != GL_COMPILE_AND_EXECUTE) 1076 { 1077 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glNewList invalid mode"); 1078 return; 1079 } 1080 1081 FLUSH(); 1082 1083 /* Must log that this key is used */ 1084 if (!crHashtableIsKeyUsed(g->shared->dlistTable, list)) { 1085 crHashtableAdd(g->shared->dlistTable, list, NULL); 1086 } 1087 1088 /* Need this??? 1089 crStateCurrentRecover(); 1090 */ 1091 1092 l->currentIndex = list; 1093 l->mode = mode; 76 1094 } 77 1095 78 1096 void STATE_APIENTRY crStateEndList (void) 79 1097 { 80 CRContext *g = GetCurrentContext(); 81 CRListsState *l = &(g->lists); 82 83 if (g->current.inBeginEnd) 84 { 85 crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "glEndList called in Begin/End"); 86 return; 87 } 88 89 if (!l->currentIndex) 90 { 91 crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "glEndList called outside display list"); 92 return; 93 } 94 95 l->currentIndex = 0; 96 l->mode = 0; 1098 CRContext *g = GetCurrentContext(); 1099 CRListsState *l = &(g->lists); 1100 1101 if (g->current.inBeginEnd) 1102 { 1103 crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "glEndList called in Begin/End"); 1104 return; 1105 } 1106 1107 if (!l->currentIndex) 1108 { 1109 crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "glEndList called outside display list"); 1110 return; 1111 } 1112 1113 #ifndef IN_GUEST 1114 if (l->mode==GL_COMPILE) 1115 { 1116 crStateQueryHWState(); 1117 } 1118 #endif 1119 1120 l->currentIndex = 0; 1121 l->mode = 0; 97 1122 } 98 1123 99 1124 GLuint STATE_APIENTRY crStateGenLists(GLsizei range) 100 1125 { 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 1126 CRContext *g = GetCurrentContext(); 1127 GLuint start; 1128 1129 if (g->current.inBeginEnd) 1130 { 1131 crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "glGenLists called in Begin/End"); 1132 return 0; 1133 } 1134 1135 if (range < 0) 1136 { 1137 crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, "Negative range passed to glGenLists: %d", range); 1138 return 0; 1139 } 1140 1141 start = crHashtableAllocKeys(g->shared->dlistTable, range); 1142 1143 CRASSERT(start > 0); 1144 return start; 120 1145 } 121 1146 122 1147 void STATE_APIENTRY crStateDeleteLists (GLuint list, GLsizei range) 123 1148 { 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 1149 CRContext *g = GetCurrentContext(); 1150 1151 if (g->current.inBeginEnd) 1152 { 1153 crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "glDeleteLists called in Begin/End"); 1154 return; 1155 } 1156 1157 if (range < 0) 1158 { 1159 crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, "Negative range passed to glDeleteLists: %d", range); 1160 return; 1161 } 1162 1163 crHashtableDeleteBlock(g->shared->dlistTable, list, range, crFree); /* call crFree to delete list data */ 139 1164 } 140 1165 141 1166 GLboolean STATE_APIENTRY crStateIsList(GLuint list) 142 1167 { 143 144 145 146 147 148 149 150 151 152 153 154 155 1168 CRContext *g = GetCurrentContext(); 1169 1170 if (g->current.inBeginEnd) 1171 { 1172 crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, 1173 "GenLists called in Begin/End"); 1174 return GL_FALSE; 1175 } 1176 1177 if (list == 0) 1178 return GL_FALSE; 1179 1180 return crHashtableIsKeyUsed(g->shared->dlistTable, list); 156 1181 } 157 1182 158 1183 void STATE_APIENTRY crStateListBase (GLuint base) 159 1184 { 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 1185 CRContext *g = GetCurrentContext(); 1186 CRListsState *l = &(g->lists); 1187 CRStateBits *sb = GetCurrentBits(); 1188 CRListsBits *lb = &(sb->lists); 1189 1190 if (g->current.inBeginEnd) 1191 { 1192 crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, 1193 "ListBase called in Begin/End"); 1194 return; 1195 } 1196 1197 l->base = base; 1198 1199 DIRTY(lb->base, g->neg_bitid); 1200 DIRTY(lb->dirty, g->neg_bitid); 176 1201 } 177 1202 … … 179 1204 void 180 1205 crStateListsDiff( CRListsBits *b, CRbitvalue *bitID, 181 1206 CRContext *fromCtx, CRContext *toCtx ) 182 1207 { 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 1208 CRListsState *from = &(fromCtx->lists); 1209 CRListsState *to = &(toCtx->lists); 1210 unsigned int j; 1211 CRbitvalue nbitID[CR_MAX_BITARRAY]; 1212 1213 for (j=0;j<CR_MAX_BITARRAY;j++) 1214 nbitID[j] = ~bitID[j]; 1215 1216 if (CHECKDIRTY(b->base, bitID)) 1217 { 1218 if (from->base != to->base) { 1219 diff_api.ListBase(to->base); 1220 from->base = to->base; 1221 } 1222 CLEARDIRTY(b->base, nbitID); 1223 } 1224 1225 CLEARDIRTY(b->dirty, nbitID); 201 1226 } 202 1227 … … 204 1229 void 205 1230 crStateListsSwitch( CRListsBits *b, CRbitvalue *bitID, 206 1231 CRContext *fromCtx, CRContext *toCtx ) 207 1232 { 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 1233 CRListsState *from = &(fromCtx->lists); 1234 CRListsState *to = &(toCtx->lists); 1235 unsigned int j; 1236 CRbitvalue nbitID[CR_MAX_BITARRAY]; 1237 1238 for (j=0;j<CR_MAX_BITARRAY;j++) 1239 nbitID[j] = ~bitID[j]; 1240 1241 if (CHECKDIRTY(b->base, bitID)) 1242 { 1243 if (from->base != to->base) { 1244 diff_api.ListBase(to->base); 1245 FILLDIRTY(b->base); 1246 FILLDIRTY(b->dirty); 1247 } 1248 CLEARDIRTY(b->base, nbitID); 1249 } 1250 1251 CLEARDIRTY(b->dirty, nbitID); 227 1252 } -
trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_lists.c
r33540 r34725 69 69 } 70 70 71 void SERVER_DISPATCH_APIENTRY crServerDispatchEndList(void) 72 { 73 cr_server.head_spu->dispatch_table.EndList(); 74 crStateEndList(); 75 } 71 76 72 77 void SERVER_DISPATCH_APIENTRY … … 79 84 /* Issue the list as-is */ 80 85 cr_server.head_spu->dispatch_table.CallList( list ); 86 crStateQueryHWState(); 81 87 } 82 88 else { … … 206 212 /* Issue the list as-is */ 207 213 cr_server.head_spu->dispatch_table.CallLists( n, type, lists ); 214 crStateQueryHWState(); 208 215 } 209 216 else { -
trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_special
r33280 r34725 246 246 GetObjectParameterfvARB 247 247 BlitFramebufferEXT 248 EndList
Note:
See TracChangeset
for help on using the changeset viewer.