From efba8403866a1c368f8bc77e0fced7fe795968ff Mon Sep 17 00:00:00 2001 From: Gert Wollny Date: Wed, 26 Sep 2018 12:08:52 +0200 Subject: [PATCH] shader: add TXP special handling on GLES host for 1D textures TXP implements perspective correction, and uses a 4D vector as input. Apply the according perspective correction in the 1D case and use only the relevant components. Closes: #34 Signed-off-by: Dave Airlie --- src/vrend_shader.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/vrend_shader.c b/src/vrend_shader.c index 093759b..6ae9891 100644 --- a/src/vrend_shader.c +++ b/src/vrend_shader.c @@ -2304,7 +2304,10 @@ static int translate_tex(struct dump_ctx *ctx, * so we use a 2D texture with a parameter set to 0.5 */ if (ctx->cfg->use_gles && inst->Texture.Texture == TGSI_TEXTURE_1D) { - snprintf(buf, 255, "%s = %s(%s(texture2D(%s, vec2(%s%s%s%s, 0.5))%s));\n", dsts[0], get_string(dinfo->dstconv), get_string(dtypeprefix), srcs[sampler_index], srcs[0], get_wm_string(twm), offbuf, bias, dinfo->dst_override_no_wm[0] ? "" : writemask); + if (inst->Instruction.Opcode == TGSI_OPCODE_TXP) + snprintf(buf, 255, "%s = %s(%s(texture2D(%s, vec2(%s.x / %s.w, 0.5))%s));\n", dsts[0], get_string(dinfo->dstconv), get_string(dtypeprefix), srcs[sampler_index], srcs[0], srcs[0], dinfo->dst_override_no_wm[0] ? "" : writemask); + else + snprintf(buf, 255, "%s = %s(%s(texture2D(%s, vec2(%s%s%s%s, 0.5))%s));\n", dsts[0], get_string(dinfo->dstconv), get_string(dtypeprefix), srcs[sampler_index], srcs[0], get_wm_string(twm), offbuf, bias, dinfo->dst_override_no_wm[0] ? "" : writemask); } else { snprintf(buf, 255, "%s = %s(%s(texture%s(%s, %s%s%s%s)%s));\n", dsts[0], get_string(dinfo->dstconv), get_string(dtypeprefix), tex_ext, srcs[sampler_index], srcs[0], get_wm_string(twm), offbuf, bias, dinfo->dst_override_no_wm[0] ? "" : writemask); }