From 6ea0a7124fc6bd2255518c58f4981e49e9f4e557 Mon Sep 17 00:00:00 2001 From: Erik Faye-Lund Date: Thu, 25 Apr 2019 12:33:22 +0200 Subject: [PATCH] shader: dst -> dst_reg "dsts" already means "array of strings", so it's reasonable that "dst" would mean "string", not "struct tgsi_full_dst_register". Let's rename this, so we can stop pointlessly passing an array into this function and still keep somewhat sane names for things. Signed-off-by: Erik Faye-Lund Reviewed-By: Gert Wollny --- src/vrend_shader.c | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/src/vrend_shader.c b/src/vrend_shader.c index 096ff66..f9f538c 100644 --- a/src/vrend_shader.c +++ b/src/vrend_shader.c @@ -2871,11 +2871,11 @@ translate_store(struct dump_ctx *ctx, const char *srcs[4], char dsts[3][255]) { - const struct tgsi_full_dst_register *dst = &inst->Dst[0]; + const struct tgsi_full_dst_register *dst_reg = &inst->Dst[0]; - if (dst->Register.File == TGSI_FILE_IMAGE) { + if (dst_reg->Register.File == TGSI_FILE_IMAGE) { bool is_ms = false; - enum vrend_type_qualifier coord_prefix = get_coord_prefix(ctx->images[dst->Register.Index].decl.Resource, &is_ms, ctx->cfg->use_gles); + enum vrend_type_qualifier coord_prefix = get_coord_prefix(ctx->images[dst_reg->Register.Index].decl.Resource, &is_ms, ctx->cfg->use_gles); enum tgsi_return_type itype; char ms_str[32] = {}; enum vrend_type_qualifier stypeprefix = TYPE_CONVERSION_NONE; @@ -2894,15 +2894,16 @@ translate_store(struct dump_ctx *ctx, default: break; } - if (!ctx->cfg->use_gles || !dst->Register.Indirect) { + if (!ctx->cfg->use_gles || !dst_reg->Register.Indirect) { emit_buff(ctx, "imageStore(%s,%s(%s(%s)),%s%s(%s));\n", dsts[0], get_string(coord_prefix), conversion, srcs[0], ms_str, get_string(stypeprefix), srcs[1]); } else { - struct vrend_array *image = lookup_image_array_ptr(ctx, dst->Register.Index); + struct vrend_array *image = lookup_image_array_ptr(ctx, dst_reg->Register.Index); if (image) { int basearrayidx = image->first; int array_size = image->array_size; - emit_buff(ctx, "switch (addr%d + %d) {\n", dst->Indirect.Index, dst->Register.Index - basearrayidx); + emit_buff(ctx, "switch (addr%d + %d) {\n", dst_reg->Indirect.Index, + dst_reg->Register.Index - basearrayidx); const char *cname = tgsi_proc_to_prefix(ctx->prog_type); for (int i = 0; i < array_size; ++i) { @@ -2914,29 +2915,34 @@ translate_store(struct dump_ctx *ctx, emit_buff(ctx, "}\n"); } } - } else if (dst->Register.File == TGSI_FILE_BUFFER || dst->Register.File == TGSI_FILE_MEMORY) { + } else if (dst_reg->Register.File == TGSI_FILE_BUFFER || + dst_reg->Register.File == TGSI_FILE_MEMORY) { enum vrend_type_qualifier dtypeprefix; - set_memory_qualifier(ctx, inst, dst->Register.Index, dst->Register.Indirect); - dtypeprefix = (is_integer_memory(ctx, dst->Register.File, dst->Register.Index)) ? FLOAT_BITS_TO_INT : FLOAT_BITS_TO_UINT; + set_memory_qualifier(ctx, inst, dst_reg->Register.Index, + dst_reg->Register.Indirect); + dtypeprefix = is_integer_memory(ctx, dst_reg->Register.File, dst_reg->Register.Index) ? + FLOAT_BITS_TO_INT : FLOAT_BITS_TO_UINT; const char *conversion = sinfo->override_no_cast[1] ? "" : get_string(dtypeprefix); - if (!ctx->cfg->use_gles || !dst->Register.Indirect) { - emit_store_mem(ctx, dsts[0], dst->Register.WriteMask, srcs, conversion); + if (!ctx->cfg->use_gles || !dst_reg->Register.Indirect) { + emit_store_mem(ctx, dsts[0], dst_reg->Register.WriteMask, srcs, + conversion); } else { const char *cname = tgsi_proc_to_prefix(ctx->prog_type); - bool atomic_ssbo = ctx->ssbo_atomic_mask & (1 << dst->Register.Index); + bool atomic_ssbo = ctx->ssbo_atomic_mask & (1 << dst_reg->Register.Index); int base = atomic_ssbo ? ctx->ssbo_atomic_array_base : ctx->ssbo_array_base; uint32_t mask = ctx->ssbo_used_mask; int start, array_count; u_bit_scan_consecutive_range(&mask, &start, &array_count); - int basearrayidx = lookup_image_array(ctx, dst->Register.Index); - emit_buff(ctx, "switch (addr%d + %d) {\n", dst->Indirect.Index, dst->Register.Index - base); + int basearrayidx = lookup_image_array(ctx, dst_reg->Register.Index); + emit_buff(ctx, "switch (addr%d + %d) {\n", dst_reg->Indirect.Index, + dst_reg->Register.Index - base); for (int i = 0; i < array_count; ++i) { char dst_tmp[128]; emit_buff(ctx, "case %d:\n", i); snprintf(dst_tmp, 128, "%simg%d[%d]", cname, basearrayidx, i); - emit_store_mem(ctx, dst_tmp, dst->Register.WriteMask, srcs, + emit_store_mem(ctx, dst_tmp, dst_reg->Register.WriteMask, srcs, conversion); emit_buff(ctx, "break;\n"); }