1259
static GLuint r200_need_dis_texgen(const GLbitfield texGenEnabled,
1260
const GLfloat *planeS,
1261
const GLfloat *planeT,
1262
const GLfloat *planeR,
1263
const GLfloat *planeQ)
1265
GLuint needtgenable = 0;
1267
if (!(texGenEnabled & S_BIT)) {
1268
if (((texGenEnabled & T_BIT) && planeT[0] != 0.0) ||
1269
((texGenEnabled & R_BIT) && planeR[0] != 0.0) ||
1270
((texGenEnabled & Q_BIT) && planeQ[0] != 0.0)) {
1271
needtgenable |= S_BIT;
1274
if (!(texGenEnabled & T_BIT)) {
1275
if (((texGenEnabled & S_BIT) && planeS[1] != 0.0) ||
1276
((texGenEnabled & R_BIT) && planeR[1] != 0.0) ||
1277
((texGenEnabled & Q_BIT) && planeQ[1] != 0.0)) {
1278
needtgenable |= T_BIT;
1281
if (!(texGenEnabled & R_BIT)) {
1282
if (((texGenEnabled & S_BIT) && planeS[2] != 0.0) ||
1283
((texGenEnabled & T_BIT) && planeT[2] != 0.0) ||
1284
((texGenEnabled & Q_BIT) && planeQ[2] != 0.0)) {
1285
needtgenable |= R_BIT;
1288
if (!(texGenEnabled & Q_BIT)) {
1289
if (((texGenEnabled & S_BIT) && planeS[3] != 0.0) ||
1290
((texGenEnabled & T_BIT) && planeT[3] != 0.0) ||
1291
((texGenEnabled & R_BIT) && planeR[3] != 0.0)) {
1292
needtgenable |= Q_BIT;
1296
return needtgenable;
1217
1301
* Returns GL_FALSE if fallback required.
1282
1366
return GL_FALSE;
1369
/* we CANNOT do mixed mode if the texgen mode requires a plane where the input
1370
is not enabled for texgen, since the planes are concatenated into texmat,
1371
and thus the input will come from texcoord rather than tex gen equation!
1372
Either fallback or just hope that those texcoords aren't really needed...
1373
Assuming the former will cause lots of unnecessary fallbacks, the latter will
1374
generate bogus results sometimes - it's pretty much impossible to really know
1375
when a fallback is needed, depends on texmat and what sort of texture is bound
1376
etc, - for now fallback if we're missing either S or T bits, there's a high
1377
probability we need the texcoords in that case.
1378
That's a lot of work for some obscure texgen mixed mode fixup - why oh why
1379
doesn't the chip just directly accept the plane parameters :-(. */
1285
1380
switch (mode) {
1286
case GL_OBJECT_LINEAR:
1381
case GL_OBJECT_LINEAR: {
1382
GLuint needtgenable = r200_need_dis_texgen( texUnit->TexGenEnabled,
1383
texUnit->ObjectPlaneS, texUnit->ObjectPlaneT,
1384
texUnit->ObjectPlaneR, texUnit->ObjectPlaneQ );
1385
if (needtgenable & (S_BIT | T_BIT)) {
1386
if (R200_DEBUG & DEBUG_FALLBACKS)
1387
fprintf(stderr, "fallback mixed texgen / obj plane, 0x%x\n",
1388
texUnit->TexGenEnabled);
1391
if (needtgenable & (R_BIT)) {
1392
tgcm &= ~(R200_TEXGEN_COMP_R << (unit * 4));
1394
if (needtgenable & (Q_BIT)) {
1395
tgcm &= ~(R200_TEXGEN_COMP_Q << (unit * 4));
1287
1398
tgi |= R200_TEXGEN_INPUT_OBJ << inputshift;
1288
1399
set_texgen_matrix( rmesa, unit,
1289
1400
(texUnit->TexGenEnabled & S_BIT) ? texUnit->ObjectPlaneS : I,
1290
1401
(texUnit->TexGenEnabled & T_BIT) ? texUnit->ObjectPlaneT : I + 4,
1291
1402
(texUnit->TexGenEnabled & R_BIT) ? texUnit->ObjectPlaneR : I + 8,
1292
1403
(texUnit->TexGenEnabled & Q_BIT) ? texUnit->ObjectPlaneQ : I + 12);
1407
case GL_EYE_LINEAR: {
1408
GLuint needtgenable = r200_need_dis_texgen( texUnit->TexGenEnabled,
1409
texUnit->EyePlaneS, texUnit->EyePlaneT,
1410
texUnit->EyePlaneR, texUnit->EyePlaneQ );
1411
if (needtgenable & (S_BIT | T_BIT)) {
1412
if (R200_DEBUG & DEBUG_FALLBACKS)
1413
fprintf(stderr, "fallback mixed texgen / eye plane, 0x%x\n",
1414
texUnit->TexGenEnabled);
1417
if (needtgenable & (R_BIT)) {
1418
tgcm &= ~(R200_TEXGEN_COMP_R << (unit * 4));
1420
if (needtgenable & (Q_BIT)) {
1421
tgcm &= ~(R200_TEXGEN_COMP_Q << (unit * 4));
1296
1423
tgi |= R200_TEXGEN_INPUT_EYE << inputshift;
1297
set_texgen_matrix( rmesa, unit,
1424
set_texgen_matrix( rmesa, unit,
1298
1425
(texUnit->TexGenEnabled & S_BIT) ? texUnit->EyePlaneS : I,
1299
1426
(texUnit->TexGenEnabled & T_BIT) ? texUnit->EyePlaneT : I + 4,
1300
1427
(texUnit->TexGenEnabled & R_BIT) ? texUnit->EyePlaneR : I + 8,
1301
1428
(texUnit->TexGenEnabled & Q_BIT) ? texUnit->EyePlaneQ : I + 12);
1304
1432
case GL_REFLECTION_MAP_NV:
1305
1433
rmesa->TexGenNeedNormals[unit] = GL_TRUE;
1306
tgi |= R200_TEXGEN_INPUT_EYE_REFLECT<<inputshift;
1307
set_texgen_matrix( rmesa, unit,
1308
(texUnit->TexGenEnabled & S_BIT) ? reflect : I,
1309
(texUnit->TexGenEnabled & T_BIT) ? reflect + 4 : I + 4,
1310
(texUnit->TexGenEnabled & R_BIT) ? reflect + 8 : I + 8,
1434
tgi |= R200_TEXGEN_INPUT_EYE_REFLECT << inputshift;
1435
/* pretty weird, must only negate when lighting is enabled? */
1436
if (ctx->Light.Enabled)
1437
set_texgen_matrix( rmesa, unit,
1438
(texUnit->TexGenEnabled & S_BIT) ? reflect : I,
1439
(texUnit->TexGenEnabled & T_BIT) ? reflect + 4 : I + 4,
1440
(texUnit->TexGenEnabled & R_BIT) ? reflect + 8 : I + 8,
1314
1444
case GL_NORMAL_MAP_NV: