[Mesa-dev] [PATCH 2/2] radeonsi: force level zero on image instructions in non-fragment shaders
Ilia Mirkin
imirkin at alum.mit.edu
Fri May 13 05:03:27 UTC 2016
On Fri, May 13, 2016 at 12:57 AM, Nicolai Hähnle <nhaehnle at gmail.com> wrote:
> 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.
>
> Of course, explicit LOD or derivative variants work in all shader types.
>
> This fixes several GL4x-CTS.texture_gather.* tests.
> --
> Note that a bunch of texture_gather sub-tests for int and uint textures still
> fail because the hardware apparently decides to offset all coordinates by 0.5
> for such textures - forcing the NUM_FORMAT to FLOAT changes the coordinate
> calculation, but that seems like such a wrong-headed hackwrong somehow (not to
> mention that there might be some actual float-handling, with NaNs or whatever
> , so...)
> ---
> src/gallium/drivers/radeonsi/si_shader.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/src/gallium/drivers/radeonsi/si_shader.c b/src/gallium/drivers/radeonsi/si_shader.c
> index 3f937ee..fa0e718 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,8 @@ static void build_tex_intrinsic(const struct lp_build_tgsi_action *action,
> break;
> case TGSI_OPCODE_TG4:
> name = "llvm.SI.gather4";
> + if (ctx->type != PIPE_SHADER_FRAGMENT)
> + infix = ".lz";
FWIW, TG4 is always on level 0, even in fragment shader.
> break;
> default:
> assert(0);
> --
> 2.7.4
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
More information about the mesa-dev
mailing list