panfrost: XMLify stencil op
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Wed, 5 Aug 2020 22:51:27 +0000 (18:51 -0400)
committerTomeu Vizoso <tomeu.vizoso@collabora.com>
Thu, 13 Aug 2020 06:55:15 +0000 (08:55 +0200)
Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Reviewed-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6195>

src/gallium/drivers/panfrost/pan_cmdstream.c
src/panfrost/include/panfrost-job.h
src/panfrost/lib/decode.c
src/panfrost/lib/midgard.xml
src/panfrost/lib/pan_blit.c

index f155f6191289263987db709507e0367bcabc0280..c1a5ebbf3ea96d83cff936e2722742c9f5d8a84e 100644 (file)
@@ -387,28 +387,28 @@ panfrost_translate_stencil_op(enum pipe_stencil_op in)
 {
         switch (in) {
         case PIPE_STENCIL_OP_KEEP:
-                return MALI_STENCIL_KEEP;
+                return MALI_STENCIL_OP_KEEP;
 
         case PIPE_STENCIL_OP_ZERO:
-                return MALI_STENCIL_ZERO;
+                return MALI_STENCIL_OP_ZERO;
 
         case PIPE_STENCIL_OP_REPLACE:
-               return MALI_STENCIL_REPLACE;
+               return MALI_STENCIL_OP_REPLACE;
 
         case PIPE_STENCIL_OP_INCR:
-                return MALI_STENCIL_INCR;
+                return MALI_STENCIL_OP_INCR_SAT;
 
         case PIPE_STENCIL_OP_DECR:
-                return MALI_STENCIL_DECR;
+                return MALI_STENCIL_OP_DECR_SAT;
 
         case PIPE_STENCIL_OP_INCR_WRAP:
-                return MALI_STENCIL_INCR_WRAP;
+                return MALI_STENCIL_OP_INCR_WRAP;
 
         case PIPE_STENCIL_OP_DECR_WRAP:
-                return MALI_STENCIL_DECR_WRAP;
+                return MALI_STENCIL_OP_DECR_WRAP;
 
         case PIPE_STENCIL_OP_INVERT:
-                return MALI_STENCIL_INVERT;
+                return MALI_STENCIL_OP_INVERT;
 
         default:
                 unreachable("Invalid stencil op");
@@ -585,9 +585,9 @@ panfrost_frag_meta_zsa_update(struct panfrost_context *ctx,
                 struct pipe_stencil_state default_stencil = {
                         .enabled = 0,
                         .func = PIPE_FUNC_ALWAYS,
-                        .fail_op = MALI_STENCIL_KEEP,
-                        .zfail_op = MALI_STENCIL_KEEP,
-                        .zpass_op = MALI_STENCIL_KEEP,
+                        .fail_op = PIPE_STENCIL_OP_KEEP,
+                        .zfail_op = PIPE_STENCIL_OP_KEEP,
+                        .zpass_op = PIPE_STENCIL_OP_KEEP,
                         .writemask = 0xFF,
                         .valuemask = 0xFF
                 };
index e8f7aaaa312ef0fcf82901026f66df78e1ccb8df..99d3d85f1bc58a4eacf2348a6fef79652f153d08 100644 (file)
@@ -88,17 +88,6 @@ typedef uint64_t mali_ptr;
 /* Stencil test state is all encoded in a single u32, just with a lot of
  * enums... */
 
-enum mali_stencil_op {
-        MALI_STENCIL_KEEP      = 0,
-        MALI_STENCIL_REPLACE   = 1,
-        MALI_STENCIL_ZERO      = 2,
-        MALI_STENCIL_INVERT    = 3,
-        MALI_STENCIL_INCR_WRAP         = 4,
-        MALI_STENCIL_DECR_WRAP         = 5,
-        MALI_STENCIL_INCR      = 6,
-        MALI_STENCIL_DECR      = 7
-};
-
 struct mali_stencil_test {
         unsigned ref                   : 8;
         unsigned mask                  : 8;
index 69f995aa5cd479ab2754b9f76b642fedcb0bd40c..66bd6827bf88230c37103ddd3858e57fefcf415a 100644 (file)
@@ -480,28 +480,6 @@ pandecode_msaa_mode(enum mali_msaa_mode mode)
 }
 #undef DEFINE_CASE
 
-#define DEFINE_CASE(name) case MALI_STENCIL_ ## name: return "MALI_STENCIL_" #name
-static char *
-pandecode_stencil_op(enum mali_stencil_op op)
-{
-        switch (op) {
-                DEFINE_CASE(KEEP);
-                DEFINE_CASE(REPLACE);
-                DEFINE_CASE(ZERO);
-                DEFINE_CASE(INVERT);
-                DEFINE_CASE(INCR_WRAP);
-                DEFINE_CASE(DECR_WRAP);
-                DEFINE_CASE(INCR);
-                DEFINE_CASE(DECR);
-
-        default:
-                pandecode_msg("XXX: invalid stencil op %X\n", op);
-                return "";
-        }
-}
-
-#undef DEFINE_CASE
-
 static char *pandecode_attr_mode_short(enum mali_attr_mode mode)
 {
         switch(mode) {
@@ -1642,9 +1620,9 @@ pandecode_stencil(const char *name, const struct mali_stencil_test *stencil)
                 return;
 
         const char *func = mali_func_as_str(stencil->func);
-        const char *sfail = pandecode_stencil_op(stencil->sfail);
-        const char *dpfail = pandecode_stencil_op(stencil->dpfail);
-        const char *dppass = pandecode_stencil_op(stencil->dppass);
+        const char *sfail = mali_stencil_op_as_str(stencil->sfail);
+        const char *dpfail = mali_stencil_op_as_str(stencil->dpfail);
+        const char *dppass = mali_stencil_op_as_str(stencil->dppass);
 
         if (stencil->zero)
                 pandecode_msg("XXX: stencil zero tripped: %X\n", stencil->zero);
index b7558146fe317b39e3aa8f856f04253ee75dd701..3a9351afe6e6677880b293c4d35d62323e557fac 100644 (file)
     <value name="Always" value="7"/>
   </enum>
 
+  <enum name="Stencil Op">
+    <value name="Keep" value="0"/>
+    <value name="Replace" value="1"/>
+    <value name="Zero" value="2"/>
+    <value name="Invert" value="3"/>
+    <value name="Incr Wrap" value="4"/>
+    <value name="Decr Wrap" value="5"/>
+    <value name="Incr Sat" value="6"/>
+    <value name="Decr Sat" value="7"/>
+  </enum>
+
 </panxml>
index a9289de35f93304cc3a367d99bef2b8cad1c6433..7d5b10de9b0203d60620a48d7fd5312a17596fbd 100644 (file)
@@ -214,9 +214,9 @@ panfrost_load_midg(
         struct mali_stencil_test stencil = {
                 .mask = 0xFF,
                 .func = MALI_FUNC_ALWAYS,
-                .sfail = MALI_STENCIL_REPLACE,
-                .dpfail = MALI_STENCIL_REPLACE,
-                .dppass = MALI_STENCIL_REPLACE,
+                .sfail = MALI_STENCIL_OP_REPLACE,
+                .dpfail = MALI_STENCIL_OP_REPLACE,
+                .dppass = MALI_STENCIL_OP_REPLACE,
         };
 
         union midgard_blend replace = {