Mesa (main): r600: Add a workaround and explanation for shadowcubearray TG4.

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Mar 28 18:01:36 UTC 2022


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

Author: Emma Anholt <emma at anholt.net>
Date:   Wed Jan  5 15:45:37 2022 -0800

r600: Add a workaround and explanation for shadowcubearray TG4.

With the NIR-to-TGSI transition, we had fewer other immediates and would
end up dereffing past the end of the literals array.

Cc: mesa-stable
Reviewed-by: Gert Wollny <gert.wollny at collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14429>

---

 src/gallium/drivers/r600/r600_shader.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/r600/r600_shader.c b/src/gallium/drivers/r600/r600_shader.c
index 4518d9e892b..e1d9bc1ec92 100644
--- a/src/gallium/drivers/r600/r600_shader.c
+++ b/src/gallium/drivers/r600/r600_shader.c
@@ -8465,8 +8465,18 @@ static int tgsi_tex(struct r600_shader_ctx *ctx)
 	}
 
 	if (inst->Instruction.Opcode == TGSI_OPCODE_TG4) {
-		int8_t texture_component_select = ctx->literals[4 * inst->Src[1].Register.Index + inst->Src[1].Register.SwizzleX];
-		tex.inst_mod = texture_component_select;
+		if (inst->Src[1].Register.File != TGSI_FILE_IMMEDIATE) {
+			/* TGSI doesn't have a spot to put the component for
+			 * shadowcubes, so it drops it on the floor.  Just
+			 * assume the user wanted component 0 (it's a shadow,
+			 * anything else would be absurd).
+			 */
+			assert(inst->Texture.Texture == TGSI_TEXTURE_SHADOWCUBE_ARRAY);
+			tex.inst_mod = 0;
+		} else {
+			int8_t texture_component_select = ctx->literals[4 * inst->Src[1].Register.Index + inst->Src[1].Register.SwizzleX];
+			tex.inst_mod = texture_component_select;
+		}
 
 		if (ctx->bc->chip_class == CAYMAN) {
 			tex.dst_sel_x = (inst->Dst[0].Register.WriteMask & 1) ? 0 : 7;



More information about the mesa-commit mailing list