shader: Factor out generic source register evaluation

Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
macos/master
Gert Wollny 6 years ago committed by Gert Wollny
parent 4885bff592
commit 820203011d
  1. 52
      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 static bool
get_source_info(struct dump_ctx *ctx, get_source_info(struct dump_ctx *ctx,
const struct tgsi_full_instruction *inst, 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) { 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); 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 && } else if (ctx->inputs[j].name == TGSI_SEMANTIC_GENERIC) {
ctx_indirect_inputs(ctx)) { if (ctx_indirect_inputs(ctx)) {
char blkarray[32] = {}; char blkarray[32] = {};
fill_blkarray(ctx, src, blkarray); fill_blkarray(ctx, src, blkarray);
if (src->Register.Indirect) 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); 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 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); 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 && } else if (ctx->inputs[j].name == TGSI_SEMANTIC_PATCH &&
ctx_indirect_inputs(ctx)) { ctx_indirect_inputs(ctx)) {
if (src->Register.Indirect) if (src->Register.Indirect)
@ -3078,14 +3096,16 @@ get_source_info(struct dump_ctx *ctx,
if (ctx->outputs[j].name == TGSI_SEMANTIC_CLIPDIST) { if (ctx->outputs[j].name == TGSI_SEMANTIC_CLIPDIST) {
snprintf(srcs[i], 255, "clip_dist_temp[%d]", ctx->outputs[j].sid); snprintf(srcs[i], 255, "clip_dist_temp[%d]", ctx->outputs[j].sid);
} }
} else if (ctx->outputs[j].name == TGSI_SEMANTIC_GENERIC && } else if (ctx->outputs[j].name == TGSI_SEMANTIC_GENERIC) {
ctx_indirect_outputs(ctx)) { if (ctx_indirect_outputs(ctx)) {
char blkarray[32] = {}; char blkarray[32] = {};
fill_blkarray(ctx, src, blkarray); fill_blkarray(ctx, src, blkarray);
if (src->Register.Indirect) 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); 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 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); 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 && } else if (ctx->outputs[j].name == TGSI_SEMANTIC_PATCH &&
ctx_indirect_outputs(ctx)) { ctx_indirect_outputs(ctx)) {
if (src->Register.Indirect) if (src->Register.Indirect)

Loading…
Cancel
Save