[Mesa-dev] [PATCH] st/mesa: don't set the border color if it's unused
Marek Olšák
maraeo at gmail.com
Thu Jun 15 11:56:18 UTC 2017
From: Marek Olšák <marek.olsak at amd.com>
---
src/mesa/state_tracker/st_atom_sampler.c | 22 ++++++++++++++++++----
1 file changed, 18 insertions(+), 4 deletions(-)
diff --git a/src/mesa/state_tracker/st_atom_sampler.c b/src/mesa/state_tracker/st_atom_sampler.c
index 8a2205d..f2f4bae 100644
--- a/src/mesa/state_tracker/st_atom_sampler.c
+++ b/src/mesa/state_tracker/st_atom_sampler.c
@@ -143,25 +143,39 @@ st_convert_sampler(const struct st_context *st,
if (sampler->max_lod < sampler->min_lod) {
/* The GL spec doesn't seem to specify what to do in this case.
* Swap the values.
*/
float tmp = sampler->max_lod;
sampler->max_lod = sampler->min_lod;
sampler->min_lod = tmp;
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 ((msamp->BorderColor.ui[0] ||
+ msamp->BorderColor.ui[1] ||
+ msamp->BorderColor.ui[2] ||
+ msamp->BorderColor.ui[3]) &&
+ /* This is true if wrap modes are using the border color. */
+ (sampler->wrap_s | sampler->wrap_t | sampler->wrap_r) & 0x1) {
const GLboolean is_integer = texobj->_IsIntegerFormat;
GLenum texBaseFormat = _mesa_base_tex_image(texobj)->_BaseFormat;
if (st->apply_texture_swizzle_to_border_color) {
const struct st_texture_object *stobj = st_texture_object_const(texobj);
const struct pipe_sampler_view *sv = NULL;
/* Just search for the first used view. We can do this because the
swizzle is per-texture, not per context. */
/* XXX: clean that up to not use the sampler view at all */
--
2.7.4
More information about the mesa-dev
mailing list