st/mesa: don't set the border color if it's unused
authorMarek Olšák <marek.olsak@amd.com>
Thu, 15 Jun 2017 11:45:24 +0000 (13:45 +0200)
committerMarek Olšák <marek.olsak@amd.com>
Wed, 21 Jun 2017 23:51:02 +0000 (01:51 +0200)
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
src/mesa/state_tracker/st_atom_sampler.c

index 00fc354532ec6b7a2e3012345c8204da088ca9e6..208b6f7a1df5c8009bc84891d37fb6bb1cb4aadb 100644 (file)
@@ -139,11 +139,25 @@ st_convert_sampler(const struct st_context *st,
       assert(sampler->min_lod <= sampler->max_lod);
    }
 
+   /* Check that only wrap modes using the border color have the first bit
+    * set.
+    */
+   STATIC_ASSERT(PIPE_TEX_WRAP_CLAMP & 0x1);
+   STATIC_ASSERT(PIPE_TEX_WRAP_CLAMP_TO_BORDER & 0x1);
+   STATIC_ASSERT(PIPE_TEX_WRAP_MIRROR_CLAMP & 0x1);
+   STATIC_ASSERT(PIPE_TEX_WRAP_MIRROR_CLAMP_TO_BORDER & 0x1);
+   STATIC_ASSERT(((PIPE_TEX_WRAP_REPEAT |
+                   PIPE_TEX_WRAP_CLAMP_TO_EDGE |
+                   PIPE_TEX_WRAP_MIRROR_REPEAT |
+                   PIPE_TEX_WRAP_MIRROR_CLAMP_TO_EDGE) & 0x1) == 0);
+
    /* For non-black borders... */
-   if (msamp->BorderColor.ui[0] ||
-       msamp->BorderColor.ui[1] ||
-       msamp->BorderColor.ui[2] ||
-       msamp->BorderColor.ui[3]) {
+   if (/* This is true if wrap modes are using the border color: */
+       (sampler->wrap_s | sampler->wrap_t | sampler->wrap_r) & 0x1 &&
+       (msamp->BorderColor.ui[0] ||
+        msamp->BorderColor.ui[1] ||
+        msamp->BorderColor.ui[2] ||
+        msamp->BorderColor.ui[3])) {
       const GLboolean is_integer = texobj->_IsIntegerFormat;
       GLenum texBaseFormat = _mesa_base_tex_image(texobj)->_BaseFormat;