From 820203011da062cacd9cb94b5cb001c236bb15a9 Mon Sep 17 00:00:00 2001 From: Gert Wollny Date: Tue, 22 Jan 2019 11:15:57 +0100 Subject: [PATCH] shader: Factor out generic source register evaluation Signed-off-by: Gert Wollny Reviewed-by: Gurchetan Singh --- src/vrend_shader.c | 52 ++++++++++++++++++++++++++++++++-------------- 1 file changed, 36 insertions(+), 16 deletions(-) diff --git a/src/vrend_shader.c b/src/vrend_shader.c index 78f021e..3b53cbf 100644 --- a/src/vrend_shader.c +++ b/src/vrend_shader.c @@ -2931,6 +2931,21 @@ static void fill_blkarray(struct dump_ctx *ctx, } } +static void get_source_info_generic(enum vrend_type_qualifier srcstypeprefix, + const char *prefix, + const struct vrend_shader_io *io, + const char *arrayname, + const char *swizzle, + char srcs[255]) +{ + if (io->first == io->last) { + snprintf(srcs, 255, "%s(%s%s%s%s)", get_string(srcstypeprefix), + prefix, io->glsl_name, arrayname, io->is_int ? "" : swizzle); + } else { + assert(0 && "Array access not yet implemented"); + } +} + static bool get_source_info(struct dump_ctx *ctx, const struct tgsi_full_instruction *inst, @@ -3043,14 +3058,17 @@ get_source_info(struct dump_ctx *ctx, if (inst->Instruction.Opcode == TGSI_OPCODE_INTERP_SAMPLE && i == 1) { snprintf(srcs[i], 255, "floatBitsToInt(%s%s%s%s)", prefix, ctx->inputs[j].glsl_name, arrayname, swizzle); - } else if (ctx->inputs[j].name == TGSI_SEMANTIC_GENERIC && - ctx_indirect_inputs(ctx)) { - char blkarray[32] = {}; - fill_blkarray(ctx, src, blkarray); - if (src->Register.Indirect) - snprintf(srcs[i], 255, "%s(%sblk%s.%s%d[addr%d + %d]%s)", get_string(srcstypeprefix), prefix, blkarray, get_stage_input_name_prefix(ctx, ctx->prog_type), ctx->generic_input_range.first, src->Indirect.Index, src->Register.Index - ctx->generic_input_range.array_id, ctx->inputs[j].is_int ? "" : swizzle); - else - snprintf(srcs[i], 255, "%s(%sblk%s.%s%d[%d]%s)", get_string(srcstypeprefix), prefix, blkarray, get_stage_input_name_prefix(ctx, ctx->prog_type), ctx->generic_input_range.first, src->Register.Index - ctx->generic_input_range.array_id, ctx->inputs[j].is_int ? "" : swizzle); + } else if (ctx->inputs[j].name == TGSI_SEMANTIC_GENERIC) { + if (ctx_indirect_inputs(ctx)) { + char blkarray[32] = {}; + fill_blkarray(ctx, src, blkarray); + if (src->Register.Indirect) + snprintf(srcs[i], 255, "%s(%sblk%s.%s%d[addr%d + %d]%s)", get_string(srcstypeprefix), prefix, blkarray, get_stage_input_name_prefix(ctx, ctx->prog_type), ctx->generic_input_range.first, src->Indirect.Index, src->Register.Index - ctx->generic_input_range.array_id, ctx->inputs[j].is_int ? "" : swizzle); + else + snprintf(srcs[i], 255, "%s(%sblk%s.%s%d[%d]%s)", get_string(srcstypeprefix), prefix, blkarray, get_stage_input_name_prefix(ctx, ctx->prog_type), ctx->generic_input_range.first, src->Register.Index - ctx->generic_input_range.array_id, ctx->inputs[j].is_int ? "" : swizzle); + } else { + get_source_info_generic(srcstypeprefix, prefix, &ctx->inputs[j], arrayname, swizzle, srcs[i]); + } } else if (ctx->inputs[j].name == TGSI_SEMANTIC_PATCH && ctx_indirect_inputs(ctx)) { if (src->Register.Indirect) @@ -3078,14 +3096,16 @@ get_source_info(struct dump_ctx *ctx, if (ctx->outputs[j].name == TGSI_SEMANTIC_CLIPDIST) { snprintf(srcs[i], 255, "clip_dist_temp[%d]", ctx->outputs[j].sid); } - } else if (ctx->outputs[j].name == TGSI_SEMANTIC_GENERIC && - ctx_indirect_outputs(ctx)) { - char blkarray[32] = {}; - fill_blkarray(ctx, src, blkarray); - if (src->Register.Indirect) - snprintf(srcs[i], 255, "%s(%soblk%s.%s%d[addr%d + %d]%s)", get_string(srcstypeprefix), prefix, blkarray, get_stage_output_name_prefix(ctx->prog_type), ctx->generic_output_range.first, src->Indirect.Index, src->Register.Index - ctx->generic_output_range.array_id, ctx->outputs[j].is_int ? "" : swizzle); - else - snprintf(srcs[i], 255, "%s(%soblk%s.%s%d[%d]%s)", get_string(srcstypeprefix), prefix, blkarray, get_stage_output_name_prefix(ctx->prog_type), ctx->generic_output_range.first, src->Register.Index - ctx->generic_output_range.array_id, ctx->outputs[j].is_int ? "" : swizzle); + } else if (ctx->outputs[j].name == TGSI_SEMANTIC_GENERIC) { + if (ctx_indirect_outputs(ctx)) { + char blkarray[32] = {}; + fill_blkarray(ctx, src, blkarray); + if (src->Register.Indirect) + snprintf(srcs[i], 255, "%s(%soblk%s.%s%d[addr%d + %d]%s)", get_string(srcstypeprefix), prefix, blkarray, get_stage_output_name_prefix(ctx->prog_type), ctx->generic_output_range.first, src->Indirect.Index, src->Register.Index - ctx->generic_output_range.array_id, ctx->outputs[j].is_int ? "" : swizzle); + else + snprintf(srcs[i], 255, "%s(%soblk%s.%s%d[%d]%s)", get_string(srcstypeprefix), prefix, blkarray, get_stage_output_name_prefix(ctx->prog_type), ctx->generic_output_range.first, src->Register.Index - ctx->generic_output_range.array_id, ctx->outputs[j].is_int ? "" : swizzle); + } else + get_source_info_generic(srcstypeprefix, prefix, &ctx->outputs[j], arrayname, swizzle, srcs[i]); } else if (ctx->outputs[j].name == TGSI_SEMANTIC_PATCH && ctx_indirect_outputs(ctx)) { if (src->Register.Indirect)