Mesa (main): r300: don't try to use inline constants instead of constant swizzles

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Sun Jun 5 21:47:43 UTC 2022


Module: Mesa
Branch: main
Commit: bc9b2f378132ee701bd4e7f418228f15127efa08
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=bc9b2f378132ee701bd4e7f418228f15127efa08

Author: Pavel Ondračka <pavel.ondracka at gmail.com>
Date:   Thu May 19 12:38:01 2022 +0200

r300: don't try to use inline constants instead of constant swizzles

It doesn't make sense and was not working anyway. This was spotted
by Filip Gawin in https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13978
however the fix there was IMO just papering over the problem.

I don't believe that this could manifest as a real issues, because
when all of the swizzles were constant the file would be set to
RC_FILE_NONE already. So in theory this could lead to an issue only
in the close to impossible circumstance that the out of bounds memory
read by constant->u.Immediate[swz] would end with the same exact value
as another inlineable constant in different channel. However in some
circumstances it would lead to following valgrind warnings:

 Conditional jump or move depends on uninitialised value(s)
    at 0x5D4E690: ieee_754_to_r300_float (radeon_inline_literals.c:61)
    by 0x5D4E690: rc_inline_literals (radeon_inline_literals.c:133)
    by 0x5D3877A: rc_run_compiler_passes (radeon_compiler.c:436)
    by 0x5D38821: rc_run_compiler (radeon_compiler.c:458)
    by 0x5D4AF63: r3xx_compile_fragment_program (r3xx_fragprog.c:139)
    by 0x5D48377: r300_translate_fragment_shader (r300_fs.c:499)
    by 0x5D491B0: r300_pick_fragment_shader (r300_fs.c:601)
    by 0x5D2BFEE: r300_create_fs_state (r300_state.c:1072)
    by 0x57DDC36: st_create_nir_shader (st_program.c:538)
    by 0x57DF10E: st_create_fp_variant (st_program.c:1056)
    by 0x57E057C: st_get_fp_variant (st_program.c:1102)
    by 0x57E0AB1: st_precompile_shader_variant (st_program.c:1287)
    by 0x57E0AB1: st_finalize_program (st_program.c:1333)
    by 0x57CB6F3: st_link_nir (st_glsl_to_nir.cpp:958)

Signed-off-by: Pavel Ondračka <pavel.ondracka at gmail.com>
Reviewed-by: Filip Gawin <filip at gawin.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16657>

---

 src/gallium/drivers/r300/compiler/radeon_inline_literals.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/gallium/drivers/r300/compiler/radeon_inline_literals.c b/src/gallium/drivers/r300/compiler/radeon_inline_literals.c
index c419f7c3d11..d1f2c4b03ef 100644
--- a/src/gallium/drivers/r300/compiler/radeon_inline_literals.c
+++ b/src/gallium/drivers/r300/compiler/radeon_inline_literals.c
@@ -126,6 +126,11 @@ void rc_inline_literals(struct radeon_compiler *c, void *user)
 				if (swz == RC_SWIZZLE_UNUSED) {
 					continue;
 				}
+				/* Don't try to inline constant swizzle */
+				if (swz >= RC_SWIZZLE_ZERO) {
+					use_literal = 0;
+					break;
+				}
 				float_value = constant->u.Immediate[swz];
 				ret = ieee_754_to_r300_float(float_value,
 								&r300_float_tmp);



More information about the mesa-commit mailing list