shader: Further fixes for the 1D texture emulation on GLES

Fixes piglits on GLES host:
   tex-miplevel-selection * 1D*

The only piglits that are not fixed from the tex-miplevel-selection
are those including sampler1DArrayShadow. emulating these by using
sampler2DArrayShadow is not always possible, because GLSL doesn't
provide the required overloads.

Namely textureOffset, textureLod, textureLodOffset, and texture with
bias parameter are not available.

Signed-off-by: Gert Wollny <gert.wollny@collabora.com>

Reviewed-By: Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
macos/master
Gert Wollny 6 years ago
parent 5eeb767d09
commit 3403b5cb0e
  1. 44
      src/vrend_shader.c

@ -2333,7 +2333,13 @@ static void translate_tex(struct dump_ctx *ctx,
snprintf(bias, 64, ", int(%s.w)", srcs[0]); snprintf(bias, 64, ", int(%s.w)", srcs[0]);
} }
} else if (inst->Instruction.Opcode == TGSI_OPCODE_TXD) { } else if (inst->Instruction.Opcode == TGSI_OPCODE_TXD) {
snprintf(bias, 128, ", %s%s, %s%s", srcs[1], get_wm_string(gwm), srcs[2], get_wm_string(gwm)); if (ctx->cfg->use_gles && (inst->Texture.Texture == TGSI_TEXTURE_1D ||
inst->Texture.Texture == TGSI_TEXTURE_SHADOW1D ||
inst->Texture.Texture == TGSI_TEXTURE_1D_ARRAY ||
inst->Texture.Texture == TGSI_TEXTURE_SHADOW1D_ARRAY))
snprintf(bias, 128, ", vec2(%s%s, 0), vec2(%s%s, 0)", srcs[1], get_wm_string(gwm), srcs[2], get_wm_string(gwm));
else
snprintf(bias, 128, ", %s%s, %s%s", srcs[1], get_wm_string(gwm), srcs[2], get_wm_string(gwm));
sampler_index = 3; sampler_index = 3;
} else if (inst->Instruction.Opcode == TGSI_OPCODE_TG4) { } else if (inst->Instruction.Opcode == TGSI_OPCODE_TG4) {
sampler_index = 2; sampler_index = 2;
@ -2448,16 +2454,40 @@ static void translate_tex(struct dump_ctx *ctx,
} else if (is_shad && inst->Instruction.Opcode != TGSI_OPCODE_TG4) { /* TGSI returns 1.0 in alpha */ } else if (is_shad && inst->Instruction.Opcode != TGSI_OPCODE_TG4) { /* TGSI returns 1.0 in alpha */
const char *cname = tgsi_proc_to_prefix(ctx->prog_type); const char *cname = tgsi_proc_to_prefix(ctx->prog_type);
const struct tgsi_full_src_register *src = &inst->Src[sampler_index]; const struct tgsi_full_src_register *src = &inst->Src[sampler_index];
emit_buff(ctx, "%s = %s(%s(vec4(vec4(texture%s(%s, %s%s%s%s)) * %sshadmask%d + %sshadadd%d)%s));\n", dsts[0], get_string(dinfo->dstconv), get_string(dtypeprefix), tex_ext, srcs[sampler_index], srcs[0], get_wm_string(twm), offbuf, bias, cname, src->Register.Index, cname, src->Register.Index, writemask);
if (ctx->cfg->use_gles &&
(inst->Texture.Texture == TGSI_TEXTURE_SHADOW1D ||
inst->Texture.Texture == TGSI_TEXTURE_SHADOW1D_ARRAY)) {
if (inst->Texture.Texture == TGSI_TEXTURE_SHADOW1D) {
if (inst->Instruction.Opcode == TGSI_OPCODE_TXP)
emit_buff(ctx, "%s = %s(%s(vec4(vec4(texture%s(%s, vec4(%s%s.xzw, 0).xwyz %s%s)) * %sshadmask%d + %sshadadd%d)%s));\n", dsts[0], get_string(dinfo->dstconv), get_string(dtypeprefix), tex_ext, srcs[sampler_index], srcs[0], get_wm_string(twm), offbuf, bias, cname, src->Register.Index, cname, src->Register.Index, writemask);
else
emit_buff(ctx, "%s = %s(%s(vec4(vec4(texture%s(%s, vec3(%s%s.xz, 0).xzy %s%s)) * %sshadmask%d + %sshadadd%d)%s));\n", dsts[0], get_string(dinfo->dstconv), get_string(dtypeprefix), tex_ext, srcs[sampler_index], srcs[0], get_wm_string(twm), offbuf, bias, cname, src->Register.Index, cname, src->Register.Index, writemask);
} else if (inst->Texture.Texture == TGSI_TEXTURE_SHADOW1D_ARRAY) {
emit_buff(ctx, "%s = %s(%s(vec4(vec4(texture%s(%s, vec4(%s%s, 0).xwyz %s%s)) * %sshadmask%d + %sshadadd%d)%s));\n", dsts[0], get_string(dinfo->dstconv), get_string(dtypeprefix), tex_ext, srcs[sampler_index], srcs[0], get_wm_string(twm), offbuf, bias, cname, src->Register.Index, cname, src->Register.Index, writemask);
}
} else
emit_buff(ctx, "%s = %s(%s(vec4(vec4(texture%s(%s, %s%s%s%s)) * %sshadmask%d + %sshadadd%d)%s));\n", dsts[0], get_string(dinfo->dstconv), get_string(dtypeprefix), tex_ext, srcs[sampler_index], srcs[0], get_wm_string(twm), offbuf, bias, cname, src->Register.Index, cname, src->Register.Index, writemask);
} else { } else {
/* OpenGL ES do not support 1D texture /* OpenGL ES do not support 1D texture
* so we use a 2D texture with a parameter set to 0.5 * so we use a 2D texture with a parameter set to 0.5
*/ */
if (ctx->cfg->use_gles && inst->Texture.Texture == TGSI_TEXTURE_1D) { if (ctx->cfg->use_gles &&
if (inst->Instruction.Opcode == TGSI_OPCODE_TXP) (inst->Texture.Texture == TGSI_TEXTURE_1D ||
emit_buff(ctx, "%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); inst->Texture.Texture == TGSI_TEXTURE_1D_ARRAY)) {
else if (inst->Texture.Texture == TGSI_TEXTURE_1D) {
emit_buff(ctx, "%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)
emit_buff(ctx, "%s = %s(%s(texture%s(%s, vec3(%s.xw, 0).xzy %s%s)%s));\n", dsts[0], get_string(dinfo->dstconv), get_string(dtypeprefix), tex_ext, srcs[sampler_index], srcs[0], offbuf, bias, dinfo->dst_override_no_wm[0] ? "" : writemask);
else
emit_buff(ctx, "%s = %s(%s(texture%s(%s, vec2(%s%s, 0.5) %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);
} else if (inst->Texture.Texture == TGSI_TEXTURE_1D_ARRAY) {
if (inst->Instruction.Opcode == TGSI_OPCODE_TXP)
emit_buff(ctx, "%s = %s(%s(texture%s(%s, vec3(%s.x / %s.w, 0, %s.y) %s%s)%s));\n", dsts[0], get_string(dinfo->dstconv), get_string(dtypeprefix), tex_ext, srcs[sampler_index], srcs[0], srcs[0], srcs[0], offbuf, bias, dinfo->dst_override_no_wm[0] ? "" : writemask);
else
emit_buff(ctx, "%s = %s(%s(texture%s(%s, vec3(%s%s, 0).xzy %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);
}
} else { } else {
emit_buff(ctx, "%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); emit_buff(ctx, "%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);
} }

Loading…
Cancel
Save