Mesa (staging/22.1): r300: Keep rc_rename_regs() from overflowing RC_REGISTER_MAX_INDEX
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Tue Jul 12 17:20:16 UTC 2022
Module: Mesa
Branch: staging/22.1
Commit: a18fe9357012bf21d7f17c06f6467ba079d7eac2
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=a18fe9357012bf21d7f17c06f6467ba079d7eac2
Author: Pavel Ondračka <pavel.ondracka at gmail.com>
Date: Thu Jul 7 10:44:41 2022 +0200
r300: Keep rc_rename_regs() from overflowing RC_REGISTER_MAX_INDEX
This pass tries to move register usage closer to SSA, and for large
shaders this means we can overflow the register index, which only has
RC_REGISTER_INDEX_BITS size. This creates invalid code and leads to
crash at a later stage. Limit the pool of available registers to
RC_REGISTER_MAX_INDEX, currently is was two times the number of
shader instructions.
This means we'll fail the compile right away if we wanted more than
RC_REGISTER_MAX_INDEX temps, but when we've got that many we're
already well past how many instructions we can support anyway.
CC: mesa-stable
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/6017
Signed-off-by: Pavel Ondračka <pavel.ondracka at gmail.com>
Reviewed-by: Emma Anholt <emma at anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17393>
(cherry picked from commit 42a3d22f165a990ba3e05ef7e8e5d147f62281b4)
---
.pick_status.json | 2 +-
src/gallium/drivers/r300/compiler/radeon_rename_regs.c | 4 +++-
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/.pick_status.json b/.pick_status.json
index e373ce2fe45..4bc0ebefb18 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -517,7 +517,7 @@
"description": "r300: Keep rc_rename_regs() from overflowing RC_REGISTER_MAX_INDEX",
"nominated": true,
"nomination_type": 0,
- "resolution": 0,
+ "resolution": 1,
"main_sha": null,
"because_sha": null
},
diff --git a/src/gallium/drivers/r300/compiler/radeon_rename_regs.c b/src/gallium/drivers/r300/compiler/radeon_rename_regs.c
index 498b88fca67..4a124e7d4d1 100644
--- a/src/gallium/drivers/r300/compiler/radeon_rename_regs.c
+++ b/src/gallium/drivers/r300/compiler/radeon_rename_regs.c
@@ -29,6 +29,8 @@
* \file
*/
+#include "util/u_math.h"
+
#include "radeon_rename_regs.h"
#include "radeon_compiler.h"
@@ -60,7 +62,7 @@ void rc_rename_regs(struct radeon_compiler *c, void *user)
return;
}
- used_length = 2 * rc_recompute_ips(c);
+ used_length = MIN2(2 * rc_recompute_ips(c), RC_REGISTER_MAX_INDEX);
used = memory_pool_malloc(&c->Pool, sizeof(unsigned char) * used_length);
memset(used, 0, sizeof(unsigned char) * used_length);
More information about the mesa-commit
mailing list