[Mesa-dev] [PATCH v2 27/27] i965/blorp: brw_blorp_clear.cpp -> blorp_clear.c

Jason Ekstrand jason at jlekstrand.net
Tue Jul 26 22:11:31 UTC 2016


---
 src/mesa/drivers/dri/i965/Makefile.sources    |   2 +-
 src/mesa/drivers/dri/i965/blorp_clear.c       | 190 +++++++++++++++++++++++++
 src/mesa/drivers/dri/i965/brw_blorp_clear.cpp | 194 --------------------------
 3 files changed, 191 insertions(+), 195 deletions(-)
 create mode 100644 src/mesa/drivers/dri/i965/blorp_clear.c
 delete mode 100644 src/mesa/drivers/dri/i965/brw_blorp_clear.cpp

diff --git a/src/mesa/drivers/dri/i965/Makefile.sources b/src/mesa/drivers/dri/i965/Makefile.sources
index b4362ce..02705a1 100644
--- a/src/mesa/drivers/dri/i965/Makefile.sources
+++ b/src/mesa/drivers/dri/i965/Makefile.sources
@@ -98,11 +98,11 @@ i965_FILES = \
 	blorp.c \
 	blorp.h \
 	blorp_blit.c \
+	blorp_clear.c \
 	blorp_priv.h \
 	brw_binding_tables.c \
 	brw_blorp.c \
 	brw_blorp.h \
-	brw_blorp_clear.cpp \
 	brw_cc.c \
 	brw_clear.c \
 	brw_clip.c \
