vshader: Emit code to query texture levels from uniform on GLES

This fixes all piglits from:
spec@arb_texture_query_levels

v2: use tgsi_proc_to_prefix

Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Acked-by: Rohan Garg <rohan.garg@collabora.com>
macos/master
Gert Wollny 4 years ago
parent e5fabecbe0
commit d2aa0783e5
  1. 24
      src/vrend_shader.c

@ -2238,6 +2238,7 @@ static void set_texture_reqs(struct dump_ctx *ctx,
}
// TODO Consider exposing non-const ctx-> members as args to make *ctx const
/* size queries are pretty much separate */
static void emit_txq(struct dump_ctx *ctx,
const struct tgsi_full_instruction *inst,
@ -2286,6 +2287,10 @@ static void emit_txq(struct dump_ctx *ctx,
emit_buff(&ctx->glsl_strbufs, "%s%s = %s(textureQueryLevels(%s));\n", dst,
get_wm_string(twm), get_string(dtypeprefix),
srcs[sampler_index]);
else
emit_buff(&ctx->glsl_strbufs, "%s%s = %s(%s_texlod[%s]);\n", dst, get_wm_string(twm),
get_string(dtypeprefix), tgsi_proc_to_prefix(ctx->info.processor),
srcs[sampler_index]);
}
if (inst->Dst[0].Register.WriteMask & 0x7) {
@ -4114,6 +4119,9 @@ get_source_info(struct dump_ctx *ctx,
strbuf_fmt(src_buf, "%s%s(%sconst%d[%d]%s)", prefix, get_string(csp), cname, dim, src->Register.Index, swizzle);
}
} else if (src->Register.File == TGSI_FILE_SAMPLER) {
if (!ctx->cfg->use_gles ||
!(inst->Instruction.Opcode == TGSI_OPCODE_TXQ) ||
!(inst->Dst[0].Register.WriteMask & 0x8)) {
const char *cname = tgsi_proc_to_prefix(ctx->prog_type);
if (ctx->info.indirect_files & (1 << TGSI_FILE_SAMPLER)) {
int basearrayidx = lookup_sampler_array(ctx, src->Register.Index);
@ -4125,6 +4133,15 @@ get_source_info(struct dump_ctx *ctx,
} else {
strbuf_fmt(src_buf, "%ssamp%d%s", cname, src->Register.Index, swizzle);
}
} else {
/* This is probably incorrect, we assume that the base-index is the sum of all arrays sizes up
* to this array of samplers */
if (ctx->info.indirect_files & (1 << TGSI_FILE_SAMPLER) && src->Register.Indirect) {
strbuf_fmt(src_buf, "addr%d+%d", src->Indirect.Index, src->Register.Index);
} else {
strbuf_fmt(src_buf, "%d", src->Register.Index);
}
}
sinfo->sreg_index = src->Register.Index;
} else if (src->Register.File == TGSI_FILE_IMAGE) {
const char *cname = tgsi_proc_to_prefix(ctx->prog_type);
@ -5898,11 +5915,14 @@ static int emit_ios_common(const struct dump_ctx *ctx,
}
}
unsigned n_samplers = 0;
if (ctx->info.indirect_files & (1 << TGSI_FILE_SAMPLER)) {
for (i = 0; i < ctx->num_sampler_arrays; i++) {
uint32_t first = ctx->sampler_arrays[i].first;
uint32_t range = ctx->sampler_arrays[i].array_size;
emit_sampler_decl(ctx, glsl_strbufs, shadow_samp_mask, first, range, ctx->samplers + first);
n_samplers += range;
}
} else {
uint nsamp = util_last_bit(ctx->samplers_used);
@ -5912,9 +5932,13 @@ static int emit_ios_common(const struct dump_ctx *ctx,
continue;
emit_sampler_decl(ctx, glsl_strbufs, shadow_samp_mask, i, 0, ctx->samplers + i);
++n_samplers;
}
}
if (ctx->cfg->use_gles && n_samplers)
emit_hdrf(glsl_strbufs, "uniform int %s_texlod[%d];\n", tgsi_proc_to_prefix(ctx->info.processor), n_samplers);
if (ctx->info.indirect_files & (1 << TGSI_FILE_IMAGE)) {
for (i = 0; i < ctx->num_image_arrays; i++) {
uint32_t first = ctx->image_arrays[i].first;

Loading…
Cancel
Save