From a56a5629fe66a9a659decf93bfcb7f3494aed037 Mon Sep 17 00:00:00 2001 From: Jerome Glisse Date: Fri, 17 Dec 2010 14:34:12 -0500 Subject: [PATCH] r600g: avoid segfault when unsetting vertex buffer Signed-off-by: Jerome Glisse --- src/gallium/drivers/r600/r600_buffer.c | 3 +++ src/gallium/drivers/r600/r600_state_common.c | 5 +++++ 2 files changed, 8 insertions(+), 0 deletions(-) diff --git a/src/gallium/drivers/r600/r600_buffer.c b/src/gallium/drivers/r600/r600_buffer.c index a17c54d..5be2aa8 100644 --- a/src/gallium/drivers/r600/r600_buffer.c +++ b/src/gallium/drivers/r600/r600_buffer.c @@ -232,6 +232,9 @@ int r600_upload_user_buffers(struct r600_pipe_context *rctx) for (i = 0; i < nr; i++) { struct pipe_vertex_buffer *vb = &rctx->vertex_buffer[i]; + if (vb == NULL) + continue; + if (r600_buffer_is_user_buffer(vb->buffer)) { struct r600_resource_buffer *rbuffer = r600_buffer(vb->buffer); unsigned upload_offset; diff --git a/src/gallium/drivers/r600/r600_state_common.c b/src/gallium/drivers/r600/r600_state_common.c index 99b372c..4de37a3 100644 --- a/src/gallium/drivers/r600/r600_state_common.c +++ b/src/gallium/drivers/r600/r600_state_common.c @@ -188,6 +188,11 @@ void r600_set_vertex_buffers(struct pipe_context *ctx, unsigned count, vbo = (struct pipe_vertex_buffer*)&buffers[i]; rctx->vertex_buffer[i].buffer = NULL; + + if (buffers[i].buffer == NULL) { + continue; + } + if (r600_buffer_is_user_buffer(buffers[i].buffer)) rctx->any_user_vbs = TRUE; pipe_resource_reference(&rctx->vertex_buffer[i].buffer, buffers[i].buffer); -- 1.7.3.2