diff --git a/src/mesa/drivers/dri/i965/blorp_clear.c b/src/mesa/drivers/dri/i965/blorp_clear.c
new file mode 100644
index 0000000..4603caa
--- /dev/null
+++ b/src/mesa/drivers/dri/i965/blorp_clear.c
@@ -0,0 +1,190 @@
+/*
+ * Copyright © 2013 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#include "blorp_priv.h"
+#include "brw_meta_util.h"
+#include "brw_context.h"
+#include "brw_state.h"
+
+#include "nir_builder.h"
+
+#define FILE_DEBUG_FLAG DEBUG_BLORP
+
+struct brw_blorp_const_color_prog_key
+{
+   bool use_simd16_replicated_data;
+   bool pad[3];
+};
+
+static void
+brw_blorp_params_get_clear_kernel(struct brw_context *brw,
+                                  struct brw_blorp_params *params,
+                                  bool use_replicated_data)
+{
+   struct brw_blorp_const_color_prog_key blorp_key;
+   memset(&blorp_key, 0, sizeof(blorp_key));
+   blorp_key.use_simd16_replicated_data = use_replicated_data;
+
+   if (brw_search_cache(&brw->cache, BRW_CACHE_BLORP_PROG,
+                        &blorp_key, sizeof(blorp_key),
+                        &params->wm_prog_kernel, &params->wm_prog_data))
+      return;
+
+   void *mem_ctx = ralloc_context(NULL);
+
+   nir_builder b;
+   nir_builder_init_simple_shader(&b, NULL, MESA_SHADER_FRAGMENT, NULL);
+   b.shader->info.name = ralloc_strdup(b.shader, "BLORP-clear");
+
+   nir_variable *v_color = nir_variable_create(b.shader, nir_var_shader_in,
+                                               glsl_vec4_type(), "v_color");
+   v_color->data.location = VARYING_SLOT_VAR0;
+   v_color->data.interpolation = INTERP_MODE_FLAT;
+
+   nir_variable *frag_color = nir_variable_create(b.shader, nir_var_shader_out,
+                                                  glsl_vec4_type(),
+                                                  "gl_FragColor");
+   frag_color->data.location = FRAG_RESULT_COLOR;
+
+   nir_copy_var(&b, frag_color, v_color);
+
+   struct brw_wm_prog_key wm_key;
+   brw_blorp_init_wm_prog_key(&wm_key);
+
+   struct brw_blorp_prog_data prog_data;
+   unsigned program_size;
+   const unsigned *program =
+      brw_blorp_compile_nir_shader(brw, b.shader, &wm_key, use_replicated_data,
+                                   &prog_data, &program_size);
+
+   brw_upload_cache(&brw->cache, BRW_CACHE_BLORP_PROG,
+                    &blorp_key, sizeof(blorp_key),
+                    program, program_size,
+                    &prog_data, sizeof(prog_data),
+                    &params->wm_prog_kernel, &params->wm_prog_data);
+
+   ralloc_free(mem_ctx);
+}
+
+void
+blorp_fast_clear(struct brw_context *brw, const struct brw_blorp_surf *surf,
+                 uint32_t level, uint32_t layer,
+                 uint32_t x0, uint32_t y0, uint32_t x1, uint32_t y1)
+{
+   struct brw_blorp_params params;
+   brw_blorp_params_init(&params);
+
+   params.x0 = x0;
+   params.y0 = y0;
+   params.x1 = x1;
+   params.y1 = y1;
+
+   memset(&params.wm_inputs, 0xff, 4*sizeof(float));
+   params.fast_clear_op = GEN7_PS_RENDER_TARGET_FAST_CLEAR_ENABLE;
+
+   brw_get_fast_clear_rect(brw, surf->aux_surf, &params.x0, &params.y0,
+                           &params.x1, &params.y1);
+
+   brw_blorp_params_get_clear_kernel(brw, &params, true);
+
+   brw_blorp_surface_info_init(brw, &params.dst, surf, level, layer,
+                               surf->surf->format, true);
+
+   brw_blorp_exec(brw, &params);
+}
+
+
+void
+blorp_clear(struct brw_context *brw, const struct brw_blorp_surf *surf,
+            uint32_t level, uint32_t layer,
+            uint32_t x0, uint32_t y0, uint32_t x1, uint32_t y1,
+            enum isl_format format, union isl_color_value clear_color,
+            bool color_write_disable[4])
+{
+   struct brw_blorp_params params;
+   brw_blorp_params_init(&params);
+
+   params.x0 = x0;
+   params.y0 = y0;
+   params.x1 = x1;
+   params.y1 = y1;
+
+   memcpy(&params.wm_inputs, clear_color.f32, sizeof(float) * 4);
+
+   bool use_simd16_replicated_data = true;
+
+   /* From the SNB PRM (Vol4_Part1):
+    *
+    *     "Replicated data (Message Type = 111) is only supported when
+    *      accessing tiled memory.  Using this Message Type to access linear
+    *      (untiled) memory is UNDEFINED."
+    */
+   if (surf->surf->tiling == ISL_TILING_LINEAR)
+      use_simd16_replicated_data = false;
+
+   /* Constant color writes ignore everyting in blend and color calculator
+    * state.  This is not documented.
+    */
+   for (unsigned i = 0; i < 4; i++) {
+      params.color_write_disable[i] = color_write_disable[i];
+      if (color_write_disable[i])
+         use_simd16_replicated_data = false;
+   }
+
+   brw_blorp_params_get_clear_kernel(brw, &params, use_simd16_replicated_data);
+
+   brw_blorp_surface_info_init(brw, &params.dst, surf, level, layer,
+                               format, true);
+
+   brw_blorp_exec(brw, &params);
+}
+
+void
+brw_blorp_ccs_resolve(struct brw_context *brw, struct brw_blorp_surf *surf,
+                      enum isl_format format)
+{
+   struct brw_blorp_params params;
+   brw_blorp_params_init(&params);
+
+   brw_blorp_surface_info_init(brw, &params.dst, surf,
+                               0 /* level */, 0 /* layer */, format, true);
+
+   brw_get_ccs_resolve_rect(&brw->isl_dev, &params.dst.aux_surf,
+                            &params.x0, &params.y0,
+                            &params.x1, &params.y1);
+
+   if (params.dst.aux_usage == ISL_AUX_USAGE_CCS_E)
+      params.resolve_type = GEN9_PS_RENDER_TARGET_RESOLVE_FULL;
+   else
+      params.resolve_type = GEN7_PS_RENDER_TARGET_RESOLVE_ENABLE;
+
+   /* Note: there is no need to initialize push constants because it doesn't
+    * matter what data gets dispatched to the render target.  However, we must
+    * ensure that the fragment shader delivers the data using the "replicated
+    * color" message.
+    */
+
+   brw_blorp_params_get_clear_kernel(brw, &params, true);
+
+   brw_blorp_exec(brw, &params);
+}
diff --git a/src/mesa/drivers/dri/i965/brw_blorp_clear.cpp b/src/mesa/drivers/dri/i965/brw_blorp_clear.cpp
deleted file mode 100644
index 583d59c..0000000
--- a/src/mesa/drivers/dri/i965/brw_blorp_clear.cpp
+++ /dev/null
@@ -1,194 +0,0 @@
-/*
- * Copyright © 2013 Intel Corporation
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
- * IN THE SOFTWARE.
- */
-
-#include "blorp_priv.h"
-#include "brw_meta_util.h"
-#include "brw_context.h"
-#include "brw_state.h"
-
-#include "nir_builder.h"
-
-#define FILE_DEBUG_FLAG DEBUG_BLORP
-
-struct brw_blorp_const_color_prog_key
-{
-   bool use_simd16_replicated_data;
-   bool pad[3];
-};
-
-static void
-brw_blorp_params_get_clear_kernel(struct brw_context *brw,
-                                  struct brw_blorp_params *params,
-                                  bool use_replicated_data)
-{
-   struct brw_blorp_const_color_prog_key blorp_key;
-   memset(&blorp_key, 0, sizeof(blorp_key));
-   blorp_key.use_simd16_replicated_data = use_replicated_data;
-
-   if (brw_search_cache(&brw->cache, BRW_CACHE_BLORP_PROG,
-                        &blorp_key, sizeof(blorp_key),
-                        &params->wm_prog_kernel, &params->wm_prog_data))
-      return;
-
-   void *mem_ctx = ralloc_context(NULL);
-
-   nir_builder b;
-   nir_builder_init_simple_shader(&b, NULL, MESA_SHADER_FRAGMENT, NULL);
-   b.shader->info.name = ralloc_strdup(b.shader, "BLORP-clear");
-
-   nir_variable *v_color = nir_variable_create(b.shader, nir_var_shader_in,
-                                               glsl_vec4_type(), "v_color");
-   v_color->data.location = VARYING_SLOT_VAR0;
-   v_color->data.interpolation = INTERP_MODE_FLAT;
-
-   nir_variable *frag_color = nir_variable_create(b.shader, nir_var_shader_out,
-                                                  glsl_vec4_type(),
-                                                  "gl_FragColor");
-   frag_color->data.location = FRAG_RESULT_COLOR;
-
-   nir_copy_var(&b, frag_color, v_color);
-
-   struct brw_wm_prog_key wm_key;
-   brw_blorp_init_wm_prog_key(&wm_key);
-
-   struct brw_blorp_prog_data prog_data;
-   unsigned program_size;
-   const unsigned *program =
-      brw_blorp_compile_nir_shader(brw, b.shader, &wm_key, use_replicated_data,
-                                   &prog_data, &program_size);
-
-   brw_upload_cache(&brw->cache, BRW_CACHE_BLORP_PROG,
-                    &blorp_key, sizeof(blorp_key),
-                    program, program_size,
-                    &prog_data, sizeof(prog_data),
-                    &params->wm_prog_kernel, &params->wm_prog_data);
-
-   ralloc_free(mem_ctx);
-}
-
-void
-blorp_fast_clear(struct brw_context *brw, const struct brw_blorp_surf *surf,
-                 uint32_t level, uint32_t layer,
-                 uint32_t x0, uint32_t y0, uint32_t x1, uint32_t y1)
-{
-   struct brw_blorp_params params;
-   brw_blorp_params_init(&params);
-
-   params.x0 = x0;
-   params.y0 = y0;
-   params.x1 = x1;
-   params.y1 = y1;
-
-   memset(&params.wm_inputs, 0xff, 4*sizeof(float));
-   params.fast_clear_op = GEN7_PS_RENDER_TARGET_FAST_CLEAR_ENABLE;
-
-   brw_get_fast_clear_rect(brw, surf->aux_surf, &params.x0, &params.y0,
-                           &params.x1, &params.y1);
-
-   brw_blorp_params_get_clear_kernel(brw, &params, true);
-
-   brw_blorp_surface_info_init(brw, &params.dst, surf, level, layer,
-                               surf->surf->format, true);
-
-   brw_blorp_exec(brw, &params);
-}
-
-
-void
-blorp_clear(struct brw_context *brw, const struct brw_blorp_surf *surf,
-            uint32_t level, uint32_t layer,
-            uint32_t x0, uint32_t y0, uint32_t x1, uint32_t y1,
-            enum isl_format format, union isl_color_value clear_color,
-            bool color_write_disable[4])
-{
-   struct brw_blorp_params params;
-   brw_blorp_params_init(&params);
-
-   params.x0 = x0;
-   params.y0 = y0;
-   params.x1 = x1;
-   params.y1 = y1;
-
-   memcpy(&params.wm_inputs, clear_color.f32, sizeof(float) * 4);
-
-   bool use_simd16_replicated_data = true;
-
-   /* From the SNB PRM (Vol4_Part1):
-    *
-    *     "Replicated data (Message Type = 111) is only supported when
-    *      accessing tiled memory.  Using this Message Type to access linear
-    *      (untiled) memory is UNDEFINED."
-    */
-   if (surf->surf->tiling == ISL_TILING_LINEAR)
-      use_simd16_replicated_data = false;
-
-   /* Constant color writes ignore everyting in blend and color calculator
-    * state.  This is not documented.
-    */
-   for (unsigned i = 0; i < 4; i++) {
-      params.color_write_disable[i] = color_write_disable[i];
-      if (color_write_disable[i])
-         use_simd16_replicated_data = false;
-   }
-
-   brw_blorp_params_get_clear_kernel(brw, &params, use_simd16_replicated_data);
-
-   brw_blorp_surface_info_init(brw, &params.dst, surf, level, layer,
-                               format, true);
-
-   brw_blorp_exec(brw, &params);
-}
-
-extern "C" {
-
-void
-brw_blorp_ccs_resolve(struct brw_context *brw, struct brw_blorp_surf *surf,
-                      enum isl_format format)
-{
-   struct brw_blorp_params params;
-   brw_blorp_params_init(&params);
-
-   brw_blorp_surface_info_init(brw, &params.dst, surf,
-                               0 /* level */, 0 /* layer */, format, true);
-
-   brw_get_ccs_resolve_rect(&brw->isl_dev, &params.dst.aux_surf,
-                            &params.x0, &params.y0,
-                            &params.x1, &params.y1);
-
-   if (params.dst.aux_usage == ISL_AUX_USAGE_CCS_E)
-      params.resolve_type = GEN9_PS_RENDER_TARGET_RESOLVE_FULL;
-   else
-      params.resolve_type = GEN7_PS_RENDER_TARGET_RESOLVE_ENABLE;
-
-   /* Note: there is no need to initialize push constants because it doesn't
-    * matter what data gets dispatched to the render target.  However, we must
-    * ensure that the fragment shader delivers the data using the "replicated
-    * color" message.
-    */
-
-   brw_blorp_params_get_clear_kernel(brw, &params, true);
-
-   brw_blorp_exec(brw, &params);
-}
-
-} /* extern "C" */
-- 
2.5.0.400.gff86faf



More information about the mesa-dev mailing list