summaryrefslogtreecommitdiff
path: root/src/mesa/drivers
diff options
context:
space:
mode:
authorCorbin Simpson <MostAwesomeDude@gmail.com>2008-06-15 23:54:32 -0700
committerCorbin Simpson <MostAwesomeDude@gmail.com>2008-06-15 23:54:32 -0700
commit776580a6afff9c6403140737ea50f36e9323528a (patch)
treedbc1ba9cbab2433271180903063d269e218947ee /src/mesa/drivers
parentf7b8a13d65e97b8a9812f813cc670e6b712d583d (diff)
r300: Enable LOD bias state emission.
Properly set t->filter_1 for r300_state to emit. Expect buggies as people see LOD bias enabled for the first time...
Diffstat (limited to 'src/mesa/drivers')
-rw-r--r--src/mesa/drivers/dri/r300/r300_tex.c65
1 files changed, 49 insertions, 16 deletions
diff --git a/src/mesa/drivers/dri/r300/r300_tex.c b/src/mesa/drivers/dri/r300/r300_tex.c
index 317b961898..85a6628e40 100644
--- a/src/mesa/drivers/dri/r300/r300_tex.c
+++ b/src/mesa/drivers/dri/r300/r300_tex.c
@@ -185,7 +185,6 @@ static GLuint aniso_filter(GLfloat anisotropy)
*/
static void r300SetTexFilter(r300TexObjPtr t, GLenum minf, GLenum magf, GLfloat anisotropy)
{
- fprintf(stderr, "Here I am!\n");
t->filter &= ~(R300_TX_MIN_FILTER_MASK | R300_TX_MIN_FILTER_MIP_MASK | R300_TX_MAG_FILTER_MASK | R300_TX_MAX_ANISO_MASK);
t->filter_1 &= ~R300_EDGE_ANISO_EDGE_ONLY;
@@ -243,6 +242,19 @@ static void r300SetTexBorderColor(r300TexObjPtr t, GLubyte c[4])
t->pp_border_color = PACK_COLOR_8888(c[3], c[0], c[1], c[2]);
}
+static void r300SetTexLodBias(r300TexObjPtr t, GLfloat bias)
+{
+ GLuint b;
+ b = (unsigned int)fabsf(ceilf(bias*31));
+ if (signbit(bias)) {
+ b ^= 0x3ff; /* 10 bits */
+ }
+ b <<= 3;
+ b &= R300_LOD_BIAS_MASK;
+
+ t->filter_1 |= b;
+}
+
/**
* Allocate space for and load the mesa images into the texture memory block.
* This will happen before drawing with a new texture, or drawing with a
@@ -271,6 +283,7 @@ static r300TexObjPtr r300AllocTexObj(struct gl_texture_object *texObj)
r300SetTexWrap(t, texObj->WrapS, texObj->WrapT, texObj->WrapR);
r300SetTexFilter(t, texObj->MinFilter, texObj->MagFilter, texObj->MaxAnisotropy);
r300SetTexBorderColor(t, texObj->_BorderChan);
+ r300SetTexLodBias(t, texObj->LodBias);
}
return t;
@@ -966,6 +979,33 @@ r300TexSubImage3D(GLcontext * ctx, GLenum target, GLint level,
t->dirty_images[0] |= (1 << level);
}
+/* This feels like a prime target for code reuse, so I'm putting it here
+ * instead of inlining it in TexEnv. */
+static GLenum r300TexUnitTarget(struct gl_texture_unit *unit) {
+ if (unit->_ReallyEnabled & (TEXTURE_RECT_BIT)) {
+ return GL_TEXTURE_RECTANGLE_NV;
+ } else if (unit->_ReallyEnabled & (TEXTURE_1D_BIT)) {
+ return GL_TEXTURE_1D;
+ } else if (unit->_ReallyEnabled & (TEXTURE_2D_BIT)) {
+ return GL_TEXTURE_2D;
+ } else if (unit->_ReallyEnabled & (TEXTURE_3D_BIT)) {
+ return GL_TEXTURE_3D;
+ } else if (unit->_ReallyEnabled & (TEXTURE_CUBE_BIT)) {
+ return GL_TEXTURE_CUBE_MAP;
+ }
+ if (unit->Enabled & (TEXTURE_RECT_BIT)) {
+ return GL_TEXTURE_RECTANGLE_NV;
+ } else if (unit->Enabled & (TEXTURE_1D_BIT)) {
+ return GL_TEXTURE_1D;
+ } else if (unit->Enabled & (TEXTURE_2D_BIT)) {
+ return GL_TEXTURE_2D;
+ } else if (unit->Enabled & (TEXTURE_3D_BIT)) {
+ return GL_TEXTURE_3D;
+ } else if (unit->Enabled & (TEXTURE_CUBE_BIT)) {
+ return GL_TEXTURE_CUBE_MAP;
+ }
+}
+
static void r300TexEnv(GLcontext * ctx, GLenum target,
GLenum pname, const GLfloat * param)
{
@@ -981,10 +1021,8 @@ static void r300TexEnv(GLcontext * ctx, GLenum target,
*/
switch (pname) {
case GL_TEXTURE_LOD_BIAS_EXT: {
- fprintf(stderr, "LOD Bias: %f\n", *param);
/* Needs to be relocated in order to make sure we got the right tmu */
GLfloat bias, min;
- GLuint b;
/* The R300's LOD bias is a signed 2's complement value with a
* range of -16.0 <= bias < 16.0.
@@ -996,21 +1034,16 @@ static void r300TexEnv(GLcontext * ctx, GLenum target,
"no_neg_lod_bias") ? 0.0 : -16.0;
bias = CLAMP(bias, min, 16.0);
- b = (unsigned int)fabsf(ceilf(bias*31));
- if (signbit(bias)) {
- b ^= 0x3ff; /* 10 bits */
- }
- fprintf(stderr, "LOD Bias (hex): 0x%x\n", b);
- b <<= 3;
- b &= R300_LOD_BIAS_MASK;
+ /* This next part feels quite hackish;
+ * is there a cleaner way? */
+ struct gl_texture_object *texObj;
+ GLenum target = r300TexUnitTarget(&ctx->Texture.Unit[ctx->Texture.CurrentUnit]);
+ texObj = _mesa_select_tex_object(ctx, &ctx->Texture.Unit[ctx->Texture.CurrentUnit], target);
+ r300TexObjPtr t = (r300TexObjPtr) texObj->DriverData;
+ texObj->LodBias = bias;
- int unit = 1;
+ r300SetTexLodBias(t, texObj->LodBias);
- if (b != (rmesa->hw.tex.filter_1.cmd[R300_TEX_CMD_0 + unit] & R300_LOD_BIAS_MASK)) {
- rmesa->hw.tex.filter_1.cmd[R300_TEX_CMD_0 + unit] &= ~R300_LOD_BIAS_MASK;
- rmesa->hw.tex.filter_1.cmd[R300_TEX_CMD_0 + unit] |= b;
- R300_STATECHANGE(rmesa, tex.filter_1);
- }
break;
}