i965/miptree: Add space to store the clear value in the aux surface.
authorRafael Antognolli <rafael.antognolli@intel.com>
Thu, 10 Aug 2017 16:36:28 +0000 (09:36 -0700)
committerRafael Antognolli <rafael.antognolli@intel.com>
Thu, 5 Apr 2018 14:42:45 +0000 (07:42 -0700)
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
v5: Unreference clear color bo (Jordan)

Signed-off-by: Rafael Antognolli <rafael.antognolli@intel.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
src/mesa/drivers/dri/i965/intel_mipmap_tree.c
src/mesa/drivers/dri/i965/intel_mipmap_tree.h

index 23cb40f3226b59580f284c1d44836e4cf84ea9d3..d11ae65243fa335b17d5a208a43e925f65c3bae0 100644 (file)
@@ -1211,6 +1211,7 @@ intel_miptree_aux_buffer_free(struct intel_miptree_aux_buffer *aux_buf)
       return;
 
    brw_bo_unreference(aux_buf->bo);
+   brw_bo_unreference(aux_buf->clear_color_bo);
 
    free(aux_buf);
 }
@@ -1678,6 +1679,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 +1704,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;
index 07c85807e8044b2c13bc85ac8190772a94e1e162..54d36400757be21ffc857c0b46b42cf59ddc63d7 100644 (file)
@@ -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