i965: Give the math opcodes information on base mrf/mrf len.
[mesa.git] / src / mesa / drivers / dri / i965 / brw_vs_state.c
index 3d2953884379fcb780b1c6565a472017ff2bb141..9b2dd5b3d1ce5198f617efc812056b2069eccd25 100644 (file)
@@ -79,12 +79,12 @@ vs_unit_populate_key(struct brw_context *brw, struct brw_vs_unit_key *key)
    }
 }
 
-static dri_bo *
+static drm_intel_bo *
 vs_unit_create_from_key(struct brw_context *brw, struct brw_vs_unit_key *key)
 {
+   struct intel_context *intel = &brw->intel;
    struct brw_vs_unit_state vs;
-   dri_bo *bo;
-   int chipset_max_threads;
+   drm_intel_bo *bo;
 
    memset(&vs, 0, sizeof(vs));
 
@@ -97,7 +97,11 @@ vs_unit_create_from_key(struct brw_context *brw, struct brw_vs_unit_key *key)
     * brw_urb_WRITE() results.
     */
    vs.thread1.single_program_flow = 0;
-   vs.thread1.binding_table_entry_count = key->nr_surfaces;
+
+   if (intel->gen == 5)
+      vs.thread1.binding_table_entry_count = 0; /* hardware requirement */
+   else
+      vs.thread1.binding_table_entry_count = key->nr_surfaces;
 
    vs.thread3.urb_entry_read_length = key->urb_entry_read_length;
    vs.thread3.const_urb_entry_read_length = key->curb_entry_read_length;
@@ -105,21 +109,49 @@ vs_unit_create_from_key(struct brw_context *brw, struct brw_vs_unit_key *key)
    vs.thread3.urb_entry_read_offset = 0;
    vs.thread3.const_urb_entry_read_offset = key->curbe_offset * 2;
 
-   vs.thread4.nr_urb_entries = key->nr_urb_entries;
+   if (intel->gen == 5) {
+      switch (key->nr_urb_entries) {
+      case 8:
+      case 12:
+      case 16:
+      case 32:
+      case 64:
+      case 96:
+      case 128:
+      case 168:
+      case 192:
+      case 224:
+      case 256:
+        vs.thread4.nr_urb_entries = key->nr_urb_entries >> 2;
+        break;
+      default:
+        assert(0);
+      }
+   } else {
+      switch (key->nr_urb_entries) {
+      case 8:
+      case 12:
+      case 16:
+      case 32:
+        break;
+      case 64:
+        assert(intel->is_g4x);
+        break;
+      default:
+        assert(0);
+      }
+      vs.thread4.nr_urb_entries = key->nr_urb_entries;
+   }
+
    vs.thread4.urb_entry_allocation_size = key->urb_size - 1;
 
-   if (BRW_IS_G4X(brw))
-      chipset_max_threads = 32;
-   else
-      chipset_max_threads = 16;
    vs.thread4.max_threads = CLAMP(key->nr_urb_entries / 2,
-                                 1, chipset_max_threads) - 1;
-
-   if (INTEL_DEBUG & DEBUG_SINGLE_THREAD)
-      vs.thread4.max_threads = 0;
+                                 1, brw->vs_max_threads) - 1;
 
    /* No samplers for ARB_vp programs:
     */
+   /* It has to be set to 0 for Ironlake
+    */
    vs.vs5.sampler_count = 0;
 
    if (INTEL_DEBUG & DEBUG_STATS)
@@ -132,15 +164,12 @@ vs_unit_create_from_key(struct brw_context *brw, struct brw_vs_unit_key *key)
    bo = brw_upload_cache(&brw->cache, BRW_VS_UNIT,
                         key, sizeof(*key),
                         &brw->vs.prog_bo, 1,
-                        &vs, sizeof(vs),
-                        NULL, NULL);
+                        &vs, sizeof(vs));
 
    /* Emit VS program relocation */
-   dri_bo_emit_reloc(bo,
-                    I915_GEM_DOMAIN_INSTRUCTION, 0,
-                    vs.thread0.grf_reg_count << 1,
-                    offsetof(struct brw_vs_unit_state, thread0),
-                    brw->vs.prog_bo);
+   drm_intel_bo_emit_reloc(bo, offsetof(struct brw_vs_unit_state, thread0),
+                          brw->vs.prog_bo, vs.thread0.grf_reg_count << 1,
+                          I915_GEM_DOMAIN_INSTRUCTION, 0);
 
    return bo;
 }
@@ -151,7 +180,7 @@ static void prepare_vs_unit(struct brw_context *brw)
 
    vs_unit_populate_key(brw, &key);
 
-   dri_bo_unreference(brw->vs.state_bo);
+   drm_intel_bo_unreference(brw->vs.state_bo);
    brw->vs.state_bo = brw_search_cache(&brw->cache, BRW_VS_UNIT,
                                       &key, sizeof(key),
                                       &brw->vs.prog_bo, 1,