From 753e2434d37d262fba6ff4a6801892f99578cb23 Mon Sep 17 00:00:00 2001 From: Gert Wollny Date: Thu, 31 Jan 2019 11:32:07 +0100 Subject: [PATCH] shader: Fix texelFetch to emulated 1D textures on GLES GLES doesn't support 1D textures, so they are emulated by using 2D textures and the access has to be fixed by adding the y lookup coordinate. v2: simplify the code flow (Gurchetan) Signed-off-by: Gert Wollny Reviewed-by: --- src/vrend_shader.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/vrend_shader.c b/src/vrend_shader.c index cb2558e..3603cba 100644 --- a/src/vrend_shader.c +++ b/src/vrend_shader.c @@ -2248,7 +2248,16 @@ static void translate_tex(struct dump_ctx *ctx, } } if (inst->Instruction.Opcode == TGSI_OPCODE_TXF) { - emit_buff(ctx, "%s = %s(%s(texelFetch%s(%s, %s(%s%s)%s%s)%s));\n", dsts[0], get_string(dinfo->dstconv), get_string(dtypeprefix), tex_ext, srcs[sampler_index], get_string(txfi), srcs[0], get_wm_string(twm), bias, offbuf, dinfo->dst_override_no_wm[0] ? "" : writemask); + if (ctx->cfg->use_gles && (inst->Texture.Texture == TGSI_TEXTURE_1D || + inst->Texture.Texture == TGSI_TEXTURE_1D_ARRAY)) { + const char *vtype = inst->Texture.Texture == TGSI_TEXTURE_1D ? "vec2" : "vec3"; + emit_buff(ctx, "%s = %s(%s(texelFetch%s(%s, %s(%s(%s%s), 0)%s%s)%s));\n", + dsts[0], get_string(dinfo->dstconv), get_string(dtypeprefix), tex_ext, srcs[sampler_index], + vtype, get_string(txfi), srcs[0], get_wm_string(twm), bias, offbuf, dinfo->dst_override_no_wm[0] ? "" : writemask); + } else { + emit_buff(ctx, "%s = %s(%s(texelFetch%s(%s, %s(%s%s)%s%s)%s));\n", dsts[0], get_string(dinfo->dstconv), get_string(dtypeprefix), + tex_ext, srcs[sampler_index], get_string(txfi), srcs[0], get_wm_string(twm), bias, offbuf, dinfo->dst_override_no_wm[0] ? "" : writemask); + } } else if (ctx->cfg->glsl_version < 140 && (ctx->shader_req_bits & SHADER_REQ_SAMPLER_RECT)) { /* rect is special in GLSL 1.30 */ if (inst->Texture.Texture == TGSI_TEXTURE_RECT)