blorp/clear: Add a binding-table-based CCS resolve function
authorNanley Chery <nanley.g.chery@intel.com>
Tue, 7 Mar 2017 01:37:49 +0000 (17:37 -0800)
committerNanley Chery <nanley.g.chery@intel.com>
Mon, 26 Jun 2017 18:09:12 +0000 (11:09 -0700)
v2:
- Do layered resolves.
(Jason Ekstrand):
- Replace "bt" suffix with "attachment".
- Rename helper function to prepare_ccs_resolve.
- Move blorp_params_init() into helper function.

Signed-off-by: Nanley Chery <nanley.g.chery@intel.com>
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
src/intel/blorp/blorp.h
src/intel/blorp/blorp_clear.c

index 744c1b1ea0a2fe2ab8a7fbf87080caab43c3b663..d5226c224814738f8390e9036a5fb155269434e5 100644 (file)
@@ -191,6 +191,17 @@ blorp_ccs_resolve(struct blorp_batch *batch,
                   enum isl_format format,
                   enum blorp_fast_clear_op resolve_op);
 
+/* Resolves subresources of the image subresource range specified in the
+ * binding table.
+ */
+void
+blorp_ccs_resolve_attachment(struct blorp_batch *batch,
+                             const uint32_t binding_table_offset,
+                             struct blorp_surf * const surf,
+                             const uint32_t level, const uint32_t num_layers,
+                             const enum isl_format format,
+                             const enum blorp_fast_clear_op resolve_op);
+
 /**
  * For an overview of the HiZ operations, see the following sections of the
  * Sandy Bridge PRM, Volume 1, Part2:
index 0e523dfe5b3d40944b09baeb2f9d40e1eb662411..581cf63c49f585ddfb3f791272011f762f32a87b 100644 (file)
@@ -703,16 +703,16 @@ blorp_clear_attachments(struct blorp_batch *batch,
    batch->blorp->exec(batch, &params);
 }
 
-void
-blorp_ccs_resolve(struct blorp_batch *batch,
-                  struct blorp_surf *surf, uint32_t level, uint32_t layer,
-                  enum isl_format format,
-                  enum blorp_fast_clear_op resolve_op)
+static void
+prepare_ccs_resolve(struct blorp_batch * const batch,
+                    struct blorp_params * const params,
+                    const struct blorp_surf * const surf,
+                    const uint32_t level, const uint32_t layer,
+                    const enum isl_format format,
+                    const enum blorp_fast_clear_op resolve_op)
 {
-   struct blorp_params params;
-   blorp_params_init(&params);
-
-   brw_blorp_surface_info_init(batch->blorp, &params.dst, surf,
+   blorp_params_init(params);
+   brw_blorp_surface_info_init(batch->blorp, &params->dst, surf,
                                level, layer, format, true);
 
    /* From the Ivy Bridge PRM, Vol2 Part1 11.9 "Render Target Resolve":
@@ -725,7 +725,7 @@ blorp_ccs_resolve(struct blorp_batch *batch,
     * multiply by 8 and 16. On Sky Lake, we multiply by 8.
     */
    const struct isl_format_layout *aux_fmtl =
-      isl_format_get_layout(params.dst.aux_surf.format);
+      isl_format_get_layout(params->dst.aux_surf.format);
    assert(aux_fmtl->txc == ISL_TXC_CCS);
 
    unsigned x_scaledown, y_scaledown;
@@ -739,11 +739,11 @@ blorp_ccs_resolve(struct blorp_batch *batch,
       x_scaledown = aux_fmtl->bw / 2;
       y_scaledown = aux_fmtl->bh / 2;
    }
-   params.x0 = params.y0 = 0;
-   params.x1 = minify(params.dst.aux_surf.logical_level0_px.width, level);
-   params.y1 = minify(params.dst.aux_surf.logical_level0_px.height, level);
-   params.x1 = ALIGN(params.x1, x_scaledown) / x_scaledown;
-   params.y1 = ALIGN(params.y1, y_scaledown) / y_scaledown;
+   params->x0 = params->y0 = 0;
+   params->x1 = minify(params->dst.aux_surf.logical_level0_px.width, level);
+   params->y1 = minify(params->dst.aux_surf.logical_level0_px.height, level);
+   params->x1 = ALIGN(params->x1, x_scaledown) / x_scaledown;
+   params->y1 = ALIGN(params->y1, y_scaledown) / y_scaledown;
 
    if (batch->blorp->isl_dev->info->gen >= 9) {
       assert(resolve_op == BLORP_FAST_CLEAR_OP_RESOLVE_FULL ||
@@ -752,7 +752,7 @@ blorp_ccs_resolve(struct blorp_batch *batch,
       /* Broadwell and earlier do not have a partial resolve */
       assert(resolve_op == BLORP_FAST_CLEAR_OP_RESOLVE_FULL);
    }
-   params.fast_clear_op = resolve_op;
+   params->fast_clear_op = resolve_op;
 
    /* 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
@@ -760,8 +760,37 @@ blorp_ccs_resolve(struct blorp_batch *batch,
     * color" message.
     */
 
-   if (!blorp_params_get_clear_kernel(batch->blorp, &params, true))
+   if (!blorp_params_get_clear_kernel(batch->blorp, params, true))
       return;
+}
+
+void
+blorp_ccs_resolve(struct blorp_batch *batch,
+                  struct blorp_surf *surf, uint32_t level, uint32_t layer,
+                  enum isl_format format,
+                  enum blorp_fast_clear_op resolve_op)
+{
+   struct blorp_params params;
+
+   prepare_ccs_resolve(batch, &params, surf, level, layer, format, resolve_op);
+
+   batch->blorp->exec(batch, &params);
+}
+
+void
+blorp_ccs_resolve_attachment(struct blorp_batch *batch,
+                             const uint32_t binding_table_offset,
+                             struct blorp_surf * const surf,
+                             const uint32_t level, const uint32_t num_layers,
+                             const enum isl_format format,
+                             const enum blorp_fast_clear_op resolve_op)
+{
+   struct blorp_params params;
+
+   prepare_ccs_resolve(batch, &params, surf, level, 0, format, resolve_op);
+   params.use_pre_baked_binding_table = true;
+   params.pre_baked_binding_table_offset = binding_table_offset;
+   params.num_layers = num_layers;
 
    batch->blorp->exec(batch, &params);
 }