r600g: properly unset vertex buffer
authorJerome Glisse <jglisse@redhat.com>
Mon, 20 Dec 2010 20:30:42 +0000 (15:30 -0500)
committerJerome Glisse <jglisse@redhat.com>
Mon, 20 Dec 2010 20:33:28 +0000 (15:33 -0500)
Fix bug http://bugs.freedesktop.org/show_bug.cgi?id=32455

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

index 07496eb..af19beb 100644 (file)
@@ -1327,16 +1327,16 @@ void evergreen_vertex_buffer_update(struct r600_pipe_context *rctx)
                        vbuffer_index = rctx->vertex_elements->elements[i].vertex_buffer_index;
                        vertex_buffer = &rctx->vertex_buffer[vbuffer_index];
                        rbuffer = (struct r600_resource*)vertex_buffer->buffer;
-                       offset = rctx->vertex_elements->vbuffer_offset[i] +
-                               vertex_buffer->buffer_offset +
-                               r600_bo_offset(rbuffer->bo);
+                       offset = rctx->vertex_elements->vbuffer_offset[i];
                } else {
                        /* bind vertex buffer once */
                        vertex_buffer = &rctx->vertex_buffer[i];
                        rbuffer = (struct r600_resource*)vertex_buffer->buffer;
-                       offset = vertex_buffer->buffer_offset +
-                               r600_bo_offset(rbuffer->bo);
+                       offset = 0;
                }
+               if (vertex_buffer == NULL)
+                       continue;
+               offset += vertex_buffer->buffer_offset + r600_bo_offset(rbuffer->bo);
 
                r600_pipe_state_add_reg(rstate, R_030000_RESOURCE0_WORD0,
                                        offset, 0xFFFFFFFF, rbuffer->bo);
index cd5f079..0d76afd 100644 (file)
@@ -167,16 +167,16 @@ void r600_vertex_buffer_update(struct r600_pipe_context *rctx)
                        vbuffer_index = rctx->vertex_elements->elements[i].vertex_buffer_index;
                        vertex_buffer = &rctx->vertex_buffer[vbuffer_index];
                        rbuffer = (struct r600_resource*)vertex_buffer->buffer;
-                       offset = rctx->vertex_elements->vbuffer_offset[i] +
-                               vertex_buffer->buffer_offset +
-                               r600_bo_offset(rbuffer->bo);
+                       offset = rctx->vertex_elements->vbuffer_offset[i];
                } else {
                        /* bind vertex buffer once */
                        vertex_buffer = &rctx->vertex_buffer[i];
                        rbuffer = (struct r600_resource*)vertex_buffer->buffer;
-                       offset = vertex_buffer->buffer_offset +
-                               r600_bo_offset(rbuffer->bo);
+                       offset = 0;
                }
+               if (vertex_buffer == NULL)
+                       continue;
+               offset += vertex_buffer->buffer_offset + r600_bo_offset(rbuffer->bo);
 
                r600_pipe_state_add_reg(rstate, R_038000_RESOURCE0_WORD0,
                                        offset, 0xFFFFFFFF, rbuffer->bo);
index 99b372c..f488cf7 100644 (file)
@@ -179,8 +179,16 @@ void r600_set_vertex_buffers(struct pipe_context *ctx, unsigned count,
        struct pipe_vertex_buffer *vbo;
        unsigned max_index = (unsigned)-1;
 
-       for (int i = 0; i < rctx->nvertex_buffer; i++) {
-               pipe_resource_reference(&rctx->vertex_buffer[i].buffer, NULL);
+       if (rctx->family >= CHIP_CEDAR) {
+               for (int i = 0; i < rctx->nvertex_buffer; i++) {
+                       pipe_resource_reference(&rctx->vertex_buffer[i].buffer, NULL);
+                       evergreen_fs_resource_set(&rctx->ctx, NULL, i);
+               }
+       } else {
+               for (int i = 0; i < rctx->nvertex_buffer; i++) {
+                       pipe_resource_reference(&rctx->vertex_buffer[i].buffer, NULL);
+                       r600_context_pipe_state_set_fs_resource(&rctx->ctx, NULL, i);
+               }
        }
        memcpy(rctx->vertex_buffer, buffers, sizeof(struct pipe_vertex_buffer) * count);
 
@@ -188,6 +196,8 @@ 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);