If take_index_buffer_ownership is true, then we should reserve
enough references of index_bo or we'll get an underflow later.
Fixes:
819627041e7 ("mesa: set pipe_draw_info::index::resource directly and remove gl_bo")
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/8747
Reviewed-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22237>
/* Fast path for u_threaded_context to eliminate atomics. */
info.index.resource = _mesa_get_bufferobj_reference(ctx, index_bo);
info.take_index_buffer_ownership = true;
+ /* Increase refcount so be able to use take_index_buffer_ownership with
+ * multiple draws.
+ */
+ if (primcount > 1 && info.index.resource)
+ p_atomic_add(&info.index.resource->reference.count, primcount - 1);
} else {
info.index.resource = index_bo->buffer;
}