[v4,09/18] i965/miptree: Add space to store the clear value in the aux surface.

Submitted by Rafael Antognolli on March 8, 2018, 4:49 p.m.

Details

Message ID 20180308164911.15375-10-rafael.antognolli@intel.com
State New
Headers show
Series "Use clear color address in surface state." ( rev: 4 3 ) in Mesa

Not browsing as part of any series.

Commit Message

Rafael Antognolli March 8, 2018, 4:49 p.m.
Similarly to vulkan where we store the clear value in the aux surface,
we can do the same in GL.

v2: Remove unneeded extra function.
v3: Use clear_value_state_size instead of clear_value_size.
v4:
 - rename to clear_color_state_size
 - store clear_color_bo and clear_color_offset in the aux buf struct

Signed-off-by: Rafael Antognolli <rafael.antognolli@intel.com>
---
 src/mesa/drivers/dri/i965/intel_mipmap_tree.c | 16 ++++++++++++++++
 src/mesa/drivers/dri/i965/intel_mipmap_tree.h | 16 ++++++++++++++++
 2 files changed, 32 insertions(+)

Patch hide | download patch | download mbox

diff --git a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
index c6213b21629..22d0ae89367 100644
--- a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
+++ b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
@@ -1678,6 +1678,17 @@  intel_alloc_aux_buffer(struct brw_context *brw,
       return false;
 
    buf->size = aux_surf->size;
+
+   const struct gen_device_info *devinfo = &brw->screen->devinfo;
+   if (devinfo->gen >= 10) {
+      /* On CNL, instead of setting the clear color in the SURFACE_STATE, we
+       * will set a pointer to a dword somewhere that contains the color. So,
+       * allocate the space for the clear color value here on the aux buffer.
+       */
+      buf->clear_color_offset = buf->size;
+      buf->size += brw->isl_dev.ss.clear_color_state_size;
+   }
+
    buf->pitch = aux_surf->row_pitch;
    buf->qpitch = isl_surf_get_array_pitch_sa_rows(aux_surf);
 
@@ -1692,6 +1703,11 @@  intel_alloc_aux_buffer(struct brw_context *brw,
       return NULL;
    }
 
+   if (devinfo->gen >= 10) {
+      buf->clear_color_bo = buf->bo;
+      brw_bo_reference(buf->clear_color_bo);
+   }
+
    buf->surf = *aux_surf;
 
    return buf;
diff --git a/src/mesa/drivers/dri/i965/intel_mipmap_tree.h b/src/mesa/drivers/dri/i965/intel_mipmap_tree.h
index 07c85807e80..54d36400757 100644
--- a/src/mesa/drivers/dri/i965/intel_mipmap_tree.h
+++ b/src/mesa/drivers/dri/i965/intel_mipmap_tree.h
@@ -180,6 +180,22 @@  struct intel_miptree_aux_buffer
     * @see 3DSTATE_HIER_DEPTH_BUFFER.SurfaceQPitch
     */
    uint32_t qpitch;
+
+   /**
+    * Buffer object containing the indirect clear color.
+    *
+    * @see create_ccs_buf_for_image
+    * @see RENDER_SURFACE_STATE.ClearValueAddress
+    */
+   struct brw_bo *clear_color_bo;
+
+   /**
+    * Offset into bo where the clear color can be found.
+    *
+    * @see create_ccs_buf_for_image
+    * @see RENDER_SURFACE_STATE.ClearValueAddress
+    */
+   uint32_t clear_color_offset;
 };
 
 struct intel_mipmap_tree