bring over latest mga DRI driver from DRI trunk
This commit is contained in:
parent
1f2d9ae69f
commit
eed5ac284c
|
@ -143,9 +143,16 @@ GLboolean mgaUpdateTextureEnvCombine( GLcontext *ctx, int unit )
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case GL_CONSTANT:
|
case GL_CONSTANT:
|
||||||
|
if (mmesa->fcol_used &&
|
||||||
|
mmesa->envcolor[source] != mmesa->envcolor[!source])
|
||||||
|
return GL_FALSE;
|
||||||
|
|
||||||
arg1[i] |= ARG_DISABLE;
|
arg1[i] |= ARG_DISABLE;
|
||||||
arg2[i] |= TD0_color_arg2_fcol;
|
arg2[i] |= TD0_color_arg2_fcol;
|
||||||
alpha[i] |= TD0_color_alpha_fcol;
|
alpha[i] |= TD0_color_alpha_fcol;
|
||||||
|
|
||||||
|
mmesa->setup.fcol = mmesa->envcolor[source];
|
||||||
|
mmesa->fcol_used = GL_TRUE;
|
||||||
break;
|
break;
|
||||||
case GL_PRIMARY_COLOR:
|
case GL_PRIMARY_COLOR:
|
||||||
arg1[i] |= ARG_DISABLE;
|
arg1[i] |= ARG_DISABLE;
|
||||||
|
@ -178,12 +185,23 @@ GLboolean mgaUpdateTextureEnvCombine( GLcontext *ctx, int unit )
|
||||||
case GL_SRC_COLOR:
|
case GL_SRC_COLOR:
|
||||||
arg1[i] |= 0;
|
arg1[i] |= 0;
|
||||||
arg2[i] |= 0;
|
arg2[i] |= 0;
|
||||||
|
if (texUnit->CombineSourceRGB[i] == GL_CONSTANT &&
|
||||||
|
RGBA_EQUAL( mmesa->envcolor[source] )) {
|
||||||
|
alpha[i] |= 0;
|
||||||
|
} else {
|
||||||
alpha[i] |= ARG_DISABLE;
|
alpha[i] |= ARG_DISABLE;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case GL_ONE_MINUS_SRC_COLOR:
|
case GL_ONE_MINUS_SRC_COLOR:
|
||||||
arg1[i] |= TD0_color_arg1_inv_enable;
|
arg1[i] |= TD0_color_arg1_inv_enable;
|
||||||
arg2[i] |= TD0_color_arg2_inv_enable;
|
arg2[i] |= TD0_color_arg2_inv_enable;
|
||||||
|
if (texUnit->CombineSourceRGB[i] == GL_CONSTANT &&
|
||||||
|
RGBA_EQUAL( mmesa->envcolor[source] )) {
|
||||||
|
alpha[i] |= (TD0_color_alpha1inv_enable |
|
||||||
|
TD0_color_alpha2inv_enable);
|
||||||
|
} else {
|
||||||
alpha[i] |= ARG_DISABLE;
|
alpha[i] |= ARG_DISABLE;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case GL_SRC_ALPHA:
|
case GL_SRC_ALPHA:
|
||||||
arg1[i] |= TD0_color_arg1_replicatealpha_enable;
|
arg1[i] |= TD0_color_arg1_replicatealpha_enable;
|
||||||
|
@ -396,7 +414,7 @@ GLboolean mgaUpdateTextureEnvCombine( GLcontext *ctx, int unit )
|
||||||
TD0_color_sel_arg2 |
|
TD0_color_sel_arg2 |
|
||||||
TD0_alpha_arg2_prevstage |
|
TD0_alpha_arg2_prevstage |
|
||||||
TD0_alpha_sel_arg2);
|
TD0_alpha_sel_arg2);
|
||||||
mmesa->dualtex_env = GL_TRUE;
|
mmesa->force_dualtex = GL_TRUE;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case GL_SUBTRACT:
|
case GL_SUBTRACT:
|
||||||
|
@ -538,8 +556,15 @@ GLboolean mgaUpdateTextureEnvCombine( GLcontext *ctx, int unit )
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case GL_CONSTANT:
|
case GL_CONSTANT:
|
||||||
|
if (mmesa->fcol_used &&
|
||||||
|
mmesa->envcolor[source] != mmesa->envcolor[!source])
|
||||||
|
return GL_FALSE;
|
||||||
|
|
||||||
arg1[i] |= ARG_DISABLE;
|
arg1[i] |= ARG_DISABLE;
|
||||||
arg2[i] |= TD0_alpha_arg2_fcol;
|
arg2[i] |= TD0_alpha_arg2_fcol;
|
||||||
|
|
||||||
|
mmesa->setup.fcol = mmesa->envcolor[source];
|
||||||
|
mmesa->fcol_used = GL_TRUE;
|
||||||
break;
|
break;
|
||||||
case GL_PRIMARY_COLOR:
|
case GL_PRIMARY_COLOR:
|
||||||
arg1[i] |= ARG_DISABLE;
|
arg1[i] |= ARG_DISABLE;
|
||||||
|
|
|
@ -48,15 +48,15 @@
|
||||||
#define TMC_nr_tformat (MESA_FORMAT_YCBCR_REV + 1)
|
#define TMC_nr_tformat (MESA_FORMAT_YCBCR_REV + 1)
|
||||||
static const unsigned TMC_tformat[ TMC_nr_tformat ] =
|
static const unsigned TMC_tformat[ TMC_nr_tformat ] =
|
||||||
{
|
{
|
||||||
[MESA_FORMAT_ARGB8888] = TMC_tformat_tw32 | TMC_takey_1 | TMC_tamask_0,
|
[MESA_FORMAT_ARGB8888] = TMC_tformat_tw32,
|
||||||
[MESA_FORMAT_RGB565] = TMC_tformat_tw16 | TMC_takey_1 | TMC_tamask_0,
|
[MESA_FORMAT_RGB565] = TMC_tformat_tw16,
|
||||||
[MESA_FORMAT_ARGB4444] = TMC_tformat_tw12 | TMC_takey_1 | TMC_tamask_0,
|
[MESA_FORMAT_ARGB4444] = TMC_tformat_tw12,
|
||||||
[MESA_FORMAT_ARGB1555] = TMC_tformat_tw15 | TMC_takey_1 | TMC_tamask_0,
|
[MESA_FORMAT_ARGB1555] = TMC_tformat_tw15,
|
||||||
[MESA_FORMAT_AL88] = TMC_tformat_tw8al | TMC_takey_1 | TMC_tamask_0,
|
[MESA_FORMAT_AL88] = TMC_tformat_tw8al,
|
||||||
[MESA_FORMAT_I8] = TMC_tformat_tw8a | TMC_takey_1 | TMC_tamask_0,
|
[MESA_FORMAT_I8] = TMC_tformat_tw8a,
|
||||||
[MESA_FORMAT_CI8] = TMC_tformat_tw8 | TMC_takey_1 | TMC_tamask_0,
|
[MESA_FORMAT_CI8] = TMC_tformat_tw8 ,
|
||||||
[MESA_FORMAT_YCBCR] = TMC_tformat_tw422uyvy | TMC_takey_1 | TMC_tamask_0,
|
[MESA_FORMAT_YCBCR] = TMC_tformat_tw422uyvy,
|
||||||
[MESA_FORMAT_YCBCR_REV] = TMC_tformat_tw422 | TMC_takey_1 | TMC_tamask_0,
|
[MESA_FORMAT_YCBCR_REV] = TMC_tformat_tw422,
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -106,8 +106,13 @@ mgaSetTexImages( mgaContextPtr mmesa,
|
||||||
#endif /* MGA_USE_TABLE_FOR_FORMAT */
|
#endif /* MGA_USE_TABLE_FOR_FORMAT */
|
||||||
|
|
||||||
driCalculateTextureFirstLastLevel( (driTextureObject *) t );
|
driCalculateTextureFirstLastLevel( (driTextureObject *) t );
|
||||||
|
if (tObj->Target == GL_TEXTURE_RECTANGLE_NV) {
|
||||||
|
log2Width = 0;
|
||||||
|
log2Height = 0;
|
||||||
|
} else {
|
||||||
log2Width = tObj->Image[t->base.firstLevel]->WidthLog2;
|
log2Width = tObj->Image[t->base.firstLevel]->WidthLog2;
|
||||||
log2Height = tObj->Image[t->base.firstLevel]->HeightLog2;
|
log2Height = tObj->Image[t->base.firstLevel]->HeightLog2;
|
||||||
|
}
|
||||||
|
|
||||||
width = tObj->Image[t->base.firstLevel]->Width;
|
width = tObj->Image[t->base.firstLevel]->Width;
|
||||||
height = tObj->Image[t->base.firstLevel]->Height;
|
height = tObj->Image[t->base.firstLevel]->Height;
|
||||||
|
@ -120,19 +125,30 @@ mgaSetTexImages( mgaContextPtr mmesa,
|
||||||
for ( i = 0 ; i < numLevels ; i++ ) {
|
for ( i = 0 ; i < numLevels ; i++ ) {
|
||||||
const struct gl_texture_image * const texImage =
|
const struct gl_texture_image * const texImage =
|
||||||
tObj->Image[ i + t->base.firstLevel ];
|
tObj->Image[ i + t->base.firstLevel ];
|
||||||
|
int size;
|
||||||
|
|
||||||
if ( (texImage == NULL)
|
if (texImage == NULL)
|
||||||
|| ((i != 0)
|
|
||||||
&& ((texImage->Width < 8) || (texImage->Height < 8))) ) {
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
|
size = texImage->Width * texImage->Height *
|
||||||
|
baseImage->TexFormat->TexelBytes;
|
||||||
|
|
||||||
t->offsets[i] = totalSize;
|
t->offsets[i] = totalSize;
|
||||||
t->base.dirty_images[0] |= (1<<i);
|
t->base.dirty_images[0] |= (1<<i);
|
||||||
|
|
||||||
totalSize += ((MAX2( texImage->Width, 8 ) *
|
/* All mipmaps must be 32-byte aligned */
|
||||||
MAX2( texImage->Height, 8 ) *
|
totalSize += (size + 31) & ~31;
|
||||||
baseImage->TexFormat->TexelBytes) + 31) & ~31;
|
|
||||||
|
/* Since G400 calculates the offsets in hardware
|
||||||
|
* it can't handle more than one < 32 byte mipmap.
|
||||||
|
*
|
||||||
|
* Further testing has indicated that it can't
|
||||||
|
* handle any < 32 byte mipmaps.
|
||||||
|
*/
|
||||||
|
if (MGA_IS_G400( mmesa ) && size <= 32) {
|
||||||
|
i++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* save these values */
|
/* save these values */
|
||||||
|
@ -152,17 +168,17 @@ mgaSetTexImages( mgaContextPtr mmesa,
|
||||||
*/
|
*/
|
||||||
|
|
||||||
t->setup.texctl |= TMC_tpitchlin_enable;
|
t->setup.texctl |= TMC_tpitchlin_enable;
|
||||||
t->setup.texctl |= (width & (2048 - 1)) << TMC_tpitchext_SHIFT;
|
t->setup.texctl |= MGA_FIELD( TMC_tpitchext, width & (2048 - 1) );
|
||||||
|
|
||||||
|
|
||||||
/* G400 specifies the number of mip levels in a strange way. Since there
|
/* G400 specifies the number of mip levels in a strange way. Since there
|
||||||
* are up to 12 levels, it requires 4 bits. Three of the bits are at the
|
* are up to 11 levels, it requires 4 bits. Three of the bits are at the
|
||||||
* high end of TEXFILTER. The other bit is in the middle. Weird.
|
* high end of TEXFILTER. The other bit is in the middle. Weird.
|
||||||
*/
|
*/
|
||||||
|
numLevels--;
|
||||||
t->setup.texfilter &= TF_mapnb_MASK & TF_mapnbhigh_MASK & TF_reserved_MASK;
|
t->setup.texfilter &= TF_mapnb_MASK & TF_mapnbhigh_MASK & TF_reserved_MASK;
|
||||||
t->setup.texfilter |= (((numLevels-1) & 0x07) << (TF_mapnb_SHIFT));
|
t->setup.texfilter |= MGA_FIELD( TF_mapnb, numLevels & 0x7 );
|
||||||
t->setup.texfilter |= (((numLevels-1) & 0x08) << (TF_mapnbhigh_SHIFT - 3));
|
t->setup.texfilter |= MGA_FIELD( TF_mapnbhigh, (numLevels >> 3) & 0x1 );
|
||||||
|
|
||||||
/* warp texture registers */
|
/* warp texture registers */
|
||||||
ofs = MGA_IS_G200(mmesa) ? 28 : 11;
|
ofs = MGA_IS_G200(mmesa) ? 28 : 11;
|
||||||
|
@ -185,53 +201,80 @@ mgaSetTexImages( mgaContextPtr mmesa,
|
||||||
|
|
||||||
static void mgaUpdateTextureEnvG200( GLcontext *ctx, GLuint unit )
|
static void mgaUpdateTextureEnvG200( GLcontext *ctx, GLuint unit )
|
||||||
{
|
{
|
||||||
|
mgaContextPtr mmesa = MGA_CONTEXT(ctx);
|
||||||
struct gl_texture_object *tObj = ctx->Texture.Unit[0]._Current;
|
struct gl_texture_object *tObj = ctx->Texture.Unit[0]._Current;
|
||||||
mgaTextureObjectPtr t;
|
mgaTextureObjectPtr t = (mgaTextureObjectPtr) tObj->DriverData;
|
||||||
|
GLenum format = tObj->Image[tObj->BaseLevel]->Format;
|
||||||
|
|
||||||
if (!tObj || !tObj->DriverData)
|
if (tObj != ctx->Texture.Unit[0].Current2D &&
|
||||||
|
tObj != ctx->Texture.Unit[0].CurrentRect)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
t = (mgaTextureObjectPtr)tObj->DriverData;
|
|
||||||
|
|
||||||
t->setup.texctl2 &= ~TMC_decalblend_enable;
|
t->setup.texctl &= ~TMC_tmodulate_enable;
|
||||||
|
t->setup.texctl2 &= ~(TMC_decalblend_enable |
|
||||||
|
TMC_idecal_enable |
|
||||||
|
TMC_decaldis_enable);
|
||||||
|
|
||||||
switch (ctx->Texture.Unit[0].EnvMode) {
|
switch (ctx->Texture.Unit[0].EnvMode) {
|
||||||
case GL_REPLACE:
|
case GL_REPLACE:
|
||||||
t->setup.texctl &= ~TMC_tmodulate_enable;
|
if (format == GL_ALPHA)
|
||||||
|
t->setup.texctl2 |= TMC_idecal_enable;
|
||||||
|
|
||||||
|
if (format == GL_RGB || format == GL_LUMINANCE)
|
||||||
|
mmesa->hw.alpha_sel = AC_alphasel_diffused;
|
||||||
|
else
|
||||||
|
mmesa->hw.alpha_sel = AC_alphasel_fromtex;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GL_MODULATE:
|
case GL_MODULATE:
|
||||||
t->setup.texctl |= TMC_tmodulate_enable;
|
t->setup.texctl |= TMC_tmodulate_enable;
|
||||||
|
|
||||||
|
if (format == GL_ALPHA)
|
||||||
|
t->setup.texctl2 |= (TMC_idecal_enable |
|
||||||
|
TMC_decaldis_enable);
|
||||||
|
|
||||||
|
if (format == GL_RGB || format == GL_LUMINANCE)
|
||||||
|
mmesa->hw.alpha_sel = AC_alphasel_diffused;
|
||||||
|
else
|
||||||
|
mmesa->hw.alpha_sel = AC_alphasel_modulated;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GL_DECAL:
|
case GL_DECAL:
|
||||||
t->setup.texctl &= ~TMC_tmodulate_enable;
|
if (format == GL_RGB || format == GL_RGBA)
|
||||||
t->setup.texctl2 |= TMC_decalblend_enable;
|
t->setup.texctl2 |= TMC_decalblend_enable;
|
||||||
|
else
|
||||||
|
t->setup.texctl2 |= TMC_idecal_enable;
|
||||||
|
|
||||||
|
mmesa->hw.alpha_sel = AC_alphasel_diffused;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GL_BLEND:
|
case GL_BLEND:
|
||||||
|
if (format == GL_ALPHA) {
|
||||||
|
t->setup.texctl2 |= TMC_idecal_enable;
|
||||||
|
mmesa->hw.alpha_sel = AC_alphasel_modulated;
|
||||||
|
} else {
|
||||||
t->texenv_fallback = GL_TRUE;
|
t->texenv_fallback = GL_TRUE;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#define MGA_DISABLE 0
|
#define MGA_REPLACE 0
|
||||||
#define MGA_REPLACE 1
|
#define MGA_MODULATE 1
|
||||||
#define MGA_MODULATE 2
|
#define MGA_DECAL 2
|
||||||
#define MGA_DECAL 3
|
#define MGA_ADD 3
|
||||||
#define MGA_BLEND 4
|
#define MGA_MAX_COMBFUNC 4
|
||||||
#define MGA_ADD 5
|
|
||||||
#define MGA_MAX_COMBFUNC 6
|
|
||||||
|
|
||||||
static const GLuint g400_color_combine[][MGA_MAX_COMBFUNC] =
|
static const GLuint g400_color_combine[][MGA_MAX_COMBFUNC] =
|
||||||
{
|
{
|
||||||
/* Unit 0:
|
/* Unit 0:
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
/* Disable combiner stage
|
|
||||||
*/
|
|
||||||
(0),
|
|
||||||
|
|
||||||
/* GL_REPLACE
|
/* GL_REPLACE
|
||||||
* Cv = Cs
|
* Cv = Cs
|
||||||
* Av = Af
|
* Av = Af
|
||||||
|
@ -257,16 +300,6 @@ static const GLuint g400_color_combine[][MGA_MAX_COMBFUNC] =
|
||||||
TD0_alpha_arg2_diffuse |
|
TD0_alpha_arg2_diffuse |
|
||||||
TD0_alpha_sel_arg2),
|
TD0_alpha_sel_arg2),
|
||||||
|
|
||||||
/* GL_BLEND (Cc=0.0)
|
|
||||||
* Cv = Cf ( 1 - Cs )
|
|
||||||
* Av = Af
|
|
||||||
*/
|
|
||||||
(TD0_color_arg1_inv_enable |
|
|
||||||
TD0_color_arg2_diffuse |
|
|
||||||
TD0_color_sel_mul |
|
|
||||||
TD0_alpha_arg2_diffuse |
|
|
||||||
TD0_alpha_sel_arg2),
|
|
||||||
|
|
||||||
/* GL_ADD
|
/* GL_ADD
|
||||||
* Cv = Cf + Cs
|
* Cv = Cf + Cs
|
||||||
* Av = Af
|
* Av = Af
|
||||||
|
@ -281,10 +314,6 @@ static const GLuint g400_color_combine[][MGA_MAX_COMBFUNC] =
|
||||||
/* Unit 1:
|
/* Unit 1:
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
/* Disable combiner stage
|
|
||||||
*/
|
|
||||||
(0),
|
|
||||||
|
|
||||||
/* GL_REPLACE
|
/* GL_REPLACE
|
||||||
* Cv = Cs
|
* Cv = Cs
|
||||||
* Av = Ap
|
* Av = Ap
|
||||||
|
@ -310,16 +339,6 @@ static const GLuint g400_color_combine[][MGA_MAX_COMBFUNC] =
|
||||||
TD0_alpha_arg2_prevstage |
|
TD0_alpha_arg2_prevstage |
|
||||||
TD0_alpha_sel_arg2),
|
TD0_alpha_sel_arg2),
|
||||||
|
|
||||||
/* GL_BLEND (Cc=0.0)
|
|
||||||
* Cv = Cp ( 1 - Cs )
|
|
||||||
* Av = Ap
|
|
||||||
*/
|
|
||||||
(TD0_color_arg1_inv_enable |
|
|
||||||
TD0_color_arg2_prevstage |
|
|
||||||
TD0_color_sel_mul |
|
|
||||||
TD0_alpha_arg2_prevstage |
|
|
||||||
TD0_alpha_sel_arg2),
|
|
||||||
|
|
||||||
/* GL_ADD
|
/* GL_ADD
|
||||||
* Cv = Cp + Cs
|
* Cv = Cp + Cs
|
||||||
* Av = Ap
|
* Av = Ap
|
||||||
|
@ -337,10 +356,6 @@ static const GLuint g400_color_alpha_combine[][MGA_MAX_COMBFUNC] =
|
||||||
/* Unit 0:
|
/* Unit 0:
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
/* Disable combiner stage
|
|
||||||
*/
|
|
||||||
(0),
|
|
||||||
|
|
||||||
/* GL_REPLACE
|
/* GL_REPLACE
|
||||||
* Cv = Cs
|
* Cv = Cs
|
||||||
* Av = As
|
* Av = As
|
||||||
|
@ -374,16 +389,6 @@ static const GLuint g400_color_alpha_combine[][MGA_MAX_COMBFUNC] =
|
||||||
TD0_alpha_arg2_diffuse |
|
TD0_alpha_arg2_diffuse |
|
||||||
TD0_alpha_sel_arg2),
|
TD0_alpha_sel_arg2),
|
||||||
|
|
||||||
/* GL_BLEND (Cc=0.0)
|
|
||||||
* Cv = Cf ( 1 - Cs )
|
|
||||||
* Av = Af As
|
|
||||||
*/
|
|
||||||
(TD0_color_arg1_inv_enable |
|
|
||||||
TD0_color_arg2_diffuse |
|
|
||||||
TD0_color_sel_mul |
|
|
||||||
TD0_alpha_arg2_diffuse |
|
|
||||||
TD0_alpha_sel_mul),
|
|
||||||
|
|
||||||
/* GL_ADD
|
/* GL_ADD
|
||||||
* Cv = Cf + Cs
|
* Cv = Cf + Cs
|
||||||
* Av = Af As
|
* Av = Af As
|
||||||
|
@ -398,10 +403,6 @@ static const GLuint g400_color_alpha_combine[][MGA_MAX_COMBFUNC] =
|
||||||
/* Unit 1:
|
/* Unit 1:
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
/* Disable combiner stage
|
|
||||||
*/
|
|
||||||
(0),
|
|
||||||
|
|
||||||
/* GL_REPLACE
|
/* GL_REPLACE
|
||||||
* Cv = Cs
|
* Cv = Cs
|
||||||
* Av = As
|
* Av = As
|
||||||
|
@ -435,16 +436,6 @@ static const GLuint g400_color_alpha_combine[][MGA_MAX_COMBFUNC] =
|
||||||
TD0_alpha_arg2_prevstage |
|
TD0_alpha_arg2_prevstage |
|
||||||
TD0_alpha_sel_arg2),
|
TD0_alpha_sel_arg2),
|
||||||
|
|
||||||
/* GL_BLEND (Cc=0.0)
|
|
||||||
* Cv = Cp ( 1 - Cs )
|
|
||||||
* Av = Ap As
|
|
||||||
*/
|
|
||||||
(TD0_color_arg1_inv_enable |
|
|
||||||
TD0_color_arg2_prevstage |
|
|
||||||
TD0_color_sel_mul |
|
|
||||||
TD0_alpha_arg2_prevstage |
|
|
||||||
TD0_alpha_sel_mul),
|
|
||||||
|
|
||||||
/* GL_ADD
|
/* GL_ADD
|
||||||
* Cv = Cp + Cs
|
* Cv = Cp + Cs
|
||||||
* Av = Ap As
|
* Av = Ap As
|
||||||
|
@ -462,10 +453,6 @@ static const GLuint g400_alpha_combine[][MGA_MAX_COMBFUNC] =
|
||||||
/* Unit 0:
|
/* Unit 0:
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
/* Disable combiner stage
|
|
||||||
*/
|
|
||||||
(0),
|
|
||||||
|
|
||||||
/* GL_REPLACE
|
/* GL_REPLACE
|
||||||
* Cv = Cf
|
* Cv = Cf
|
||||||
* Av = As
|
* Av = As
|
||||||
|
@ -492,15 +479,6 @@ static const GLuint g400_alpha_combine[][MGA_MAX_COMBFUNC] =
|
||||||
TD0_alpha_arg2_diffuse |
|
TD0_alpha_arg2_diffuse |
|
||||||
TD0_alpha_sel_arg2),
|
TD0_alpha_sel_arg2),
|
||||||
|
|
||||||
/* GL_BLEND
|
|
||||||
* Cv = Cf
|
|
||||||
* Av = Af As
|
|
||||||
*/
|
|
||||||
(TD0_color_arg2_diffuse |
|
|
||||||
TD0_color_sel_arg2 |
|
|
||||||
TD0_alpha_arg2_diffuse |
|
|
||||||
TD0_alpha_sel_mul),
|
|
||||||
|
|
||||||
/* GL_ADD
|
/* GL_ADD
|
||||||
* Cv = Cf
|
* Cv = Cf
|
||||||
* Av = Af As
|
* Av = Af As
|
||||||
|
@ -514,10 +492,6 @@ static const GLuint g400_alpha_combine[][MGA_MAX_COMBFUNC] =
|
||||||
/* Unit 1:
|
/* Unit 1:
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
/* Disable combiner stage
|
|
||||||
*/
|
|
||||||
(0),
|
|
||||||
|
|
||||||
/* GL_REPLACE
|
/* GL_REPLACE
|
||||||
* Cv = Cp
|
* Cv = Cp
|
||||||
* Av = As
|
* Av = As
|
||||||
|
@ -544,15 +518,6 @@ static const GLuint g400_alpha_combine[][MGA_MAX_COMBFUNC] =
|
||||||
TD0_alpha_arg2_prevstage |
|
TD0_alpha_arg2_prevstage |
|
||||||
TD0_alpha_sel_arg2),
|
TD0_alpha_sel_arg2),
|
||||||
|
|
||||||
/* GL_BLEND
|
|
||||||
* Cv = Cp
|
|
||||||
* Av = Ap As
|
|
||||||
*/
|
|
||||||
(TD0_color_arg2_prevstage |
|
|
||||||
TD0_color_sel_arg2 |
|
|
||||||
TD0_alpha_arg2_prevstage |
|
|
||||||
TD0_alpha_sel_mul),
|
|
||||||
|
|
||||||
/* GL_ADD
|
/* GL_ADD
|
||||||
* Cv = Cp
|
* Cv = Cp
|
||||||
* Av = Ap As
|
* Av = Ap As
|
||||||
|
@ -564,6 +529,102 @@ static const GLuint g400_alpha_combine[][MGA_MAX_COMBFUNC] =
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static GLboolean mgaUpdateTextureEnvBlend( GLcontext *ctx, int unit )
|
||||||
|
{
|
||||||
|
mgaContextPtr mmesa = MGA_CONTEXT(ctx);
|
||||||
|
const int source = mmesa->tmu_source[unit];
|
||||||
|
const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[source];
|
||||||
|
const struct gl_texture_object *tObj = texUnit->_Current;
|
||||||
|
GLuint *reg = ((GLuint *)&mmesa->setup.tdualstage0 + unit);
|
||||||
|
GLenum format = tObj->Image[tObj->BaseLevel]->Format;
|
||||||
|
|
||||||
|
*reg = 0;
|
||||||
|
|
||||||
|
if (format == GL_ALPHA) {
|
||||||
|
/* Cv = Cf */
|
||||||
|
*reg |= (TD0_color_arg2_diffuse |
|
||||||
|
TD0_color_sel_arg2);
|
||||||
|
/* Av = Af As */
|
||||||
|
*reg |= (TD0_alpha_arg2_diffuse |
|
||||||
|
TD0_alpha_sel_mul);
|
||||||
|
return GL_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* C1 = Cf ( 1 - Cs ) */
|
||||||
|
*reg |= (TD0_color_arg1_inv_enable |
|
||||||
|
TD0_color_arg2_diffuse |
|
||||||
|
TD0_color_sel_mul);
|
||||||
|
|
||||||
|
if (format == GL_RGB || format == GL_LUMINANCE) {
|
||||||
|
/* A1 = Af */
|
||||||
|
*reg |= (TD0_alpha_arg2_diffuse |
|
||||||
|
TD0_alpha_sel_arg2);
|
||||||
|
} else
|
||||||
|
if (format == GL_RGBA || format == GL_LUMINANCE_ALPHA) {
|
||||||
|
/* A1 = Af As */
|
||||||
|
*reg |= (TD0_alpha_arg2_diffuse |
|
||||||
|
TD0_alpha_sel_mul);
|
||||||
|
} else
|
||||||
|
if (format == GL_INTENSITY) {
|
||||||
|
/* A1 = Af ( 1 - As ) */
|
||||||
|
*reg |= (TD0_alpha_arg1_inv_enable |
|
||||||
|
TD0_alpha_arg2_diffuse |
|
||||||
|
TD0_alpha_sel_mul);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (RGB_ZERO(mmesa->envcolor[source]) &&
|
||||||
|
(format != GL_INTENSITY || ALPHA_ZERO(mmesa->envcolor[source])))
|
||||||
|
return GL_TRUE; /* all done */
|
||||||
|
|
||||||
|
if (ctx->Texture._EnabledUnits == 0x03)
|
||||||
|
return GL_FALSE; /* need both units */
|
||||||
|
|
||||||
|
mmesa->force_dualtex = GL_TRUE;
|
||||||
|
reg = &mmesa->setup.tdualstage1;
|
||||||
|
*reg = 0;
|
||||||
|
|
||||||
|
if (RGB_ZERO(mmesa->envcolor[source])) {
|
||||||
|
/* Cv = C1 */
|
||||||
|
*reg |= (TD0_color_arg2_prevstage |
|
||||||
|
TD0_color_sel_arg2);
|
||||||
|
} else
|
||||||
|
if (RGB_ONE(mmesa->envcolor[source])) {
|
||||||
|
/* Cv = C1 + Cs */
|
||||||
|
*reg |= (TD0_color_arg2_prevstage |
|
||||||
|
TD0_color_add_add |
|
||||||
|
TD0_color_sel_add);
|
||||||
|
} else
|
||||||
|
if (RGBA_EQUAL(mmesa->envcolor[source])) {
|
||||||
|
/* Cv = C1 + Cc Cs */
|
||||||
|
*reg |= (TD0_color_arg2_prevstage |
|
||||||
|
TD0_color_alpha_fcol |
|
||||||
|
TD0_color_arg2mul_alpha2 |
|
||||||
|
TD0_color_arg1add_mulout |
|
||||||
|
TD0_color_add_add |
|
||||||
|
TD0_color_sel_add);
|
||||||
|
|
||||||
|
mmesa->setup.fcol = mmesa->envcolor[source];
|
||||||
|
} else {
|
||||||
|
return GL_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (format != GL_INTENSITY || ALPHA_ZERO(mmesa->envcolor[source])) {
|
||||||
|
/* Av = A1 */
|
||||||
|
*reg |= (TD0_alpha_arg2_prevstage |
|
||||||
|
TD0_alpha_sel_arg2);
|
||||||
|
} else
|
||||||
|
if (ALPHA_ONE(mmesa->envcolor[source])) {
|
||||||
|
/* Av = A1 + As */
|
||||||
|
*reg |= (TD0_alpha_arg2_prevstage |
|
||||||
|
TD0_alpha_add_enable |
|
||||||
|
TD0_alpha_sel_add);
|
||||||
|
} else {
|
||||||
|
return GL_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return GL_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
static void mgaUpdateTextureEnvG400( GLcontext *ctx, GLuint unit )
|
static void mgaUpdateTextureEnvG400( GLcontext *ctx, GLuint unit )
|
||||||
{
|
{
|
||||||
mgaContextPtr mmesa = MGA_CONTEXT( ctx );
|
mgaContextPtr mmesa = MGA_CONTEXT( ctx );
|
||||||
|
@ -571,18 +632,13 @@ static void mgaUpdateTextureEnvG400( GLcontext *ctx, GLuint unit )
|
||||||
const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[source];
|
const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[source];
|
||||||
const struct gl_texture_object *tObj = texUnit->_Current;
|
const struct gl_texture_object *tObj = texUnit->_Current;
|
||||||
GLuint *reg = ((GLuint *)&mmesa->setup.tdualstage0 + unit);
|
GLuint *reg = ((GLuint *)&mmesa->setup.tdualstage0 + unit);
|
||||||
mgaTextureObjectPtr t;
|
mgaTextureObjectPtr t = (mgaTextureObjectPtr) tObj->DriverData;
|
||||||
GLenum format;
|
GLenum format = tObj->Image[tObj->BaseLevel]->Format;
|
||||||
|
|
||||||
if ( !tObj ||
|
if (tObj != ctx->Texture.Unit[source].Current2D &&
|
||||||
(tObj != ctx->Texture.Unit[source].Current2D &&
|
tObj != ctx->Texture.Unit[source].CurrentRect)
|
||||||
tObj != ctx->Texture.Unit[source].CurrentRect) )
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
format = tObj->Image[tObj->BaseLevel]->Format;
|
|
||||||
|
|
||||||
t = (mgaTextureObjectPtr) tObj->DriverData;
|
|
||||||
|
|
||||||
switch (ctx->Texture.Unit[source].EnvMode) {
|
switch (ctx->Texture.Unit[source].EnvMode) {
|
||||||
case GL_REPLACE:
|
case GL_REPLACE:
|
||||||
if (format == GL_ALPHA) {
|
if (format == GL_ALPHA) {
|
||||||
|
@ -615,7 +671,7 @@ static void mgaUpdateTextureEnvG400( GLcontext *ctx, GLuint unit )
|
||||||
TD0_color_sel_arg2 |
|
TD0_color_sel_arg2 |
|
||||||
TD0_alpha_arg2_prevstage |
|
TD0_alpha_arg2_prevstage |
|
||||||
TD0_alpha_sel_arg2);
|
TD0_alpha_sel_arg2);
|
||||||
mmesa->dualtex_env = GL_TRUE;
|
mmesa->force_dualtex = GL_TRUE;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* Undefined */
|
/* Undefined */
|
||||||
|
@ -653,146 +709,11 @@ static void mgaUpdateTextureEnvG400( GLcontext *ctx, GLuint unit )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GL_BLEND:
|
case GL_BLEND:
|
||||||
if (format == GL_ALPHA) {
|
if (!mgaUpdateTextureEnvBlend(ctx, unit))
|
||||||
*reg = g400_alpha_combine[unit][MGA_BLEND];
|
|
||||||
} else {
|
|
||||||
if (mmesa->blend_flags & MGA_BLEND_RGB_ZERO) {
|
|
||||||
if (format == GL_RGB || format == GL_LUMINANCE) {
|
|
||||||
*reg = g400_color_combine[unit][MGA_BLEND];
|
|
||||||
} else if (format == GL_RGBA || format == GL_LUMINANCE_ALPHA) {
|
|
||||||
*reg = g400_color_alpha_combine[unit][MGA_BLEND];
|
|
||||||
} else if (format == GL_INTENSITY) {
|
|
||||||
if (mmesa->blend_flags & MGA_BLEND_ALPHA_ZERO) {
|
|
||||||
/* Cv = Cf ( 1 - Cs )
|
|
||||||
* Av = Af ( 1 - As )
|
|
||||||
*/
|
|
||||||
if (unit == 0) {
|
|
||||||
*reg = (TD0_color_arg1_inv_enable |
|
|
||||||
TD0_color_arg2_diffuse |
|
|
||||||
TD0_color_sel_mul |
|
|
||||||
TD0_alpha_arg1_inv_enable |
|
|
||||||
TD0_alpha_arg2_diffuse |
|
|
||||||
TD0_alpha_sel_mul);
|
|
||||||
} else {
|
|
||||||
*reg = (TD0_color_arg1_inv_enable |
|
|
||||||
TD0_color_arg2_prevstage |
|
|
||||||
TD0_color_sel_mul |
|
|
||||||
TD0_alpha_arg1_inv_enable |
|
|
||||||
TD0_alpha_arg2_prevstage |
|
|
||||||
TD0_alpha_sel_mul);
|
|
||||||
}
|
|
||||||
} else if (mmesa->blend_flags & MGA_BLEND_ALPHA_ONE &&
|
|
||||||
ctx->Texture._EnabledUnits != 0x03) {
|
|
||||||
/* C1 = Cf ( 1 - Cs )
|
|
||||||
* A1 = Af ( 1 - As )
|
|
||||||
*/
|
|
||||||
*reg = (TD0_color_arg1_inv_enable |
|
|
||||||
TD0_color_arg2_diffuse |
|
|
||||||
TD0_color_sel_mul |
|
|
||||||
TD0_alpha_arg1_inv_enable |
|
|
||||||
TD0_alpha_arg2_diffuse |
|
|
||||||
TD0_alpha_sel_mul);
|
|
||||||
/* Cv = C1
|
|
||||||
* Av = A1 + As
|
|
||||||
*/
|
|
||||||
*(reg+1) = (TD0_color_arg2_prevstage |
|
|
||||||
TD0_color_sel_arg2 |
|
|
||||||
TD0_alpha_arg2_prevstage |
|
|
||||||
TD0_alpha_add_enable |
|
|
||||||
TD0_alpha_sel_add);
|
|
||||||
mmesa->dualtex_env = GL_TRUE;
|
|
||||||
} else {
|
|
||||||
t->texenv_fallback = GL_TRUE;
|
t->texenv_fallback = GL_TRUE;
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (mmesa->blend_flags & MGA_BLEND_RGB_ONE &&
|
|
||||||
ctx->Texture._EnabledUnits != 0x03) {
|
|
||||||
if (format == GL_RGB || format == GL_LUMINANCE) {
|
|
||||||
/* C1 = Cf ( 1 - Cs )
|
|
||||||
* A1 = Af
|
|
||||||
*/
|
|
||||||
*reg = (TD0_color_arg1_inv_enable |
|
|
||||||
TD0_color_arg2_diffuse |
|
|
||||||
TD0_color_sel_mul |
|
|
||||||
TD0_alpha_arg2_diffuse |
|
|
||||||
TD0_alpha_sel_arg2);
|
|
||||||
/* Cv = C1 + Cs
|
|
||||||
* Av = A1
|
|
||||||
*/
|
|
||||||
*(reg+1) = (TD0_color_arg2_prevstage |
|
|
||||||
TD0_color_add_add |
|
|
||||||
TD0_color_sel_add |
|
|
||||||
TD0_alpha_arg2_prevstage |
|
|
||||||
TD0_alpha_sel_arg2);
|
|
||||||
mmesa->dualtex_env = GL_TRUE;
|
|
||||||
} else if (format == GL_RGBA || format == GL_LUMINANCE_ALPHA) {
|
|
||||||
/* C1 = Cf ( 1 - Cs )
|
|
||||||
* A1 = Af As
|
|
||||||
*/
|
|
||||||
*reg = (TD0_color_arg1_inv_enable |
|
|
||||||
TD0_color_arg2_diffuse |
|
|
||||||
TD0_color_sel_mul |
|
|
||||||
TD0_alpha_arg2_diffuse |
|
|
||||||
TD0_alpha_sel_mul);
|
|
||||||
/* Cv = C1 + Cs
|
|
||||||
* Av = A1
|
|
||||||
*/
|
|
||||||
*(reg+1) = (TD0_color_arg2_prevstage |
|
|
||||||
TD0_color_add_add |
|
|
||||||
TD0_color_sel_add |
|
|
||||||
TD0_alpha_arg2_prevstage |
|
|
||||||
TD0_alpha_sel_arg2);
|
|
||||||
mmesa->dualtex_env = GL_TRUE;
|
|
||||||
} else if (format == GL_INTENSITY) {
|
|
||||||
if (mmesa->blend_flags & MGA_BLEND_ALPHA_ZERO) {
|
|
||||||
/* C1 = Cf ( 1 - Cs )
|
|
||||||
* A1 = Af ( 1 - As )
|
|
||||||
*/
|
|
||||||
*reg = (TD0_color_arg1_inv_enable |
|
|
||||||
TD0_color_arg2_diffuse |
|
|
||||||
TD0_color_sel_mul |
|
|
||||||
TD0_alpha_arg1_inv_enable |
|
|
||||||
TD0_alpha_arg2_diffuse |
|
|
||||||
TD0_alpha_sel_mul);
|
|
||||||
/* Cv = C1 + Cs
|
|
||||||
* Av = A1
|
|
||||||
*/
|
|
||||||
*(reg+1) = (TD0_color_arg2_prevstage |
|
|
||||||
TD0_color_add_add |
|
|
||||||
TD0_color_sel_add |
|
|
||||||
TD0_alpha_arg2_prevstage |
|
|
||||||
TD0_alpha_sel_arg2);
|
|
||||||
mmesa->dualtex_env = GL_TRUE;
|
|
||||||
} else if (mmesa->blend_flags & MGA_BLEND_ALPHA_ONE) {
|
|
||||||
/* C1 = Cf ( 1 - Cs )
|
|
||||||
* A1 = Af ( 1 - As )
|
|
||||||
*/
|
|
||||||
*reg = (TD0_color_arg1_inv_enable |
|
|
||||||
TD0_color_arg2_diffuse |
|
|
||||||
TD0_color_sel_mul |
|
|
||||||
TD0_alpha_arg1_inv_enable |
|
|
||||||
TD0_alpha_arg2_diffuse |
|
|
||||||
TD0_alpha_sel_mul);
|
|
||||||
/* Cv = C1 + Cs
|
|
||||||
* Av = A1 + As
|
|
||||||
*/
|
|
||||||
*(reg+1) = (TD0_color_arg2_prevstage |
|
|
||||||
TD0_color_add_add |
|
|
||||||
TD0_color_sel_add |
|
|
||||||
TD0_alpha_arg2_prevstage |
|
|
||||||
TD0_alpha_add_enable |
|
|
||||||
TD0_alpha_sel_add);
|
|
||||||
mmesa->dualtex_env = GL_TRUE;
|
|
||||||
} else {
|
|
||||||
t->texenv_fallback = GL_TRUE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
t->texenv_fallback = GL_TRUE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case GL_COMBINE_EXT:
|
|
||||||
|
case GL_COMBINE:
|
||||||
if (!mgaUpdateTextureEnvCombine(ctx, unit))
|
if (!mgaUpdateTextureEnvCombine(ctx, unit))
|
||||||
t->texenv_fallback = GL_TRUE;
|
t->texenv_fallback = GL_TRUE;
|
||||||
break;
|
break;
|
||||||
|
@ -816,7 +737,7 @@ static void disable_tex( GLcontext *ctx, int unit )
|
||||||
mmesa->CurrentTexObj[unit] = NULL;
|
mmesa->CurrentTexObj[unit] = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( unit != 0 && !mmesa->dualtex_env ) {
|
if ( unit != 0 && !mmesa->force_dualtex ) {
|
||||||
mmesa->setup.tdualstage1 = mmesa->setup.tdualstage0;
|
mmesa->setup.tdualstage1 = mmesa->setup.tdualstage0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -887,11 +808,6 @@ static GLboolean update_tex_common( GLcontext *ctx, int unit )
|
||||||
mmesa->setup.tdualstage1 = mmesa->setup.tdualstage0;
|
mmesa->setup.tdualstage1 = mmesa->setup.tdualstage0;
|
||||||
}
|
}
|
||||||
|
|
||||||
t->setup.texctl2 &= TMC_dualtex_MASK;
|
|
||||||
if (ctx->Texture._EnabledUnits == 0x03) {
|
|
||||||
t->setup.texctl2 |= TMC_dualtex_enable;
|
|
||||||
}
|
|
||||||
|
|
||||||
t->texenv_fallback = GL_FALSE;
|
t->texenv_fallback = GL_FALSE;
|
||||||
|
|
||||||
/* Set this before mgaUpdateTextureEnvG400() since
|
/* Set this before mgaUpdateTextureEnvG400() since
|
||||||
|
@ -914,23 +830,14 @@ static GLboolean update_tex_common( GLcontext *ctx, int unit )
|
||||||
|
|
||||||
mgaUpdateTextureEnvG400( ctx, unit );
|
mgaUpdateTextureEnvG400( ctx, unit );
|
||||||
} else {
|
} else {
|
||||||
mmesa->hw.alpha_sel = 0;
|
|
||||||
switch (ctx->Texture.Unit[0].EnvMode) {
|
|
||||||
case GL_DECAL:
|
|
||||||
mmesa->hw.alpha_sel |= AC_alphasel_diffused;
|
|
||||||
case GL_REPLACE:
|
|
||||||
mmesa->hw.alpha_sel |= AC_alphasel_fromtex;
|
|
||||||
break;
|
|
||||||
case GL_BLEND:
|
|
||||||
case GL_MODULATE:
|
|
||||||
mmesa->hw.alpha_sel |= AC_alphasel_modulated;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
mgaUpdateTextureEnvG200( ctx, unit );
|
mgaUpdateTextureEnvG200( ctx, unit );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
t->setup.texctl2 &= TMC_dualtex_MASK;
|
||||||
|
if (ctx->Texture._EnabledUnits == 0x03 || mmesa->force_dualtex) {
|
||||||
|
t->setup.texctl2 |= TMC_dualtex_enable;
|
||||||
|
}
|
||||||
|
|
||||||
mmesa->dirty |= MGA_UPLOAD_CONTEXT | (MGA_UPLOAD_TEX0 << unit);
|
mmesa->dirty |= MGA_UPLOAD_CONTEXT | (MGA_UPLOAD_TEX0 << unit);
|
||||||
|
|
||||||
FALLBACK( ctx, MGA_FALLBACK_BORDER_MODE, t->border_fallback );
|
FALLBACK( ctx, MGA_FALLBACK_BORDER_MODE, t->border_fallback );
|
||||||
|
@ -967,7 +874,8 @@ void mgaUpdateTextureState( GLcontext *ctx )
|
||||||
GLboolean ok;
|
GLboolean ok;
|
||||||
unsigned i;
|
unsigned i;
|
||||||
|
|
||||||
mmesa->dualtex_env = GL_FALSE;
|
mmesa->force_dualtex = GL_FALSE;
|
||||||
|
mmesa->fcol_used = GL_FALSE;
|
||||||
|
|
||||||
/* This works around a quirk with the MGA hardware. If only OpenGL
|
/* This works around a quirk with the MGA hardware. If only OpenGL
|
||||||
* TEXTURE1 is enabled, then the hardware TEXTURE0 must be used. The
|
* TEXTURE1 is enabled, then the hardware TEXTURE0 must be used. The
|
||||||
|
|
|
@ -26,8 +26,6 @@
|
||||||
* Keith Whitwell <keith@tungstengraphics.com>
|
* Keith Whitwell <keith@tungstengraphics.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef GLX_DIRECT_RENDERING
|
|
||||||
|
|
||||||
#include "mga_common.h"
|
#include "mga_common.h"
|
||||||
#include "mga_xmesa.h"
|
#include "mga_xmesa.h"
|
||||||
#include "context.h"
|
#include "context.h"
|
||||||
|
@ -70,8 +68,12 @@ DRI_CONF_BEGIN
|
||||||
DRI_CONF_SECTION_PERFORMANCE
|
DRI_CONF_SECTION_PERFORMANCE
|
||||||
DRI_CONF_VBLANK_MODE(DRI_CONF_VBLANK_DEF_INTERVAL_0)
|
DRI_CONF_VBLANK_MODE(DRI_CONF_VBLANK_DEF_INTERVAL_0)
|
||||||
DRI_CONF_SECTION_END
|
DRI_CONF_SECTION_END
|
||||||
|
DRI_CONF_SECTION_QUALITY
|
||||||
|
DRI_CONF_TEXTURE_DEPTH(DRI_CONF_TEXTURE_DEPTH_FB)
|
||||||
|
DRI_CONF_COLOR_REDUCTION(DRI_CONF_COLOR_REDUCTION_DITHER)
|
||||||
|
DRI_CONF_SECTION_END
|
||||||
DRI_CONF_END;
|
DRI_CONF_END;
|
||||||
const GLuint __driNConfigOptions = 1;
|
const GLuint __driNConfigOptions = 3;
|
||||||
|
|
||||||
#ifndef MGA_DEBUG
|
#ifndef MGA_DEBUG
|
||||||
int MGA_DEBUG = 0;
|
int MGA_DEBUG = 0;
|
||||||
|
@ -130,10 +132,12 @@ mgaInitDriver(__DRIscreenPrivate *sPriv)
|
||||||
(*glx_enable_extension)( psc, "GLX_MESA_swap_control" );
|
(*glx_enable_extension)( psc, "GLX_MESA_swap_control" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
(*glx_enable_extension)( psc, "GLX_SGI_make_current_read" );
|
||||||
(*glx_enable_extension)( psc, "GLX_MESA_swap_frame_usage" );
|
(*glx_enable_extension)( psc, "GLX_MESA_swap_frame_usage" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (serverInfo->chipset != MGA_CARD_TYPE_G200 &&
|
if (serverInfo->chipset != MGA_CARD_TYPE_G200 &&
|
||||||
serverInfo->chipset != MGA_CARD_TYPE_G400) {
|
serverInfo->chipset != MGA_CARD_TYPE_G400) {
|
||||||
FREE(mgaScreen);
|
FREE(mgaScreen);
|
||||||
|
@ -301,6 +305,7 @@ static const char * const card_extensions[] =
|
||||||
{
|
{
|
||||||
"GL_ARB_multisample",
|
"GL_ARB_multisample",
|
||||||
"GL_ARB_texture_compression",
|
"GL_ARB_texture_compression",
|
||||||
|
"GL_EXT_blend_logic_op",
|
||||||
"GL_EXT_fog_coord",
|
"GL_EXT_fog_coord",
|
||||||
/* paletted_textures currently doesn't work, but we could fix them later */
|
/* paletted_textures currently doesn't work, but we could fix them later */
|
||||||
#if 0
|
#if 0
|
||||||
|
@ -328,7 +333,7 @@ static const struct dri_debug_control debug_control[] =
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
get_ust_nop( uint64_t * ust )
|
get_ust_nop( int64_t * ust )
|
||||||
{
|
{
|
||||||
*ust = 1;
|
*ust = 1;
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -378,7 +383,6 @@ mgaCreateContext( const __GLcontextModes *mesaVis,
|
||||||
mmesa->mgaScreen = mgaScreen;
|
mmesa->mgaScreen = mgaScreen;
|
||||||
mmesa->driScreen = sPriv;
|
mmesa->driScreen = sPriv;
|
||||||
mmesa->sarea = (void *)saPriv;
|
mmesa->sarea = (void *)saPriv;
|
||||||
mmesa->glBuffer = NULL;
|
|
||||||
|
|
||||||
/* Parse configuration files */
|
/* Parse configuration files */
|
||||||
driParseConfigFiles (&mmesa->optionCache, &mgaScreen->optionCache,
|
driParseConfigFiles (&mmesa->optionCache, &mgaScreen->optionCache,
|
||||||
|
@ -432,7 +436,11 @@ mgaCreateContext( const __GLcontextModes *mesaVis,
|
||||||
ctx->Const.MaxLineWidthAA = 10.0;
|
ctx->Const.MaxLineWidthAA = 10.0;
|
||||||
ctx->Const.LineWidthGranularity = 1.0;
|
ctx->Const.LineWidthGranularity = 1.0;
|
||||||
|
|
||||||
mmesa->default32BitTextures = (mesaVis->rgbBits >= 24);
|
mmesa->texture_depth = driQueryOptioni (&mmesa->optionCache,
|
||||||
|
"texture_depth");
|
||||||
|
if (mmesa->texture_depth == DRI_CONF_TEXTURE_DEPTH_FB)
|
||||||
|
mmesa->texture_depth = ( mesaVis->rgbBits >= 24 ) ?
|
||||||
|
DRI_CONF_TEXTURE_DEPTH_32 : DRI_CONF_TEXTURE_DEPTH_16;
|
||||||
mmesa->hw_stencil = mesaVis->stencilBits && mesaVis->depthBits == 24;
|
mmesa->hw_stencil = mesaVis->stencilBits && mesaVis->depthBits == 24;
|
||||||
|
|
||||||
switch (mesaVis->depthBits) {
|
switch (mesaVis->depthBits) {
|
||||||
|
@ -616,6 +624,24 @@ mgaDestroyBuffer(__DRIdrawablePrivate *driDrawPriv)
|
||||||
_mesa_destroy_framebuffer((GLframebuffer *) (driDrawPriv->driverPrivate));
|
_mesa_destroy_framebuffer((GLframebuffer *) (driDrawPriv->driverPrivate));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
mgaSwapBuffers(__DRIdrawablePrivate *dPriv)
|
||||||
|
{
|
||||||
|
if (dPriv->driContextPriv && dPriv->driContextPriv->driverPrivate) {
|
||||||
|
mgaContextPtr mmesa;
|
||||||
|
GLcontext *ctx;
|
||||||
|
mmesa = (mgaContextPtr) dPriv->driContextPriv->driverPrivate;
|
||||||
|
ctx = mmesa->glCtx;
|
||||||
|
|
||||||
|
if (ctx->Visual.doubleBufferMode) {
|
||||||
|
_mesa_notifySwapBuffers( ctx );
|
||||||
|
mgaCopyBuffer( dPriv );
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
/* XXX this shouldn't be an error but we can't handle it for now */
|
||||||
|
_mesa_problem(NULL, "%s: drawable has no context!\n", __FUNCTION__);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static GLboolean
|
static GLboolean
|
||||||
mgaUnbindContext(__DRIcontextPrivate *driContextPriv)
|
mgaUnbindContext(__DRIcontextPrivate *driContextPriv)
|
||||||
|
@ -653,8 +679,11 @@ mgaMakeCurrent(__DRIcontextPrivate *driContextPriv,
|
||||||
mmesa->driDrawable = driDrawPriv;
|
mmesa->driDrawable = driDrawPriv;
|
||||||
mmesa->dirty = ~0;
|
mmesa->dirty = ~0;
|
||||||
mmesa->dirty_cliprects = (MGA_FRONT|MGA_BACK);
|
mmesa->dirty_cliprects = (MGA_FRONT|MGA_BACK);
|
||||||
|
mmesa->mesa_drawable = driDrawPriv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mmesa->driReadable = driReadPriv;
|
||||||
|
|
||||||
_mesa_make_current2(mmesa->glCtx,
|
_mesa_make_current2(mmesa->glCtx,
|
||||||
(GLframebuffer *) driDrawPriv->driverPrivate,
|
(GLframebuffer *) driDrawPriv->driverPrivate,
|
||||||
(GLframebuffer *) driReadPriv->driverPrivate);
|
(GLframebuffer *) driReadPriv->driverPrivate);
|
||||||
|
@ -775,4 +804,3 @@ getSwapInfo( __DRIdrawablePrivate *dPriv, __DRIswapInfo * sInfo )
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
|
@ -32,10 +32,10 @@
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include "dri_util.h"
|
#include "dri_util.h"
|
||||||
#include "mtypes.h"
|
#include "mtypes.h"
|
||||||
#include "colormac.h"
|
|
||||||
#include "xf86drm.h"
|
#include "xf86drm.h"
|
||||||
#include "mm.h"
|
#include "mm.h"
|
||||||
#include "mga_sarea.h"
|
#include "mga_sarea.h"
|
||||||
|
#include "colormac.h"
|
||||||
#include "texmem.h"
|
#include "texmem.h"
|
||||||
#include "macros.h"
|
#include "macros.h"
|
||||||
#include "xmlconfig.h"
|
#include "xmlconfig.h"
|
||||||
|
@ -57,7 +57,7 @@
|
||||||
#define MGA_FALLBACK_TEXTURE 0x1
|
#define MGA_FALLBACK_TEXTURE 0x1
|
||||||
#define MGA_FALLBACK_DRAW_BUFFER 0x2
|
#define MGA_FALLBACK_DRAW_BUFFER 0x2
|
||||||
#define MGA_FALLBACK_READ_BUFFER 0x4
|
#define MGA_FALLBACK_READ_BUFFER 0x4
|
||||||
#define MGA_FALLBACK_LOGICOP 0x8
|
#define MGA_FALLBACK_BLEND 0x8
|
||||||
#define MGA_FALLBACK_RENDERMODE 0x10
|
#define MGA_FALLBACK_RENDERMODE 0x10
|
||||||
#define MGA_FALLBACK_STENCIL 0x20
|
#define MGA_FALLBACK_STENCIL 0x20
|
||||||
#define MGA_FALLBACK_DEPTH 0x40
|
#define MGA_FALLBACK_DEPTH 0x40
|
||||||
|
@ -80,12 +80,14 @@ typedef void (*mga_point_func)( mgaContextPtr, mgaVertex * );
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* GL_BLEND has some limitations
|
/* Texture environment color
|
||||||
*/
|
*/
|
||||||
#define MGA_BLEND_RGB_ZERO 0x1
|
#define RGB_ZERO(c) (((c) & 0xffffff) == 0x000000)
|
||||||
#define MGA_BLEND_RGB_ONE 0x2
|
#define RGB_ONE(c) (((c) & 0xffffff) == 0xffffff)
|
||||||
#define MGA_BLEND_ALPHA_ZERO 0x4
|
#define ALPHA_ZERO(c) (((c) >> 24) == 0x00)
|
||||||
#define MGA_BLEND_ALPHA_ONE 0x8
|
#define ALPHA_ONE(c) (((c) >> 24) == 0xff)
|
||||||
|
#define RGBA_EQUAL(c) ((c) == PACK_COLOR_8888( (c) & 0xff, (c) & 0xff, \
|
||||||
|
(c) & 0xff, (c) & 0xff ))
|
||||||
|
|
||||||
struct mga_texture_object_s;
|
struct mga_texture_object_s;
|
||||||
struct mga_screen_private_s;
|
struct mga_screen_private_s;
|
||||||
|
@ -197,7 +199,7 @@ struct mga_context_t {
|
||||||
*/
|
*/
|
||||||
GLuint tmu_source[2];
|
GLuint tmu_source[2];
|
||||||
|
|
||||||
GLboolean default32BitTextures;
|
int texture_depth;
|
||||||
|
|
||||||
/* Manage fallbacks
|
/* Manage fallbacks
|
||||||
*/
|
*/
|
||||||
|
@ -209,11 +211,11 @@ struct mga_context_t {
|
||||||
struct gl_client_array UbyteColor;
|
struct gl_client_array UbyteColor;
|
||||||
struct gl_client_array UbyteSecondaryColor;
|
struct gl_client_array UbyteSecondaryColor;
|
||||||
|
|
||||||
/* Support for GL_DECAL and GL_BLEND
|
/* Texture environment color.
|
||||||
*/
|
*/
|
||||||
unsigned int blend_flags;
|
unsigned int envcolor[2];
|
||||||
unsigned int envcolor;
|
GLboolean fcol_used;
|
||||||
GLboolean dualtex_env;
|
GLboolean force_dualtex;
|
||||||
|
|
||||||
/* Rasterization state
|
/* Rasterization state
|
||||||
*/
|
*/
|
||||||
|
@ -299,11 +301,19 @@ struct mga_context_t {
|
||||||
|
|
||||||
/* Mirrors of some DRI state.
|
/* Mirrors of some DRI state.
|
||||||
*/
|
*/
|
||||||
GLframebuffer *glBuffer;
|
|
||||||
drmContext hHWContext;
|
drmContext hHWContext;
|
||||||
drmLock *driHwLock;
|
drmLock *driHwLock;
|
||||||
int driFd;
|
int driFd;
|
||||||
__DRIdrawablePrivate *driDrawable;
|
__DRIdrawablePrivate *driDrawable;
|
||||||
|
__DRIdrawablePrivate *driReadable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Drawable used by Mesa for software fallbacks for reading and
|
||||||
|
* writing. It is set by Mesa's \c SetBuffer callback, and will always be
|
||||||
|
* either \c mga_context_t::driDrawable or \c mga_context_t::driReadable.
|
||||||
|
*/
|
||||||
|
__DRIdrawablePrivate *mesa_drawable;
|
||||||
|
|
||||||
__DRIscreenPrivate *driScreen;
|
__DRIscreenPrivate *driScreen;
|
||||||
struct mga_screen_private_s *mgaScreen;
|
struct mga_screen_private_s *mgaScreen;
|
||||||
MGASAREAPrivPtr sarea;
|
MGASAREAPrivPtr sarea;
|
||||||
|
|
|
@ -26,8 +26,6 @@
|
||||||
* Gareth Hughes <gareth@valinux.com>
|
* Gareth Hughes <gareth@valinux.com>
|
||||||
*/
|
*/
|
||||||
/* $XFree86: xc/lib/GL/mesa/src/drv/mga/mgaioctl.c,v 1.16 2002/12/16 16:18:52 dawes Exp $ */
|
/* $XFree86: xc/lib/GL/mesa/src/drv/mga/mgaioctl.c,v 1.16 2002/12/16 16:18:52 dawes Exp $ */
|
||||||
#include <errno.h>
|
|
||||||
#include <sched.h>
|
|
||||||
|
|
||||||
#include "mtypes.h"
|
#include "mtypes.h"
|
||||||
#include "macros.h"
|
#include "macros.h"
|
||||||
|
@ -323,7 +321,7 @@ static void mgaWaitForFrameCompletion( mgaContextPtr mmesa )
|
||||||
/*
|
/*
|
||||||
* Copy the back buffer to the front buffer.
|
* Copy the back buffer to the front buffer.
|
||||||
*/
|
*/
|
||||||
void mgaSwapBuffers( __DRIdrawablePrivate *dPriv )
|
void mgaCopyBuffer( const __DRIdrawablePrivate *dPriv )
|
||||||
{
|
{
|
||||||
mgaContextPtr mmesa;
|
mgaContextPtr mmesa;
|
||||||
XF86DRIClipRectPtr pbox;
|
XF86DRIClipRectPtr pbox;
|
||||||
|
|
|
@ -33,7 +33,7 @@
|
||||||
#include "mgacontext.h"
|
#include "mgacontext.h"
|
||||||
#include "mga_xmesa.h"
|
#include "mga_xmesa.h"
|
||||||
|
|
||||||
void mgaSwapBuffers( __DRIdrawablePrivate *dPriv );
|
void mgaCopyBuffer( const __DRIdrawablePrivate *dPriv );
|
||||||
void mgaWaitForVBlank( mgaContextPtr mmesa );
|
void mgaWaitForVBlank( mgaContextPtr mmesa );
|
||||||
|
|
||||||
GLuint *mgaAllocVertexDwords( mgaContextPtr mmesa, int dwords );
|
GLuint *mgaAllocVertexDwords( mgaContextPtr mmesa, int dwords );
|
||||||
|
|
|
@ -37,7 +37,7 @@
|
||||||
|
|
||||||
|
|
||||||
#define LOCAL_VARS \
|
#define LOCAL_VARS \
|
||||||
__DRIdrawablePrivate *dPriv = mmesa->driDrawable; \
|
__DRIdrawablePrivate *dPriv = mmesa->mesa_drawable; \
|
||||||
mgaScreenPrivate *mgaScreen = mmesa->mgaScreen; \
|
mgaScreenPrivate *mgaScreen = mmesa->mgaScreen; \
|
||||||
__DRIscreenPrivate *sPriv = mmesa->driScreen; \
|
__DRIscreenPrivate *sPriv = mmesa->driScreen; \
|
||||||
GLuint pitch = mgaScreen->frontPitch; \
|
GLuint pitch = mgaScreen->frontPitch; \
|
||||||
|
@ -56,7 +56,7 @@
|
||||||
|
|
||||||
|
|
||||||
#define LOCAL_DEPTH_VARS \
|
#define LOCAL_DEPTH_VARS \
|
||||||
__DRIdrawablePrivate *dPriv = mmesa->driDrawable; \
|
__DRIdrawablePrivate *dPriv = mmesa->mesa_drawable; \
|
||||||
mgaScreenPrivate *mgaScreen = mmesa->mgaScreen; \
|
mgaScreenPrivate *mgaScreen = mmesa->mgaScreen; \
|
||||||
__DRIscreenPrivate *sPriv = mmesa->driScreen; \
|
__DRIscreenPrivate *sPriv = mmesa->driScreen; \
|
||||||
GLuint pitch = mgaScreen->frontPitch; \
|
GLuint pitch = mgaScreen->frontPitch; \
|
||||||
|
@ -242,20 +242,22 @@ static void mgaDDSetBuffer(GLcontext *ctx, GLframebuffer *buffer,
|
||||||
GLuint bufferBit)
|
GLuint bufferBit)
|
||||||
{
|
{
|
||||||
mgaContextPtr mmesa = MGA_CONTEXT(ctx);
|
mgaContextPtr mmesa = MGA_CONTEXT(ctx);
|
||||||
|
unsigned int offset;
|
||||||
|
|
||||||
if (bufferBit == FRONT_LEFT_BIT)
|
assert( (bufferBit == FRONT_LEFT_BIT) || (bufferBit == BACK_LEFT_BIT) );
|
||||||
{
|
|
||||||
mmesa->drawOffset = mmesa->mgaScreen->frontOffset;
|
offset = (bufferBit == FRONT_LEFT_BIT)
|
||||||
mmesa->readOffset = mmesa->mgaScreen->frontOffset;
|
? mmesa->mgaScreen->frontOffset
|
||||||
}
|
: mmesa->mgaScreen->backOffset;
|
||||||
else if (bufferBit == BACK_LEFT_BIT)
|
|
||||||
{
|
mmesa->drawOffset = offset;
|
||||||
mmesa->drawOffset = mmesa->mgaScreen->backOffset;
|
mmesa->readOffset = offset;
|
||||||
mmesa->readOffset = mmesa->mgaScreen->backOffset;
|
|
||||||
}
|
assert( (buffer == mmesa->driDrawable->driverPrivate)
|
||||||
else {
|
|| (buffer == mmesa->driReadable->driverPrivate) );
|
||||||
assert(0);
|
|
||||||
}
|
mmesa->mesa_drawable = (buffer == mmesa->driDrawable->driverPrivate)
|
||||||
|
? mmesa->driDrawable : mmesa->driReadable;
|
||||||
}
|
}
|
||||||
|
|
||||||
void mgaDDInitSpanFuncs( GLcontext *ctx )
|
void mgaDDInitSpanFuncs( GLcontext *ctx )
|
||||||
|
|
|
@ -48,13 +48,10 @@
|
||||||
#include "tnl/t_pipeline.h"
|
#include "tnl/t_pipeline.h"
|
||||||
#include "swrast_setup/swrast_setup.h"
|
#include "swrast_setup/swrast_setup.h"
|
||||||
|
|
||||||
|
#include "xmlpool.h"
|
||||||
|
|
||||||
static void updateSpecularLighting( GLcontext *ctx );
|
static void updateSpecularLighting( GLcontext *ctx );
|
||||||
|
|
||||||
|
|
||||||
/* Some outstanding problems with accelerating logic ops...
|
|
||||||
*/
|
|
||||||
#if defined(ACCEL_ROP)
|
|
||||||
static const GLuint mgarop_NoBLK[16] = {
|
static const GLuint mgarop_NoBLK[16] = {
|
||||||
DC_atype_rpl | 0x00000000, DC_atype_rstr | 0x00080000,
|
DC_atype_rpl | 0x00000000, DC_atype_rstr | 0x00080000,
|
||||||
DC_atype_rstr | 0x00040000, DC_atype_rpl | 0x000c0000,
|
DC_atype_rstr | 0x00040000, DC_atype_rpl | 0x000c0000,
|
||||||
|
@ -65,8 +62,6 @@ static const GLuint mgarop_NoBLK[16] = {
|
||||||
DC_atype_rpl | 0x00030000, DC_atype_rstr | 0x000b0000,
|
DC_atype_rpl | 0x00030000, DC_atype_rstr | 0x000b0000,
|
||||||
DC_atype_rstr | 0x00070000, DC_atype_rpl | 0x000f0000
|
DC_atype_rstr | 0x00070000, DC_atype_rpl | 0x000f0000
|
||||||
};
|
};
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/* =============================================================
|
/* =============================================================
|
||||||
* Alpha blending
|
* Alpha blending
|
||||||
|
@ -111,27 +106,32 @@ static void mgaDDAlphaFunc(GLcontext *ctx, GLenum func, GLfloat ref)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
FLUSH_BATCH( mmesa );
|
MGA_STATECHANGE( mmesa, MGA_UPLOAD_CONTEXT );
|
||||||
mmesa->hw.alpha_func = a | MGA_FIELD( AC_atref, refByte );
|
mmesa->hw.alpha_func = a | MGA_FIELD( AC_atref, refByte );
|
||||||
mmesa->dirty |= MGA_UPLOAD_CONTEXT;
|
}
|
||||||
|
|
||||||
|
static void updateBlendLogicOp(GLcontext *ctx)
|
||||||
|
{
|
||||||
|
mgaContextPtr mmesa = MGA_CONTEXT(ctx);
|
||||||
|
|
||||||
|
MGA_STATECHANGE( mmesa, MGA_UPLOAD_CONTEXT );
|
||||||
|
|
||||||
|
mmesa->hw.blend_func_enable =
|
||||||
|
(ctx->Color.BlendEnabled && !ctx->Color._LogicOpEnabled) ? ~0 : 0;
|
||||||
|
|
||||||
|
FALLBACK( ctx, MGA_FALLBACK_BLEND,
|
||||||
|
ctx->Color.BlendEnabled && !ctx->Color._LogicOpEnabled &&
|
||||||
|
mmesa->hw.blend_func == (AC_src_src_alpha_sat | AC_dst_zero) );
|
||||||
}
|
}
|
||||||
|
|
||||||
static void mgaDDBlendEquation(GLcontext *ctx, GLenum mode)
|
static void mgaDDBlendEquation(GLcontext *ctx, GLenum mode)
|
||||||
{
|
{
|
||||||
FLUSH_BATCH( MGA_CONTEXT(ctx) );
|
updateBlendLogicOp( ctx );
|
||||||
|
|
||||||
/* BlendEquation sets ColorLogicOpEnabled in an unexpected
|
|
||||||
* manner.
|
|
||||||
*/
|
|
||||||
FALLBACK( ctx, MGA_FALLBACK_LOGICOP,
|
|
||||||
(ctx->Color.ColorLogicOpEnabled &&
|
|
||||||
ctx->Color.LogicOp != GL_COPY));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void mgaDDBlendFunc(GLcontext *ctx, GLenum sfactor, GLenum dfactor)
|
static void mgaDDBlendFunc(GLcontext *ctx, GLenum sfactor, GLenum dfactor)
|
||||||
{
|
{
|
||||||
mgaContextPtr mmesa = MGA_CONTEXT(ctx);
|
mgaContextPtr mmesa = MGA_CONTEXT(ctx);
|
||||||
mgaScreenPrivate *mgaScreen = mmesa->mgaScreen;
|
|
||||||
GLuint src;
|
GLuint src;
|
||||||
GLuint dst;
|
GLuint dst;
|
||||||
|
|
||||||
|
@ -150,11 +150,11 @@ static void mgaDDBlendFunc(GLcontext *ctx, GLenum sfactor, GLenum dfactor)
|
||||||
case GL_ONE_MINUS_SRC_ALPHA:
|
case GL_ONE_MINUS_SRC_ALPHA:
|
||||||
src = AC_src_om_src_alpha; break;
|
src = AC_src_om_src_alpha; break;
|
||||||
case GL_DST_ALPHA:
|
case GL_DST_ALPHA:
|
||||||
src = (mgaScreen->cpp == 4)
|
src = (ctx->Visual.alphaBits > 0)
|
||||||
? AC_src_dst_alpha : AC_src_one;
|
? AC_src_dst_alpha : AC_src_one;
|
||||||
break;
|
break;
|
||||||
case GL_ONE_MINUS_DST_ALPHA:
|
case GL_ONE_MINUS_DST_ALPHA:
|
||||||
src = (mgaScreen->cpp == 4)
|
src = (ctx->Visual.alphaBits > 0)
|
||||||
? AC_src_om_dst_alpha : AC_src_zero;
|
? AC_src_om_dst_alpha : AC_src_zero;
|
||||||
break;
|
break;
|
||||||
case GL_SRC_ALPHA_SATURATE:
|
case GL_SRC_ALPHA_SATURATE:
|
||||||
|
@ -178,18 +178,21 @@ static void mgaDDBlendFunc(GLcontext *ctx, GLenum sfactor, GLenum dfactor)
|
||||||
case GL_ONE_MINUS_SRC_COLOR:
|
case GL_ONE_MINUS_SRC_COLOR:
|
||||||
dst = AC_dst_om_src_color; break;
|
dst = AC_dst_om_src_color; break;
|
||||||
case GL_DST_ALPHA:
|
case GL_DST_ALPHA:
|
||||||
dst = (mgaScreen->cpp == 4)
|
dst = (ctx->Visual.alphaBits > 0)
|
||||||
? AC_dst_dst_alpha : AC_dst_one;
|
? AC_dst_dst_alpha : AC_dst_one;
|
||||||
break;
|
break;
|
||||||
case GL_ONE_MINUS_DST_ALPHA:
|
case GL_ONE_MINUS_DST_ALPHA:
|
||||||
dst = (mgaScreen->cpp == 4)
|
dst = (ctx->Visual.alphaBits > 0)
|
||||||
? AC_dst_om_dst_alpha : AC_dst_zero;
|
? AC_dst_om_dst_alpha : AC_dst_zero;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
FLUSH_BATCH( mmesa );
|
MGA_STATECHANGE( mmesa, MGA_UPLOAD_CONTEXT );
|
||||||
mmesa->hw.blend_func = (src | dst);
|
mmesa->hw.blend_func = (src | dst);
|
||||||
mmesa->dirty |= MGA_UPLOAD_CONTEXT;
|
|
||||||
|
FALLBACK( ctx, MGA_FALLBACK_BLEND,
|
||||||
|
ctx->Color.BlendEnabled && !ctx->Color._LogicOpEnabled &&
|
||||||
|
mmesa->hw.blend_func == (AC_src_src_alpha_sat | AC_dst_zero) );
|
||||||
}
|
}
|
||||||
|
|
||||||
static void mgaDDBlendFuncSeparate( GLcontext *ctx, GLenum sfactorRGB,
|
static void mgaDDBlendFuncSeparate( GLcontext *ctx, GLenum sfactorRGB,
|
||||||
|
@ -199,7 +202,6 @@ static void mgaDDBlendFuncSeparate( GLcontext *ctx, GLenum sfactorRGB,
|
||||||
mgaDDBlendFunc( ctx, sfactorRGB, dfactorRGB );
|
mgaDDBlendFunc( ctx, sfactorRGB, dfactorRGB );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* =============================================================
|
/* =============================================================
|
||||||
* Depth testing
|
* Depth testing
|
||||||
*/
|
*/
|
||||||
|
@ -233,10 +235,9 @@ static void mgaDDDepthFunc(GLcontext *ctx, GLenum func)
|
||||||
zmode = 0; break;
|
zmode = 0; break;
|
||||||
}
|
}
|
||||||
|
|
||||||
FLUSH_BATCH( mmesa );
|
MGA_STATECHANGE( mmesa, MGA_UPLOAD_CONTEXT );
|
||||||
mmesa->hw.zmode &= DC_zmode_MASK;
|
mmesa->hw.zmode &= DC_zmode_MASK;
|
||||||
mmesa->hw.zmode |= zmode;
|
mmesa->hw.zmode |= zmode;
|
||||||
mmesa->dirty |= MGA_UPLOAD_CONTEXT;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void mgaDDDepthMask(GLcontext *ctx, GLboolean flag)
|
static void mgaDDDepthMask(GLcontext *ctx, GLboolean flag)
|
||||||
|
@ -244,10 +245,9 @@ static void mgaDDDepthMask(GLcontext *ctx, GLboolean flag)
|
||||||
mgaContextPtr mmesa = MGA_CONTEXT( ctx );
|
mgaContextPtr mmesa = MGA_CONTEXT( ctx );
|
||||||
|
|
||||||
|
|
||||||
FLUSH_BATCH( mmesa );
|
MGA_STATECHANGE( mmesa, MGA_UPLOAD_CONTEXT );
|
||||||
mmesa->hw.zmode &= DC_atype_MASK;
|
mmesa->hw.zmode &= DC_atype_MASK;
|
||||||
mmesa->hw.zmode |= (flag) ? DC_atype_zi : DC_atype_i;
|
mmesa->hw.zmode |= (flag) ? DC_atype_zi : DC_atype_i;
|
||||||
mmesa->dirty |= MGA_UPLOAD_CONTEXT;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -343,8 +343,7 @@ static void mgaDDCullFaceFrontFace(GLcontext *ctx, GLenum unused)
|
||||||
{
|
{
|
||||||
mgaContextPtr mmesa = MGA_CONTEXT(ctx);
|
mgaContextPtr mmesa = MGA_CONTEXT(ctx);
|
||||||
|
|
||||||
|
MGA_STATECHANGE( mmesa, MGA_UPLOAD_CONTEXT );
|
||||||
FLUSH_BATCH( mmesa );
|
|
||||||
if (ctx->Polygon.CullFlag &&
|
if (ctx->Polygon.CullFlag &&
|
||||||
ctx->Polygon.CullFaceMode != GL_FRONT_AND_BACK)
|
ctx->Polygon.CullFaceMode != GL_FRONT_AND_BACK)
|
||||||
{
|
{
|
||||||
|
@ -363,8 +362,6 @@ static void mgaDDCullFaceFrontFace(GLcontext *ctx, GLenum unused)
|
||||||
mmesa->hw.cull = _CULL_DISABLE;
|
mmesa->hw.cull = _CULL_DISABLE;
|
||||||
mmesa->hw.cull_dualtex = _CULL_DISABLE;
|
mmesa->hw.cull_dualtex = _CULL_DISABLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
mmesa->dirty |= MGA_UPLOAD_CONTEXT;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -494,8 +491,6 @@ static void updateSpecularLighting( GLcontext *ctx )
|
||||||
if ( specen != mmesa->hw.specen ) {
|
if ( specen != mmesa->hw.specen ) {
|
||||||
mmesa->hw.specen = specen;
|
mmesa->hw.specen = specen;
|
||||||
mmesa->dirty |= MGA_UPLOAD_TEX0 | MGA_UPLOAD_TEX1;
|
mmesa->dirty |= MGA_UPLOAD_TEX0 | MGA_UPLOAD_TEX1;
|
||||||
|
|
||||||
mgaChooseVertexState( ctx );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -527,7 +522,7 @@ static void mgaDDStencilFunc(GLcontext *ctx, GLenum func, GLint ref,
|
||||||
GLuint stencil;
|
GLuint stencil;
|
||||||
GLuint stencilctl;
|
GLuint stencilctl;
|
||||||
|
|
||||||
stencil = (ref << S_sref_SHIFT) | (mask << S_smsk_SHIFT);
|
stencil = MGA_FIELD( S_sref, ref ) | MGA_FIELD( S_smsk, mask );
|
||||||
switch (func)
|
switch (func)
|
||||||
{
|
{
|
||||||
case GL_NEVER:
|
case GL_NEVER:
|
||||||
|
@ -557,22 +552,20 @@ static void mgaDDStencilFunc(GLcontext *ctx, GLenum func, GLint ref,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
FLUSH_BATCH( mmesa );
|
MGA_STATECHANGE( mmesa, MGA_UPLOAD_CONTEXT );
|
||||||
mmesa->hw.stencil &= (S_sref_MASK & S_smsk_MASK);
|
mmesa->hw.stencil &= (S_sref_MASK & S_smsk_MASK);
|
||||||
mmesa->hw.stencil |= stencil;
|
mmesa->hw.stencil |= stencil;
|
||||||
mmesa->hw.stencilctl &= SC_smode_MASK;
|
mmesa->hw.stencilctl &= SC_smode_MASK;
|
||||||
mmesa->hw.stencilctl |= stencilctl;
|
mmesa->hw.stencilctl |= stencilctl;
|
||||||
mmesa->dirty |= MGA_UPLOAD_CONTEXT;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void mgaDDStencilMask(GLcontext *ctx, GLuint mask)
|
static void mgaDDStencilMask(GLcontext *ctx, GLuint mask)
|
||||||
{
|
{
|
||||||
mgaContextPtr mmesa = MGA_CONTEXT(ctx);
|
mgaContextPtr mmesa = MGA_CONTEXT(ctx);
|
||||||
|
|
||||||
FLUSH_BATCH( mmesa );
|
MGA_STATECHANGE( mmesa, MGA_UPLOAD_CONTEXT );
|
||||||
mmesa->hw.stencil &= S_swtmsk_MASK;
|
mmesa->hw.stencil &= S_swtmsk_MASK;
|
||||||
mmesa->hw.stencil |= (mask << S_swtmsk_SHIFT);
|
mmesa->hw.stencil |= MGA_FIELD( S_swtmsk, mask );
|
||||||
mmesa->dirty |= MGA_UPLOAD_CONTEXT;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void mgaDDStencilOp(GLcontext *ctx, GLenum fail, GLenum zfail,
|
static void mgaDDStencilOp(GLcontext *ctx, GLenum fail, GLenum zfail,
|
||||||
|
@ -672,11 +665,10 @@ static void mgaDDStencilOp(GLcontext *ctx, GLenum fail, GLenum zfail,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
FLUSH_BATCH( mmesa );
|
MGA_STATECHANGE( mmesa, MGA_UPLOAD_CONTEXT );
|
||||||
mmesa->hw.stencilctl &= (SC_sfailop_MASK & SC_szfailop_MASK
|
mmesa->hw.stencilctl &= (SC_sfailop_MASK & SC_szfailop_MASK
|
||||||
& SC_szpassop_MASK);
|
& SC_szpassop_MASK);
|
||||||
mmesa->hw.stencilctl |= stencilctl;
|
mmesa->hw.stencilctl |= stencilctl;
|
||||||
mmesa->dirty |= MGA_UPLOAD_CONTEXT;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -747,14 +739,8 @@ static void mgaDDLogicOp( GLcontext *ctx, GLenum opcode )
|
||||||
{
|
{
|
||||||
mgaContextPtr mmesa = MGA_CONTEXT( ctx );
|
mgaContextPtr mmesa = MGA_CONTEXT( ctx );
|
||||||
|
|
||||||
FLUSH_BATCH( mmesa );
|
MGA_STATECHANGE( mmesa, MGA_UPLOAD_CONTEXT );
|
||||||
#if defined(ACCEL_ROP)
|
|
||||||
mmesa->hw.rop = mgarop_NoBLK[ opcode & 0x0f ];
|
mmesa->hw.rop = mgarop_NoBLK[ opcode & 0x0f ];
|
||||||
mmesa->dirty |= MGA_UPLOAD_CONTEXT;
|
|
||||||
#else
|
|
||||||
FALLBACK( ctx, MGA_FALLBACK_LOGICOP,
|
|
||||||
(ctx->Color.ColorLogicOpEnabled && opcode != GL_COPY) );
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -884,27 +870,24 @@ static void mgaDDEnable(GLcontext *ctx, GLenum cap, GLboolean state)
|
||||||
mgaContextPtr mmesa = MGA_CONTEXT( ctx );
|
mgaContextPtr mmesa = MGA_CONTEXT( ctx );
|
||||||
|
|
||||||
switch(cap) {
|
switch(cap) {
|
||||||
|
case GL_DITHER:
|
||||||
|
MGA_STATECHANGE( mmesa, MGA_UPLOAD_CONTEXT );
|
||||||
|
if (!ctx->Color.DitherFlag)
|
||||||
|
mmesa->setup.maccess |= MA_nodither_enable;
|
||||||
|
else
|
||||||
|
mmesa->setup.maccess &= ~MA_nodither_enable;
|
||||||
|
break;
|
||||||
case GL_LIGHTING:
|
case GL_LIGHTING:
|
||||||
case GL_COLOR_SUM_EXT:
|
case GL_COLOR_SUM_EXT:
|
||||||
FLUSH_BATCH( mmesa );
|
FLUSH_BATCH( mmesa );
|
||||||
updateSpecularLighting( ctx );
|
updateSpecularLighting( ctx );
|
||||||
break;
|
break;
|
||||||
case GL_ALPHA_TEST:
|
case GL_ALPHA_TEST:
|
||||||
FLUSH_BATCH( mmesa );
|
MGA_STATECHANGE( mmesa, MGA_UPLOAD_CONTEXT );
|
||||||
mmesa->hw.alpha_func_enable = (state) ? ~0 : 0;
|
mmesa->hw.alpha_func_enable = (state) ? ~0 : 0;
|
||||||
break;
|
break;
|
||||||
case GL_BLEND:
|
|
||||||
FLUSH_BATCH( mmesa );
|
|
||||||
mmesa->hw.blend_func_enable = (state) ? ~0 : 0;
|
|
||||||
|
|
||||||
/* For some reason enable(GL_BLEND) affects ColorLogicOpEnabled.
|
|
||||||
*/
|
|
||||||
FALLBACK( ctx, MGA_FALLBACK_LOGICOP,
|
|
||||||
(ctx->Color.ColorLogicOpEnabled &&
|
|
||||||
ctx->Color.LogicOp != GL_COPY));
|
|
||||||
break;
|
|
||||||
case GL_DEPTH_TEST:
|
case GL_DEPTH_TEST:
|
||||||
FLUSH_BATCH( mmesa );
|
MGA_STATECHANGE( mmesa, MGA_UPLOAD_CONTEXT );
|
||||||
FALLBACK (ctx, MGA_FALLBACK_DEPTH,
|
FALLBACK (ctx, MGA_FALLBACK_DEPTH,
|
||||||
ctx->Depth.Func == GL_NEVER && ctx->Depth.Test);
|
ctx->Depth.Func == GL_NEVER && ctx->Depth.Test);
|
||||||
break;
|
break;
|
||||||
|
@ -921,8 +904,6 @@ static void mgaDDEnable(GLcontext *ctx, GLenum cap, GLboolean state)
|
||||||
mmesa->setup.maccess |= MA_fogen_enable;
|
mmesa->setup.maccess |= MA_fogen_enable;
|
||||||
else
|
else
|
||||||
mmesa->setup.maccess &= ~MA_fogen_enable;
|
mmesa->setup.maccess &= ~MA_fogen_enable;
|
||||||
|
|
||||||
mgaChooseVertexState( ctx );
|
|
||||||
break;
|
break;
|
||||||
case GL_CULL_FACE:
|
case GL_CULL_FACE:
|
||||||
mgaDDCullFaceFrontFace( ctx, 0 );
|
mgaDDCullFaceFrontFace( ctx, 0 );
|
||||||
|
@ -933,22 +914,20 @@ static void mgaDDEnable(GLcontext *ctx, GLenum cap, GLboolean state)
|
||||||
break;
|
break;
|
||||||
case GL_POLYGON_STIPPLE:
|
case GL_POLYGON_STIPPLE:
|
||||||
if (mmesa->haveHwStipple && mmesa->raster_primitive == GL_TRIANGLES) {
|
if (mmesa->haveHwStipple && mmesa->raster_primitive == GL_TRIANGLES) {
|
||||||
FLUSH_BATCH(mmesa);
|
MGA_STATECHANGE( mmesa, MGA_UPLOAD_CONTEXT );
|
||||||
mmesa->dirty |= MGA_UPLOAD_CONTEXT;
|
|
||||||
mmesa->setup.dwgctl &= ~(0xf<<20);
|
mmesa->setup.dwgctl &= ~(0xf<<20);
|
||||||
if (state)
|
if (state)
|
||||||
mmesa->setup.dwgctl |= mmesa->poly_stipple;
|
mmesa->setup.dwgctl |= mmesa->poly_stipple;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case GL_BLEND:
|
||||||
case GL_COLOR_LOGIC_OP:
|
case GL_COLOR_LOGIC_OP:
|
||||||
FLUSH_BATCH( mmesa );
|
updateBlendLogicOp( ctx );
|
||||||
#if !defined(ACCEL_ROP)
|
|
||||||
FALLBACK( ctx, MGA_FALLBACK_LOGICOP,
|
|
||||||
(state && ctx->Color.LogicOp != GL_COPY));
|
|
||||||
#endif
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GL_STENCIL_TEST:
|
case GL_STENCIL_TEST:
|
||||||
FLUSH_BATCH( mmesa );
|
MGA_STATECHANGE( mmesa, MGA_UPLOAD_CONTEXT );
|
||||||
if (mmesa->hw_stencil) {
|
if (mmesa->hw_stencil) {
|
||||||
mmesa->hw.stencil_enable = ( state ) ? ~0 : 0;
|
mmesa->hw.stencil_enable = ( state ) ? ~0 : 0;
|
||||||
}
|
}
|
||||||
|
@ -1013,23 +992,17 @@ void mgaEmitHwStateLocked( mgaContextPtr mmesa )
|
||||||
mmesa->setup.dwgctl |= (ctx->Depth.Test)
|
mmesa->setup.dwgctl |= (ctx->Depth.Test)
|
||||||
? mmesa->hw.zmode : (DC_zmode_nozcmp | DC_atype_i);
|
? mmesa->hw.zmode : (DC_zmode_nozcmp | DC_atype_i);
|
||||||
|
|
||||||
#if defined(ACCEL_ROP)
|
|
||||||
mmesa->setup.dwgctl &= DC_bop_MASK;
|
mmesa->setup.dwgctl &= DC_bop_MASK;
|
||||||
mmesa->setup.dwgctl |= (ctx->Color.ColorLogicOpEnabled)
|
mmesa->setup.dwgctl |= (ctx->Color._LogicOpEnabled)
|
||||||
? mmesa->hw.rop : mgarop_NoBLK[ GL_COPY & 0x0f ];
|
? mmesa->hw.rop : mgarop_NoBLK[ GL_COPY & 0x0f ];
|
||||||
#endif
|
|
||||||
|
|
||||||
mmesa->setup.alphactrl &= AC_src_MASK & AC_dst_MASK & AC_atmode_MASK
|
mmesa->setup.alphactrl &= AC_src_MASK & AC_dst_MASK & AC_atmode_MASK
|
||||||
& AC_atref_MASK & AC_alphasel_MASK;
|
& AC_atref_MASK & AC_alphasel_MASK;
|
||||||
mmesa->setup.alphactrl |=
|
mmesa->setup.alphactrl |=
|
||||||
((mmesa->hw.alpha_func & mmesa->hw.alpha_func_enable)
|
(mmesa->hw.alpha_func & mmesa->hw.alpha_func_enable) |
|
||||||
| ((mmesa->hw.blend_func & mmesa->hw.blend_func_enable)
|
(mmesa->hw.blend_func & mmesa->hw.blend_func_enable) |
|
||||||
| ((AC_src_one | AC_dst_zero) & ~mmesa->hw.blend_func_enable))
|
((AC_src_one | AC_dst_zero) & ~mmesa->hw.blend_func_enable) |
|
||||||
| mmesa->hw.alpha_sel
|
mmesa->hw.alpha_sel;
|
||||||
| (AC_amode_alpha_channel
|
|
||||||
| AC_astipple_disable
|
|
||||||
| AC_aten_disable
|
|
||||||
| AC_atmode_noacmp));
|
|
||||||
|
|
||||||
memcpy( &sarea->ContextState, &mmesa->setup, sizeof(mmesa->setup));
|
memcpy( &sarea->ContextState, &mmesa->setup, sizeof(mmesa->setup));
|
||||||
}
|
}
|
||||||
|
@ -1046,19 +1019,11 @@ void mgaEmitHwStateLocked( mgaContextPtr mmesa )
|
||||||
sizeof(sarea->TexState[1]));
|
sizeof(sarea->TexState[1]));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mmesa->dualtex_env) {
|
if (mmesa->dirty & (MGA_UPLOAD_TEX0 | MGA_UPLOAD_TEX1)) {
|
||||||
sarea->TexState[0].texctl2 |= TMC_dualtex_enable;
|
sarea->TexState[0].texctl2 &= ~TMC_specen_enable;
|
||||||
memcpy( &sarea->TexState[1], &sarea->TexState[0],
|
sarea->TexState[1].texctl2 &= ~TMC_specen_enable;
|
||||||
sizeof(sarea->TexState[0]) );
|
sarea->TexState[0].texctl2 |= mmesa->hw.specen;
|
||||||
mmesa->dirty |= MGA_UPLOAD_TEX1|MGA_UPLOAD_TEX0;
|
sarea->TexState[1].texctl2 |= mmesa->hw.specen;
|
||||||
} else if ( (sarea->TexState[0].texctl2 & TMC_borderen_MASK) !=
|
|
||||||
(sarea->TexState[1].texctl2 & TMC_borderen_MASK) ) {
|
|
||||||
const int borderen = sarea->TexState[1].texctl2 & ~TMC_borderen_MASK;
|
|
||||||
|
|
||||||
memcpy( &sarea->TexState[1], &sarea->TexState[0],
|
|
||||||
sizeof(sarea->TexState[0]) );
|
|
||||||
sarea->TexState[1].texctl2 |= borderen;
|
|
||||||
mmesa->dirty |= MGA_UPLOAD_TEX1|MGA_UPLOAD_TEX0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mmesa->dirty & MGA_UPLOAD_PIPE) {
|
if (mmesa->dirty & MGA_UPLOAD_PIPE) {
|
||||||
|
@ -1069,14 +1034,8 @@ void mgaEmitHwStateLocked( mgaContextPtr mmesa )
|
||||||
|
|
||||||
mmesa->sarea->dirty |= mmesa->dirty;
|
mmesa->sarea->dirty |= mmesa->dirty;
|
||||||
mmesa->dirty &= MGA_UPLOAD_CLIPRECTS;
|
mmesa->dirty &= MGA_UPLOAD_CLIPRECTS;
|
||||||
|
|
||||||
sarea->TexState[0].texctl2 &= ~TMC_specen_enable;
|
|
||||||
sarea->TexState[1].texctl2 &= ~TMC_specen_enable;
|
|
||||||
sarea->TexState[0].texctl2 |= mmesa->hw.specen;
|
|
||||||
sarea->TexState[1].texctl2 |= mmesa->hw.specen;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* =============================================================
|
/* =============================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -1155,6 +1114,9 @@ void mgaInitState( mgaContextPtr mmesa )
|
||||||
MA_tlutload_disable |
|
MA_tlutload_disable |
|
||||||
MA_nodither_disable |
|
MA_nodither_disable |
|
||||||
MA_dit555_disable);
|
MA_dit555_disable);
|
||||||
|
if (driQueryOptioni (&mmesa->optionCache, "color_reduction") !=
|
||||||
|
DRI_CONF_COLOR_REDUCTION_DITHER)
|
||||||
|
mmesa->setup.maccess |= MA_nodither_enable;
|
||||||
|
|
||||||
switch (mmesa->mgaScreen->cpp) {
|
switch (mmesa->mgaScreen->cpp) {
|
||||||
case 2:
|
case 2:
|
||||||
|
@ -1182,14 +1144,20 @@ void mgaInitState( mgaContextPtr mmesa )
|
||||||
}
|
}
|
||||||
|
|
||||||
mmesa->hw.blend_func = AC_src_one | AC_dst_zero;
|
mmesa->hw.blend_func = AC_src_one | AC_dst_zero;
|
||||||
|
mmesa->hw.blend_func_enable = 0;
|
||||||
|
mmesa->hw.alpha_func = AC_atmode_noacmp | MGA_FIELD( AC_atref, 0x00 );
|
||||||
|
mmesa->hw.alpha_func_enable = 0;
|
||||||
|
mmesa->hw.rop = mgarop_NoBLK[ GL_COPY & 0x0f ];
|
||||||
mmesa->hw.zmode = DC_zmode_zlt | DC_atype_zi;
|
mmesa->hw.zmode = DC_zmode_zlt | DC_atype_zi;
|
||||||
mmesa->hw.stencil = (0x0ff << S_smsk_SHIFT) | (0x0ff << S_swtmsk_SHIFT);
|
mmesa->hw.stencil = MGA_FIELD( S_sref, 0x00) | MGA_FIELD( S_smsk, 0xff ) |
|
||||||
|
MGA_FIELD( S_swtmsk, 0xff );
|
||||||
mmesa->hw.stencilctl = SC_smode_salways | SC_sfailop_keep
|
mmesa->hw.stencilctl = SC_smode_salways | SC_sfailop_keep
|
||||||
| SC_szfailop_keep | SC_szpassop_keep;
|
| SC_szfailop_keep | SC_szpassop_keep;
|
||||||
mmesa->hw.stencil_enable = 0;
|
mmesa->hw.stencil_enable = 0;
|
||||||
mmesa->hw.cull = _CULL_DISABLE;
|
mmesa->hw.cull = _CULL_DISABLE;
|
||||||
mmesa->hw.cull_dualtex = _CULL_DISABLE;
|
mmesa->hw.cull_dualtex = _CULL_DISABLE;
|
||||||
mmesa->hw.specen = 0;
|
mmesa->hw.specen = 0;
|
||||||
|
mmesa->hw.alpha_sel = AC_alphasel_diffused;
|
||||||
|
|
||||||
mmesa->setup.dwgctl = (DC_opcod_trap |
|
mmesa->setup.dwgctl = (DC_opcod_trap |
|
||||||
DC_linear_xy |
|
DC_linear_xy |
|
||||||
|
@ -1197,22 +1165,17 @@ void mgaInitState( mgaContextPtr mmesa )
|
||||||
DC_arzero_disable |
|
DC_arzero_disable |
|
||||||
DC_sgnzero_disable |
|
DC_sgnzero_disable |
|
||||||
DC_shftzero_enable |
|
DC_shftzero_enable |
|
||||||
(0xC << DC_bop_SHIFT) |
|
MGA_FIELD( DC_bop, 0xC ) |
|
||||||
(0x0 << DC_trans_SHIFT) |
|
MGA_FIELD( DC_trans, 0x0 ) |
|
||||||
DC_bltmod_bmonolef |
|
DC_bltmod_bmonolef |
|
||||||
DC_pattern_disable |
|
DC_pattern_disable |
|
||||||
DC_transc_disable |
|
DC_transc_disable |
|
||||||
DC_clipdis_disable);
|
DC_clipdis_disable);
|
||||||
|
|
||||||
|
|
||||||
mmesa->setup.plnwt = ~0;
|
mmesa->setup.plnwt = ~0;
|
||||||
mmesa->setup.alphactrl = ( AC_src_one |
|
mmesa->setup.alphactrl = (AC_amode_alpha_channel |
|
||||||
AC_dst_zero |
|
|
||||||
AC_amode_FCOL |
|
|
||||||
AC_astipple_disable |
|
AC_astipple_disable |
|
||||||
AC_aten_disable |
|
AC_aten_disable);
|
||||||
AC_atmode_noacmp |
|
|
||||||
AC_alphasel_fromtex );
|
|
||||||
|
|
||||||
mmesa->setup.fogcolor = PACK_COLOR_888((GLubyte)(ctx->Fog.Color[0]*255.0F),
|
mmesa->setup.fogcolor = PACK_COLOR_888((GLubyte)(ctx->Fog.Color[0]*255.0F),
|
||||||
(GLubyte)(ctx->Fog.Color[1]*255.0F),
|
(GLubyte)(ctx->Fog.Color[1]*255.0F),
|
||||||
|
@ -1224,9 +1187,8 @@ void mgaInitState( mgaContextPtr mmesa )
|
||||||
mmesa->setup.fcol = 0;
|
mmesa->setup.fcol = 0;
|
||||||
mmesa->dirty |= MGA_UPLOAD_CONTEXT;
|
mmesa->dirty |= MGA_UPLOAD_CONTEXT;
|
||||||
|
|
||||||
mmesa->envcolor = 0;
|
mmesa->envcolor[0] = 0;
|
||||||
mmesa->blend_flags = MGA_BLEND_RGB_ZERO | MGA_BLEND_ALPHA_ZERO;
|
mmesa->envcolor[1] = 0;
|
||||||
mmesa->dualtex_env = GL_FALSE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -46,6 +46,8 @@
|
||||||
|
|
||||||
#include "swrast/swrast.h"
|
#include "swrast/swrast.h"
|
||||||
|
|
||||||
|
#include "xmlpool.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the texture wrap modes.
|
* Set the texture wrap modes.
|
||||||
* Currently \c GL_REPEAT, \c GL_CLAMP and \c GL_CLAMP_TO_EDGE are supported.
|
* Currently \c GL_REPEAT, \c GL_CLAMP and \c GL_CLAMP_TO_EDGE are supported.
|
||||||
|
@ -134,9 +136,9 @@ mgaSetTexFilter( mgaTextureObjectPtr t, GLenum minf, GLenum magf )
|
||||||
/* See OpenGL 1.2 specification */
|
/* See OpenGL 1.2 specification */
|
||||||
if (magf == GL_LINEAR && (minf == GL_NEAREST_MIPMAP_NEAREST ||
|
if (magf == GL_LINEAR && (minf == GL_NEAREST_MIPMAP_NEAREST ||
|
||||||
minf == GL_NEAREST_MIPMAP_LINEAR)) {
|
minf == GL_NEAREST_MIPMAP_LINEAR)) {
|
||||||
val |= (0x20 << TF_fthres_SHIFT); /* c = 0.5 */
|
val |= MGA_FIELD( TF_fthres, 0x20 ); /* c = 0.5 */
|
||||||
} else {
|
} else {
|
||||||
val |= (0x10 << TF_fthres_SHIFT); /* c = 0 */
|
val |= MGA_FIELD( TF_fthres, 0x10 ); /* c = 0 */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -163,38 +165,53 @@ mgaChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
|
||||||
GLenum format, GLenum type )
|
GLenum format, GLenum type )
|
||||||
{
|
{
|
||||||
mgaContextPtr mmesa = MGA_CONTEXT(ctx);
|
mgaContextPtr mmesa = MGA_CONTEXT(ctx);
|
||||||
const GLboolean do32bpt = mmesa->default32BitTextures;
|
const GLboolean do32bpt =
|
||||||
|
( mmesa->texture_depth == DRI_CONF_TEXTURE_DEPTH_32 );
|
||||||
|
const GLboolean force16bpt =
|
||||||
|
( mmesa->texture_depth == DRI_CONF_TEXTURE_DEPTH_FORCE_16 );
|
||||||
|
(void) format;
|
||||||
|
|
||||||
switch ( internalFormat ) {
|
switch ( internalFormat ) {
|
||||||
case 4:
|
case 4:
|
||||||
case GL_RGBA:
|
case GL_RGBA:
|
||||||
case GL_COMPRESSED_RGBA:
|
case GL_COMPRESSED_RGBA:
|
||||||
if ( format == GL_BGRA ) {
|
switch ( type ) {
|
||||||
if ( type == GL_UNSIGNED_INT_8_8_8_8_REV ) {
|
case GL_UNSIGNED_INT_10_10_10_2:
|
||||||
return &_mesa_texformat_argb8888;
|
case GL_UNSIGNED_INT_2_10_10_10_REV:
|
||||||
}
|
return do32bpt ? &_mesa_texformat_argb8888 : &_mesa_texformat_argb1555;
|
||||||
else if ( type == GL_UNSIGNED_SHORT_4_4_4_4_REV ) {
|
case GL_UNSIGNED_SHORT_4_4_4_4:
|
||||||
|
case GL_UNSIGNED_SHORT_4_4_4_4_REV:
|
||||||
return &_mesa_texformat_argb4444;
|
return &_mesa_texformat_argb4444;
|
||||||
}
|
case GL_UNSIGNED_SHORT_5_5_5_1:
|
||||||
else if ( type == GL_UNSIGNED_SHORT_1_5_5_5_REV ) {
|
case GL_UNSIGNED_SHORT_1_5_5_5_REV:
|
||||||
return &_mesa_texformat_argb1555;
|
return &_mesa_texformat_argb1555;
|
||||||
}
|
default:
|
||||||
}
|
|
||||||
return do32bpt ? &_mesa_texformat_argb8888 : &_mesa_texformat_argb4444;
|
return do32bpt ? &_mesa_texformat_argb8888 : &_mesa_texformat_argb4444;
|
||||||
|
}
|
||||||
|
|
||||||
case 3:
|
case 3:
|
||||||
case GL_RGB:
|
case GL_RGB:
|
||||||
case GL_COMPRESSED_RGB:
|
case GL_COMPRESSED_RGB:
|
||||||
if ( format == GL_RGB && type == GL_UNSIGNED_SHORT_5_6_5 ) {
|
switch ( type ) {
|
||||||
|
case GL_UNSIGNED_SHORT_4_4_4_4:
|
||||||
|
case GL_UNSIGNED_SHORT_4_4_4_4_REV:
|
||||||
|
return &_mesa_texformat_argb4444;
|
||||||
|
case GL_UNSIGNED_SHORT_5_5_5_1:
|
||||||
|
case GL_UNSIGNED_SHORT_1_5_5_5_REV:
|
||||||
|
return &_mesa_texformat_argb1555;
|
||||||
|
case GL_UNSIGNED_SHORT_5_6_5:
|
||||||
|
case GL_UNSIGNED_SHORT_5_6_5_REV:
|
||||||
return &_mesa_texformat_rgb565;
|
return &_mesa_texformat_rgb565;
|
||||||
}
|
default:
|
||||||
return do32bpt ? &_mesa_texformat_argb8888 : &_mesa_texformat_rgb565;
|
return do32bpt ? &_mesa_texformat_argb8888 : &_mesa_texformat_rgb565;
|
||||||
|
}
|
||||||
|
|
||||||
case GL_RGBA8:
|
case GL_RGBA8:
|
||||||
case GL_RGB10_A2:
|
case GL_RGB10_A2:
|
||||||
case GL_RGBA12:
|
case GL_RGBA12:
|
||||||
case GL_RGBA16:
|
case GL_RGBA16:
|
||||||
return do32bpt ? &_mesa_texformat_argb8888 : &_mesa_texformat_argb4444;
|
return !force16bpt ?
|
||||||
|
&_mesa_texformat_argb8888 : &_mesa_texformat_argb4444;
|
||||||
|
|
||||||
case GL_RGBA4:
|
case GL_RGBA4:
|
||||||
case GL_RGBA2:
|
case GL_RGBA2:
|
||||||
|
@ -207,7 +224,7 @@ mgaChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
|
||||||
case GL_RGB10:
|
case GL_RGB10:
|
||||||
case GL_RGB12:
|
case GL_RGB12:
|
||||||
case GL_RGB16:
|
case GL_RGB16:
|
||||||
return do32bpt ? &_mesa_texformat_argb8888 : &_mesa_texformat_rgb565;
|
return !force16bpt ? &_mesa_texformat_argb8888 : &_mesa_texformat_rgb565;
|
||||||
|
|
||||||
case GL_RGB5:
|
case GL_RGB5:
|
||||||
case GL_RGB4:
|
case GL_RGB4:
|
||||||
|
@ -303,10 +320,7 @@ mgaAllocTexObj( struct gl_texture_object *tObj )
|
||||||
|
|
||||||
t->setup.texctl = TMC_takey_1 | TMC_tamask_0;
|
t->setup.texctl = TMC_takey_1 | TMC_tamask_0;
|
||||||
t->setup.texctl2 = TMC_ckstransdis_enable;
|
t->setup.texctl2 = TMC_ckstransdis_enable;
|
||||||
t->setup.texfilter = (TF_minfilter_nrst
|
t->setup.texfilter = TF_filteralpha_enable | TF_uvoffset_OGL;
|
||||||
| TF_magfilter_nrst
|
|
||||||
| TF_filteralpha_enable
|
|
||||||
| TF_uvoffset_OGL);
|
|
||||||
|
|
||||||
t->border_fallback = GL_FALSE;
|
t->border_fallback = GL_FALSE;
|
||||||
t->texenv_fallback = GL_FALSE;
|
t->texenv_fallback = GL_FALSE;
|
||||||
|
@ -334,27 +348,7 @@ static void mgaDDTexEnv( GLcontext *ctx, GLenum target,
|
||||||
GLubyte c[4];
|
GLubyte c[4];
|
||||||
|
|
||||||
UNCLAMPED_FLOAT_TO_RGBA_CHAN( c, texUnit->EnvColor );
|
UNCLAMPED_FLOAT_TO_RGBA_CHAN( c, texUnit->EnvColor );
|
||||||
mmesa->envcolor = PACK_COLOR_8888( c[3], c[0], c[1], c[2] );
|
mmesa->envcolor[unit] = PACK_COLOR_8888( c[3], c[0], c[1], c[2] );
|
||||||
|
|
||||||
if (mmesa->setup.fcol != mmesa->envcolor) {
|
|
||||||
FLUSH_BATCH(mmesa);
|
|
||||||
mmesa->setup.fcol = mmesa->envcolor;
|
|
||||||
mmesa->dirty |= MGA_UPLOAD_CONTEXT;
|
|
||||||
|
|
||||||
mmesa->blend_flags = 0;
|
|
||||||
|
|
||||||
if ((mmesa->envcolor & 0xffffff) == 0x0) {
|
|
||||||
mmesa->blend_flags |= MGA_BLEND_RGB_ZERO;
|
|
||||||
} else if ((mmesa->envcolor & 0xffffff) == 0xffffff) {
|
|
||||||
mmesa->blend_flags |= MGA_BLEND_RGB_ONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((mmesa->envcolor >> 24) == 0x0) {
|
|
||||||
mmesa->blend_flags |= MGA_BLEND_ALPHA_ZERO;
|
|
||||||
} else if ((mmesa->envcolor >> 24) == 0xff) {
|
|
||||||
mmesa->blend_flags |= MGA_BLEND_ALPHA_ONE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -131,10 +131,6 @@ static void mgaUploadSubImage( mgaContextPtr mmesa,
|
||||||
for ( i = 0 ; i < hwlevel ; i++ ) {
|
for ( i = 0 ; i < hwlevel ; i++ ) {
|
||||||
offset += (t->offsets[1] >> (i * 2));
|
offset += (t->offsets[1] >> (i * 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Each mipmap must be DWORD aligned.
|
|
||||||
*/
|
|
||||||
offset &= ~0x03;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -830,7 +830,7 @@ static const char * const fallbackStrings[] = {
|
||||||
"Texture mode",
|
"Texture mode",
|
||||||
"glDrawBuffer(GL_FRONT_AND_BACK)",
|
"glDrawBuffer(GL_FRONT_AND_BACK)",
|
||||||
"read buffer",
|
"read buffer",
|
||||||
"LogicOp != GL_COPY",
|
"glBlendFunc(GL_SRC_ALPHA_SATURATE, GL_ZERO)",
|
||||||
"glRenderMode(selection or feedback)",
|
"glRenderMode(selection or feedback)",
|
||||||
"No hardware stencil",
|
"No hardware stencil",
|
||||||
"glDepthFunc( GL_NEVER )",
|
"glDepthFunc( GL_NEVER )",
|
||||||
|
|
|
@ -38,10 +38,14 @@ extern void mgaRasterPrimitive( GLcontext *ctx, GLenum prim, GLuint hwprim );
|
||||||
extern void mgaFallback( GLcontext *ctx, GLuint bit, GLboolean mode );
|
extern void mgaFallback( GLcontext *ctx, GLuint bit, GLboolean mode );
|
||||||
#define FALLBACK( ctx, bit, mode ) mgaFallback( ctx, bit, mode )
|
#define FALLBACK( ctx, bit, mode ) mgaFallback( ctx, bit, mode )
|
||||||
|
|
||||||
#define _MGA_NEW_RENDERSTATE (_DD_NEW_LINE_STIPPLE | \
|
#define _MGA_NEW_RENDERSTATE (_DD_NEW_POINT_SMOOTH | \
|
||||||
_DD_NEW_TRI_UNFILLED | \
|
_DD_NEW_LINE_SMOOTH | \
|
||||||
|
_DD_NEW_LINE_STIPPLE | \
|
||||||
|
_DD_NEW_TRI_SMOOTH | \
|
||||||
|
_DD_NEW_FLATSHADE | \
|
||||||
_DD_NEW_TRI_LIGHT_TWOSIDE | \
|
_DD_NEW_TRI_LIGHT_TWOSIDE | \
|
||||||
_DD_NEW_TRI_OFFSET | \
|
_DD_NEW_TRI_OFFSET | \
|
||||||
|
_DD_NEW_TRI_UNFILLED | \
|
||||||
_DD_NEW_TRI_STIPPLE | \
|
_DD_NEW_TRI_STIPPLE | \
|
||||||
_NEW_POLYGONSTIPPLE)
|
_NEW_POLYGONSTIPPLE)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue