[Mesa-dev] [PATCH 4/8] i965: move brw_meta_set_fast_clear_color to brw_meta_util.c

Jason Ekstrand jason at jlekstrand.net
Thu May 12 23:30:46 UTC 2016


---
 src/mesa/drivers/dri/i965/brw_meta_fast_clear.c | 64 -------------------------
 src/mesa/drivers/dri/i965/brw_meta_util.c       | 63 ++++++++++++++++++++++++
 2 files changed, 63 insertions(+), 64 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_meta_fast_clear.c b/src/mesa/drivers/dri/i965/brw_meta_fast_clear.c
index ace671c..245125d 100644
--- a/src/mesa/drivers/dri/i965/brw_meta_fast_clear.c
+++ b/src/mesa/drivers/dri/i965/brw_meta_fast_clear.c
@@ -44,8 +44,6 @@
 #include "main/api_validate.h"
 #include "main/state.h"
 
-#include "util/format_srgb.h"
-
 #include "vbo/vbo_context.h"
 
 #include "drivers/common/meta.h"
@@ -216,68 +214,6 @@ brw_draw_rectlist(struct brw_context *brw, struct rect *rect, int num_instances)
                   NULL, 0, NULL);
 }
 
-/**
- * Convert the given color to a bitfield suitable for ORing into DWORD 7 of
- * SURFACE_STATE (DWORD 12-15 on SKL+).
- */
-void
-brw_meta_set_fast_clear_color(struct brw_context *brw,
-                              struct intel_mipmap_tree *mt,
-                              const union gl_color_union *color)
-{
-   union gl_color_union override_color = *color;
-
-   /* The sampler doesn't look at the format of the surface when the fast
-    * clear color is used so we need to implement luminance, intensity and
-    * missing components manually.
-    */
-   switch (_mesa_get_format_base_format(mt->format)) {
-   case GL_INTENSITY:
-      override_color.ui[3] = override_color.ui[0];
-      /* flow through */
-   case GL_LUMINANCE:
-   case GL_LUMINANCE_ALPHA:
-      override_color.ui[1] = override_color.ui[0];
-      override_color.ui[2] = override_color.ui[0];
-      break;
-   default:
-      for (int i = 0; i < 3; i++) {
-         if (!_mesa_format_has_color_component(mt->format, i))
-            override_color.ui[i] = 0;
-      }
-      break;
-   }
-
-   if (!_mesa_format_has_color_component(mt->format, 3)) {
-      if (_mesa_is_format_integer_color(mt->format))
-         override_color.ui[3] = 1;
-      else
-         override_color.f[3] = 1.0f;
-   }
-
-   /* Handle linear→SRGB conversion */
-   if (brw->ctx.Color.sRGBEnabled &&
-       _mesa_get_srgb_format_linear(mt->format) != mt->format) {
-      for (int i = 0; i < 3; i++) {
-         override_color.f[i] =
-            util_format_linear_to_srgb_float(override_color.f[i]);
-      }
-   }
-
-   if (brw->gen >= 9) {
-      mt->gen9_fast_clear_color = override_color;
-   } else {
-      mt->fast_clear_color_value = 0;
-      for (int i = 0; i < 4; i++) {
-         /* Testing for non-0 works for integer and float colors */
-         if (override_color.f[i] != 0.0f) {
-             mt->fast_clear_color_value |=
-                1 << (GEN7_SURFACE_CLEAR_COLOR_SHIFT + (3 - i));
-         }
-      }
-   }
-}
-
 static const uint32_t fast_clear_color[4] = { ~0, ~0, ~0, ~0 };
 
 static void
diff --git a/src/mesa/drivers/dri/i965/brw_meta_util.c b/src/mesa/drivers/dri/i965/brw_meta_util.c
index a5d7b11..9267d6e 100644
--- a/src/mesa/drivers/dri/i965/brw_meta_util.c
+++ b/src/mesa/drivers/dri/i965/brw_meta_util.c
@@ -27,6 +27,7 @@
 #include "brw_state.h"
 #include "main/blend.h"
 #include "main/fbobject.h"
+#include "util/format_srgb.h"
 
 /**
  * Helper function for handling mirror image blits.
@@ -367,6 +368,68 @@ brw_is_color_fast_clear_compatible(struct brw_context *brw,
    return true;
 }
 
+/**
+ * Convert the given color to a bitfield suitable for ORing into DWORD 7 of
+ * SURFACE_STATE (DWORD 12-15 on SKL+).
+ */
+void
+brw_meta_set_fast_clear_color(struct brw_context *brw,
+                              struct intel_mipmap_tree *mt,
+                              const union gl_color_union *color)
+{
+   union gl_color_union override_color = *color;
+
+   /* The sampler doesn't look at the format of the surface when the fast
+    * clear color is used so we need to implement luminance, intensity and
+    * missing components manually.
+    */
+   switch (_mesa_get_format_base_format(mt->format)) {
+   case GL_INTENSITY:
+      override_color.ui[3] = override_color.ui[0];
+      /* flow through */
+   case GL_LUMINANCE:
+   case GL_LUMINANCE_ALPHA:
+      override_color.ui[1] = override_color.ui[0];
+      override_color.ui[2] = override_color.ui[0];
+      break;
+   default:
+      for (int i = 0; i < 3; i++) {
+         if (!_mesa_format_has_color_component(mt->format, i))
+            override_color.ui[i] = 0;
+      }
+      break;
+   }
+
+   if (!_mesa_format_has_color_component(mt->format, 3)) {
+      if (_mesa_is_format_integer_color(mt->format))
+         override_color.ui[3] = 1;
+      else
+         override_color.f[3] = 1.0f;
+   }
+
+   /* Handle linear→SRGB conversion */
+   if (brw->ctx.Color.sRGBEnabled &&
+       _mesa_get_srgb_format_linear(mt->format) != mt->format) {
+      for (int i = 0; i < 3; i++) {
+         override_color.f[i] =
+            util_format_linear_to_srgb_float(override_color.f[i]);
+      }
+   }
+
+   if (brw->gen >= 9) {
+      mt->gen9_fast_clear_color = override_color;
+   } else {
+      mt->fast_clear_color_value = 0;
+      for (int i = 0; i < 4; i++) {
+         /* Testing for non-0 works for integer and float colors */
+         if (override_color.f[i] != 0.0f) {
+             mt->fast_clear_color_value |=
+                1 << (GEN7_SURFACE_CLEAR_COLOR_SHIFT + (3 - i));
+         }
+      }
+   }
+}
+
 void
 brw_get_fast_clear_rect(const struct brw_context *brw,
                         const struct gl_framebuffer *fb,
-- 
2.5.0.400.gff86faf



More information about the mesa-dev mailing list