Merge commit 'origin/master' into gallium-sampler-view
[mesa.git] / src / gallium / drivers / r300 / r300_context.c
index 86b98a4ba526e1c6eef53fb9d0c082ad9dc65d8d..d994a46ccfe9b1d8b98437db546ae6505d308fc0 100644 (file)
@@ -24,6 +24,7 @@
 
 #include "util/u_memory.h"
 #include "util/u_simple_list.h"
+#include "util/u_upload_mgr.h"
 
 #include "r300_blit.h"
 #include "r300_context.h"
@@ -34,6 +35,7 @@
 #include "r300_screen.h"
 #include "r300_state_invariant.h"
 #include "r300_texture.h"
+#include "r300_transfer.h"
 
 #include "radeon_winsys.h"
 
@@ -54,13 +56,15 @@ static void r300_destroy_context(struct pipe_context* context)
         FREE(query);
     }
 
+    u_upload_destroy(r300->upload_vb);
+    u_upload_destroy(r300->upload_ib);
+
     FREE(r300->blend_color_state.state);
     FREE(r300->clip_state.state);
     FREE(r300->fb_state.state);
     FREE(r300->rs_block_state.state);
     FREE(r300->scissor_state.state);
     FREE(r300->textures_state.state);
-    FREE(r300->vertex_stream_state.state);
     FREE(r300->vap_output_state.state);
     FREE(r300->viewport_state.state);
     FREE(r300->ztop_state.state);
@@ -72,11 +76,7 @@ r300_is_texture_referenced(struct pipe_context *pipe,
                            struct pipe_texture *texture,
                            unsigned face, unsigned level)
 {
-    struct pipe_buffer* buf = 0;
-
-    r300_get_texture_buffer(pipe->screen, texture, &buf, NULL);
-
-    return pipe->is_buffer_referenced(pipe, buf);
+    return 0;
 }
 
 static unsigned int
@@ -86,7 +86,14 @@ r300_is_buffer_referenced(struct pipe_context *pipe,
     /* This only checks to see whether actual hardware buffers are
      * referenced. Since we use managed BOs and transfers, it's actually not
      * possible for pipe_buffers to ever reference the actual hardware, so
-     * buffers are never referenced. */
+     * buffers are never referenced. 
+     */
+
+    /* XXX: that doesn't make sense given that
+     * r300_is_texture_referenced is implemented on top of this
+     * function and hardware can certainly refer to textures
+     * directly...
+     */
     return 0;
 }
 
@@ -143,7 +150,6 @@ static void r300_setup_atoms(struct r300_context* r300)
     r300->rs_block_state.state = CALLOC_STRUCT(r300_rs_block);
     r300->scissor_state.state = CALLOC_STRUCT(pipe_scissor_state);
     r300->textures_state.state = CALLOC_STRUCT(r300_textures_state);
-    r300->vertex_stream_state.state = CALLOC_STRUCT(r300_vertex_stream_state);
     r300->vap_output_state.state = CALLOC_STRUCT(r300_vap_output_state);
     r300->viewport_state.state = CALLOC_STRUCT(r300_viewport_state);
     r300->ztop_state.state = CALLOC_STRUCT(r300_ztop_state);
@@ -154,14 +160,14 @@ struct pipe_context* r300_create_context(struct pipe_screen* screen,
 {
     struct r300_context* r300 = CALLOC_STRUCT(r300_context);
     struct r300_screen* r300screen = r300_screen(screen);
-    struct radeon_winsys* radeon_winsys = r300screen->radeon_winsys;
+    struct r300_winsys_screen *rws = r300screen->rws;
 
     if (!r300)
         return NULL;
 
-    r300->winsys = radeon_winsys;
+    r300->rws = rws;
 
-    r300->context.winsys = (struct pipe_winsys*)radeon_winsys;
+    r300->context.winsys = (struct pipe_winsys*)rws;
     r300->context.screen = screen;
     r300->context.priv = priv;
 
@@ -205,17 +211,35 @@ struct pipe_context* r300_create_context(struct pipe_screen* screen,
 
     r300_init_query_functions(r300);
 
-    /* r300_init_surface_functions(r300); */
+    r300_init_transfer_functions(r300);
 
     r300_init_state_functions(r300);
 
     r300->invariant_state.dirty = TRUE;
 
-    r300->winsys->set_flush_cb(r300->winsys, r300_flush_cb, r300);
-    r300->dirty_state = R300_NEW_KITCHEN_SINK;
+    rws->set_flush_cb(r300->rws, r300_flush_cb, r300);
     r300->dirty_hw++;
 
     r300->blitter = util_blitter_create(&r300->context);
 
+    r300->upload_ib = u_upload_create(screen,
+                                     32 * 1024, 16,
+                                     PIPE_BUFFER_USAGE_INDEX);
+
+    if (r300->upload_ib == NULL)
+        goto no_upload_ib;
+
+    r300->upload_vb = u_upload_create(screen,
+                                     128 * 1024, 16,
+                                     PIPE_BUFFER_USAGE_VERTEX);
+    if (r300->upload_vb == NULL)
+        goto no_upload_vb;
+
     return &r300->context;
+
+ no_upload_ib:
+    u_upload_destroy(r300->upload_ib);
+ no_upload_vb:
+    FREE(r300);
+    return NULL;
 }