From cada1db3d4a551e0801cfa1c2ca37173f77ea4cc Mon Sep 17 00:00:00 2001 From: Rohan Garg Date: Wed, 1 Sep 2021 15:53:21 +0200 Subject: [PATCH] vrend_shader: Use the binding location and offset for atomic_uint variable names when emiting GLSL When emitting GLSL for atomic_uint variables, use the binding location and offset instead of a generic index as this might lead to cases where the same variable is bound to two locations with different offsets causing a linking error on the host. This fixes: KHR-GL43.shader_atomic_counters.basic-usage-cs KHR-GL43.shader_atomic_counters.advanced-usage-switch-programs Signed-off-by: Rohan Garg Reviewed-by: Gert Wollny --- src/vrend_shader.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/vrend_shader.c b/src/vrend_shader.c index 2a02bff..84e1dd4 100644 --- a/src/vrend_shader.c +++ b/src/vrend_shader.c @@ -4467,15 +4467,17 @@ get_source_info(struct dump_ctx *ctx, if (src->Dimension.Index == ctx->abo_idx[j] && src->Register.Index >= ctx->abo_offsets[j] && src->Register.Index < ctx->abo_offsets[j] + ctx->abo_sizes[j]) { + int abo_idx = ctx->abo_idx[j]; + int abo_offset = ctx->abo_offsets[j] * 4; if (ctx->abo_sizes[j] > 1) { int offset = src->Register.Index - ctx->abo_offsets[j]; if (src->Register.Indirect) { assert(src->Indirect.File == TGSI_FILE_ADDRESS); - strbuf_fmt(src_buf, "ac%d[addr%d + %d]", j, src->Indirect.Index, offset); + strbuf_fmt(src_buf, "ac%d_%d[addr%d + %d]", abo_idx, abo_offset, src->Indirect.Index, offset); } else - strbuf_fmt(src_buf, "ac%d[%d]", j, offset); + strbuf_fmt(src_buf, "ac%d_%d[%d]", abo_idx, abo_offset, offset); } else - strbuf_fmt(src_buf, "ac%d", j); + strbuf_fmt(src_buf, "ac%d_%d", abo_idx, abo_offset); break; } } @@ -6080,9 +6082,9 @@ static int emit_ios_common(const struct dump_ctx *ctx, for (i = 0; i < ctx->num_abo; i++){ if (ctx->abo_sizes[i] > 1) - emit_hdrf(glsl_strbufs, "layout (binding = %d, offset = %d) uniform atomic_uint ac%d[%d];\n", ctx->abo_idx[i], ctx->abo_offsets[i] * 4, i, ctx->abo_sizes[i]); + emit_hdrf(glsl_strbufs, "layout (binding = %d, offset = %d) uniform atomic_uint ac%d_%d[%d];\n", ctx->abo_idx[i], ctx->abo_offsets[i] * 4, ctx->abo_idx[i], ctx->abo_offsets[i] * 4, ctx->abo_sizes[i]); else - emit_hdrf(glsl_strbufs, "layout (binding = %d, offset = %d) uniform atomic_uint ac%d;\n", ctx->abo_idx[i], ctx->abo_offsets[i] * 4, i); + emit_hdrf(glsl_strbufs, "layout (binding = %d, offset = %d) uniform atomic_uint ac%d_%d;\n", ctx->abo_idx[i], ctx->abo_offsets[i] * 4, ctx->abo_idx[i], ctx->abo_offsets[i] * 4); } if (ctx->info.indirect_files & (1 << TGSI_FILE_BUFFER)) {