[965] Replace the state cache suballocator with direct dri_bufmgr use.
[mesa.git] / src / mesa / drivers / dri / i965 / brw_clip_state.c
index ba2f0edf5135a1ca94ceb2b1e9e157720338d5c9..7640a39b452ee6110af462ed1b9a16c5a4032842 100644 (file)
@@ -45,7 +45,8 @@ static void upload_clip_unit( struct brw_context *brw )
    /* CACHE_NEW_CLIP_PROG */
    clip.thread0.grf_reg_count =
       ALIGN(brw->clip.prog_data->total_grf, 16) / 16 - 1;
-   clip.thread0.kernel_start_pointer = brw->clip.prog_gs_offset >> 6;
+   /* reloc */
+   clip.thread0.kernel_start_pointer = brw->clip.prog_bo->offset >> 6;
    clip.thread3.urb_entry_read_length = brw->clip.prog_data->urb_read_length;
    clip.thread3.const_urb_entry_read_length = brw->clip.prog_data->curb_read_length;
    clip.clip5.clip_mode = brw->clip.prog_data->clip_mode;
@@ -79,9 +80,24 @@ static void upload_clip_unit( struct brw_context *brw )
    clip.viewport_ymin = -1;
    clip.viewport_ymax = 1;
 
-   brw->clip.state_gs_offset = brw_cache_data( &brw->cache[BRW_CLIP_UNIT], &clip );
+   brw->clip.thread0_delta = clip.thread0.grf_reg_count << 1;
+
+   dri_bo_unreference(brw->clip.state_bo);
+   brw->clip.state_bo = brw_cache_data( &brw->cache, BRW_CLIP_UNIT, &clip,
+                                       &brw->clip.prog_bo, 1);
 }
 
+static void emit_reloc_clip_unit(struct brw_context *brw)
+{
+   if (!brw->metaops.active) {
+      /* Emit clip program relocation */
+      dri_emit_reloc(brw->clip.state_bo,
+                    DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_READ,
+                    brw->clip.thread0_delta,
+                    offsetof(struct brw_clip_unit_state, thread0),
+                    brw->clip.prog_bo);
+   }
+}
 
 const struct brw_tracked_state brw_clip_unit = {
    .dirty = {
@@ -90,5 +106,6 @@ const struct brw_tracked_state brw_clip_unit = {
                BRW_NEW_URB_FENCE),
       .cache = CACHE_NEW_CLIP_PROG
    },
-   .update = upload_clip_unit
+   .update = upload_clip_unit,
+   .emit_reloc = emit_reloc_clip_unit,
 };