Commit cdcd2d42 authored by Marek Olšák's avatar Marek Olšák

st/mesa: set take_index_buffer_ownership to skip an atomic in u_threaded

This reduces overhead by skipping the atomic, which is slow on AMD Zen.
It uses the same mechanism as vertex buffers.
Reviewed-by: Zoltán Böszörményi's avatarZoltán Böszörményi <zboszor@gmail.com>
parent 1f33e898
Pipeline #260499 waiting for manual action with stages
in 9 seconds
......@@ -2389,7 +2389,7 @@ tc_call_draw_multi(struct pipe_context *pipe, union tc_payload *payload)
#define DRAW_INFO_SIZE_WITHOUT_INDEXBUF_AND_MIN_MAX_INDEX \
offsetof(struct pipe_draw_info, index)
static void
void
tc_draw_vbo(struct pipe_context *_pipe, const struct pipe_draw_info *info,
const struct pipe_draw_indirect_info *indirect,
const struct pipe_draw_start_count *draws,
......
......@@ -396,6 +396,12 @@ threaded_context_flush(struct pipe_context *_pipe,
struct tc_unflushed_batch_token *token,
bool prefer_async);
void
tc_draw_vbo(struct pipe_context *_pipe, const struct pipe_draw_info *info,
const struct pipe_draw_indirect_info *indirect,
const struct pipe_draw_start_count *draws,
unsigned num_draws);
static inline struct threaded_context *
threaded_context(struct pipe_context *pipe)
{
......
......@@ -65,6 +65,7 @@
#include "util/u_prim.h"
#include "util/u_draw.h"
#include "util/u_upload_mgr.h"
#include "util/u_threaded_context.h"
#include "draw/draw_context.h"
#include "cso_cache/cso_context.h"
......@@ -247,7 +248,17 @@ prepare_indexed_draw(/* pass both st and ctx to reduce dereferences */
}
if (!info->has_user_indices) {
info->index.resource = st_buffer_object(info->index.gl_bo)->buffer;
if (st->pipe->draw_vbo == tc_draw_vbo) {
/* Fast path for u_threaded_context. This eliminates the atomic
* increment for the index buffer refcount when adding it into
* the threaded batch buffer.
*/
info->index.resource =
st_get_buffer_reference(ctx, info->index.gl_bo);
info->take_index_buffer_ownership = true;
} else {
info->index.resource = st_buffer_object(info->index.gl_bo)->buffer;
}
/* Return if the bound element array buffer doesn't have any backing
* storage. (nothing to do)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment