[Mesa-dev] [PATCH] r600g: limit texture offset application to specific types

Dave Airlie airlied at gmail.com
Mon Nov 17 22:46:31 PST 2014


From: Dave Airlie <airlied at redhat.com>

For 1D and 2D arrays we don't want the other coordinates being
offset and affecting where we sample. I wrote this patch 6 months
ago but lost it.

This fixes at least
./bin/tex-miplevel-selection textureOffset 1DArray
./bin/tex-miplevel-selection textureOffset 2DArray

Signed-off-by: Dave Airlie <airlied at redhat.com>
---
 src/gallium/drivers/r600/r600_shader.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/gallium/drivers/r600/r600_shader.c b/src/gallium/drivers/r600/r600_shader.c
index ab2a838..f889399 100644
--- a/src/gallium/drivers/r600/r600_shader.c
+++ b/src/gallium/drivers/r600/r600_shader.c
@@ -5536,8 +5536,11 @@ static int tgsi_tex(struct r600_shader_ctx *ctx)
 			}
 		} else {
 			offset_x = ctx->literals[4 * inst->TexOffsets[0].Index + inst->TexOffsets[0].SwizzleX] << 1;
-			offset_y = ctx->literals[4 * inst->TexOffsets[0].Index + inst->TexOffsets[0].SwizzleY] << 1;
+			if (inst->Texture.Texture != TGSI_TEXTURE_1D && inst->Texture.Texture != TGSI_TEXTURE_1D_ARRAY) {
+				offset_y = ctx->literals[4 * inst->TexOffsets[0].Index + inst->TexOffsets[0].SwizzleY] << 1;
+				if (inst->Texture.Texture != TGSI_TEXTURE_2D && inst->Texture.Texture != TGSI_TEXTURE_2D_ARRAY && inst->Texture.Texture != TGSI_TEXTURE_RECT)
 			offset_z = ctx->literals[4 * inst->TexOffsets[0].Index + inst->TexOffsets[0].SwizzleZ] << 1;
+			}
 		}
 	}
 
-- 
1.9.3



More information about the mesa-dev mailing list