draw: Properly limit vertex buffer fetches on draw arrays.
[mesa.git] / src / gallium / drivers / r300 / r300_context.c
index cb8cef151346c7de97643c32729b494ad871d498..048f810b6b481a8c7529f36808aaf1ac5c49cfc9 100644 (file)
 #include "r300_emit.h"
 #include "r300_screen.h"
 #include "r300_screen_buffer.h"
-
-static void r300_update_num_contexts(struct r300_screen *r300screen,
-                                     int diff)
-{
-    pipe_mutex_lock(r300screen->num_contexts_mutex);
-    if (diff > 0) {
-        r300screen->num_contexts++;
-
-        if (r300screen->num_contexts > 1)
-            util_slab_set_thread_safety(&r300screen->pool_buffers,
-                                        UTIL_SLAB_MULTITHREADED);
-    } else {
-        r300screen->num_contexts--;
-
-        if (r300screen->num_contexts <= 1)
-            util_slab_set_thread_safety(&r300screen->pool_buffers,
-                                        UTIL_SLAB_SINGLETHREADED);
-    }
-    pipe_mutex_unlock(r300screen->num_contexts_mutex);
-}
+#include "compiler/radeon_regalloc.h"
 
 static void r300_release_referenced_objects(struct r300_context *r300)
 {
@@ -100,10 +81,8 @@ static void r300_destroy_context(struct pipe_context* context)
     if (r300->draw)
         draw_destroy(r300->draw);
 
-    if (r300->vbuf_mgr)
-        u_vbuf_destroy(r300->vbuf_mgr);
-
-    u_upload_destroy(r300->uploader);
+    if (r300->uploader)
+        u_upload_destroy(r300->uploader);
 
     /* XXX: This function assumes r300->query_list was initialized */
     r300_release_referenced_objects(r300);
@@ -111,11 +90,11 @@ static void r300_destroy_context(struct pipe_context* context)
     if (r300->cs)
         r300->rws->cs_destroy(r300->cs);
 
+    rc_destroy_regalloc_state(&r300->fs_regalloc_state);
+
     /* XXX: No way to tell if this was initialized or not? */
     util_slab_destroy(&r300->pool_transfers);
 
-    r300_update_num_contexts(r300->screen, -1);
-
     /* Free the structs allocated in r300_setup_atoms() */
     if (r300->aa_state.state) {
         FREE(r300->aa_state.state);
@@ -220,9 +199,9 @@ static boolean r300_setup_atoms(struct r300_context* r300)
     R300_INIT_ATOM(texture_cache_inval, 2);
     R300_INIT_ATOM(textures_state, 0);
     /* HiZ Clear */
-    R300_INIT_ATOM(hiz_clear, r300->screen->caps.hiz_ram > 0 ? 4 : 0);
+    R300_INIT_ATOM(hiz_clear, r300->screen->caps.hiz_ram > 0 ? 6 : 0);
     /* zmask clear */
-    R300_INIT_ATOM(zmask_clear, r300->screen->caps.zmask_ram > 0 ? 4 : 0);
+    R300_INIT_ATOM(zmask_clear, r300->screen->caps.zmask_ram > 0 ? 6 : 0);
     /* ZB (unpipelined), SU. */
     R300_INIT_ATOM(query_start, 4);
 
@@ -382,8 +361,6 @@ struct pipe_context* r300_create_context(struct pipe_screen* screen,
     if (!r300)
         return NULL;
 
-    r300_update_num_contexts(r300screen, 1);
-
     r300->rws = rws;
     r300->screen = r300screen;
 
@@ -429,22 +406,11 @@ struct pipe_context* r300_create_context(struct pipe_screen* screen,
     r300->context.create_video_decoder = vl_create_decoder;
     r300->context.create_video_buffer = vl_video_buffer_create;
 
-    if (r300->screen->caps.has_tcl) {
-        struct u_vbuf_caps caps;
-
-        u_vbuf_get_caps(screen, &caps);
-        caps.format_fixed32 = 0;
-
-        r300->vbuf_mgr = u_vbuf_create(&r300->context, &caps, 1024 * 1024, 4,
-                                       PIPE_BIND_VERTEX_BUFFER |
-                                       PIPE_BIND_INDEX_BUFFER);
-        if (!r300->vbuf_mgr)
-            goto fail;
+    if (r300screen->caps.has_tcl) {
+        r300->uploader = u_upload_create(&r300->context, 256 * 1024, 4,
+                                         PIPE_BIND_INDEX_BUFFER);
     }
 
-    r300->uploader = u_upload_create(&r300->context, 256 * 1024, 16,
-                                     PIPE_BIND_INDEX_BUFFER);
-
     r300->blitter = util_blitter_create(&r300->context);
     if (r300->blitter == NULL)
         goto fail;
@@ -477,7 +443,7 @@ struct pipe_context* r300_create_context(struct pipe_screen* screen,
         pipe_resource_reference(&tex, NULL);
     }
 
-    {
+    if (r300screen->caps.has_tcl) {
         struct pipe_resource vb;
         memset(&vb, 0, sizeof(vb));
         vb.target = PIPE_BUFFER;
@@ -503,6 +469,9 @@ struct pipe_context* r300_create_context(struct pipe_screen* screen,
 
     r300->hyperz_time_of_last_flush = os_time_get();
 
+    /* Register allocator state */
+    rc_init_regalloc_state(&r300->fs_regalloc_state);
+
     /* Print driver info. */
 #ifdef DEBUG
     {