r300g/swtcl: fix crash in ETQW and minor fixups
authorMarek Olšák <maraeo@gmail.com>
Thu, 29 Jul 2010 18:52:17 +0000 (20:52 +0200)
committerMarek Olšák <maraeo@gmail.com>
Thu, 29 Jul 2010 18:57:18 +0000 (20:57 +0200)
The Draw flush inside r300_flush was the culprit.

Also, no need to flush Draw when changing a state since the flush is
already inside swtcl_draw_vbo.

src/gallium/drivers/r300/r300_flush.c
src/gallium/drivers/r300/r300_render.c
src/gallium/drivers/r300/r300_state.c

index ae7b5759e78bbd9b27d8b443257561864afff133..fe182b6615b7578cc1f15e7b10b5ef0fc66bc277 100644 (file)
@@ -43,14 +43,6 @@ static void r300_flush(struct pipe_context* pipe,
     u_upload_flush(r300->upload_vb);
     u_upload_flush(r300->upload_ib);
 
-    /* We probably need to flush Draw, but we may have been called from
-     * within Draw. This feels kludgy, but it might be the best thing.
-     *
-     * Of course, the best thing is to kill Draw with fire. :3 */
-    if (r300->draw && !r300->draw->flushing) {
-        draw_flush(r300->draw);
-    }
-
     if (r300->dirty_hw) {
         r300_emit_hyperz_end(r300);
         r300_emit_query_end(r300);
index 987fbaf6a4294f6b425f640dcf39202309dd426b..7c4294bc9f58ab80aaf6749b8783b865c602141e 100644 (file)
@@ -681,11 +681,13 @@ static void r300_swtcl_draw_vbo(struct pipe_context* pipe,
     r300_update_derived_state(r300);
 
     for (i = 0; i < r300->vertex_buffer_count; i++) {
-        void* buf = pipe_buffer_map(pipe,
-                                    r300->vertex_buffer[i].buffer,
-                                    PIPE_TRANSFER_READ,
-                                    &vb_transfer[i]);
-        draw_set_mapped_vertex_buffer(r300->draw, i, buf);
+        if (r300->vertex_buffer[i].buffer) {
+            void *buf = pipe_buffer_map(pipe,
+                                  r300->vertex_buffer[i].buffer,
+                                  PIPE_TRANSFER_READ,
+                                  &vb_transfer[i]);
+            draw_set_mapped_vertex_buffer(r300->draw, i, buf);
+        }
     }
 
     if (info->indexed && r300->index_buffer.buffer) {
@@ -709,9 +711,11 @@ static void r300_swtcl_draw_vbo(struct pipe_context* pipe,
     draw_flush(r300->draw);
 
     for (i = 0; i < r300->vertex_buffer_count; i++) {
-        pipe_buffer_unmap(pipe, r300->vertex_buffer[i].buffer,
-                          vb_transfer[i]);
-        draw_set_mapped_vertex_buffer(r300->draw, i, NULL);
+        if (r300->vertex_buffer[i].buffer) {
+            pipe_buffer_unmap(pipe, r300->vertex_buffer[i].buffer,
+                              vb_transfer[i]);
+            draw_set_mapped_vertex_buffer(r300->draw, i, NULL);
+        }
     }
 
     if (ib_transfer) {
@@ -796,6 +800,8 @@ static void* r300_render_map_vertices(struct vbuf_render* render)
                                           PIPE_TRANSFER_WRITE,
                                          &r300render->vbo_transfer);
 
+    assert(r300render->vbo_ptr);
+
     return ((uint8_t*)r300render->vbo_ptr + r300render->vbo_offset);
 }
 
index bccd7d78591b0473e2d4f481585affc4604bfb1c..fced77e6f1923c6daf7a4efcf090df75bc039de9 100644 (file)
@@ -446,7 +446,6 @@ static void r300_set_clip_state(struct pipe_context* pipe,
 
         r300->clip_state.dirty = TRUE;
     } else {
-        draw_flush(r300->draw);
         draw_set_clip_state(r300->draw, state);
     }
 }
@@ -728,10 +727,6 @@ static void
         return;
     }
 
-    if (r300->draw) {
-        draw_flush(r300->draw);
-    }
-
     /* If nr_cbufs is changed from zero to non-zero or vice versa... */
     if (!!old_state->nr_cbufs != !!state->nr_cbufs) {
         r300->blend_state.dirty = TRUE;
@@ -1096,7 +1091,6 @@ static void r300_bind_rs_state(struct pipe_context* pipe, void* state)
     boolean last_two_sided_color = r300->two_sided_color;
 
     if (r300->draw && rs) {
-        draw_flush(r300->draw);
         draw_set_rasterizer_state(r300->draw, &rs->rs_draw, state);
     }
 
@@ -1385,7 +1379,6 @@ static void r300_set_viewport_state(struct pipe_context* pipe,
     r300->viewport = *state;
 
     if (r300->draw) {
-        draw_flush(r300->draw);
         draw_set_viewport_state(r300->draw, state);
         viewport->vte_control = R300_VTX_XY_FMT | R300_VTX_Z_FMT;
         return;
@@ -1486,7 +1479,6 @@ static void r300_set_vertex_buffers(struct pipe_context* pipe,
 
     } else {
         /* SW TCL. */
-        draw_flush(r300->draw);
         draw_set_vertex_buffers(r300->draw, count, buffers);
     }
 
@@ -1671,7 +1663,6 @@ static void r300_bind_vertex_elements_state(struct pipe_context *pipe,
     r300->velems = velems;
 
     if (r300->draw) {
-        draw_flush(r300->draw);
         draw_set_vertex_elements(r300->draw, velems->count, velems->velem);
         return;
     }
@@ -1737,7 +1728,6 @@ static void r300_bind_vs_state(struct pipe_context* pipe, void* shader)
 
         r300->pvs_flush.dirty = TRUE;
     } else {
-        draw_flush(r300->draw);
         draw_bind_vertex_shader(r300->draw,
                 (struct draw_vertex_shader*)vs->draw_vs);
     }