mesa: do not use bitfields for advanced-blend state
authorErik Faye-Lund <erik.faye-lund@collabora.com>
Wed, 24 Jun 2020 13:40:34 +0000 (15:40 +0200)
committerMarge Bot <eric+marge@anholt.net>
Fri, 17 Jul 2020 06:19:16 +0000 (06:19 +0000)
Signed-off-by: Elie Tournier <elie.tournier@collabora.com>
Reviewed-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5516>

src/compiler/glsl/glsl_parser.yy
src/compiler/glsl/lower_blend_equation_advanced.cpp
src/compiler/shader_enums.h
src/mesa/main/draw_validate.c

index 944329a92d88b2890e6e8f8d0a4ee13f201778fc..ec2dd6a05138c059f183a74d19f6464b9c7bd171 100644 (file)
@@ -1598,22 +1598,22 @@ layout_qualifier_id:
             const char *s;
             uint32_t mask;
          } map[] = {
-                 { "blend_support_multiply",       BLEND_MULTIPLY },
-                 { "blend_support_screen",         BLEND_SCREEN },
-                 { "blend_support_overlay",        BLEND_OVERLAY },
-                 { "blend_support_darken",         BLEND_DARKEN },
-                 { "blend_support_lighten",        BLEND_LIGHTEN },
-                 { "blend_support_colordodge",     BLEND_COLORDODGE },
-                 { "blend_support_colorburn",      BLEND_COLORBURN },
-                 { "blend_support_hardlight",      BLEND_HARDLIGHT },
-                 { "blend_support_softlight",      BLEND_SOFTLIGHT },
-                 { "blend_support_difference",     BLEND_DIFFERENCE },
-                 { "blend_support_exclusion",      BLEND_EXCLUSION },
-                 { "blend_support_hsl_hue",        BLEND_HSL_HUE },
-                 { "blend_support_hsl_saturation", BLEND_HSL_SATURATION },
-                 { "blend_support_hsl_color",      BLEND_HSL_COLOR },
-                 { "blend_support_hsl_luminosity", BLEND_HSL_LUMINOSITY },
-                 { "blend_support_all_equations",  BLEND_ALL },
+                 { "blend_support_multiply",       BITFIELD_BIT(BLEND_MULTIPLY) },
+                 { "blend_support_screen",         BITFIELD_BIT(BLEND_SCREEN) },
+                 { "blend_support_overlay",        BITFIELD_BIT(BLEND_OVERLAY) },
+                 { "blend_support_darken",         BITFIELD_BIT(BLEND_DARKEN) },
+                 { "blend_support_lighten",        BITFIELD_BIT(BLEND_LIGHTEN) },
+                 { "blend_support_colordodge",     BITFIELD_BIT(BLEND_COLORDODGE) },
+                 { "blend_support_colorburn",      BITFIELD_BIT(BLEND_COLORBURN) },
+                 { "blend_support_hardlight",      BITFIELD_BIT(BLEND_HARDLIGHT) },
+                 { "blend_support_softlight",      BITFIELD_BIT(BLEND_SOFTLIGHT) },
+                 { "blend_support_difference",     BITFIELD_BIT(BLEND_DIFFERENCE) },
+                 { "blend_support_exclusion",      BITFIELD_BIT(BLEND_EXCLUSION) },
+                 { "blend_support_hsl_hue",        BITFIELD_BIT(BLEND_HSL_HUE) },
+                 { "blend_support_hsl_saturation", BITFIELD_BIT(BLEND_HSL_SATURATION) },
+                 { "blend_support_hsl_color",      BITFIELD_BIT(BLEND_HSL_COLOR) },
+                 { "blend_support_hsl_luminosity", BITFIELD_BIT(BLEND_HSL_LUMINOSITY) },
+                 { "blend_support_all_equations",  (1u << (BLEND_HSL_LUMINOSITY + 1)) - 2 },
          };
          for (unsigned i = 0; i < ARRAY_SIZE(map); i++) {
             if (match_layout_qualifier($1, map[i].s, state) == 0) {
index c85b39bcaa343691b4c83737a77f9fb562988e02..76d4c8b7be4a5ba2751ce493a647ca045056a337 100644 (file)
@@ -329,8 +329,7 @@ calc_blend_result(ir_factory f,
 
    unsigned choices = blend_qualifiers;
    while (choices) {
-      enum gl_advanced_blend_mode choice = (enum gl_advanced_blend_mode)
-         (1u << u_bit_scan(&choices));
+      enum gl_advanced_blend_mode choice = (enum gl_advanced_blend_mode)u_bit_scan(&choices);
 
       ir_if *iff = new(mem_ctx) ir_if(is_mode(mode, choice));
       casefactory.emit(iff);
@@ -385,7 +384,6 @@ calc_blend_result(ir_factory f,
          set_lum(&casefactory, factor, dst_rgb, src_rgb);
          break;
       case BLEND_NONE:
-      case BLEND_ALL:
          unreachable("not real cases");
       }
 
index 440d853aec591d280ce5a6667fc0c39641247c76..4ef3512849f28e66a0e56f35dc0ff31cfb74eaee 100644 (file)
@@ -772,25 +772,22 @@ enum gl_access_qualifier
  */
 enum gl_advanced_blend_mode
 {
-   BLEND_NONE           = 0x0000,
-
-   BLEND_MULTIPLY       = 0x0001,
-   BLEND_SCREEN         = 0x0002,
-   BLEND_OVERLAY        = 0x0004,
-   BLEND_DARKEN         = 0x0008,
-   BLEND_LIGHTEN        = 0x0010,
-   BLEND_COLORDODGE     = 0x0020,
-   BLEND_COLORBURN      = 0x0040,
-   BLEND_HARDLIGHT      = 0x0080,
-   BLEND_SOFTLIGHT      = 0x0100,
-   BLEND_DIFFERENCE     = 0x0200,
-   BLEND_EXCLUSION      = 0x0400,
-   BLEND_HSL_HUE        = 0x0800,
-   BLEND_HSL_SATURATION = 0x1000,
-   BLEND_HSL_COLOR      = 0x2000,
-   BLEND_HSL_LUMINOSITY = 0x4000,
-
-   BLEND_ALL            = 0x7fff,
+   BLEND_NONE = 0,
+   BLEND_MULTIPLY,
+   BLEND_SCREEN,
+   BLEND_OVERLAY,
+   BLEND_DARKEN,
+   BLEND_LIGHTEN,
+   BLEND_COLORDODGE,
+   BLEND_COLORBURN,
+   BLEND_HARDLIGHT,
+   BLEND_SOFTLIGHT,
+   BLEND_DIFFERENCE,
+   BLEND_EXCLUSION,
+   BLEND_HSL_HUE,
+   BLEND_HSL_SATURATION,
+   BLEND_HSL_COLOR,
+   BLEND_HSL_LUMINOSITY,
 };
 
 enum blend_func
index 5a1f6d2a194bbb5ebd24569a278c01c319b9d7a9..36734c52445666c787d44adbc2fa584ff3755844 100644 (file)
@@ -101,7 +101,7 @@ check_blend_func_error(struct gl_context *ctx)
       const struct gl_program *prog = ctx->FragmentProgram._Current;
       const GLbitfield blend_support = !prog ? 0 : prog->sh.fs.BlendSupport;
 
-      if ((blend_support & ctx->Color._AdvancedBlendMode) == 0) {
+      if ((blend_support & BITFIELD_BIT(ctx->Color._AdvancedBlendMode)) == 0) {
          _mesa_error(ctx, GL_INVALID_OPERATION,
                      "fragment shader does not allow advanced blending mode "
                      "(%s)",