From 384fc52dd3335541b0b8b33b8322bf8cc6ceb809 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20Ondra=C4=8Dka?= Date: Fri, 25 Nov 2022 10:02:32 +0100 Subject: [PATCH] r300: doublecheck for free alpha source when coventing to alpha MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit For any instruction that can be reasonably converted to alpha we check all of its readers to see if the conversion is possible (including check for at least one free alpha source) at the beginning of pair scheduling. However, if the reader instruction has multiples sources that could be converted to alpha and multiple indeed are, than we could run of of the alpha sources eventually. So recheck just before converting that there are still some unused sources left. Signed-off-by: Pavel Ondračka Reviewed-by: Filip Gawin Tested-by: Filip Gawin Part-of: --- .../drivers/r300/compiler/radeon_pair_schedule.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/gallium/drivers/r300/compiler/radeon_pair_schedule.c b/src/gallium/drivers/r300/compiler/radeon_pair_schedule.c index 9230df16be9..e232e93f0f3 100644 --- a/src/gallium/drivers/r300/compiler/radeon_pair_schedule.c +++ b/src/gallium/drivers/r300/compiler/radeon_pair_schedule.c @@ -898,6 +898,16 @@ static int convert_rgb_to_alpha( if (sched_inst->GlobalReaders.Abort) return 0; + /* Even though we checked that we can convert to alpha previously, it is + * possible that another rgb source of the reader instructions was already + * converted to alpha and we thus have no longer free alpha sources. + */ + for(i = 0; i < sched_inst->GlobalReaders.ReaderCount; i++) { + struct rc_reader reader = sched_inst->GlobalReaders.Readers[i]; + if (reader.Inst->U.P.Alpha.Src[2].Used) + return 0; + } + if (!pair_inst->RGB.WriteMask) return 0;