r600g: fix segfault when translating vertex buffer
authorJerome Glisse <jglisse@redhat.com>
Tue, 14 Dec 2010 18:50:46 +0000 (13:50 -0500)
committerJerome Glisse <jglisse@redhat.com>
Tue, 14 Dec 2010 18:50:46 +0000 (13:50 -0500)
Note the support for non float vertex draw likely regressed need to
find what we want to do there.

candidates for 7.10 branches

Signed-off-by: Jerome Glisse <jglisse@redhat.com>
src/gallium/drivers/r600/evergreen_state.c
src/gallium/drivers/r600/r600_state.c
src/gallium/drivers/r600/r600_state_common.c
src/gallium/drivers/r600/r600_translate.c

index a9d4a862c32f238d8592da3f9771a396db7119b5..07496ebf51e9d260f341a87489ab9aa83d01c0df 100644 (file)
@@ -1295,11 +1295,6 @@ void evergreen_vertex_buffer_update(struct r600_pipe_context *rctx)
        if (rctx->vertex_elements == NULL || !rctx->nvertex_buffer)
                return;
 
-       /* delete previous translated vertex elements */
-       if (rctx->tran.new_velems) {
-               r600_end_vertex_translate(rctx);
-       }
-
        if (rctx->vertex_elements->incompatible_layout) {
                /* translate rebind new vertex elements so
                 * return once translated
index 67ea21712f749691be9da5c7ca4625ce7c051c6b..cd5f0792d5e95380f8fecef3dc503c4333ef02b3 100644 (file)
@@ -135,11 +135,6 @@ void r600_vertex_buffer_update(struct r600_pipe_context *rctx)
        if (rctx->vertex_elements == NULL || !rctx->nvertex_buffer)
                return;
 
-       /* delete previous translated vertex elements */
-       if (rctx->tran.new_velems) {
-               r600_end_vertex_translate(rctx);
-       }
-
        if (rctx->vertex_elements->incompatible_layout) {
                /* translate rebind new vertex elements so
                 * return once translated
@@ -280,7 +275,6 @@ void r600_draw_vbo(struct pipe_context *ctx, const struct pipe_draw_info *info)
 {
        struct r600_pipe_context *rctx = (struct r600_pipe_context *)ctx;
        struct r600_drawl draw;
-       boolean translate = FALSE;
 
        memset(&draw, 0, sizeof(struct r600_drawl));
        draw.ctx = ctx;
@@ -312,9 +306,6 @@ void r600_draw_vbo(struct pipe_context *ctx, const struct pipe_draw_info *info)
        }
        r600_draw_common(&draw);
 
-       if (translate)
-               r600_end_vertex_translate(rctx);
-
        pipe_resource_reference(&draw.index_buffer, NULL);
 }
 
index 1333808c66f702800fe04a1f372050a81203d0f1..99b372caacef92a434834338d77594a3f708861e 100644 (file)
@@ -119,6 +119,11 @@ void r600_bind_vertex_elements(struct pipe_context *ctx, void *state)
        struct r600_pipe_context *rctx = (struct r600_pipe_context *)ctx;
        struct r600_vertex_element *v = (struct r600_vertex_element*)state;
 
+       /* delete previous translated vertex elements */
+       if (rctx->tran.new_velems) {
+               r600_end_vertex_translate(rctx);
+       }
+
        rctx->vertex_elements = v;
        if (v) {
                rctx->states[v->rstate.id] = &v->rstate;
index 1c227d3215115319a37b300e8f284c6f2f3ceb95..ba12eee2b5637ec921f546f2a2d4b5198a3ad897 100644 (file)
@@ -42,6 +42,7 @@ void r600_begin_vertex_translate(struct r600_pipe_context *rctx)
        struct pipe_resource *out_buffer;
        unsigned i, num_verts;
        struct pipe_vertex_element new_velems[PIPE_MAX_ATTRIBS];
+       void *tmp;
 
        /* Initialize the translate key, i.e. the recipe how vertices should be
         * translated. */
@@ -159,8 +160,9 @@ void r600_begin_vertex_translate(struct r600_pipe_context *rctx)
                }
        }
 
-       rctx->tran.new_velems = pipe->create_vertex_elements_state(pipe, ve->count, new_velems);
-       pipe->bind_vertex_elements_state(pipe, rctx->tran.new_velems);
+       tmp = pipe->create_vertex_elements_state(pipe, ve->count, new_velems);
+       pipe->bind_vertex_elements_state(pipe, tmp);
+       rctx->tran.new_velems = tmp;
 
        pipe_resource_reference(&out_buffer, NULL);
 }
@@ -173,15 +175,11 @@ void r600_end_vertex_translate(struct r600_pipe_context *rctx)
                return;
        }
        /* Restore vertex elements. */
-       if (rctx->vertex_elements == rctx->tran.new_velems) {
-               pipe->bind_vertex_elements_state(pipe, NULL);
-       }
        pipe->delete_vertex_elements_state(pipe, rctx->tran.new_velems);
        rctx->tran.new_velems = NULL;
 
        /* Delete the now-unused VBO. */
-       pipe_resource_reference(&rctx->vertex_buffer[rctx->tran.vb_slot].buffer,
-                               NULL);
+       pipe_resource_reference(&rctx->vertex_buffer[rctx->tran.vb_slot].buffer, NULL);
 }
 
 void r600_translate_index_buffer(struct r600_pipe_context *r600,