[965] Replace the state cache suballocator with direct dri_bufmgr use.
[mesa.git] / src / mesa / drivers / dri / i965 / brw_cc.c
index 8a1d1527db30aab77a9fdbf5f34bebd20e7771d9..245d2ddcad1b1015abc929c4c75cb75a1e604166 100644 (file)
@@ -46,7 +46,8 @@ static void upload_cc_vp( struct brw_context *brw )
    ccv.min_depth = 0.0;
    ccv.max_depth = 1.0;
 
-   brw->cc.vp_gs_offset = brw_cache_data( &brw->cache[BRW_CC_VP], &ccv );
+   dri_bo_unreference(brw->cc.vp_bo);
+   brw->cc.vp_bo = brw_cache_data( &brw->cache, BRW_CC_VP, &ccv, NULL, 0 );
 }
 
 const struct brw_tracked_state brw_cc_vp = {
@@ -152,12 +153,24 @@ static void upload_cc_unit( struct brw_context *brw )
    }
  
    /* CACHE_NEW_CC_VP */
-   cc.cc4.cc_viewport_state_offset =  brw->cc.vp_gs_offset >> 5;
+   cc.cc4.cc_viewport_state_offset = brw->cc.vp_bo->offset >> 5; /* reloc */
  
    if (INTEL_DEBUG & DEBUG_STATS)
       cc.cc5.statistics_enable = 1; 
 
-   brw->cc.state_gs_offset = brw_cache_data( &brw->cache[BRW_CC_UNIT], &cc );
+   dri_bo_unreference(brw->cc.state_bo);
+   brw->cc.state_bo = brw_cache_data( &brw->cache, BRW_CC_UNIT, &cc,
+                                     &brw->cc.vp_bo, 1);
+}
+
+static void emit_reloc_cc_unit(struct brw_context *brw)
+{
+   /* Emit CC viewport relocation */
+   dri_emit_reloc(brw->cc.state_bo,
+                 DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_READ,
+                 0,
+                 offsetof(struct brw_cc_unit_state, cc4),
+                 brw->cc.vp_bo);
 }
 
 const struct brw_tracked_state brw_cc_unit = {
@@ -166,7 +179,8 @@ const struct brw_tracked_state brw_cc_unit = {
       .brw = 0,
       .cache = CACHE_NEW_CC_VP
    },
-   .update = upload_cc_unit
+   .update = upload_cc_unit,
+   .emit_reloc = emit_reloc_cc_unit,
 };