intel/blorp: Add support for swizzling fast-clear colors
authorJason Ekstrand <jason@jlekstrand.net>
Tue, 17 Mar 2020 18:36:40 +0000 (13:36 -0500)
committerMarge Bot <eric+marge@anholt.net>
Wed, 18 Mar 2020 21:05:07 +0000 (21:05 +0000)
Cc: mesa-stable@lists.freedesktop.org
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4218>

src/gallium/drivers/iris/iris_clear.c
src/intel/blorp/blorp.h
src/intel/blorp/blorp_clear.c
src/intel/vulkan/anv_blorp.c
src/mesa/drivers/dri/i965/brw_blorp.c

index 087b32f7180ea00fdbaae9608fdd3c87d26ac105..0639b32e9f6e3dc8aa1b985741008e58dd792524 100644 (file)
@@ -315,6 +315,7 @@ fast_clear_color(struct iris_context *ice,
     * conversion in convert_fast_clear_color().
     */
    blorp_fast_clear(&blorp_batch, &surf, isl_format_srgb_to_linear(format),
+                    ISL_SWIZZLE_IDENTITY,
                     level, box->z, box->depth,
                     box->x, box->y, box->x + box->width,
                     box->y + box->height);
index 9ab537177fb44591825c9aee89a5855ca110ac27..dd31ef2e2dc5677b6b53526f98ecdb831676ba2c 100644 (file)
@@ -166,7 +166,8 @@ swizzle_color_value(union isl_color_value src, struct isl_swizzle swizzle);
 
 void
 blorp_fast_clear(struct blorp_batch *batch,
-                 const struct blorp_surf *surf, enum isl_format format,
+                 const struct blorp_surf *surf,
+                 enum isl_format format, struct isl_swizzle swizzle,
                  uint32_t level, uint32_t start_layer, uint32_t num_layers,
                  uint32_t x0, uint32_t y0, uint32_t x1, uint32_t y1);
 
index 6999101c58eaef8277550a2bc19601d211c5aa54..e95f30b747d7fb6e0839adf36c1cf2ea99b7c833 100644 (file)
@@ -334,7 +334,8 @@ get_fast_clear_rect(const struct isl_device *dev,
 
 void
 blorp_fast_clear(struct blorp_batch *batch,
-                 const struct blorp_surf *surf, enum isl_format format,
+                 const struct blorp_surf *surf,
+                 enum isl_format format, struct isl_swizzle swizzle,
                  uint32_t level, uint32_t start_layer, uint32_t num_layers,
                  uint32_t x0, uint32_t y0, uint32_t x1, uint32_t y1)
 {
@@ -360,6 +361,12 @@ blorp_fast_clear(struct blorp_batch *batch,
                                start_layer, format, true);
    params.num_samples = params.dst.surf.samples;
 
+   /* If a swizzle was provided, we need to swizzle the clear color so that
+    * the hardware color format conversion will work properly.
+    */
+   params.dst.clear_color = swizzle_color_value(params.dst.clear_color,
+                                                swizzle);
+
    batch->blorp->exec(batch, &params);
 }
 
index 8cbe6aaaa8996a7e88d9db71b3afc017c9cfdafb..0409ef099ea23381f5c65be42621acdcaf34d405 100644 (file)
@@ -1782,7 +1782,7 @@ anv_image_mcs_op(struct anv_cmd_buffer *cmd_buffer,
 
    switch (mcs_op) {
    case ISL_AUX_OP_FAST_CLEAR:
-      blorp_fast_clear(&batch, &surf, format,
+      blorp_fast_clear(&batch, &surf, format, ISL_SWIZZLE_IDENTITY,
                        0, base_layer, layer_count,
                        0, 0, image->extent.width, image->extent.height);
       break;
@@ -1863,7 +1863,7 @@ anv_image_ccs_op(struct anv_cmd_buffer *cmd_buffer,
 
    switch (ccs_op) {
    case ISL_AUX_OP_FAST_CLEAR:
-      blorp_fast_clear(&batch, &surf, format,
+      blorp_fast_clear(&batch, &surf, format, ISL_SWIZZLE_IDENTITY,
                        level, base_layer, layer_count,
                        0, 0, level_width, level_height);
       break;
index 93ca63ff1a21870a71d1b17dcdad5b088872373f..43363e5f63cf746a518557af05899fedc902a154 100644 (file)
@@ -1307,6 +1307,7 @@ do_single_blorp_clear(struct brw_context *brw, struct gl_framebuffer *fb,
       struct blorp_batch batch;
       blorp_batch_init(&brw->blorp, &batch, brw, 0);
       blorp_fast_clear(&batch, &surf, isl_format_srgb_to_linear(isl_format),
+                       ISL_SWIZZLE_IDENTITY,
                        level, irb->mt_layer, num_layers, x0, y0, x1, y1);
       blorp_batch_finish(&batch);