summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKenneth Graunke <kenneth@whitecape.org>2014-05-28 23:31:48 -0700
committerKenneth Graunke <kenneth@whitecape.org>2014-06-05 01:26:05 -0700
commit221169693bf1dfdaf46dddc1df318cee992237aa (patch)
tree26c17e0f0d2f436f8dc8c46775372d5907636622
parent7f3d64a77b9ca6d738f67c7a3dd4499cdf817d79 (diff)
i965: Support GL_CLAMP natively on Broadwell.
The new hardware actually supports this OpenGL 1.x feature natively, so we can finally drop our shader workarounds. Not many applications use GL_CLAMP, and most use it unintentionally, but it's trivial to do right, so we should. Signed-off-by: Kenneth Graunke <kenneth@whitecape.org> Reviewed-by: Matt Turner <mattst88@gmail.com> Cc: "10.2" <mesa-stable@lists.freedesktop.org>
-rw-r--r--src/mesa/drivers/dri/i965/brw_defines.h1
-rw-r--r--src/mesa/drivers/dri/i965/brw_wm.c3
-rw-r--r--src/mesa/drivers/dri/i965/brw_wm_sampler_state.c13
3 files changed, 13 insertions, 4 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_defines.h b/src/mesa/drivers/dri/i965/brw_defines.h
index ed8efcada94..3afd399ab1d 100644
--- a/src/mesa/drivers/dri/i965/brw_defines.h
+++ b/src/mesa/drivers/dri/i965/brw_defines.h
@@ -606,6 +606,7 @@
#define BRW_TEXCOORDMODE_CUBE 3
#define BRW_TEXCOORDMODE_CLAMP_BORDER 4
#define BRW_TEXCOORDMODE_MIRROR_ONCE 5
+#define GEN8_TEXCOORDMODE_HALF_BORDER 6
#define BRW_THREAD_PRIORITY_NORMAL 0
#define BRW_THREAD_PRIORITY_HIGH 1
diff --git a/src/mesa/drivers/dri/i965/brw_wm.c b/src/mesa/drivers/dri/i965/brw_wm.c
index c2d38b36087..d716e6f9325 100644
--- a/src/mesa/drivers/dri/i965/brw_wm.c
+++ b/src/mesa/drivers/dri/i965/brw_wm.c
@@ -347,7 +347,8 @@ brw_populate_sampler_prog_key_data(struct gl_context *ctx,
if (alpha_depth || (brw->gen < 8 && !brw->is_haswell))
key->swizzles[s] = brw_get_texture_swizzle(ctx, t);
- if (sampler->MinFilter != GL_NEAREST &&
+ if (brw->gen < 8 &&
+ sampler->MinFilter != GL_NEAREST &&
sampler->MagFilter != GL_NEAREST) {
if (sampler->WrapS == GL_CLAMP)
key->gl_clamp_mask[0] |= 1 << s;
diff --git a/src/mesa/drivers/dri/i965/brw_wm_sampler_state.c b/src/mesa/drivers/dri/i965/brw_wm_sampler_state.c
index 6f8dde4a29b..8a4bfead550 100644
--- a/src/mesa/drivers/dri/i965/brw_wm_sampler_state.c
+++ b/src/mesa/drivers/dri/i965/brw_wm_sampler_state.c
@@ -55,9 +55,16 @@ translate_wrap_mode(struct brw_context *brw, GLenum wrap, bool using_nearest)
/* GL_CLAMP is the weird mode where coordinates are clamped to
* [0.0, 1.0], so linear filtering of coordinates outside of
* [0.0, 1.0] give you half edge texel value and half border
- * color. The fragment shader will clamp the coordinates, and
- * we set clamp_border here, which gets the result desired. We
- * just use clamp(_to_edge) for nearest, because for nearest
+ * color.
+ *
+ * Gen8+ supports this natively.
+ */
+ if (brw->gen >= 8)
+ return GEN8_TEXCOORDMODE_HALF_BORDER;
+
+ /* On Gen4-7.5, we clamp the coordinates in the fragment shader
+ * and set clamp_border here, which gets the result desired.
+ * We just use clamp(_to_edge) for nearest, because for nearest
* clamping to 1.0 gives border color instead of the desired
* edge texels.
*/