summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChia-I Wu <[email protected]>2015-01-25 18:05:04 +0800
committerChia-I Wu <[email protected]>2015-02-12 07:56:12 +0800
commita57805cb750c4b2aa57a387e4145bba6c1a0b86e (patch)
tree41dcabc840438f97db42c0d5db14d36b989f7682 /src
parent7e7e45db65968df7a56c8c5aabed0a700633c72b (diff)
ilo: update SAMPLER_STATE for Gen8
Diffstat (limited to 'src')
-rw-r--r--src/gallium/drivers/ilo/ilo_state_3d_top.c71
1 files changed, 42 insertions, 29 deletions
diff --git a/src/gallium/drivers/ilo/ilo_state_3d_top.c b/src/gallium/drivers/ilo/ilo_state_3d_top.c
index 2fb31325fbf..73f8402be0b 100644
--- a/src/gallium/drivers/ilo/ilo_state_3d_top.c
+++ b/src/gallium/drivers/ilo/ilo_state_3d_top.c
@@ -1358,20 +1358,14 @@ gen6_translate_tex_filter(unsigned filter)
* wrapping mode.
*/
static int
-gen6_translate_tex_wrap(unsigned wrap, bool clamp_to_edge)
+gen6_translate_tex_wrap(unsigned wrap)
{
- /* clamp to edge or border? */
- if (wrap == PIPE_TEX_WRAP_CLAMP) {
- wrap = (clamp_to_edge) ?
- PIPE_TEX_WRAP_CLAMP_TO_EDGE : PIPE_TEX_WRAP_CLAMP_TO_BORDER;
- }
-
switch (wrap) {
+ case PIPE_TEX_WRAP_CLAMP: return GEN8_TEXCOORDMODE_HALF_BORDER;
case PIPE_TEX_WRAP_REPEAT: return GEN6_TEXCOORDMODE_WRAP;
case PIPE_TEX_WRAP_CLAMP_TO_EDGE: return GEN6_TEXCOORDMODE_CLAMP;
case PIPE_TEX_WRAP_CLAMP_TO_BORDER: return GEN6_TEXCOORDMODE_CLAMP_BORDER;
case PIPE_TEX_WRAP_MIRROR_REPEAT: return GEN6_TEXCOORDMODE_MIRROR;
- case PIPE_TEX_WRAP_CLAMP:
case PIPE_TEX_WRAP_MIRROR_CLAMP:
case PIPE_TEX_WRAP_MIRROR_CLAMP_TO_EDGE:
case PIPE_TEX_WRAP_MIRROR_CLAMP_TO_BORDER:
@@ -1418,10 +1412,9 @@ ilo_gpe_init_sampler_cso(const struct ilo_dev_info *dev,
int mip_filter, min_filter, mag_filter, max_aniso;
int lod_bias, max_lod, min_lod;
int wrap_s, wrap_t, wrap_r, wrap_cube;
- bool clamp_is_to_edge;
uint32_t dw0, dw1, dw3;
- ILO_DEV_ASSERT(dev, 6, 7.5);
+ ILO_DEV_ASSERT(dev, 6, 8);
memset(sampler, 0, sizeof(*sampler));
@@ -1498,26 +1491,46 @@ ilo_gpe_init_sampler_cso(const struct ilo_dev_info *dev,
mag_filter = min_filter;
}
- /*
- * For nearest filtering, PIPE_TEX_WRAP_CLAMP means
- * PIPE_TEX_WRAP_CLAMP_TO_EDGE; for linear filtering, PIPE_TEX_WRAP_CLAMP
- * means PIPE_TEX_WRAP_CLAMP_TO_BORDER while additionally clamping the
- * texture coordinates to [0.0, 1.0].
- *
- * The clamping will be taken care of in the shaders. There are two
- * filters here, but let the minification one has a say.
- */
- clamp_is_to_edge = (state->min_img_filter == PIPE_TEX_FILTER_NEAREST);
- if (!clamp_is_to_edge) {
- sampler->saturate_s = (state->wrap_s == PIPE_TEX_WRAP_CLAMP);
- sampler->saturate_t = (state->wrap_t == PIPE_TEX_WRAP_CLAMP);
- sampler->saturate_r = (state->wrap_r == PIPE_TEX_WRAP_CLAMP);
- }
-
/* determine wrap s/t/r */
- wrap_s = gen6_translate_tex_wrap(state->wrap_s, clamp_is_to_edge);
- wrap_t = gen6_translate_tex_wrap(state->wrap_t, clamp_is_to_edge);
- wrap_r = gen6_translate_tex_wrap(state->wrap_r, clamp_is_to_edge);
+ wrap_s = gen6_translate_tex_wrap(state->wrap_s);
+ wrap_t = gen6_translate_tex_wrap(state->wrap_t);
+ wrap_r = gen6_translate_tex_wrap(state->wrap_r);
+ if (ilo_dev_gen(dev) < ILO_GEN(8)) {
+ /*
+ * For nearest filtering, PIPE_TEX_WRAP_CLAMP means
+ * PIPE_TEX_WRAP_CLAMP_TO_EDGE; for linear filtering,
+ * PIPE_TEX_WRAP_CLAMP means PIPE_TEX_WRAP_CLAMP_TO_BORDER while
+ * additionally clamping the texture coordinates to [0.0, 1.0].
+ *
+ * PIPE_TEX_WRAP_CLAMP is not supported natively until Gen8. The
+ * clamping has to be taken care of in the shaders. There are two
+ * filters here, but let the minification one has a say.
+ */
+ const bool clamp_is_to_edge =
+ (state->min_img_filter == PIPE_TEX_FILTER_NEAREST);
+
+ if (clamp_is_to_edge) {
+ if (wrap_s == GEN8_TEXCOORDMODE_HALF_BORDER)
+ wrap_s = GEN6_TEXCOORDMODE_CLAMP;
+ if (wrap_t == GEN8_TEXCOORDMODE_HALF_BORDER)
+ wrap_t = GEN6_TEXCOORDMODE_CLAMP;
+ if (wrap_r == GEN8_TEXCOORDMODE_HALF_BORDER)
+ wrap_r = GEN6_TEXCOORDMODE_CLAMP;
+ } else {
+ if (wrap_s == GEN8_TEXCOORDMODE_HALF_BORDER) {
+ wrap_s = GEN6_TEXCOORDMODE_CLAMP_BORDER;
+ sampler->saturate_s = true;
+ }
+ if (wrap_t == GEN8_TEXCOORDMODE_HALF_BORDER) {
+ wrap_t = GEN6_TEXCOORDMODE_CLAMP_BORDER;
+ sampler->saturate_t = true;
+ }
+ if (wrap_r == GEN8_TEXCOORDMODE_HALF_BORDER) {
+ wrap_r = GEN6_TEXCOORDMODE_CLAMP_BORDER;
+ sampler->saturate_r = true;
+ }
+ }
+ }
/*
* From the Sandy Bridge PRM, volume 4 part 1, page 107: