broadcom/compiler: disable TMU pipelining if we fail to register allocate
TMU pipelining can severely reduce our capacity to emit TMU spills, causing us to fail to compile a shader we may otherwise be able to compile. This is because pipelining extends the liveness of TMU sequences by posponing the thread switch and LDTMU until a result is needed, and we can't emit TMU spills while in the middle of a TMU sequence. Reviewed-by: Alejandro Piñeiro <apinheiro@igalia.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8825>
This commit is contained in:

committed by
Marge Bot

parent
ecd654bf00
commit
e18d6bbf2f
@@ -286,6 +286,9 @@ ntq_add_pending_tmu_flush(struct v3d_compile *c,
|
|||||||
c->tmu.flush[c->tmu.flush_count].dest = dest;
|
c->tmu.flush[c->tmu.flush_count].dest = dest;
|
||||||
c->tmu.flush[c->tmu.flush_count].component_mask = component_mask;
|
c->tmu.flush[c->tmu.flush_count].component_mask = component_mask;
|
||||||
c->tmu.flush_count++;
|
c->tmu.flush_count++;
|
||||||
|
|
||||||
|
if (c->disable_tmu_pipelining)
|
||||||
|
ntq_flush_tmu(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
enum emit_mode {
|
enum emit_mode {
|
||||||
|
@@ -627,6 +627,12 @@ struct v3d_compile {
|
|||||||
*/
|
*/
|
||||||
bool fallback_scheduler;
|
bool fallback_scheduler;
|
||||||
|
|
||||||
|
/* Disable TMU pipelining. This may increase the chances of being able
|
||||||
|
* to compile shaders with high register pressure that require to emit
|
||||||
|
* TMU spills.
|
||||||
|
*/
|
||||||
|
bool disable_tmu_pipelining;
|
||||||
|
|
||||||
/* State for whether we're executing on each channel currently. 0 if
|
/* State for whether we're executing on each channel currently. 0 if
|
||||||
* yes, otherwise a block number + 1 that the channel jumped to.
|
* yes, otherwise a block number + 1 that the channel jumped to.
|
||||||
*/
|
*/
|
||||||
|
@@ -512,6 +512,7 @@ vir_compile_init(const struct v3d_compiler *compiler,
|
|||||||
void *debug_output_data),
|
void *debug_output_data),
|
||||||
void *debug_output_data,
|
void *debug_output_data,
|
||||||
int program_id, int variant_id,
|
int program_id, int variant_id,
|
||||||
|
bool disable_tmu_pipelining,
|
||||||
bool fallback_scheduler)
|
bool fallback_scheduler)
|
||||||
{
|
{
|
||||||
struct v3d_compile *c = rzalloc(NULL, struct v3d_compile);
|
struct v3d_compile *c = rzalloc(NULL, struct v3d_compile);
|
||||||
@@ -526,6 +527,7 @@ vir_compile_init(const struct v3d_compiler *compiler,
|
|||||||
c->debug_output_data = debug_output_data;
|
c->debug_output_data = debug_output_data;
|
||||||
c->compilation_result = V3D_COMPILATION_SUCCEEDED;
|
c->compilation_result = V3D_COMPILATION_SUCCEEDED;
|
||||||
c->fallback_scheduler = fallback_scheduler;
|
c->fallback_scheduler = fallback_scheduler;
|
||||||
|
c->disable_tmu_pipelining = disable_tmu_pipelining;
|
||||||
|
|
||||||
s = nir_shader_clone(c, s);
|
s = nir_shader_clone(c, s);
|
||||||
c->s = s;
|
c->s = s;
|
||||||
@@ -1237,22 +1239,32 @@ uint64_t *v3d_compile(const struct v3d_compiler *compiler,
|
|||||||
{
|
{
|
||||||
struct v3d_compile *c;
|
struct v3d_compile *c;
|
||||||
|
|
||||||
for (int i = 0; true; i++) {
|
static const char *strategies[] = {
|
||||||
|
"default",
|
||||||
|
"disable TMU pipelining",
|
||||||
|
"fallback scheduler"
|
||||||
|
};
|
||||||
|
|
||||||
|
for (int i = 0; i < ARRAY_SIZE(strategies); i++) {
|
||||||
c = vir_compile_init(compiler, key, s,
|
c = vir_compile_init(compiler, key, s,
|
||||||
debug_output, debug_output_data,
|
debug_output, debug_output_data,
|
||||||
program_id, variant_id,
|
program_id, variant_id,
|
||||||
i > 0 /* fallback_scheduler */);
|
i > 0, /* Disable TMU pipelining */
|
||||||
|
i > 1 /* Fallback_scheduler */);
|
||||||
|
|
||||||
v3d_attempt_compile(c);
|
v3d_attempt_compile(c);
|
||||||
|
|
||||||
if (i > 0 ||
|
if (i >= ARRAY_SIZE(strategies) - 1 ||
|
||||||
c->compilation_result !=
|
c->compilation_result !=
|
||||||
V3D_COMPILATION_FAILED_REGISTER_ALLOCATION)
|
V3D_COMPILATION_FAILED_REGISTER_ALLOCATION) {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Fallback strategy */
|
||||||
char *debug_msg;
|
char *debug_msg;
|
||||||
int ret = asprintf(&debug_msg,
|
int ret = asprintf(&debug_msg,
|
||||||
"Using fallback scheduler for %s",
|
"Falling back to strategy '%s' for %s",
|
||||||
|
strategies[i + 1],
|
||||||
vir_get_stage_name(c));
|
vir_get_stage_name(c));
|
||||||
|
|
||||||
if (ret >= 0) {
|
if (ret >= 0) {
|
||||||
|
Reference in New Issue
Block a user