radeonsi: remove unused si_shader_context::type
[mesa.git] / src / gallium / drivers / panfrost / pan_blending.c
index 72eeb59280ca12fd9d5b89ae834df41fcfe10cc8..5a94975230db16bf3004c92e158bcc7a6942699d 100644 (file)
@@ -26,7 +26,7 @@
 #include "pan_blending.h"
 #include "pan_context.h"
 #include "gallium/auxiliary/util/u_blend.h"
-#include "util/u_format.h"
+#include "util/format/u_format.h"
 
 /*
  * Implements fixed-function blending on Midgard.
@@ -107,23 +107,18 @@ panfrost_can_fixed_blend(enum pipe_format format)
         /* Fixed-function can handle sRGB */
         format = util_format_linear(format);
 
-        /* Decompose the format */
-        const struct util_format_description *desc =
-                util_format_description(format);
-
-        /* Any 8-bit unorm is supported */
-        if (util_format_is_unorm8(desc))
+        switch (panfrost_pipe_format_table[format].hw) {
+        case MALI_RGB565:
+        case MALI_RGB5_A1_UNORM:
+        case MALI_RGB10_A2_UNORM:
+        case MALI_RGBA4_UNORM:
+        case MALI_R8_UNORM:
+        case MALI_RG8_UNORM:
+        case MALI_RGB8_UNORM:
+        case MALI_RGBA8_UNORM:
                 return true;
-
-        /* Certain special formats are, too */
-        switch (format) {
-                case PIPE_FORMAT_B5G6R5_UNORM:
-                case PIPE_FORMAT_B4G4R4A4_UNORM:
-                case PIPE_FORMAT_B5G5R5A1_UNORM:
-                case PIPE_FORMAT_R10G10B10A2_UNORM:
-                        return true;
-                default:
-                        return false;
+        default:
+                return false;
         }
 }
 
@@ -235,14 +230,14 @@ panfrost_make_fixed_blend_part(unsigned func, unsigned src_factor, unsigned dst_
         /* Make sure that the blend function is representible */
 
         switch (func) {
-                case PIPE_BLEND_ADD:
-                        break;
-
-                /* TODO: Reenable subtraction modes when those fixed */
-                case PIPE_BLEND_SUBTRACT:
-                case PIPE_BLEND_REVERSE_SUBTRACT:
-                default:
-                        return false;
+        case PIPE_BLEND_ADD:
+                break;
+
+        /* TODO: Reenable subtraction modes when those fixed */
+        case PIPE_BLEND_SUBTRACT:
+        case PIPE_BLEND_REVERSE_SUBTRACT:
+        default:
+                return false;
         }
 
         part.clip_modifier = MALI_BLEND_MOD_NORMAL;
@@ -267,7 +262,7 @@ panfrost_make_fixed_blend_part(unsigned func, unsigned src_factor, unsigned dst_
         } else if (src_factor == dst_factor) {
                 /* XXX: Why? */
                 part.dominant = func == PIPE_BLEND_ADD ?
-                        MALI_BLEND_DOM_DESTINATION : MALI_BLEND_DOM_SOURCE;
+                                MALI_BLEND_DOM_DESTINATION : MALI_BLEND_DOM_SOURCE;
 
                 part.nondominant_mode = MALI_BLEND_NON_MIRROR;
         } else if (src_factor == complement_factor(dst_factor)) {
@@ -346,21 +341,18 @@ panfrost_constant_mask(unsigned *factors, unsigned num_factors)
 
 bool
 panfrost_make_fixed_blend_mode(
-                const struct pipe_rt_blend_state *blend,
-                struct mali_blend_equation *out,
-                unsigned *constant_mask,
-                unsigned colormask)
+        struct pipe_rt_blend_state blend,
+        struct mali_blend_equation_packed *out,
+        unsigned *constant_mask)
 {
-        /* Gallium and Mali represent colour masks identically. XXX: Static
-         * assert for future proof */
-
-        out->color_mask = colormask;
-
         /* If no blending is enabled, default back on `replace` mode */
 
-        if (!blend->blend_enable) {
-                out->rgb_mode = 0x122;
-                out->alpha_mode = 0x122;
+        if (!blend.blend_enable) {
+                pan_pack(out, BLEND_EQUATION, cfg) {
+                        cfg.color_mask = blend.colormask;
+                        cfg.rgb_mode = cfg.alpha_mode = 0x122;
+                }
+
                 return true;
         }
 
@@ -369,8 +361,8 @@ panfrost_make_fixed_blend_mode(
          * fixed-function blending */
 
         unsigned factors[] = {
-                blend->rgb_src_factor, blend->rgb_dst_factor,
-                blend->alpha_src_factor, blend->alpha_dst_factor,
+                blend.rgb_src_factor, blend.rgb_dst_factor,
+                blend.alpha_src_factor, blend.alpha_dst_factor,
         };
 
         *constant_mask = panfrost_constant_mask(factors, ARRAY_SIZE(factors));
@@ -381,17 +373,20 @@ panfrost_make_fixed_blend_mode(
         unsigned alpha_mode = 0;
 
         if (!panfrost_make_fixed_blend_part(
-                                blend->rgb_func, blend->rgb_src_factor, blend->rgb_dst_factor,
-                                &rgb_mode))
+                    blend.rgb_func, blend.rgb_src_factor, blend.rgb_dst_factor,
+                    &rgb_mode))
                 return false;
 
         if (!panfrost_make_fixed_blend_part(
-                                blend->alpha_func, blend->alpha_src_factor, blend->alpha_dst_factor,
-                                &alpha_mode))
+                    blend.alpha_func, blend.alpha_src_factor, blend.alpha_dst_factor,
+                    &alpha_mode))
                 return false;
 
-        out->rgb_mode = rgb_mode;
-        out->alpha_mode = alpha_mode;
+        pan_pack(out, BLEND_EQUATION, cfg) {
+                cfg.color_mask = blend.colormask;
+                cfg.rgb_mode = rgb_mode;
+                cfg.alpha_mode = alpha_mode;
+        }
 
         return true;
 }