Module: Mesa Branch: main Commit: c68c36f890c2f798144f24c93c85c9f353c0121e URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=c68c36f890c2f798144f24c93c85c9f353c0121e
Author: Mike Blumenkrantz <[email protected]> Date: Mon Aug 1 10:41:49 2022 -0400 mesa/st: simplify sampler border color swizzling this reuses the pre-calculated swizzle value to resolve a TODO item and improve perf Reviewed-by: Marek Olšák <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17687> --- src/mesa/state_tracker/st_atom_sampler.c | 39 +++++++++++++------------------- 1 file changed, 16 insertions(+), 23 deletions(-) diff --git a/src/mesa/state_tracker/st_atom_sampler.c b/src/mesa/state_tracker/st_atom_sampler.c index 5ed72c9c696..78be9aa1ca6 100644 --- a/src/mesa/state_tracker/st_atom_sampler.c +++ b/src/mesa/state_tracker/st_atom_sampler.c @@ -50,6 +50,7 @@ #include "cso_cache/cso_context.h" #include "util/format/u_format.h" +#include "program/prog_instruction.h" /** @@ -105,29 +106,21 @@ st_convert_sampler(const struct st_context *st, if (st->apply_texture_swizzle_to_border_color || st->alpha_border_color_is_not_w || st->use_format_with_border_color) { if (st->apply_texture_swizzle_to_border_color) { - const struct gl_texture_object *stobj = st_texture_object_const(texobj); - /* XXX: clean that up to not use the sampler view at all */ - const struct st_sampler_view *sv = st_texture_get_current_sampler_view(st, stobj); - - if (sv) { - struct pipe_sampler_view *view = sv->view; - union pipe_color_union tmp = sampler->border_color; - const unsigned char swz[4] = - { - view->swizzle_r, - view->swizzle_g, - view->swizzle_b, - view->swizzle_a, - }; - - st_translate_color(&tmp, texBaseFormat, is_integer); - - util_format_apply_color_swizzle(&sampler->border_color, - &tmp, swz, is_integer); - } else { - st_translate_color(&sampler->border_color, - texBaseFormat, is_integer); - } + const unsigned swizzle = glsl130_or_later ? texobj->SwizzleGLSL130 : texobj->Swizzle; + + union pipe_color_union tmp = sampler->border_color; + const unsigned char swz[4] = + { + GET_SWZ(swizzle, 0), + GET_SWZ(swizzle, 1), + GET_SWZ(swizzle, 2), + GET_SWZ(swizzle, 3), + }; + + st_translate_color(&tmp, texBaseFormat, is_integer); + + util_format_apply_color_swizzle(&sampler->border_color, + &tmp, swz, is_integer); } else { bool srgb_skip_decode = false;
