[PATCH] r600g: add support for anisotropic filtering
Carl-Philip Haensch (none)
carli at carli-laptop.
Fri May 6 13:48:08 PDT 2011
---
src/gallium/drivers/r600/r600_state.c | 20 +++++++++++++++++---
src/gallium/drivers/r600/r600d.h | 9 +++++++++
2 files changed, 26 insertions(+), 3 deletions(-)
diff --git a/src/gallium/drivers/r600/r600_state.c b/src/gallium/drivers/r60=
0/r600_state.c
index 3f979cf..aeffb9e 100644
--- a/src/gallium/drivers/r600/r600_state.c
+++ b/src/gallium/drivers/r600/r600_state.c
@@ -364,6 +364,17 @@ static void *r600_create_rs_state(struct pipe_context *=
ctx,
=09return rstate;
}
=20
+
+
+static inline unsigned r600_tex_aniso_filter(unsigned filter)
+{
+=09if (filter <=3D 1) return 0;
+=09if (filter <=3D 2) return 1;
+=09if (filter <=3D 4) return 2;
+=09if (filter <=3D 8) return 3;
+=09 /* else */ return 4;
+}
+
static void *r600_create_sampler_state(struct pipe_context *ctx,
=09=09=09=09=09const struct pipe_sampler_state *state)
{
@@ -376,13 +387,15 @@ static void *r600_create_sampler_state(struct pipe_con=
text *ctx,
=20
=09rstate->id =3D R600_PIPE_STATE_SAMPLER;
=09util_pack_color(state->border_color, PIPE_FORMAT_B8G8R8A8_UNORM, &uc);
+=09unsigned aniso_flag_offset =3D state->max_anisotropy > 1 ? 4 : 0;
=09r600_pipe_state_add_reg(rstate, R_03C000_SQ_TEX_SAMPLER_WORD0_0,
=09=09=09S_03C000_CLAMP_X(r600_tex_wrap(state->wrap_s)) |
=09=09=09S_03C000_CLAMP_Y(r600_tex_wrap(state->wrap_t)) |
=09=09=09S_03C000_CLAMP_Z(r600_tex_wrap(state->wrap_r)) |
-=09=09=09S_03C000_XY_MAG_FILTER(r600_tex_filter(state->mag_img_filter)) |
-=09=09=09S_03C000_XY_MIN_FILTER(r600_tex_filter(state->min_img_filter)) |
+=09=09=09S_03C000_XY_MAG_FILTER(r600_tex_filter(state->mag_img_filter) | an=
iso_flag_offset) |
+=09=09=09S_03C000_XY_MIN_FILTER(r600_tex_filter(state->min_img_filter) | an=
iso_flag_offset) |
=09=09=09S_03C000_MIP_FILTER(r600_tex_mipfilter(state->min_mip_filter)) |
+=09=09=09S_03C000_ANISO(r600_tex_aniso_filter(state->max_anisotropy)) |
=09=09=09S_03C000_DEPTH_COMPARE_FUNCTION(r600_tex_compare(state->compare_fu=
nc)) |
=09=09=09S_03C000_BORDER_COLOR_TYPE(uc.ui ? V_03C000_SQ_TEX_BORDER_COLOR_RE=
GISTER : 0), 0xFFFFFFFF, NULL);
=09r600_pipe_state_add_reg(rstate, R_03C004_SQ_TEX_SAMPLER_WORD1_0,
@@ -492,7 +505,8 @@ static struct pipe_sampler_view *r600_create_sampler_vie=
w(struct pipe_context *c
=09=09=09=09S_038014_BASE_ARRAY(state->u.tex.first_layer) |
=09=09=09=09S_038014_LAST_ARRAY(state->u.tex.last_layer), 0xFFFFFFFF, NULL)=
;
=09r600_pipe_state_add_reg(rstate, R_038018_RESOURCE0_WORD6,
-=09=09=09=09S_038018_TYPE(V_038010_SQ_TEX_VTX_VALID_TEXTURE), 0xFFFFFFFF, N=
ULL);
+=09=09=09=09S_038018_TYPE(V_038010_SQ_TEX_VTX_VALID_TEXTURE) |
+=09=09=09=09S_038018_ANISO(4 /* max 16 samples */), 0xFFFFFFFF, NULL);
=20
=09return &resource->base;
}
diff --git a/src/gallium/drivers/r600/r600d.h b/src/gallium/drivers/r600/r60=
0d.h
index 8296b52..c997462 100644
--- a/src/gallium/drivers/r600/r600d.h
+++ b/src/gallium/drivers/r600/r600d.h
@@ -1012,6 +1012,9 @@
#define S_038018_MPEG_CLAMP(x) (((x) & 0x3) << 0)
#define G_038018_MPEG_CLAMP(x) (((x) >> 0) & 0x3)
#define C_038018_MPEG_CLAMP 0xFFFFFFFC
+#define S_038018_ANISO(x) (((x) & 0x7) << 2)
+#define G_038018_ANISO(x) (((x) >> 2) & 0x7)
+#define C_038018_ANISO 0xFFFFFFE3
#define S_038018_PERF_MODULATION(x) (((x) & 0x7) << 5)
#define G_038018_PERF_MODULATION(x) (((x) >> 5) & 0x7)
#define C_038018_PERF_MODULATION 0xFFFFFF1F
@@ -1090,6 +1093,9 @@
#define S_03C000_MIP_FILTER(x) (((x) & 0x3) << 17)
#define G_03C000_MIP_FILTER(x) (((x) >> 17) & 0x3)
#define C_03C000_MIP_FILTER 0xFFF9FFFF
+#define S_03C000_ANISO(x) (((x) & 0x7) << 19)
+#define G_03C000_ANISO(x) (((x) >> 19) & 0x7)
+#define C_03C000_ANISO 0xFFB7FFFF
#define S_03C000_BORDER_COLOR_TYPE(x) (((x) & 0x3) << 22)
#define G_03C000_BORDER_COLOR_TYPE(x) (((x) >> 22) & 0x3)
#define C_03C000_BORDER_COLOR_TYPE 0xFF3FFFFF
@@ -1152,6 +1158,9 @@
#define S_03C008_PERF_Z(x) (((x) & 0x3) << 18)
#define G_03C008_PERF_Z(x) (((x) >> 18) & 0x3)
#define C_03C008_PERF_Z 0xFFF3FFFF
+#define S_03C008_ANISO_BIAS(x) (((x) & 0x3f) << 22)
+#define G_03C008_ANISO_BIAS(x) (((x) >> 22) & 0x3f)
+#define C_03C008_ANISO_BIAS (~(0x3f << 22))
#define S_03C008_FETCH_4(x) (((x) & 0x1) << 26)
#define G_03C008_FETCH_4(x) (((x) >> 26) & 0x1)
#define C_03C008_FETCH_4 0xFBFFFFFF
--=20
1.7.1
--=_3hdgmpb37w2n--
More information about the mesa-dev
mailing list