gallium: extract out logicop helper
authorRob Clark <robdclark@chromium.org>
Thu, 30 Apr 2020 00:31:56 +0000 (17:31 -0700)
committerMarge Bot <eric+marge@anholt.net>
Thu, 30 Apr 2020 03:45:12 +0000 (03:45 +0000)
Signed-off-by: Rob Clark <robdclark@chromium.org>
Reviewed-by: Kristian H. Kristensen <hoegsberg@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4826>

src/gallium/auxiliary/util/u_inlines.h
src/gallium/drivers/freedreno/a3xx/fd3_blend.c
src/gallium/drivers/freedreno/a4xx/fd4_blend.c
src/gallium/drivers/freedreno/a5xx/fd5_blend.c
src/gallium/drivers/freedreno/a6xx/fd6_blend.c

index 8adf343cf8a417b533cf2f3b6bc763ab84187428..8d656f63fa3e38a5559fff4e748d157d9249e146 100644 (file)
@@ -736,6 +736,32 @@ util_texrange_covers_whole_level(const struct pipe_resource *tex,
           depth == util_num_layers(tex, level);
 }
 
+static inline bool
+util_logicop_reads_dest(enum pipe_logicop op)
+{
+   switch (op) {
+   case PIPE_LOGICOP_NOR:
+   case PIPE_LOGICOP_AND_INVERTED:
+   case PIPE_LOGICOP_AND_REVERSE:
+   case PIPE_LOGICOP_INVERT:
+   case PIPE_LOGICOP_XOR:
+   case PIPE_LOGICOP_NAND:
+   case PIPE_LOGICOP_AND:
+   case PIPE_LOGICOP_EQUIV:
+   case PIPE_LOGICOP_NOOP:
+   case PIPE_LOGICOP_OR_INVERTED:
+   case PIPE_LOGICOP_OR_REVERSE:
+   case PIPE_LOGICOP_OR:
+      return true;
+   case PIPE_LOGICOP_CLEAR:
+   case PIPE_LOGICOP_COPY_INVERTED:
+   case PIPE_LOGICOP_COPY:
+   case PIPE_LOGICOP_SET:
+      return false;
+   }
+   unreachable("bad logicop");
+}
+
 static inline struct pipe_context *
 pipe_create_multimedia_context(struct pipe_screen *screen)
 {
index 383e557f18ea33b06122892935cdcabe759ad6ae..5773ed2eef42ca0d1d3a49511f6011e7156dfa7c 100644 (file)
@@ -66,23 +66,7 @@ fd3_blend_state_create(struct pipe_context *pctx,
 
        if (cso->logicop_enable) {
                rop = cso->logicop_func;  /* maps 1:1 */
-
-               switch (cso->logicop_func) {
-               case PIPE_LOGICOP_NOR:
-               case PIPE_LOGICOP_AND_INVERTED:
-               case PIPE_LOGICOP_AND_REVERSE:
-               case PIPE_LOGICOP_INVERT:
-               case PIPE_LOGICOP_XOR:
-               case PIPE_LOGICOP_NAND:
-               case PIPE_LOGICOP_AND:
-               case PIPE_LOGICOP_EQUIV:
-               case PIPE_LOGICOP_NOOP:
-               case PIPE_LOGICOP_OR_INVERTED:
-               case PIPE_LOGICOP_OR_REVERSE:
-               case PIPE_LOGICOP_OR:
-                       reads_dest = true;
-                       break;
-               }
+               reads_dest = util_logicop_reads_dest(cso->logicop_func);
        }
 
        so = CALLOC_STRUCT(fd3_blend_stateobj);
index 9a728088192c13d735ec51f13cadcd401987840e..9b067e0e07b9eb5b280f643ffc4d0604eb955a7f 100644 (file)
@@ -64,23 +64,7 @@ fd4_blend_state_create(struct pipe_context *pctx,
 
        if (cso->logicop_enable) {
                rop = cso->logicop_func;  /* maps 1:1 */
-
-               switch (cso->logicop_func) {
-               case PIPE_LOGICOP_NOR:
-               case PIPE_LOGICOP_AND_INVERTED:
-               case PIPE_LOGICOP_AND_REVERSE:
-               case PIPE_LOGICOP_INVERT:
-               case PIPE_LOGICOP_XOR:
-               case PIPE_LOGICOP_NAND:
-               case PIPE_LOGICOP_AND:
-               case PIPE_LOGICOP_EQUIV:
-               case PIPE_LOGICOP_NOOP:
-               case PIPE_LOGICOP_OR_INVERTED:
-               case PIPE_LOGICOP_OR_REVERSE:
-               case PIPE_LOGICOP_OR:
-                       reads_dest = true;
-                       break;
-               }
+               reads_dest = util_logicop_reads_dest(cso->logicop_func);
        }
 
        so = CALLOC_STRUCT(fd4_blend_stateobj);
index a7efcca6187fe2049b4963a99d5c43f2ea8d2513..c98d7c5863a5ecd92f072278aae54cd6421bfced 100644 (file)
@@ -65,23 +65,7 @@ fd5_blend_state_create(struct pipe_context *pctx,
 
        if (cso->logicop_enable) {
                rop = cso->logicop_func;  /* maps 1:1 */
-
-               switch (cso->logicop_func) {
-               case PIPE_LOGICOP_NOR:
-               case PIPE_LOGICOP_AND_INVERTED:
-               case PIPE_LOGICOP_AND_REVERSE:
-               case PIPE_LOGICOP_INVERT:
-               case PIPE_LOGICOP_XOR:
-               case PIPE_LOGICOP_NAND:
-               case PIPE_LOGICOP_AND:
-               case PIPE_LOGICOP_EQUIV:
-               case PIPE_LOGICOP_NOOP:
-               case PIPE_LOGICOP_OR_INVERTED:
-               case PIPE_LOGICOP_OR_REVERSE:
-               case PIPE_LOGICOP_OR:
-                       reads_dest = true;
-                       break;
-               }
+               reads_dest = util_logicop_reads_dest(cso->logicop_func);
        }
 
        so = CALLOC_STRUCT(fd5_blend_stateobj);
index 734f1868b01099f5ffda7e441d3e98254b039470..40a99822297651cc2993c3e88361bf541147e129 100644 (file)
@@ -68,23 +68,7 @@ fd6_blend_state_create(struct pipe_context *pctx,
 
        if (cso->logicop_enable) {
                rop = cso->logicop_func;  /* maps 1:1 */
-
-               switch (cso->logicop_func) {
-               case PIPE_LOGICOP_NOR:
-               case PIPE_LOGICOP_AND_INVERTED:
-               case PIPE_LOGICOP_AND_REVERSE:
-               case PIPE_LOGICOP_INVERT:
-               case PIPE_LOGICOP_XOR:
-               case PIPE_LOGICOP_NAND:
-               case PIPE_LOGICOP_AND:
-               case PIPE_LOGICOP_EQUIV:
-               case PIPE_LOGICOP_NOOP:
-               case PIPE_LOGICOP_OR_INVERTED:
-               case PIPE_LOGICOP_OR_REVERSE:
-               case PIPE_LOGICOP_OR:
-                       reads_dest = true;
-                       break;
-               }
+               reads_dest = util_logicop_reads_dest(cso->logicop_func);
        }
 
        so = CALLOC_STRUCT(fd6_blend_stateobj);