vrend: Fix TXQ on GLES when not only the levels are queried

To query the size and number of levels we have to obtain the
sampler as source for the size query, but also the index for
the emulated level lookup, so default to always obtaining the
right sampler, and add a special case for obtaining the sampler
index.

v2: - Fix possible endless loop (John)
    - Use the sampler source index to find find the real index

v3: Make loop easier to read, and rename variables (John)

Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: John Bates <jbates@chromium.org>
macos/master
Gert Wollny 3 years ago
parent 11143f2e00
commit c4c8b3e6b8
  1. 2
      src/vrend_renderer.c
  2. 49
      src/vrend_shader.c

@ -4889,7 +4889,7 @@ int vrend_draw_vbo(struct vrend_context *ctx,
for (unsigned i = PIPE_SHADER_VERTEX; i < PIPE_SHADER_COMPUTE; ++i) {
if (sub_ctx->prog->gles_use_query_texturelevel_mask & (1 << i)) {
char loc_name[32];
snprintf(loc_name, 32, "%s_texlod[0]", pipe_shader_to_prefix(i));
snprintf(loc_name, 32, "%s_texlod", pipe_shader_to_prefix(i));
sub_ctx->prog->tex_levels_uniform_id[i] = glGetUniformLocation(sub_ctx->prog->id, loc_name);
} else {
sub_ctx->prog->tex_levels_uniform_id[i] = -1;

@ -2429,9 +2429,24 @@ static void emit_txq(struct dump_ctx *ctx,
get_wm_string(twm), get_string(dtypeprefix),
srcs[sampler_index]);
} else {
const struct tgsi_full_src_register *src = &inst->Src[1];
int gles_sampler_index = 0;
for (int i = 0; i < src->Register.Index; ++i) {
if (ctx->samplers_used & (1 << i))
++gles_sampler_index;
}
char sampler_str[64];
if (ctx->info.indirect_files & (1 << TGSI_FILE_SAMPLER) && src->Register.Indirect) {
snprintf(sampler_str, sizeof(sampler_str), "addr%d+%d", src->Indirect.Index, gles_sampler_index);
} else {
snprintf(sampler_str, sizeof(sampler_str), "%d", gles_sampler_index);
}
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]);
sampler_str);
ctx->gles_use_tex_query_level = true;
}
}
@ -4315,28 +4330,16 @@ 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);
if (src->Register.Indirect) {
strbuf_fmt(src_buf, "%ssamp%d[addr%d+%d]%s", cname, basearrayidx, src->Indirect.Index, src->Register.Index - basearrayidx, swizzle);
} else {
strbuf_fmt(src_buf, "%ssamp%d[%d]%s", cname, basearrayidx, src->Register.Index - basearrayidx, swizzle);
}
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);
if (src->Register.Indirect) {
strbuf_fmt(src_buf, "%ssamp%d[addr%d+%d]%s", cname, basearrayidx, src->Indirect.Index, src->Register.Index - basearrayidx, swizzle);
} else {
strbuf_fmt(src_buf, "%ssamp%d%s", cname, src->Register.Index, swizzle);
strbuf_fmt(src_buf, "%ssamp%d[%d]%s", cname, basearrayidx, src->Register.Index - basearrayidx, 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);
}
strbuf_fmt(src_buf, "%ssamp%d%s", cname, src->Register.Index, swizzle);
}
sinfo->sreg_index = src->Register.Index;
} else if (src->Register.File == TGSI_FILE_IMAGE) {
@ -6115,14 +6118,12 @@ 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);
@ -6132,12 +6133,12 @@ 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 && ctx->gles_use_tex_query_level)
emit_hdrf(glsl_strbufs, "uniform int %s_texlod[%d];\n", tgsi_proc_to_prefix(ctx->info.processor), n_samplers);
emit_hdrf(glsl_strbufs, "uniform int %s_texlod[%d];\n", tgsi_proc_to_prefix(ctx->info.processor),
util_bitcount(ctx->samplers_used));
if (ctx->info.indirect_files & (1 << TGSI_FILE_IMAGE)) {
for (i = 0; i < ctx->num_image_arrays; i++) {

Loading…
Cancel
Save