diff options
author | Rohan Garg <rohan.garg@collabora.com> | 2021-09-01 15:53:21 +0200 |
---|---|---|
committer | Gert Wollny <gw.fossdev@gmail.com> | 2021-09-16 06:45:25 +0000 |
commit | cada1db3d4a551e0801cfa1c2ca37173f77ea4cc (patch) | |
tree | 1ff97db66b32fa2d008165ecb55a22496fef04ae | |
parent | 86eb26ee82ba9058cdccc3ece47fb02d3a167e36 (diff) | |
download | virglrenderer-cada1db3d4a551e0801cfa1c2ca37173f77ea4cc.tar.gz |
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 <rohan.garg@collabora.com>
Reviewed-by: Gert Wollny <gert.wollny@collabora.com>
-rw-r--r-- | src/vrend_shader.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/vrend_shader.c b/src/vrend_shader.c index 2a02bffe..84e1dd44 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)) { |