[virglrenderer-devel] [PATCH 2/2] Avoid needless repetition

Erik Faye-Lund erik.faye-lund at collabora.com
Tue Jul 17 07:44:55 UTC 2018


We end up evaluating vrend_format_is_emulated_alpha once in either
case, so let's just lift the logic up so we only have one call-site
in this function.

Signed-off-by: Erik Faye-Lund <erik.faye-lund at collabora.com>
---
 src/vrend_renderer.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/vrend_renderer.c b/src/vrend_renderer.c
index afb291d..cdb7931 100644
--- a/src/vrend_renderer.c
+++ b/src/vrend_renderer.c
@@ -4178,8 +4178,9 @@ static void vrend_apply_sampler_state(struct vrend_context *ctx,
     * the sampler to use the red channel and not the alpha one
     * by swizzling the GL_TEXTURE_BORDER_COLOR parameter.
     */
+   bool is_emulated_alpha = vrend_format_is_emulated_alpha(res->base.format);
    if (vrend_state.have_samplers) {
-      if (vrend_format_is_emulated_alpha(res->base.format)) {
+      if (is_emulated_alpha) {
          union pipe_color_union border_color;
          border_color = state->border_color;
          border_color.ui[0] = border_color.ui[3];
@@ -4241,7 +4242,6 @@ static void vrend_apply_sampler_state(struct vrend_context *ctx,
       }
    }
 
-   bool is_emulated_alpha = vrend_format_is_emulated_alpha(res->base.format);
    if (memcmp(&tex->state.border_color, &state->border_color, 16) || set_all ||
        is_emulated_alpha) {
       if (is_emulated_alpha) {
-- 
2.18.0.rc2



More information about the virglrenderer-devel mailing list