intel: Add a new "common" library for more code sharing
[mesa.git] / src / mesa / drivers / dri / i965 / brw_urb.c
index 5797ceaa782368ca665116a0af65b70b8515b551..83851c1205f98d8833eb2ce18de19ce0d82c2416 100644 (file)
@@ -139,11 +139,11 @@ static void recalculate_urb_fence( struct brw_context *brw )
       brw->urb.sfsize = sfsize;
       brw->urb.vsize = vsize;
 
-      brw->urb.nr_vs_entries = limits[VS].preferred_nr_entries;        
-      brw->urb.nr_gs_entries = limits[GS].preferred_nr_entries;        
+      brw->urb.nr_vs_entries = limits[VS].preferred_nr_entries;
+      brw->urb.nr_gs_entries = limits[GS].preferred_nr_entries;
       brw->urb.nr_clip_entries = limits[CLP].preferred_nr_entries;
-      brw->urb.nr_sf_entries = limits[SF].preferred_nr_entries;        
-      brw->urb.nr_cs_entries = limits[CS].preferred_nr_entries;        
+      brw->urb.nr_sf_entries = limits[SF].preferred_nr_entries;
+      brw->urb.nr_cs_entries = limits[CS].preferred_nr_entries;
 
       brw->urb.constrained = 0;
 
@@ -168,42 +168,43 @@ static void recalculate_urb_fence( struct brw_context *brw )
       }
 
       if (!check_urb_layout(brw)) {
-        brw->urb.nr_vs_entries = limits[VS].min_nr_entries;    
-        brw->urb.nr_gs_entries = limits[GS].min_nr_entries;    
+        brw->urb.nr_vs_entries = limits[VS].min_nr_entries;
+        brw->urb.nr_gs_entries = limits[GS].min_nr_entries;
         brw->urb.nr_clip_entries = limits[CLP].min_nr_entries;
-        brw->urb.nr_sf_entries = limits[SF].min_nr_entries;    
-        brw->urb.nr_cs_entries = limits[CS].min_nr_entries;    
+        brw->urb.nr_sf_entries = limits[SF].min_nr_entries;
+        brw->urb.nr_cs_entries = limits[CS].min_nr_entries;
 
         /* Mark us as operating with constrained nr_entries, so that next
          * time we recalculate we'll resize the fences in the hope of
          * escaping constrained mode and getting back to normal performance.
          */
         brw->urb.constrained = 1;
-       
+
         if (!check_urb_layout(brw)) {
            /* This is impossible, given the maximal sizes of urb
             * entries and the values for minimum nr of entries
             * provided above.
             */
-           printf("couldn't calculate URB layout!\n");
+           fprintf(stderr, "couldn't calculate URB layout!\n");
            exit(1);
         }
-       
+
         if (unlikely(INTEL_DEBUG & (DEBUG_URB|DEBUG_PERF)))
-           printf("URB CONSTRAINED\n");
+           fprintf(stderr, "URB CONSTRAINED\n");
       }
 
 done:
       if (unlikely(INTEL_DEBUG & DEBUG_URB))
-        printf("URB fence: %d ..VS.. %d ..GS.. %d ..CLP.. %d ..SF.. %d ..CS.. %d\n",
-                     brw->urb.vs_start,
-                     brw->urb.gs_start,
-                     brw->urb.clip_start,
-                     brw->urb.sf_start,
-                     brw->urb.cs_start,
-                     brw->urb.size);
-
-      brw->state.dirty.brw |= BRW_NEW_URB_FENCE;
+        fprintf(stderr,
+                 "URB fence: %d ..VS.. %d ..GS.. %d ..CLP.. %d ..SF.. %d ..CS.. %d\n",
+                 brw->urb.vs_start,
+                 brw->urb.gs_start,
+                 brw->urb.clip_start,
+                 brw->urb.sf_start,
+                 brw->urb.cs_start,
+                 brw->urb.size);
+
+      brw->ctx.NewDriverState |= BRW_NEW_URB_FENCE;
    }
 }
 
@@ -211,9 +212,10 @@ done:
 const struct brw_tracked_state brw_recalculate_urb_fence = {
    .dirty = {
       .mesa = 0,
-      .brw = BRW_NEW_CURBE_OFFSETS,
-      .cache = (CACHE_NEW_VS_PROG |
-               CACHE_NEW_SF_PROG)
+      .brw = BRW_NEW_BLORP |
+             BRW_NEW_CURBE_OFFSETS |
+             BRW_NEW_SF_PROG_DATA |
+             BRW_NEW_VS_PROG_DATA,
    },
    .emit = recalculate_urb_fence
 };
@@ -248,10 +250,10 @@ void brw_upload_urb_fence(struct brw_context *brw)
    uf.bits1.cs_fence  = brw->urb.size;
 
    /* erratum: URB_FENCE must not cross a 64byte cacheline */
-   if ((brw->batch.used & 15) > 12) {
-      int pad = 16 - (brw->batch.used & 15);
+   if ((USED_BATCH(brw->batch) & 15) > 12) {
+      int pad = 16 - (USED_BATCH(brw->batch) & 15);
       do
-        brw->batch.map[brw->batch.used++] = MI_NOOP;
+         *brw->batch.map_next++ = MI_NOOP;
       while (--pad);
    }