radeonsi: align pipe_resource & sampler_view allocations to a cache line

It eliminates "False Sharing" for atomic operations. (see wikipedia)

Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11618>
This commit is contained in:
Marek Olšák 2021-06-27 17:57:56 -04:00 committed by Marge Bot
parent 8c6e18bc51
commit c85ce2531e
3 changed files with 11 additions and 13 deletions

View file

@ -218,12 +218,12 @@ static void si_resource_destroy(struct pipe_screen *screen, struct pipe_resource
util_range_destroy(&buffer->valid_buffer_range); util_range_destroy(&buffer->valid_buffer_range);
radeon_bo_reference(((struct si_screen*)screen)->ws, &buffer->buf, NULL); radeon_bo_reference(((struct si_screen*)screen)->ws, &buffer->buf, NULL);
util_idalloc_mt_free(&sscreen->buffer_ids, buffer->b.buffer_id_unique); util_idalloc_mt_free(&sscreen->buffer_ids, buffer->b.buffer_id_unique);
FREE(buffer); FREE_CL(buffer);
} else if (buf->flags & SI_RESOURCE_AUX_PLANE) { } else if (buf->flags & SI_RESOURCE_AUX_PLANE) {
struct si_auxiliary_texture *tex = (struct si_auxiliary_texture *)buf; struct si_auxiliary_texture *tex = (struct si_auxiliary_texture *)buf;
radeon_bo_reference(((struct si_screen*)screen)->ws, &tex->buffer, NULL); radeon_bo_reference(((struct si_screen*)screen)->ws, &tex->buffer, NULL);
FREE(tex); FREE_CL(tex);
} else { } else {
struct si_texture *tex = (struct si_texture *)buf; struct si_texture *tex = (struct si_texture *)buf;
struct si_resource *resource = &tex->buffer; struct si_resource *resource = &tex->buffer;
@ -234,7 +234,7 @@ static void si_resource_destroy(struct pipe_screen *screen, struct pipe_resource
si_resource_reference(&tex->cmask_buffer, NULL); si_resource_reference(&tex->cmask_buffer, NULL);
} }
radeon_bo_reference(((struct si_screen*)screen)->ws, &resource->buf, NULL); radeon_bo_reference(((struct si_screen*)screen)->ws, &resource->buf, NULL);
FREE(tex); FREE_CL(tex);
} }
} }
@ -560,9 +560,7 @@ static void si_buffer_subdata(struct pipe_context *ctx, struct pipe_resource *bu
static struct si_resource *si_alloc_buffer_struct(struct pipe_screen *screen, static struct si_resource *si_alloc_buffer_struct(struct pipe_screen *screen,
const struct pipe_resource *templ) const struct pipe_resource *templ)
{ {
struct si_resource *buf; struct si_resource *buf = MALLOC_STRUCT_CL(si_resource);
buf = MALLOC_STRUCT(si_resource);
buf->b.b = *templ; buf->b.b = *templ;
buf->b.b.next = NULL; buf->b.b.next = NULL;
@ -594,7 +592,7 @@ static struct pipe_resource *si_buffer_create(struct pipe_screen *screen,
if (!si_alloc_resource(sscreen, buf)) { if (!si_alloc_resource(sscreen, buf)) {
threaded_resource_deinit(&buf->b.b); threaded_resource_deinit(&buf->b.b);
FREE(buf); FREE_CL(buf);
return NULL; return NULL;
} }
@ -644,7 +642,7 @@ static struct pipe_resource *si_buffer_from_user_memory(struct pipe_screen *scre
buf->buf = ws->buffer_from_ptr(ws, user_memory, templ->width0); buf->buf = ws->buffer_from_ptr(ws, user_memory, templ->width0);
if (!buf->buf) { if (!buf->buf) {
threaded_resource_deinit(&buf->b.b); threaded_resource_deinit(&buf->b.b);
FREE(buf); FREE_CL(buf);
return NULL; return NULL;
} }

View file

@ -4321,7 +4321,7 @@ struct pipe_sampler_view *si_create_sampler_view_custom(struct pipe_context *ctx
unsigned force_level) unsigned force_level)
{ {
struct si_context *sctx = (struct si_context *)ctx; struct si_context *sctx = (struct si_context *)ctx;
struct si_sampler_view *view = CALLOC_STRUCT(si_sampler_view); struct si_sampler_view *view = CALLOC_STRUCT_CL(si_sampler_view);
struct si_texture *tex = (struct si_texture *)texture; struct si_texture *tex = (struct si_texture *)texture;
unsigned base_level, first_level, last_level; unsigned base_level, first_level, last_level;
unsigned char state_swizzle[4]; unsigned char state_swizzle[4];
@ -4455,7 +4455,7 @@ static void si_sampler_view_destroy(struct pipe_context *ctx, struct pipe_sample
struct si_sampler_view *view = (struct si_sampler_view *)state; struct si_sampler_view *view = (struct si_sampler_view *)state;
pipe_resource_reference(&state->texture, NULL); pipe_resource_reference(&state->texture, NULL);
FREE(view); FREE_CL(view);
} }
static bool wrap_mode_uses_border_color(unsigned wrap, bool linear_filter) static bool wrap_mode_uses_border_color(unsigned wrap, bool linear_filter)

View file

@ -896,7 +896,7 @@ static struct si_texture *si_texture_create_object(struct pipe_screen *screen,
return NULL; return NULL;
} }
tex = CALLOC_STRUCT(si_texture); tex = CALLOC_STRUCT_CL(si_texture);
if (!tex) if (!tex)
goto error; goto error;
@ -1129,7 +1129,7 @@ static struct si_texture *si_texture_create_object(struct pipe_screen *screen,
return tex; return tex;
error: error:
FREE(tex); FREE_CL(tex);
return NULL; return NULL;
} }
@ -1584,7 +1584,7 @@ static struct pipe_resource *si_texture_from_handle(struct pipe_screen *screen,
return NULL; return NULL;
if (whandle->plane >= util_format_get_num_planes(whandle->format)) { if (whandle->plane >= util_format_get_num_planes(whandle->format)) {
struct si_auxiliary_texture *tex = CALLOC_STRUCT(si_auxiliary_texture); struct si_auxiliary_texture *tex = CALLOC_STRUCT_CL(si_auxiliary_texture);
if (!tex) if (!tex)
return NULL; return NULL;
tex->b.b = *templ; tex->b.b = *templ;