iris: Fix iris_rebind_buffer() for VBOs with non-zero offsets.
authorKenneth Graunke <kenneth@whitecape.org>
Tue, 24 Sep 2019 03:37:39 +0000 (20:37 -0700)
committerKenneth Graunke <kenneth@whitecape.org>
Mon, 30 Sep 2019 19:41:03 +0000 (12:41 -0700)
We can't just check for the BO base address, we need to check for the
full address including any offset we may have applied.  When updating
the address, we need to include the offset again.

Fixes: 5ad0c88dbe3 ("iris: Replace buffer backing storage and rebind to update addresses.")

src/gallium/drivers/iris/iris_state.c

index 113e2b4..3278a28 100644 (file)
@@ -900,6 +900,8 @@ struct iris_vertex_buffer_state {
 
    /** The resource to source vertex data from. */
    struct pipe_resource *resource;
+
+   int offset;
 };
 
 struct iris_depth_buffer_state {
@@ -2928,6 +2930,8 @@ iris_set_vertex_buffers(struct pipe_context *ctx,
       pipe_resource_reference(&state->resource, buffer->buffer.resource);
       struct iris_resource *res = (void *) state->resource;
 
+      state->offset = (int) buffer->buffer_offset;
+
       if (res) {
          ice->state.bound_vertex_buffers |= 1ull << (start_slot + i);
          res->bind_history |= PIPE_BIND_VERTEX_BUFFER;
@@ -6001,8 +6005,8 @@ iris_rebind_buffer(struct iris_context *ice,
          STATIC_ASSERT(GENX(VERTEX_BUFFER_STATE_BufferStartingAddress_bits) == 64);
          uint64_t *addr = (uint64_t *) &state->state[1];
 
-         if (*addr == old_address) {
-            *addr = res->bo->gtt_offset;
+         if (*addr == old_address + state->offset) {
+            *addr = res->bo->gtt_offset + state->offset;
             ice->state.dirty |= IRIS_DIRTY_VERTEX_BUFFERS;
          }
       }