From 7ab753f213fd4195eafa6daa823476910571d2fb Mon Sep 17 00:00:00 2001 From: Gert Wollny Date: Tue, 22 Jan 2019 11:20:05 +0100 Subject: [PATCH] shader: Factor out patch source register evaluation Signed-off-by: Gert Wollny Reviewed-by: Gurchetan Singh --- src/vrend_shader.c | 47 ++++++++++++++++++++++++++++++++++------------ 1 file changed, 35 insertions(+), 12 deletions(-) diff --git a/src/vrend_shader.c b/src/vrend_shader.c index 3b53cbf..f834f5a 100644 --- a/src/vrend_shader.c +++ b/src/vrend_shader.c @@ -2946,6 +2946,23 @@ static void get_source_info_generic(enum vrend_type_qualifier srcstypeprefix, } } +static void get_source_info_patch(enum vrend_type_qualifier srcstypeprefix, + const char *prefix, + const struct vrend_shader_io *io, + const char *arrayname, + const char *swizzle, + char srcs[255]) +{ + const char *wm = io->is_int ? "" : swizzle; + + if (io->last == io->first) + snprintf(srcs, 255, "%s(%s%s%s%s)", get_string(srcstypeprefix), prefix, io->glsl_name, + arrayname, wm); + else + assert(0 && "Array access not yet implemented"); +} + + static bool get_source_info(struct dump_ctx *ctx, const struct tgsi_full_instruction *inst, @@ -3069,12 +3086,15 @@ get_source_info(struct dump_ctx *ctx, } 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) - snprintf(srcs[i], 255, "%s(%s%sp%d[addr%d + %d]%s)", get_string(srcstypeprefix), prefix, get_stage_input_name_prefix(ctx, ctx->prog_type), ctx->patch_input_range.first, src->Indirect.Index, src->Register.Index - ctx->patch_input_range.array_id, ctx->inputs[j].is_int ? "" : swizzle); - else - snprintf(srcs[i], 255, "%s(%s%sp%d[%d]%s)", get_string(srcstypeprefix), prefix, get_stage_input_name_prefix(ctx, ctx->prog_type), ctx->patch_input_range.first, src->Register.Index - ctx->patch_input_range.array_id, ctx->inputs[j].is_int ? "" : swizzle); + } else if (ctx->inputs[j].name == TGSI_SEMANTIC_PATCH) { + if (ctx_indirect_inputs(ctx)) { + if (src->Register.Indirect) + snprintf(srcs[i], 255, "%s(%s%sp%d[addr%d + %d]%s)", get_string(srcstypeprefix), prefix, get_stage_input_name_prefix(ctx, ctx->prog_type), ctx->patch_input_range.first, src->Indirect.Index, src->Register.Index - ctx->patch_input_range.array_id, ctx->inputs[j].is_int ? "" : swizzle); + else + snprintf(srcs[i], 255, "%s(%s%sp%d[%d]%s)", get_string(srcstypeprefix), prefix, get_stage_input_name_prefix(ctx, ctx->prog_type), ctx->patch_input_range.first, src->Register.Index - ctx->patch_input_range.array_id, ctx->inputs[j].is_int ? "" : swizzle); + } else { + get_source_info_patch(srcstypeprefix, prefix, &ctx->inputs[j], arrayname, swizzle, srcs[i]); + } } else snprintf(srcs[i], 255, "%s(%s%s%s%s)", get_string(srcstypeprefix), prefix, ctx->inputs[j].glsl_name, arrayname, ctx->inputs[j].is_int ? "" : swizzle); } @@ -3106,12 +3126,15 @@ get_source_info(struct dump_ctx *ctx, 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) - snprintf(srcs[i], 255, "%s(%s%sp%d[addr%d + %d]%s)", get_string(srcstypeprefix), prefix, get_stage_output_name_prefix(ctx->prog_type), ctx->patch_output_range.first, src->Indirect.Index, src->Register.Index - ctx->patch_output_range.array_id, ctx->outputs[j].is_int ? "" : swizzle); - else - snprintf(srcs[i], 255, "%s(%s%sp%d[%d]%s)", get_string(srcstypeprefix), prefix, get_stage_output_name_prefix(ctx->prog_type), ctx->patch_output_range.first, src->Register.Index - ctx->patch_output_range.array_id, ctx->outputs[j].is_int ? "" : swizzle); + } else if (ctx->outputs[j].name == TGSI_SEMANTIC_PATCH) { + if (ctx_indirect_outputs(ctx)) { + if (src->Register.Indirect) + snprintf(srcs[i], 255, "%s(%s%sp%d[addr%d + %d]%s)", get_string(srcstypeprefix), prefix, get_stage_output_name_prefix(ctx->prog_type), ctx->patch_output_range.first, src->Indirect.Index, src->Register.Index - ctx->patch_output_range.array_id, ctx->outputs[j].is_int ? "" : swizzle); + else + snprintf(srcs[i], 255, "%s(%s%sp%d[%d]%s)", get_string(srcstypeprefix), prefix, get_stage_output_name_prefix(ctx->prog_type), ctx->patch_output_range.first, src->Register.Index - ctx->patch_output_range.array_id, ctx->outputs[j].is_int ? "" : swizzle); + } else { + get_source_info_patch(srcstypeprefix, prefix, &ctx->outputs[j], arrayname, swizzle, srcs[i]); + } } else { snprintf(srcs[i], 255, "%s(%s%s%s%s)", get_string(srcstypeprefix), prefix, ctx->outputs[j].glsl_name, arrayname, ctx->outputs[j].is_int ? "" : swizzle); }