[Mesa-dev] [PATCH 40/42] panfrost/midgard: Cleanup blend switch

Alyssa Rosenzweig alyssa.rosenzweig at collabora.com
Mon Jul 8 14:08:53 UTC 2019


Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig at collabora.com>
---
 .../panfrost/midgard/nir_lower_framebuffer.c  | 49 ++++++++++++-------
 1 file changed, 31 insertions(+), 18 deletions(-)

diff --git a/src/gallium/drivers/panfrost/midgard/nir_lower_framebuffer.c b/src/gallium/drivers/panfrost/midgard/nir_lower_framebuffer.c
index c66f77aa406..fe6ae121a4c 100644
--- a/src/gallium/drivers/panfrost/midgard/nir_lower_framebuffer.c
+++ b/src/gallium/drivers/panfrost/midgard/nir_lower_framebuffer.c
@@ -167,24 +167,37 @@ nir_shader_to_native(nir_builder *b,
       return nir_float_to_unorm8(b, c_shader);
    else if (homogenous_bits && float_or_pure_int)
       return c_shader; /* type is already correct */
-   else if (homogenous_bits && bits == 4 && util_format_is_unorm(desc->format)) {
-      /* TODO: Swizzle generally */
-      unsigned swiz[4] = { 2, 1, 0, 3 }; /* BGRA */
-      c_shader = nir_swizzle(b, c_shader, swiz, 4);
-      return nir_float_to_unorm4(b, c_shader);
-   } else if (desc->format == PIPE_FORMAT_R10G10B10A2_UNORM || desc->format == PIPE_FORMAT_B10G10R10A2_UNORM)
-     return nir_float_to_rgb10a2(b, c_shader, true); 
-   else if (desc->format == PIPE_FORMAT_R10G10B10A2_UINT)
-     return nir_float_to_rgb10a2(b, c_shader, false); 
-   else if (desc->format == PIPE_FORMAT_B5G5R5A1_UNORM) {
-      unsigned swiz[4] = { 2, 1, 0, 3 }; /* BGRA */
-      c_shader = nir_swizzle(b, c_shader, swiz, 4);
-      return nir_float_to_rgb5a1(b, c_shader);
-   } else if (desc->format == PIPE_FORMAT_R11G11B10_FLOAT) {
-      return nir_format_pack_11f11f10f(b, c_shader);
-   } else {
-      printf("%s\n", desc->name);
-      unreachable("Unknown format name");
+
+   //unsigned bgra[4] = { 2, 1, 0, 3 }; /* BGRA */
+   //c_shader = nir_swizzle(b, c_shader, swiz, 4);
+
+   /* Special formats */
+   switch (desc->format) {
+      case PIPE_FORMAT_B4G4R4A4_UNORM:
+      case PIPE_FORMAT_B4G4R4X4_UNORM:
+      case PIPE_FORMAT_A4R4_UNORM:
+      case PIPE_FORMAT_R4A4_UNORM:
+      case PIPE_FORMAT_A4B4G4R4_UNORM:
+         return nir_float_to_unorm4(b, c_shader);
+
+      case PIPE_FORMAT_R10G10B10A2_UNORM:
+      case PIPE_FORMAT_B10G10R10A2_UNORM:
+      case PIPE_FORMAT_R10G10B10X2_UNORM:
+      case PIPE_FORMAT_B10G10R10X2_UNORM:
+        return nir_float_to_rgb10a2(b, c_shader, true); 
+
+      case PIPE_FORMAT_R10G10B10A2_UINT:
+        return nir_float_to_rgb10a2(b, c_shader, false); 
+
+      case PIPE_FORMAT_B5G5R5A1_UNORM:
+         return nir_float_to_rgb5a1(b, c_shader);
+
+      case PIPE_FORMAT_R11G11B10_FLOAT:
+         return nir_format_pack_11f11f10f(b, c_shader);
+
+      default:
+         printf("%s\n", desc->name);
+         unreachable("Unknown format name");
    }
 }
 
-- 
2.20.1



More information about the mesa-dev mailing list