r300: Further anisotropic filtering fixes

Thanks to Corbin for the initial cut today. Fixed some minor stuff (in
particular, make sure we still use a MIP_LINEAR filtering mode; anisotropy
without MIP_LINEAR filtering is not the truly pleasing anisotropy).
This commit is contained in:
Nicolai Haehnle 2008-06-07 18:54:35 +02:00
parent bf1a7c884d
commit 75bfe630ff
2 changed files with 26 additions and 33 deletions

View file

@ -1380,14 +1380,13 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
# define R300_TX_MIN_FILTER_MIP_NONE (0 << 13)
# define R300_TX_MIN_FILTER_MIP_NEAREST (1 << 13)
# define R300_TX_MIN_FILTER_MIP_LINEAR (2 << 13)
# define R300_TX_MIN_FILTER_MIP_ANISO (3 << 13)
# define R300_TX_MIN_FILTER_MIP_MASK (3 << 13)
# define R300_TX_MAX_ANISO_1_TO_1 (0 << 21)
# define R300_TX_MAX_ANISO_2_TO_1 (2 << 21)
# define R300_TX_MAX_ANISO_4_TO_1 (4 << 21)
# define R300_TX_MAX_ANISO_8_TO_1 (6 << 21)
# define R300_TX_MAX_ANISO_16_TO_1 (8 << 21)
# define R300_TX_MAX_ANISO_MASK (14 << 21)
# define R300_TX_MAX_ANISO_1_TO_1 (0 << 21)
# define R300_TX_MAX_ANISO_2_TO_1 (1 << 21)
# define R300_TX_MAX_ANISO_4_TO_1 (2 << 21)
# define R300_TX_MAX_ANISO_8_TO_1 (3 << 21)
# define R300_TX_MAX_ANISO_16_TO_1 (4 << 21)
# define R300_TX_MAX_ANISO_MASK (7 << 21)
#define R300_TX_FILTER1_0 0x4440
# define R300_CHROMA_KEY_MODE_DISABLE 0

View file

@ -160,21 +160,18 @@ static void r300SetTexWrap(r300TexObjPtr t, GLenum swrap, GLenum twrap,
t->filter |= hw_qwrap << R300_TX_WRAP_Q_SHIFT;
}
static void r300SetTexMaxAnisotropy(r300TexObjPtr t, GLfloat max)
static GLuint aniso_filter(GLfloat anisotropy)
{
t->filter &= ~R300_TX_MAX_ANISO_MASK;
if (max <= 1.0) {
t->filter |= R300_TX_MAX_ANISO_1_TO_1;
} else if (max <= 2.0) {
t->filter |= R300_TX_MAX_ANISO_2_TO_1;
} else if (max <= 4.0) {
t->filter |= R300_TX_MAX_ANISO_4_TO_1;
} else if (max <= 8.0) {
t->filter |= R300_TX_MAX_ANISO_8_TO_1;
if (anisotropy >= 16.0) {
return R300_TX_MAX_ANISO_16_TO_1;
} else if (anisotropy >= 8.0) {
return R300_TX_MAX_ANISO_8_TO_1;
} else if (anisotropy >= 4.0) {
return R300_TX_MAX_ANISO_4_TO_1;
} else if (anisotropy >= 2.0) {
return R300_TX_MAX_ANISO_2_TO_1;
} else {
t->filter |= R300_TX_MAX_ANISO_16_TO_1;
return R300_TX_MAX_ANISO_1_TO_1;
}
}
@ -188,13 +185,19 @@ static void r300SetTexMaxAnisotropy(r300TexObjPtr t, GLfloat max)
*/
static void r300SetTexFilter(r300TexObjPtr t, GLenum minf, GLenum magf, GLfloat anisotropy)
{
t->filter &= ~(R300_TX_MIN_FILTER_MASK | R300_TX_MIN_FILTER_MIP_MASK | R300_TX_MAG_FILTER_MASK);
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;
if (anisotropy > 1.0) {
/* Note that EXT_texture_filter_anisotropic is extremely vague about
* how anisotropic filtering interacts with the "normal" filter modes.
* When anisotropic filtering is enabled, we override min and mag
* filter settings.
*/
if (anisotropy >= 2.0 && (minf != GL_NEAREST && minf != GL_LINEAR)) {
t->filter |= R300_TX_MAG_FILTER_ANISO
| R300_TX_MIN_FILTER_ANISO
| R300_TX_MIN_FILTER_MIP_ANISO;
r300SetTexMaxAnisotropy(t, anisotropy);
| R300_TX_MIN_FILTER_MIP_LINEAR
| aniso_filter(anisotropy);
return;
}
@ -219,15 +222,6 @@ static void r300SetTexFilter(r300TexObjPtr t, GLenum minf, GLenum magf, GLfloat
break;
}
/* Note that EXT_texture_filter_anisotropic is extremely vague about
* how anisotropic filtering interacts with the "normal" filter modes.
* When anisotropic filtering is enabled, we zero the filter setting
* inside a mip level.
*/
if (t->filter & R300_TX_MAX_ANISO_MASK) {
/* t->filter &= ~R300_TX_MIN_FILTER_MASK; */
}
/* Note we don't have 3D mipmaps so only use the mag filter setting
* to set the 3D texture filter mode.
*/