summaryrefslogtreecommitdiffstats
path: root/src/mesa/drivers/dri/mga
diff options
context:
space:
mode:
authorAlan Hourihane <[email protected]>2003-12-05 00:32:15 +0000
committerAlan Hourihane <[email protected]>2003-12-05 00:32:15 +0000
commiteed5ac284cb4edca5400d55040e83fdf2f329f84 (patch)
treeaddcbdefa6d8fae9635ee830d9d4cd97d096c110 /src/mesa/drivers/dri/mga
parent1f2d9ae69fa6d368b1df3f316e7bb7186ca8f746 (diff)
bring over latest mga DRI driver from DRI trunk
Diffstat (limited to 'src/mesa/drivers/dri/mga')
-rw-r--r--src/mesa/drivers/dri/mga/mga_texcombine.c35
-rw-r--r--src/mesa/drivers/dri/mga/mga_texstate.c490
-rw-r--r--src/mesa/drivers/dri/mga/mga_xmesa.c42
-rw-r--r--src/mesa/drivers/dri/mga/mgacontext.h36
-rw-r--r--src/mesa/drivers/dri/mga/mgaioctl.c4
-rw-r--r--src/mesa/drivers/dri/mga/mgaioctl.h2
-rw-r--r--src/mesa/drivers/dri/mga/mgaspan.c32
-rw-r--r--src/mesa/drivers/dri/mga/mgastate.c196
-rw-r--r--src/mesa/drivers/dri/mga/mgatex.c80
-rw-r--r--src/mesa/drivers/dri/mga/mgatexmem.c4
-rw-r--r--src/mesa/drivers/dri/mga/mgatris.c2
-rw-r--r--src/mesa/drivers/dri/mga/mgatris.h16
12 files changed, 433 insertions, 506 deletions
diff --git a/src/mesa/drivers/dri/mga/mga_texcombine.c b/src/mesa/drivers/dri/mga/mga_texcombine.c
index f0664e37cfa..ca7322a599d 100644
--- a/src/mesa/drivers/dri/mga/mga_texcombine.c
+++ b/src/mesa/drivers/dri/mga/mga_texcombine.c
@@ -143,9 +143,16 @@ GLboolean mgaUpdateTextureEnvCombine( GLcontext *ctx, int unit )
}
break;
case GL_CONSTANT:
+ if (mmesa->fcol_used &&
+ mmesa->envcolor[source] != mmesa->envcolor[!source])
+ return GL_FALSE;
+
arg1[i] |= ARG_DISABLE;
arg2[i] |= TD0_color_arg2_fcol;
alpha[i] |= TD0_color_alpha_fcol;
+
+ mmesa->setup.fcol = mmesa->envcolor[source];
+ mmesa->fcol_used = GL_TRUE;
break;
case GL_PRIMARY_COLOR:
arg1[i] |= ARG_DISABLE;
@@ -178,12 +185,23 @@ GLboolean mgaUpdateTextureEnvCombine( GLcontext *ctx, int unit )
case GL_SRC_COLOR:
arg1[i] |= 0;
arg2[i] |= 0;
- alpha[i] |= ARG_DISABLE;
+ if (texUnit->CombineSourceRGB[i] == GL_CONSTANT &&
+ RGBA_EQUAL( mmesa->envcolor[source] )) {
+ alpha[i] |= 0;
+ } else {
+ alpha[i] |= ARG_DISABLE;
+ }
break;
case GL_ONE_MINUS_SRC_COLOR:
arg1[i] |= TD0_color_arg1_inv_enable;
arg2[i] |= TD0_color_arg2_inv_enable;
- alpha[i] |= ARG_DISABLE;
+ 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;
+ }
break;
case GL_SRC_ALPHA:
arg1[i] |= TD0_color_arg1_replicatealpha_enable;
@@ -346,7 +364,7 @@ GLboolean mgaUpdateTextureEnvCombine( GLcontext *ctx, int unit )
*reg |= TD0_color_addbias_enable;
/* fallthrough */
case GL_ADD:
- if (args[0] == MGA_ALPHA || args[1] == MGA_ALPHA){
+ if (args[0] == MGA_ALPHA || args[1] == MGA_ALPHA) {
/* Can't get alpha to the adder */
return GL_FALSE;
}
@@ -396,7 +414,7 @@ GLboolean mgaUpdateTextureEnvCombine( GLcontext *ctx, int unit )
TD0_color_sel_arg2 |
TD0_alpha_arg2_prevstage |
TD0_alpha_sel_arg2);
- mmesa->dualtex_env = GL_TRUE;
+ mmesa->force_dualtex = GL_TRUE;
}
break;
case GL_SUBTRACT:
@@ -538,8 +556,15 @@ GLboolean mgaUpdateTextureEnvCombine( GLcontext *ctx, int unit )
}
break;
case GL_CONSTANT:
+ if (mmesa->fcol_used &&
+ mmesa->envcolor[source] != mmesa->envcolor[!source])
+ return GL_FALSE;
+
arg1[i] |= ARG_DISABLE;
arg2[i] |= TD0_alpha_arg2_fcol;
+
+ mmesa->setup.fcol = mmesa->envcolor[source];
+ mmesa->fcol_used = GL_TRUE;
break;
case GL_PRIMARY_COLOR:
arg1[i] |= ARG_DISABLE;
@@ -595,7 +620,7 @@ GLboolean mgaUpdateTextureEnvCombine( GLcontext *ctx, int unit )
return GL_FALSE;
}
- if (args[0] == MGA_ARG1){
+ if (args[0] == MGA_ARG1) {
*reg |= TD0_alpha_sel_arg1;
} else if (args[0] == MGA_ARG2) {
*reg |= TD0_alpha_sel_arg2;
diff --git a/src/mesa/drivers/dri/mga/mga_texstate.c b/src/mesa/drivers/dri/mga/mga_texstate.c
index 5f3e1b1bacc..e22a69e052c 100644
--- a/src/mesa/drivers/dri/mga/mga_texstate.c
+++ b/src/mesa/drivers/dri/mga/mga_texstate.c
@@ -48,15 +48,15 @@
#define TMC_nr_tformat (MESA_FORMAT_YCBCR_REV + 1)
static const unsigned TMC_tformat[ TMC_nr_tformat ] =
{
- [MESA_FORMAT_ARGB8888] = TMC_tformat_tw32 | TMC_takey_1 | TMC_tamask_0,
- [MESA_FORMAT_RGB565] = TMC_tformat_tw16 | TMC_takey_1 | TMC_tamask_0,
- [MESA_FORMAT_ARGB4444] = TMC_tformat_tw12 | TMC_takey_1 | TMC_tamask_0,
- [MESA_FORMAT_ARGB1555] = TMC_tformat_tw15 | TMC_takey_1 | TMC_tamask_0,
- [MESA_FORMAT_AL88] = TMC_tformat_tw8al | TMC_takey_1 | TMC_tamask_0,
- [MESA_FORMAT_I8] = TMC_tformat_tw8a | TMC_takey_1 | TMC_tamask_0,
- [MESA_FORMAT_CI8] = TMC_tformat_tw8 | TMC_takey_1 | TMC_tamask_0,
- [MESA_FORMAT_YCBCR] = TMC_tformat_tw422uyvy | TMC_takey_1 | TMC_tamask_0,
- [MESA_FORMAT_YCBCR_REV] = TMC_tformat_tw422 | TMC_takey_1 | TMC_tamask_0,
+ [MESA_FORMAT_ARGB8888] = TMC_tformat_tw32,
+ [MESA_FORMAT_RGB565] = TMC_tformat_tw16,
+ [MESA_FORMAT_ARGB4444] = TMC_tformat_tw12,
+ [MESA_FORMAT_ARGB1555] = TMC_tformat_tw15,
+ [MESA_FORMAT_AL88] = TMC_tformat_tw8al,
+ [MESA_FORMAT_I8] = TMC_tformat_tw8a,
+ [MESA_FORMAT_CI8] = TMC_tformat_tw8 ,
+ [MESA_FORMAT_YCBCR] = TMC_tformat_tw422uyvy,
+ [MESA_FORMAT_YCBCR_REV] = TMC_tformat_tw422,
};
#endif
@@ -106,8 +106,13 @@ mgaSetTexImages( mgaContextPtr mmesa,
#endif /* MGA_USE_TABLE_FOR_FORMAT */
driCalculateTextureFirstLastLevel( (driTextureObject *) t );
- log2Width = tObj->Image[t->base.firstLevel]->WidthLog2;
- log2Height = tObj->Image[t->base.firstLevel]->HeightLog2;
+ if (tObj->Target == GL_TEXTURE_RECTANGLE_NV) {
+ log2Width = 0;
+ log2Height = 0;
+ } else {
+ log2Width = tObj->Image[t->base.firstLevel]->WidthLog2;
+ log2Height = tObj->Image[t->base.firstLevel]->HeightLog2;
+ }
width = tObj->Image[t->base.firstLevel]->Width;
height = tObj->Image[t->base.firstLevel]->Height;
@@ -120,19 +125,30 @@ mgaSetTexImages( mgaContextPtr mmesa,
for ( i = 0 ; i < numLevels ; i++ ) {
const struct gl_texture_image * const texImage =
tObj->Image[ i + t->base.firstLevel ];
+ int size;
- if ( (texImage == NULL)
- || ((i != 0)
- && ((texImage->Width < 8) || (texImage->Height < 8))) ) {
+ if (texImage == NULL)
break;
- }
+
+ size = texImage->Width * texImage->Height *
+ baseImage->TexFormat->TexelBytes;
t->offsets[i] = totalSize;
t->base.dirty_images[0] |= (1<<i);
- totalSize += ((MAX2( texImage->Width, 8 ) *
- MAX2( texImage->Height, 8 ) *
- baseImage->TexFormat->TexelBytes) + 31) & ~31;
+ /* All mipmaps must be 32-byte aligned */
+ totalSize += (size + 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 */
@@ -152,17 +168,17 @@ mgaSetTexImages( mgaContextPtr mmesa,
*/
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
- * 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.
*/
-
+ numLevels--;
t->setup.texfilter &= TF_mapnb_MASK & TF_mapnbhigh_MASK & TF_reserved_MASK;
- t->setup.texfilter |= (((numLevels-1) & 0x07) << (TF_mapnb_SHIFT));
- t->setup.texfilter |= (((numLevels-1) & 0x08) << (TF_mapnbhigh_SHIFT - 3));
+ t->setup.texfilter |= MGA_FIELD( TF_mapnb, numLevels & 0x7 );
+ t->setup.texfilter |= MGA_FIELD( TF_mapnbhigh, (numLevels >> 3) & 0x1 );
/* warp texture registers */
ofs = MGA_IS_G200(mmesa) ? 28 : 11;
@@ -185,53 +201,80 @@ mgaSetTexImages( mgaContextPtr mmesa,
static void mgaUpdateTextureEnvG200( GLcontext *ctx, GLuint unit )
{
+ mgaContextPtr mmesa = MGA_CONTEXT(ctx);
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;
- 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) {
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;
+
case GL_MODULATE:
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;
+
case GL_DECAL:
- t->setup.texctl &= ~TMC_tmodulate_enable;
- t->setup.texctl2 |= TMC_decalblend_enable;
+ if (format == GL_RGB || format == GL_RGBA)
+ t->setup.texctl2 |= TMC_decalblend_enable;
+ else
+ t->setup.texctl2 |= TMC_idecal_enable;
+
+ mmesa->hw.alpha_sel = AC_alphasel_diffused;
break;
+
case GL_BLEND:
- t->texenv_fallback = GL_TRUE;
+ if (format == GL_ALPHA) {
+ t->setup.texctl2 |= TMC_idecal_enable;
+ mmesa->hw.alpha_sel = AC_alphasel_modulated;
+ } else {
+ t->texenv_fallback = GL_TRUE;
+ }
break;
+
default:
break;
}
}
-#define MGA_DISABLE 0
-#define MGA_REPLACE 1
-#define MGA_MODULATE 2
-#define MGA_DECAL 3
-#define MGA_BLEND 4
-#define MGA_ADD 5
-#define MGA_MAX_COMBFUNC 6
+#define MGA_REPLACE 0
+#define MGA_MODULATE 1
+#define MGA_DECAL 2
+#define MGA_ADD 3
+#define MGA_MAX_COMBFUNC 4
static const GLuint g400_color_combine[][MGA_MAX_COMBFUNC] =
{
/* Unit 0:
*/
{
- /* Disable combiner stage
- */
- (0),
-
/* GL_REPLACE
* Cv = Cs
* Av = Af
@@ -257,16 +300,6 @@ static const GLuint g400_color_combine[][MGA_MAX_COMBFUNC] =
TD0_alpha_arg2_diffuse |
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
* Cv = Cf + Cs
* Av = Af
@@ -281,10 +314,6 @@ static const GLuint g400_color_combine[][MGA_MAX_COMBFUNC] =
/* Unit 1:
*/
{
- /* Disable combiner stage
- */
- (0),
-
/* GL_REPLACE
* Cv = Cs
* Av = Ap
@@ -310,16 +339,6 @@ static const GLuint g400_color_combine[][MGA_MAX_COMBFUNC] =
TD0_alpha_arg2_prevstage |
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
* Cv = Cp + Cs
* Av = Ap
@@ -337,10 +356,6 @@ static const GLuint g400_color_alpha_combine[][MGA_MAX_COMBFUNC] =
/* Unit 0:
*/
{
- /* Disable combiner stage
- */
- (0),
-
/* GL_REPLACE
* Cv = Cs
* Av = As
@@ -374,16 +389,6 @@ static const GLuint g400_color_alpha_combine[][MGA_MAX_COMBFUNC] =
TD0_alpha_arg2_diffuse |
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
* Cv = Cf + Cs
* Av = Af As
@@ -398,10 +403,6 @@ static const GLuint g400_color_alpha_combine[][MGA_MAX_COMBFUNC] =
/* Unit 1:
*/
{
- /* Disable combiner stage
- */
- (0),
-
/* GL_REPLACE
* Cv = Cs
* Av = As
@@ -435,16 +436,6 @@ static const GLuint g400_color_alpha_combine[][MGA_MAX_COMBFUNC] =
TD0_alpha_arg2_prevstage |
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
* Cv = Cp + Cs
* Av = Ap As
@@ -462,10 +453,6 @@ static const GLuint g400_alpha_combine[][MGA_MAX_COMBFUNC] =
/* Unit 0:
*/
{
- /* Disable combiner stage
- */
- (0),
-
/* GL_REPLACE
* Cv = Cf
* Av = As
@@ -492,15 +479,6 @@ static const GLuint g400_alpha_combine[][MGA_MAX_COMBFUNC] =
TD0_alpha_arg2_diffuse |
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
* Cv = Cf
* Av = Af As
@@ -514,10 +492,6 @@ static const GLuint g400_alpha_combine[][MGA_MAX_COMBFUNC] =
/* Unit 1:
*/
{
- /* Disable combiner stage
- */
- (0),
-
/* GL_REPLACE
* Cv = Cp
* Av = As
@@ -544,15 +518,6 @@ static const GLuint g400_alpha_combine[][MGA_MAX_COMBFUNC] =
TD0_alpha_arg2_prevstage |
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
* Cv = Cp
* 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 )
{
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_object *tObj = texUnit->_Current;
GLuint *reg = ((GLuint *)&mmesa->setup.tdualstage0 + unit);
- mgaTextureObjectPtr t;
- GLenum format;
+ mgaTextureObjectPtr t = (mgaTextureObjectPtr) tObj->DriverData;
+ GLenum format = tObj->Image[tObj->BaseLevel]->Format;
- if ( !tObj ||
- (tObj != ctx->Texture.Unit[source].Current2D &&
- tObj != ctx->Texture.Unit[source].CurrentRect) )
+ if (tObj != ctx->Texture.Unit[source].Current2D &&
+ tObj != ctx->Texture.Unit[source].CurrentRect)
return;
- format = tObj->Image[tObj->BaseLevel]->Format;
-
- t = (mgaTextureObjectPtr) tObj->DriverData;
-
switch (ctx->Texture.Unit[source].EnvMode) {
case GL_REPLACE:
if (format == GL_ALPHA) {
@@ -615,7 +671,7 @@ static void mgaUpdateTextureEnvG400( GLcontext *ctx, GLuint unit )
TD0_color_sel_arg2 |
TD0_alpha_arg2_prevstage |
TD0_alpha_sel_arg2);
- mmesa->dualtex_env = GL_TRUE;
+ mmesa->force_dualtex = GL_TRUE;
}
} else {
/* Undefined */
@@ -653,146 +709,11 @@ static void mgaUpdateTextureEnvG400( GLcontext *ctx, GLuint unit )
break;
case GL_BLEND:
- if (format == GL_ALPHA) {
- *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;
- }
- }
- } 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;
- }
- }
+ if (!mgaUpdateTextureEnvBlend(ctx, unit))
+ t->texenv_fallback = GL_TRUE;
break;
- case GL_COMBINE_EXT:
+
+ case GL_COMBINE:
if (!mgaUpdateTextureEnvCombine(ctx, unit))
t->texenv_fallback = GL_TRUE;
break;
@@ -816,7 +737,7 @@ static void disable_tex( GLcontext *ctx, int unit )
mmesa->CurrentTexObj[unit] = NULL;
}
- if ( unit != 0 && !mmesa->dualtex_env ) {
+ if ( unit != 0 && !mmesa->force_dualtex ) {
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;
}
- t->setup.texctl2 &= TMC_dualtex_MASK;
- if (ctx->Texture._EnabledUnits == 0x03) {
- t->setup.texctl2 |= TMC_dualtex_enable;
- }
-
t->texenv_fallback = GL_FALSE;
/* Set this before mgaUpdateTextureEnvG400() since
@@ -914,23 +830,14 @@ static GLboolean update_tex_common( GLcontext *ctx, int unit )
mgaUpdateTextureEnvG400( ctx, unit );
} 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 );
}
+
+ 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);
FALLBACK( ctx, MGA_FALLBACK_BORDER_MODE, t->border_fallback );
@@ -967,7 +874,8 @@ void mgaUpdateTextureState( GLcontext *ctx )
GLboolean ok;
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
* TEXTURE1 is enabled, then the hardware TEXTURE0 must be used. The
diff --git a/src/mesa/drivers/dri/mga/mga_xmesa.c b/src/mesa/drivers/dri/mga/mga_xmesa.c
index 11daf9aaf4f..3752a8b13c0 100644
--- a/src/mesa/drivers/dri/mga/mga_xmesa.c
+++ b/src/mesa/drivers/dri/mga/mga_xmesa.c
@@ -26,8 +26,6 @@
* Keith Whitwell <[email protected]>
*/
-#ifdef GLX_DIRECT_RENDERING
-
#include "mga_common.h"
#include "mga_xmesa.h"
#include "context.h"
@@ -70,8 +68,12 @@ DRI_CONF_BEGIN
DRI_CONF_SECTION_PERFORMANCE
DRI_CONF_VBLANK_MODE(DRI_CONF_VBLANK_DEF_INTERVAL_0)
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;
-const GLuint __driNConfigOptions = 1;
+const GLuint __driNConfigOptions = 3;
#ifndef MGA_DEBUG
int MGA_DEBUG = 0;
@@ -130,10 +132,12 @@ mgaInitDriver(__DRIscreenPrivate *sPriv)
(*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" );
}
}
#endif
+
if (serverInfo->chipset != MGA_CARD_TYPE_G200 &&
serverInfo->chipset != MGA_CARD_TYPE_G400) {
FREE(mgaScreen);
@@ -301,6 +305,7 @@ static const char * const card_extensions[] =
{
"GL_ARB_multisample",
"GL_ARB_texture_compression",
+ "GL_EXT_blend_logic_op",
"GL_EXT_fog_coord",
/* paletted_textures currently doesn't work, but we could fix them later */
#if 0
@@ -328,7 +333,7 @@ static const struct dri_debug_control debug_control[] =
static int
-get_ust_nop( uint64_t * ust )
+get_ust_nop( int64_t * ust )
{
*ust = 1;
return 0;
@@ -378,7 +383,6 @@ mgaCreateContext( const __GLcontextModes *mesaVis,
mmesa->mgaScreen = mgaScreen;
mmesa->driScreen = sPriv;
mmesa->sarea = (void *)saPriv;
- mmesa->glBuffer = NULL;
/* Parse configuration files */
driParseConfigFiles (&mmesa->optionCache, &mgaScreen->optionCache,
@@ -432,7 +436,11 @@ mgaCreateContext( const __GLcontextModes *mesaVis,
ctx->Const.MaxLineWidthAA = 10.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;
switch (mesaVis->depthBits) {
@@ -616,6 +624,24 @@ mgaDestroyBuffer(__DRIdrawablePrivate *driDrawPriv)
_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
mgaUnbindContext(__DRIcontextPrivate *driContextPriv)
@@ -653,8 +679,11 @@ mgaMakeCurrent(__DRIcontextPrivate *driContextPriv,
mmesa->driDrawable = driDrawPriv;
mmesa->dirty = ~0;
mmesa->dirty_cliprects = (MGA_FRONT|MGA_BACK);
+ mmesa->mesa_drawable = driDrawPriv;
}
+ mmesa->driReadable = driReadPriv;
+
_mesa_make_current2(mmesa->glCtx,
(GLframebuffer *) driDrawPriv->driverPrivate,
(GLframebuffer *) driReadPriv->driverPrivate);
@@ -775,4 +804,3 @@ getSwapInfo( __DRIdrawablePrivate *dPriv, __DRIswapInfo * sInfo )
return 0;
}
-#endif
diff --git a/src/mesa/drivers/dri/mga/mgacontext.h b/src/mesa/drivers/dri/mga/mgacontext.h
index 50efe4c817f..245cb5eb737 100644
--- a/src/mesa/drivers/dri/mga/mgacontext.h
+++ b/src/mesa/drivers/dri/mga/mgacontext.h
@@ -32,10 +32,10 @@
#include <inttypes.h>
#include "dri_util.h"
#include "mtypes.h"
-#include "colormac.h"
#include "xf86drm.h"
#include "mm.h"
#include "mga_sarea.h"
+#include "colormac.h"
#include "texmem.h"
#include "macros.h"
#include "xmlconfig.h"
@@ -57,7 +57,7 @@
#define MGA_FALLBACK_TEXTURE 0x1
#define MGA_FALLBACK_DRAW_BUFFER 0x2
#define MGA_FALLBACK_READ_BUFFER 0x4
-#define MGA_FALLBACK_LOGICOP 0x8
+#define MGA_FALLBACK_BLEND 0x8
#define MGA_FALLBACK_RENDERMODE 0x10
#define MGA_FALLBACK_STENCIL 0x20
#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 MGA_BLEND_RGB_ONE 0x2
-#define MGA_BLEND_ALPHA_ZERO 0x4
-#define MGA_BLEND_ALPHA_ONE 0x8
+#define RGB_ZERO(c) (((c) & 0xffffff) == 0x000000)
+#define RGB_ONE(c) (((c) & 0xffffff) == 0xffffff)
+#define ALPHA_ZERO(c) (((c) >> 24) == 0x00)
+#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_screen_private_s;
@@ -197,7 +199,7 @@ struct mga_context_t {
*/
GLuint tmu_source[2];
- GLboolean default32BitTextures;
+ int texture_depth;
/* Manage fallbacks
*/
@@ -209,11 +211,11 @@ struct mga_context_t {
struct gl_client_array UbyteColor;
struct gl_client_array UbyteSecondaryColor;
- /* Support for GL_DECAL and GL_BLEND
+ /* Texture environment color.
*/
- unsigned int blend_flags;
- unsigned int envcolor;
- GLboolean dualtex_env;
+ unsigned int envcolor[2];
+ GLboolean fcol_used;
+ GLboolean force_dualtex;
/* Rasterization state
*/
@@ -299,11 +301,19 @@ struct mga_context_t {
/* Mirrors of some DRI state.
*/
- GLframebuffer *glBuffer;
drmContext hHWContext;
drmLock *driHwLock;
int driFd;
__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;
struct mga_screen_private_s *mgaScreen;
MGASAREAPrivPtr sarea;
diff --git a/src/mesa/drivers/dri/mga/mgaioctl.c b/src/mesa/drivers/dri/mga/mgaioctl.c
index fc53912af4c..2709a40c694 100644
--- a/src/mesa/drivers/dri/mga/mgaioctl.c
+++ b/src/mesa/drivers/dri/mga/mgaioctl.c
@@ -26,8 +26,6 @@
* Gareth Hughes <[email protected]>
*/
/* $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 "macros.h"
@@ -323,7 +321,7 @@ static void mgaWaitForFrameCompletion( mgaContextPtr mmesa )
/*
* Copy the back buffer to the front buffer.
*/
-void mgaSwapBuffers( __DRIdrawablePrivate *dPriv )
+void mgaCopyBuffer( const __DRIdrawablePrivate *dPriv )
{
mgaContextPtr mmesa;
XF86DRIClipRectPtr pbox;
diff --git a/src/mesa/drivers/dri/mga/mgaioctl.h b/src/mesa/drivers/dri/mga/mgaioctl.h
index 2d959d8246d..9e57d48cea7 100644
--- a/src/mesa/drivers/dri/mga/mgaioctl.h
+++ b/src/mesa/drivers/dri/mga/mgaioctl.h
@@ -33,7 +33,7 @@
#include "mgacontext.h"
#include "mga_xmesa.h"
-void mgaSwapBuffers( __DRIdrawablePrivate *dPriv );
+void mgaCopyBuffer( const __DRIdrawablePrivate *dPriv );
void mgaWaitForVBlank( mgaContextPtr mmesa );
GLuint *mgaAllocVertexDwords( mgaContextPtr mmesa, int dwords );
diff --git a/src/mesa/drivers/dri/mga/mgaspan.c b/src/mesa/drivers/dri/mga/mgaspan.c
index 684239865f7..c8a55d4cd15 100644
--- a/src/mesa/drivers/dri/mga/mgaspan.c
+++ b/src/mesa/drivers/dri/mga/mgaspan.c
@@ -37,7 +37,7 @@
#define LOCAL_VARS \
- __DRIdrawablePrivate *dPriv = mmesa->driDrawable; \
+ __DRIdrawablePrivate *dPriv = mmesa->mesa_drawable; \
mgaScreenPrivate *mgaScreen = mmesa->mgaScreen; \
__DRIscreenPrivate *sPriv = mmesa->driScreen; \
GLuint pitch = mgaScreen->frontPitch; \
@@ -56,7 +56,7 @@
#define LOCAL_DEPTH_VARS \
- __DRIdrawablePrivate *dPriv = mmesa->driDrawable; \
+ __DRIdrawablePrivate *dPriv = mmesa->mesa_drawable; \
mgaScreenPrivate *mgaScreen = mmesa->mgaScreen; \
__DRIscreenPrivate *sPriv = mmesa->driScreen; \
GLuint pitch = mgaScreen->frontPitch; \
@@ -242,20 +242,22 @@ static void mgaDDSetBuffer(GLcontext *ctx, GLframebuffer *buffer,
GLuint bufferBit)
{
mgaContextPtr mmesa = MGA_CONTEXT(ctx);
+ unsigned int offset;
- if (bufferBit == FRONT_LEFT_BIT)
- {
- mmesa->drawOffset = mmesa->mgaScreen->frontOffset;
- mmesa->readOffset = mmesa->mgaScreen->frontOffset;
- }
- else if (bufferBit == BACK_LEFT_BIT)
- {
- mmesa->drawOffset = mmesa->mgaScreen->backOffset;
- mmesa->readOffset = mmesa->mgaScreen->backOffset;
- }
- else {
- assert(0);
- }
+ assert( (bufferBit == FRONT_LEFT_BIT) || (bufferBit == BACK_LEFT_BIT) );
+
+ offset = (bufferBit == FRONT_LEFT_BIT)
+ ? mmesa->mgaScreen->frontOffset
+ : mmesa->mgaScreen->backOffset;
+
+ mmesa->drawOffset = offset;
+ mmesa->readOffset = offset;
+
+ assert( (buffer == mmesa->driDrawable->driverPrivate)
+ || (buffer == mmesa->driReadable->driverPrivate) );
+
+ mmesa->mesa_drawable = (buffer == mmesa->driDrawable->driverPrivate)
+ ? mmesa->driDrawable : mmesa->driReadable;
}
void mgaDDInitSpanFuncs( GLcontext *ctx )
diff --git a/src/mesa/drivers/dri/mga/mgastate.c b/src/mesa/drivers/dri/mga/mgastate.c
index 29815008be9..becb08a2080 100644
--- a/src/mesa/drivers/dri/mga/mgastate.c
+++ b/src/mesa/drivers/dri/mga/mgastate.c
@@ -48,13 +48,10 @@
#include "tnl/t_pipeline.h"
#include "swrast_setup/swrast_setup.h"
+#include "xmlpool.h"
static void updateSpecularLighting( GLcontext *ctx );
-
-/* Some outstanding problems with accelerating logic ops...
- */
-#if defined(ACCEL_ROP)
static const GLuint mgarop_NoBLK[16] = {
DC_atype_rpl | 0x00000000, DC_atype_rstr | 0x00080000,
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_rstr | 0x00070000, DC_atype_rpl | 0x000f0000
};
-#endif
-
/* =============================================================
* Alpha blending
@@ -111,27 +106,32 @@ static void mgaDDAlphaFunc(GLcontext *ctx, GLenum func, GLfloat ref)
break;
}
- FLUSH_BATCH( mmesa );
+ MGA_STATECHANGE( mmesa, MGA_UPLOAD_CONTEXT );
mmesa->hw.alpha_func = a | MGA_FIELD( AC_atref, refByte );
- mmesa->dirty |= MGA_UPLOAD_CONTEXT;
}
-static void mgaDDBlendEquation(GLcontext *ctx, GLenum mode)
+static void updateBlendLogicOp(GLcontext *ctx)
{
- FLUSH_BATCH( MGA_CONTEXT(ctx) );
+ mgaContextPtr mmesa = MGA_CONTEXT(ctx);
- /* BlendEquation sets ColorLogicOpEnabled in an unexpected
- * manner.
- */
- FALLBACK( ctx, MGA_FALLBACK_LOGICOP,
- (ctx->Color.ColorLogicOpEnabled &&
- ctx->Color.LogicOp != GL_COPY));
+ 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)
+{
+ updateBlendLogicOp( ctx );
}
static void mgaDDBlendFunc(GLcontext *ctx, GLenum sfactor, GLenum dfactor)
{
mgaContextPtr mmesa = MGA_CONTEXT(ctx);
- mgaScreenPrivate *mgaScreen = mmesa->mgaScreen;
GLuint src;
GLuint dst;
@@ -150,11 +150,11 @@ static void mgaDDBlendFunc(GLcontext *ctx, GLenum sfactor, GLenum dfactor)
case GL_ONE_MINUS_SRC_ALPHA:
src = AC_src_om_src_alpha; break;
case GL_DST_ALPHA:
- src = (mgaScreen->cpp == 4)
+ src = (ctx->Visual.alphaBits > 0)
? AC_src_dst_alpha : AC_src_one;
break;
case GL_ONE_MINUS_DST_ALPHA:
- src = (mgaScreen->cpp == 4)
+ src = (ctx->Visual.alphaBits > 0)
? AC_src_om_dst_alpha : AC_src_zero;
break;
case GL_SRC_ALPHA_SATURATE:
@@ -178,18 +178,21 @@ static void mgaDDBlendFunc(GLcontext *ctx, GLenum sfactor, GLenum dfactor)
case GL_ONE_MINUS_SRC_COLOR:
dst = AC_dst_om_src_color; break;
case GL_DST_ALPHA:
- dst = (mgaScreen->cpp == 4)
+ dst = (ctx->Visual.alphaBits > 0)
? AC_dst_dst_alpha : AC_dst_one;
break;
case GL_ONE_MINUS_DST_ALPHA:
- dst = (mgaScreen->cpp == 4)
+ dst = (ctx->Visual.alphaBits > 0)
? AC_dst_om_dst_alpha : AC_dst_zero;
break;
}
- FLUSH_BATCH( mmesa );
+ MGA_STATECHANGE( mmesa, MGA_UPLOAD_CONTEXT );
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,
@@ -199,7 +202,6 @@ static void mgaDDBlendFuncSeparate( GLcontext *ctx, GLenum sfactorRGB,
mgaDDBlendFunc( ctx, sfactorRGB, dfactorRGB );
}
-
/* =============================================================
* Depth testing
*/
@@ -233,10 +235,9 @@ static void mgaDDDepthFunc(GLcontext *ctx, GLenum func)
zmode = 0; break;
}
- FLUSH_BATCH( mmesa );
+ MGA_STATECHANGE( mmesa, MGA_UPLOAD_CONTEXT );
mmesa->hw.zmode &= DC_zmode_MASK;
mmesa->hw.zmode |= zmode;
- mmesa->dirty |= MGA_UPLOAD_CONTEXT;
}
static void mgaDDDepthMask(GLcontext *ctx, GLboolean flag)
@@ -244,10 +245,9 @@ static void mgaDDDepthMask(GLcontext *ctx, GLboolean flag)
mgaContextPtr mmesa = MGA_CONTEXT( ctx );
- FLUSH_BATCH( mmesa );
+ MGA_STATECHANGE( mmesa, MGA_UPLOAD_CONTEXT );
mmesa->hw.zmode &= DC_atype_MASK;
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);
-
- FLUSH_BATCH( mmesa );
+ MGA_STATECHANGE( mmesa, MGA_UPLOAD_CONTEXT );
if (ctx->Polygon.CullFlag &&
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_dualtex = _CULL_DISABLE;
}
-
- mmesa->dirty |= MGA_UPLOAD_CONTEXT;
}
@@ -494,8 +491,6 @@ static void updateSpecularLighting( GLcontext *ctx )
if ( specen != mmesa->hw.specen ) {
mmesa->hw.specen = specen;
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 stencilctl;
- stencil = (ref << S_sref_SHIFT) | (mask << S_smsk_SHIFT);
+ stencil = MGA_FIELD( S_sref, ref ) | MGA_FIELD( S_smsk, mask );
switch (func)
{
case GL_NEVER:
@@ -557,22 +552,20 @@ static void mgaDDStencilFunc(GLcontext *ctx, GLenum func, GLint ref,
break;
}
- FLUSH_BATCH( mmesa );
+ MGA_STATECHANGE( mmesa, MGA_UPLOAD_CONTEXT );
mmesa->hw.stencil &= (S_sref_MASK & S_smsk_MASK);
mmesa->hw.stencil |= stencil;
mmesa->hw.stencilctl &= SC_smode_MASK;
mmesa->hw.stencilctl |= stencilctl;
- mmesa->dirty |= MGA_UPLOAD_CONTEXT;
}
static void mgaDDStencilMask(GLcontext *ctx, GLuint mask)
{
mgaContextPtr mmesa = MGA_CONTEXT(ctx);
- FLUSH_BATCH( mmesa );
+ MGA_STATECHANGE( mmesa, MGA_UPLOAD_CONTEXT );
mmesa->hw.stencil &= S_swtmsk_MASK;
- mmesa->hw.stencil |= (mask << S_swtmsk_SHIFT);
- mmesa->dirty |= MGA_UPLOAD_CONTEXT;
+ mmesa->hw.stencil |= MGA_FIELD( S_swtmsk, mask );
}
static void mgaDDStencilOp(GLcontext *ctx, GLenum fail, GLenum zfail,
@@ -672,11 +665,10 @@ static void mgaDDStencilOp(GLcontext *ctx, GLenum fail, GLenum zfail,
break;
}
- FLUSH_BATCH( mmesa );
+ MGA_STATECHANGE( mmesa, MGA_UPLOAD_CONTEXT );
mmesa->hw.stencilctl &= (SC_sfailop_MASK & SC_szfailop_MASK
& SC_szpassop_MASK);
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 );
- FLUSH_BATCH( mmesa );
-#if defined(ACCEL_ROP)
+ MGA_STATECHANGE( mmesa, MGA_UPLOAD_CONTEXT );
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 );
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_COLOR_SUM_EXT:
FLUSH_BATCH( mmesa );
updateSpecularLighting( ctx );
break;
case GL_ALPHA_TEST:
- FLUSH_BATCH( mmesa );
+ MGA_STATECHANGE( mmesa, MGA_UPLOAD_CONTEXT );
mmesa->hw.alpha_func_enable = (state) ? ~0 : 0;
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:
- FLUSH_BATCH( mmesa );
+ MGA_STATECHANGE( mmesa, MGA_UPLOAD_CONTEXT );
FALLBACK (ctx, MGA_FALLBACK_DEPTH,
ctx->Depth.Func == GL_NEVER && ctx->Depth.Test);
break;
@@ -921,8 +904,6 @@ static void mgaDDEnable(GLcontext *ctx, GLenum cap, GLboolean state)
mmesa->setup.maccess |= MA_fogen_enable;
else
mmesa->setup.maccess &= ~MA_fogen_enable;
-
- mgaChooseVertexState( ctx );
break;
case GL_CULL_FACE:
mgaDDCullFaceFrontFace( ctx, 0 );
@@ -933,22 +914,20 @@ static void mgaDDEnable(GLcontext *ctx, GLenum cap, GLboolean state)
break;
case GL_POLYGON_STIPPLE:
if (mmesa->haveHwStipple && mmesa->raster_primitive == GL_TRIANGLES) {
- FLUSH_BATCH(mmesa);
- mmesa->dirty |= MGA_UPLOAD_CONTEXT;
+ MGA_STATECHANGE( mmesa, MGA_UPLOAD_CONTEXT );
mmesa->setup.dwgctl &= ~(0xf<<20);
if (state)
mmesa->setup.dwgctl |= mmesa->poly_stipple;
}
break;
+
+ case GL_BLEND:
case GL_COLOR_LOGIC_OP:
- FLUSH_BATCH( mmesa );
-#if !defined(ACCEL_ROP)
- FALLBACK( ctx, MGA_FALLBACK_LOGICOP,
- (state && ctx->Color.LogicOp != GL_COPY));
-#endif
+ updateBlendLogicOp( ctx );
break;
+
case GL_STENCIL_TEST:
- FLUSH_BATCH( mmesa );
+ MGA_STATECHANGE( mmesa, MGA_UPLOAD_CONTEXT );
if (mmesa->hw_stencil) {
mmesa->hw.stencil_enable = ( state ) ? ~0 : 0;
}
@@ -1013,23 +992,17 @@ void mgaEmitHwStateLocked( mgaContextPtr mmesa )
mmesa->setup.dwgctl |= (ctx->Depth.Test)
? mmesa->hw.zmode : (DC_zmode_nozcmp | DC_atype_i);
-#if defined(ACCEL_ROP)
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 ];
-#endif
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->hw.alpha_func & mmesa->hw.alpha_func_enable)
- | ((mmesa->hw.blend_func & mmesa->hw.blend_func_enable)
- | ((AC_src_one | AC_dst_zero) & ~mmesa->hw.blend_func_enable))
- | mmesa->hw.alpha_sel
- | (AC_amode_alpha_channel
- | AC_astipple_disable
- | AC_aten_disable
- | AC_atmode_noacmp));
+ (mmesa->hw.alpha_func & mmesa->hw.alpha_func_enable) |
+ (mmesa->hw.blend_func & mmesa->hw.blend_func_enable) |
+ ((AC_src_one | AC_dst_zero) & ~mmesa->hw.blend_func_enable) |
+ mmesa->hw.alpha_sel;
memcpy( &sarea->ContextState, &mmesa->setup, sizeof(mmesa->setup));
}
@@ -1046,19 +1019,11 @@ void mgaEmitHwStateLocked( mgaContextPtr mmesa )
sizeof(sarea->TexState[1]));
}
- if (mmesa->dualtex_env) {
- sarea->TexState[0].texctl2 |= TMC_dualtex_enable;
- memcpy( &sarea->TexState[1], &sarea->TexState[0],
- sizeof(sarea->TexState[0]) );
- mmesa->dirty |= MGA_UPLOAD_TEX1|MGA_UPLOAD_TEX0;
- } 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_TEX0 | MGA_UPLOAD_TEX1)) {
+ 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;
}
if (mmesa->dirty & MGA_UPLOAD_PIPE) {
@@ -1069,14 +1034,8 @@ void mgaEmitHwStateLocked( mgaContextPtr mmesa )
mmesa->sarea->dirty |= mmesa->dirty;
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_nodither_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) {
case 2:
@@ -1182,14 +1144,20 @@ void mgaInitState( mgaContextPtr mmesa )
}
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.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
- | SC_szfailop_keep | SC_szpassop_keep;
+ | SC_szfailop_keep | SC_szpassop_keep;
mmesa->hw.stencil_enable = 0;
mmesa->hw.cull = _CULL_DISABLE;
mmesa->hw.cull_dualtex = _CULL_DISABLE;
mmesa->hw.specen = 0;
+ mmesa->hw.alpha_sel = AC_alphasel_diffused;
mmesa->setup.dwgctl = (DC_opcod_trap |
DC_linear_xy |
@@ -1197,22 +1165,17 @@ void mgaInitState( mgaContextPtr mmesa )
DC_arzero_disable |
DC_sgnzero_disable |
DC_shftzero_enable |
- (0xC << DC_bop_SHIFT) |
- (0x0 << DC_trans_SHIFT) |
+ MGA_FIELD( DC_bop, 0xC ) |
+ MGA_FIELD( DC_trans, 0x0 ) |
DC_bltmod_bmonolef |
DC_pattern_disable |
DC_transc_disable |
DC_clipdis_disable);
-
mmesa->setup.plnwt = ~0;
- mmesa->setup.alphactrl = ( AC_src_one |
- AC_dst_zero |
- AC_amode_FCOL |
- AC_astipple_disable |
- AC_aten_disable |
- AC_atmode_noacmp |
- AC_alphasel_fromtex );
+ mmesa->setup.alphactrl = (AC_amode_alpha_channel |
+ AC_astipple_disable |
+ AC_aten_disable);
mmesa->setup.fogcolor = PACK_COLOR_888((GLubyte)(ctx->Fog.Color[0]*255.0F),
(GLubyte)(ctx->Fog.Color[1]*255.0F),
@@ -1224,9 +1187,8 @@ void mgaInitState( mgaContextPtr mmesa )
mmesa->setup.fcol = 0;
mmesa->dirty |= MGA_UPLOAD_CONTEXT;
- mmesa->envcolor = 0;
- mmesa->blend_flags = MGA_BLEND_RGB_ZERO | MGA_BLEND_ALPHA_ZERO;
- mmesa->dualtex_env = GL_FALSE;
+ mmesa->envcolor[0] = 0;
+ mmesa->envcolor[1] = 0;
}
diff --git a/src/mesa/drivers/dri/mga/mgatex.c b/src/mesa/drivers/dri/mga/mgatex.c
index 166bdfc22f3..8b8d472c525 100644
--- a/src/mesa/drivers/dri/mga/mgatex.c
+++ b/src/mesa/drivers/dri/mga/mgatex.c
@@ -46,6 +46,8 @@
#include "swrast/swrast.h"
+#include "xmlpool.h"
+
/**
* Set the texture wrap modes.
* 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 */
if (magf == GL_LINEAR && (minf == GL_NEAREST_MIPMAP_NEAREST ||
minf == GL_NEAREST_MIPMAP_LINEAR)) {
- val |= (0x20 << TF_fthres_SHIFT); /* c = 0.5 */
+ val |= MGA_FIELD( TF_fthres, 0x20 ); /* c = 0.5 */
} 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 )
{
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 ) {
case 4:
case GL_RGBA:
case GL_COMPRESSED_RGBA:
- if ( format == GL_BGRA ) {
- if ( type == GL_UNSIGNED_INT_8_8_8_8_REV ) {
- return &_mesa_texformat_argb8888;
- }
- else if ( type == GL_UNSIGNED_SHORT_4_4_4_4_REV ) {
- return &_mesa_texformat_argb4444;
- }
- else if ( type == GL_UNSIGNED_SHORT_1_5_5_5_REV ) {
- return &_mesa_texformat_argb1555;
- }
+ switch ( type ) {
+ case GL_UNSIGNED_INT_10_10_10_2:
+ case GL_UNSIGNED_INT_2_10_10_10_REV:
+ return do32bpt ? &_mesa_texformat_argb8888 : &_mesa_texformat_argb1555;
+ 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;
+ default:
+ return do32bpt ? &_mesa_texformat_argb8888 : &_mesa_texformat_argb4444;
}
- return do32bpt ? &_mesa_texformat_argb8888 : &_mesa_texformat_argb4444;
case 3:
case GL_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;
+ default:
+ return do32bpt ? &_mesa_texformat_argb8888 : &_mesa_texformat_rgb565;
}
- return do32bpt ? &_mesa_texformat_argb8888 : &_mesa_texformat_rgb565;
case GL_RGBA8:
case GL_RGB10_A2:
case GL_RGBA12:
case GL_RGBA16:
- return do32bpt ? &_mesa_texformat_argb8888 : &_mesa_texformat_argb4444;
+ return !force16bpt ?
+ &_mesa_texformat_argb8888 : &_mesa_texformat_argb4444;
case GL_RGBA4:
case GL_RGBA2:
@@ -207,7 +224,7 @@ mgaChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
case GL_RGB10:
case GL_RGB12:
case GL_RGB16:
- return do32bpt ? &_mesa_texformat_argb8888 : &_mesa_texformat_rgb565;
+ return !force16bpt ? &_mesa_texformat_argb8888 : &_mesa_texformat_rgb565;
case GL_RGB5:
case GL_RGB4:
@@ -303,10 +320,7 @@ mgaAllocTexObj( struct gl_texture_object *tObj )
t->setup.texctl = TMC_takey_1 | TMC_tamask_0;
t->setup.texctl2 = TMC_ckstransdis_enable;
- t->setup.texfilter = (TF_minfilter_nrst
- | TF_magfilter_nrst
- | TF_filteralpha_enable
- | TF_uvoffset_OGL);
+ t->setup.texfilter = TF_filteralpha_enable | TF_uvoffset_OGL;
t->border_fallback = GL_FALSE;
t->texenv_fallback = GL_FALSE;
@@ -334,27 +348,7 @@ static void mgaDDTexEnv( GLcontext *ctx, GLenum target,
GLubyte c[4];
UNCLAMPED_FLOAT_TO_RGBA_CHAN( c, texUnit->EnvColor );
- mmesa->envcolor = 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;
- }
- }
+ mmesa->envcolor[unit] = PACK_COLOR_8888( c[3], c[0], c[1], c[2] );
break;
}
}
diff --git a/src/mesa/drivers/dri/mga/mgatexmem.c b/src/mesa/drivers/dri/mga/mgatexmem.c
index 4e7fd6b24b3..66c69bf3e5e 100644
--- a/src/mesa/drivers/dri/mga/mgatexmem.c
+++ b/src/mesa/drivers/dri/mga/mgatexmem.c
@@ -131,10 +131,6 @@ static void mgaUploadSubImage( mgaContextPtr mmesa,
for ( i = 0 ; i < hwlevel ; i++ ) {
offset += (t->offsets[1] >> (i * 2));
}
-
- /* Each mipmap must be DWORD aligned.
- */
- offset &= ~0x03;
}
diff --git a/src/mesa/drivers/dri/mga/mgatris.c b/src/mesa/drivers/dri/mga/mgatris.c
index 1c193066ff3..651c93ccd42 100644
--- a/src/mesa/drivers/dri/mga/mgatris.c
+++ b/src/mesa/drivers/dri/mga/mgatris.c
@@ -830,7 +830,7 @@ static const char * const fallbackStrings[] = {
"Texture mode",
"glDrawBuffer(GL_FRONT_AND_BACK)",
"read buffer",
- "LogicOp != GL_COPY",
+ "glBlendFunc(GL_SRC_ALPHA_SATURATE, GL_ZERO)",
"glRenderMode(selection or feedback)",
"No hardware stencil",
"glDepthFunc( GL_NEVER )",
diff --git a/src/mesa/drivers/dri/mga/mgatris.h b/src/mesa/drivers/dri/mga/mgatris.h
index a8c0b8936b7..f3ece3a053b 100644
--- a/src/mesa/drivers/dri/mga/mgatris.h
+++ b/src/mesa/drivers/dri/mga/mgatris.h
@@ -38,11 +38,15 @@ extern void mgaRasterPrimitive( GLcontext *ctx, GLenum prim, GLuint hwprim );
extern void mgaFallback( GLcontext *ctx, GLuint bit, GLboolean mode );
#define FALLBACK( ctx, bit, mode ) mgaFallback( ctx, bit, mode )
-#define _MGA_NEW_RENDERSTATE (_DD_NEW_LINE_STIPPLE | \
- _DD_NEW_TRI_UNFILLED | \
- _DD_NEW_TRI_LIGHT_TWOSIDE | \
- _DD_NEW_TRI_OFFSET | \
- _DD_NEW_TRI_STIPPLE | \
- _NEW_POLYGONSTIPPLE)
+#define _MGA_NEW_RENDERSTATE (_DD_NEW_POINT_SMOOTH | \
+ _DD_NEW_LINE_SMOOTH | \
+ _DD_NEW_LINE_STIPPLE | \
+ _DD_NEW_TRI_SMOOTH | \
+ _DD_NEW_FLATSHADE | \
+ _DD_NEW_TRI_LIGHT_TWOSIDE | \
+ _DD_NEW_TRI_OFFSET | \
+ _DD_NEW_TRI_UNFILLED | \
+ _DD_NEW_TRI_STIPPLE | \
+ _NEW_POLYGONSTIPPLE)
#endif