radeonsi: add an option to use CPU storage uploads for threaded context

It's only enabled for viewperf for now.

Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13400>
This commit is contained in:
Marek Olšák 2021-10-17 17:17:14 -04:00 committed by Marge Bot
parent 745ea99484
commit 9f2a97e9df
7 changed files with 18 additions and 5 deletions

View file

@ -8,6 +8,7 @@ DRI_CONF_SECTION_END
DRI_CONF_SECTION_DEBUG
#define OPT_BOOL(name, dflt, description) DRI_CONF_OPT_B(radeonsi_##name, dflt, description)
#define OPT_INT(name, dflt, description) DRI_CONF_OPT_I(radeonsi_##name, dflt, INT_MIN, INT_MAX, description)
#include "radeonsi/si_debug_options.h"
DRI_CONF_SECTION_END

View file

@ -154,6 +154,7 @@ void si_init_resource_fields(struct si_screen *sscreen, struct si_resource *res,
*/
if (!sscreen->info.smart_access_memory &&
sscreen->info.has_dedicated_vram &&
!res->b.cpu_storage && /* TODO: The CPU storage breaks this. */
size >= SI_MAX_VRAM_MAP_SIZE)
res->b.b.flags |= PIPE_RESOURCE_FLAG_DONT_MAP_DIRECTLY;
}
@ -555,7 +556,8 @@ 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,
const struct pipe_resource *templ)
const struct pipe_resource *templ,
bool allow_cpu_storage)
{
struct si_resource *buf = MALLOC_STRUCT_CL(si_resource);
@ -564,7 +566,7 @@ static struct si_resource *si_alloc_buffer_struct(struct pipe_screen *screen,
pipe_reference_init(&buf->b.b.reference, 1);
buf->b.b.screen = screen;
threaded_resource_init(&buf->b.b, false, 0);
threaded_resource_init(&buf->b.b, allow_cpu_storage, SI_MAP_BUFFER_ALIGNMENT);
buf->buf = NULL;
buf->bind_history = 0;
@ -577,7 +579,9 @@ static struct pipe_resource *si_buffer_create(struct pipe_screen *screen,
const struct pipe_resource *templ, unsigned alignment)
{
struct si_screen *sscreen = (struct si_screen *)screen;
struct si_resource *buf = si_alloc_buffer_struct(screen, templ);
struct si_resource *buf =
si_alloc_buffer_struct(screen, templ,
templ->width0 <= sscreen->options.tc_max_cpu_storage_size);
if (templ->flags & PIPE_RESOURCE_FLAG_SPARSE)
buf->b.b.flags |= SI_RESOURCE_FLAG_UNMAPPABLE;
@ -627,7 +631,7 @@ static struct pipe_resource *si_buffer_from_user_memory(struct pipe_screen *scre
{
struct si_screen *sscreen = (struct si_screen *)screen;
struct radeon_winsys *ws = sscreen->ws;
struct si_resource *buf = si_alloc_buffer_struct(screen, templ);
struct si_resource *buf = si_alloc_buffer_struct(screen, templ, false);
buf->domains = RADEON_DOMAIN_GTT;
buf->flags = 0;
@ -655,7 +659,7 @@ struct pipe_resource *si_buffer_from_winsys_buffer(struct pipe_screen *screen,
bool dedicated)
{
struct si_screen *sscreen = (struct si_screen *)screen;
struct si_resource *res = si_alloc_buffer_struct(screen, templ);
struct si_resource *res = si_alloc_buffer_struct(screen, templ, false);
if (!res)
return 0;

View file

@ -14,5 +14,7 @@ OPT_BOOL(vrs2x2, false, "Enable 2x2 coarse shading for non-GUI elements")
OPT_BOOL(enable_sam, false, "Enable Smart Access Memory with Above 4G Decoding for unvalidated platforms.")
OPT_BOOL(disable_sam, false, "Disable Smart Access Memory.")
OPT_BOOL(fp16, false, "Enable FP16 for mediump.")
OPT_INT(tc_max_cpu_storage_size, 0, "Enable the CPU storage for pipelined buffer uploads in TC.")
#undef OPT_BOOL
#undef OPT_INT

View file

@ -1073,6 +1073,8 @@ static struct pipe_screen *radeonsi_screen_create_impl(struct radeon_winsys *ws,
{
#define OPT_BOOL(name, dflt, description) \
sscreen->options.name = driQueryOptionb(config->options, "radeonsi_" #name);
#define OPT_INT(name, dflt, description) \
sscreen->options.name = driQueryOptioni(config->options, "radeonsi_" #name);
#include "si_debug_options.h"
}

View file

@ -556,6 +556,7 @@ struct si_screen {
struct {
#define OPT_BOOL(name, dflt, description) bool name : 1;
#define OPT_INT(name, dflt, description) int name;
#include "si_debug_options.h"
} options;

View file

@ -733,6 +733,8 @@ static bool si_texture_get_handle(struct pipe_screen *screen, struct pipe_contex
modifier = tex->surface.modifier;
} else {
tc_buffer_disable_cpu_storage(&res->b.b);
/* Buffer exports are for the OpenCL interop. */
/* Move a suballocated buffer into a non-suballocated allocation. */
if (sscreen->ws->buffer_is_suballocated(res->buf) ||

View file

@ -769,6 +769,7 @@ TODO: document the other workarounds.
<option name="radeonsi_sync_compile" value="true" />
<option name="radeonsi_clamp_div_by_zero" value="true" />
<option name="radeonsi_inline_uniforms" value="true" />
<option name="radeonsi_tc_max_cpu_storage_size" value="1000" />
</application>
<application name="Road Redemption" executable="RoadRedemption.x86_64">
<option name="radeonsi_clamp_div_by_zero" value="true" />