[Mesa-dev] [PATCH] radeonsi: force level zero on image instructions in non-fragment shaders (v2)

Nicolai Hähnle nhaehnle at gmail.com
Fri May 13 05:22:37 UTC 2016


From: Nicolai Hähnle <nicolai.haehnle at amd.com>

Section 8.9 (Texture Functions) of the OpenGL Shading Language 4.5
specification:

   However, automatic level of detail is computed only for fragment shaders.
   Other shaders operate as though the base level of detail were computed as
   zero.

and Section 8.9.3 (Texture Gather Functions):

   When performing a texture gather operation, the minification and
   magnification filters are ignored, and the rules for LINEAR filtering in
   the OpenGL Specification are applied to the base level of the texture
   image to identify the four texels i_0 j_1, i_1 j_1, i_1 j_0, and i_0 j_0.

Of course, explicit LOD or derivative variants work in all shader types.

This fixes several GL4x-CTS.texture_gather.* tests.

v2: TG4 is always level zero (thanks, Ilia)
---
 src/gallium/drivers/radeonsi/si_shader.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/gallium/drivers/radeonsi/si_shader.c b/src/gallium/drivers/radeonsi/si_shader.c
index 3f937ee..d492c62 100644
--- a/src/gallium/drivers/radeonsi/si_shader.c
+++ b/src/gallium/drivers/radeonsi/si_shader.c
@@ -4301,6 +4301,7 @@ static void build_tex_intrinsic(const struct lp_build_tgsi_action *action,
 				struct lp_build_tgsi_context *bld_base,
 				struct lp_build_emit_data *emit_data)
 {
+	struct si_shader_context *ctx = si_shader_context(bld_base);
 	struct lp_build_context *base = &bld_base->base;
 	unsigned opcode = emit_data->inst->Instruction.Opcode;
 	unsigned target = emit_data->inst->Texture.Texture;
@@ -4337,9 +4338,12 @@ static void build_tex_intrinsic(const struct lp_build_tgsi_action *action,
 	case TGSI_OPCODE_TEX:
 	case TGSI_OPCODE_TEX2:
 	case TGSI_OPCODE_TXP:
+		if (ctx->type != PIPE_SHADER_FRAGMENT)
+			infix = ".lz";
 		break;
 	case TGSI_OPCODE_TXB:
 	case TGSI_OPCODE_TXB2:
+		assert(ctx->type == PIPE_SHADER_FRAGMENT);
 		infix = ".b";
 		break;
 	case TGSI_OPCODE_TXL:
@@ -4351,6 +4355,7 @@ static void build_tex_intrinsic(const struct lp_build_tgsi_action *action,
 		break;
 	case TGSI_OPCODE_TG4:
 		name = "llvm.SI.gather4";
+		infix = ".lz";
 		break;
 	default:
 		assert(0);
-- 
2.7.4



More information about the mesa-dev mailing list