diff --git a/src/vrend_renderer.c b/src/vrend_renderer.c index 8136435..346f245 100644 --- a/src/vrend_renderer.c +++ b/src/vrend_renderer.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; diff --git a/src/vrend_shader.c b/src/vrend_shader.c index 21d78d7..57a3e75 100644 --- a/src/vrend_shader.c +++ b/src/vrend_shader.c @@ -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++) {