mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-25 19:30:11 +01:00
lima/parser: add shader disassembly to dump
Reviewed-by: Vasily Khoruzhick <anarsoul@gmail.com> Reviewed-by: Erico Nunes <nunes.erico@gmail.com> Signed-off-by: Andreas Baierl <ichgeh@imkreisrum.de> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13138>
This commit is contained in:
parent
445996379b
commit
1e9f18008f
12 changed files with 393 additions and 353 deletions
|
|
@ -608,7 +608,7 @@ bool gpir_codegen_prog(gpir_compiler *comp)
|
|||
|
||||
if (lima_debug & LIMA_DEBUG_GP) {
|
||||
gpir_codegen_print_prog(comp);
|
||||
gpir_disassemble_program(code, num_instr);
|
||||
gpir_disassemble_program(code, num_instr, stdout);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -161,6 +161,6 @@ typedef struct __attribute__((__packed__)) {
|
|||
unsigned branch_target : 8;
|
||||
} gpir_codegen_instr;
|
||||
|
||||
void gpir_disassemble_program(gpir_codegen_instr *code, unsigned num_instr);
|
||||
void gpir_disassemble_program(gpir_codegen_instr *code, unsigned num_instr, FILE *fp);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -47,9 +47,9 @@ static const gpir_codegen_store_src gp_unit_to_store_src[num_units] = {
|
|||
};
|
||||
|
||||
static void
|
||||
print_dest(gpir_codegen_instr *instr, gp_unit unit, unsigned cur_dest_index)
|
||||
print_dest(gpir_codegen_instr *instr, gp_unit unit, unsigned cur_dest_index, FILE *fp)
|
||||
{
|
||||
printf("^%u", cur_dest_index + unit);
|
||||
fprintf(fp, "^%u", cur_dest_index + unit);
|
||||
|
||||
gpir_codegen_store_src src = gp_unit_to_store_src[unit];
|
||||
|
||||
|
|
@ -59,54 +59,54 @@ print_dest(gpir_codegen_instr *instr, gp_unit unit, unsigned cur_dest_index)
|
|||
/* Temporary stores ignore the address, and always use whatever's
|
||||
* stored in address register 0.
|
||||
*/
|
||||
printf("/t[addr0]");
|
||||
fprintf(fp, "/t[addr0]");
|
||||
} else {
|
||||
if (instr->store0_varying)
|
||||
printf("/v");
|
||||
fprintf(fp, "/v");
|
||||
else
|
||||
printf("/$");
|
||||
printf("%u", instr->store0_addr);
|
||||
fprintf(fp, "/$");
|
||||
fprintf(fp, "%u", instr->store0_addr);
|
||||
}
|
||||
|
||||
printf(".");
|
||||
fprintf(fp, ".");
|
||||
if (instr->store0_src_x == src)
|
||||
printf("x");
|
||||
fprintf(fp, "x");
|
||||
if (instr->store0_src_y == src)
|
||||
printf("y");
|
||||
fprintf(fp, "y");
|
||||
}
|
||||
|
||||
if (instr->store1_src_z == src ||
|
||||
instr->store1_src_w == src) {
|
||||
if (instr->store1_temporary) {
|
||||
printf("/t[addr0]");
|
||||
fprintf(fp, "/t[addr0]");
|
||||
} else {
|
||||
if (instr->store1_varying)
|
||||
printf("/v");
|
||||
fprintf(fp, "/v");
|
||||
else
|
||||
printf("/$");
|
||||
printf("%u", instr->store1_addr);
|
||||
fprintf(fp, "/$");
|
||||
fprintf(fp, "%u", instr->store1_addr);
|
||||
}
|
||||
|
||||
printf(".");
|
||||
fprintf(fp, ".");
|
||||
if (instr->store1_src_z == src)
|
||||
printf("z");
|
||||
fprintf(fp, "z");
|
||||
if (instr->store1_src_w == src)
|
||||
printf("w");
|
||||
fprintf(fp, "w");
|
||||
}
|
||||
|
||||
if (unit == unit_complex) {
|
||||
switch (instr->complex_op) {
|
||||
case gpir_codegen_complex_op_temp_store_addr:
|
||||
printf("/addr0");
|
||||
fprintf(fp, "/addr0");
|
||||
break;
|
||||
case gpir_codegen_complex_op_temp_load_addr_0:
|
||||
printf("/addr1");
|
||||
fprintf(fp, "/addr1");
|
||||
break;
|
||||
case gpir_codegen_complex_op_temp_load_addr_1:
|
||||
printf("/addr2");
|
||||
fprintf(fp, "/addr2");
|
||||
break;
|
||||
case gpir_codegen_complex_op_temp_load_addr_2:
|
||||
printf("/addr3");
|
||||
fprintf(fp, "/addr3");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
|
@ -117,14 +117,14 @@ print_dest(gpir_codegen_instr *instr, gp_unit unit, unsigned cur_dest_index)
|
|||
static void
|
||||
print_src(gpir_codegen_src src, gp_unit unit, unsigned unit_src_num,
|
||||
gpir_codegen_instr *instr, gpir_codegen_instr *prev_instr,
|
||||
unsigned cur_dest_index)
|
||||
unsigned cur_dest_index, FILE *fp)
|
||||
{
|
||||
switch (src) {
|
||||
case gpir_codegen_src_attrib_x:
|
||||
case gpir_codegen_src_attrib_y:
|
||||
case gpir_codegen_src_attrib_z:
|
||||
case gpir_codegen_src_attrib_w:
|
||||
printf("%c%d.%c", instr->register0_attribute ? 'a' : '$',
|
||||
fprintf(fp, "%c%d.%c", instr->register0_attribute ? 'a' : '$',
|
||||
instr->register0_addr, "xyzw"[src - gpir_codegen_src_attrib_x]);
|
||||
break;
|
||||
|
||||
|
|
@ -132,7 +132,7 @@ print_src(gpir_codegen_src src, gp_unit unit, unsigned unit_src_num,
|
|||
case gpir_codegen_src_register_y:
|
||||
case gpir_codegen_src_register_z:
|
||||
case gpir_codegen_src_register_w:
|
||||
printf("$%d.%c", instr->register1_addr,
|
||||
fprintf(fp, "$%d.%c", instr->register1_addr,
|
||||
"xyzw"[src - gpir_codegen_src_register_x]);
|
||||
break;
|
||||
|
||||
|
|
@ -140,54 +140,54 @@ print_src(gpir_codegen_src src, gp_unit unit, unsigned unit_src_num,
|
|||
case gpir_codegen_src_unknown_1:
|
||||
case gpir_codegen_src_unknown_2:
|
||||
case gpir_codegen_src_unknown_3:
|
||||
printf("unknown%d", src - gpir_codegen_src_unknown_0);
|
||||
fprintf(fp, "unknown%d", src - gpir_codegen_src_unknown_0);
|
||||
break;
|
||||
|
||||
case gpir_codegen_src_load_x:
|
||||
case gpir_codegen_src_load_y:
|
||||
case gpir_codegen_src_load_z:
|
||||
case gpir_codegen_src_load_w:
|
||||
printf("t[%d", instr->load_addr);
|
||||
fprintf(fp, "t[%d", instr->load_addr);
|
||||
switch (instr->load_offset) {
|
||||
case gpir_codegen_load_off_ld_addr_0:
|
||||
printf("+addr1");
|
||||
fprintf(fp, "+addr1");
|
||||
break;
|
||||
case gpir_codegen_load_off_ld_addr_1:
|
||||
printf("+addr2");
|
||||
fprintf(fp, "+addr2");
|
||||
break;
|
||||
case gpir_codegen_load_off_ld_addr_2:
|
||||
printf("+addr3");
|
||||
fprintf(fp, "+addr3");
|
||||
break;
|
||||
case gpir_codegen_load_off_none:
|
||||
break;
|
||||
default:
|
||||
printf("+unk%d", instr->load_offset);
|
||||
fprintf(fp, "+unk%d", instr->load_offset);
|
||||
}
|
||||
printf("].%c", "xyzw"[src - gpir_codegen_src_load_x]);
|
||||
fprintf(fp, "].%c", "xyzw"[src - gpir_codegen_src_load_x]);
|
||||
break;
|
||||
|
||||
case gpir_codegen_src_p1_acc_0:
|
||||
printf("^%d", cur_dest_index - 1 * num_units + unit_acc_0);
|
||||
fprintf(fp, "^%d", cur_dest_index - 1 * num_units + unit_acc_0);
|
||||
break;
|
||||
|
||||
case gpir_codegen_src_p1_acc_1:
|
||||
printf("^%d", cur_dest_index - 1 * num_units + unit_acc_1);
|
||||
fprintf(fp, "^%d", cur_dest_index - 1 * num_units + unit_acc_1);
|
||||
break;
|
||||
|
||||
case gpir_codegen_src_p1_mul_0:
|
||||
printf("^%d", cur_dest_index - 1 * num_units + unit_mul_0);
|
||||
fprintf(fp, "^%d", cur_dest_index - 1 * num_units + unit_mul_0);
|
||||
break;
|
||||
|
||||
case gpir_codegen_src_p1_mul_1:
|
||||
printf("^%d", cur_dest_index - 1 * num_units + unit_mul_1);
|
||||
fprintf(fp, "^%d", cur_dest_index - 1 * num_units + unit_mul_1);
|
||||
break;
|
||||
|
||||
case gpir_codegen_src_p1_pass:
|
||||
printf("^%d", cur_dest_index - 1 * num_units + unit_pass);
|
||||
fprintf(fp, "^%d", cur_dest_index - 1 * num_units + unit_pass);
|
||||
break;
|
||||
|
||||
case gpir_codegen_src_unused:
|
||||
printf("unused");
|
||||
fprintf(fp, "unused");
|
||||
break;
|
||||
|
||||
case gpir_codegen_src_p1_complex: /* Also ident */
|
||||
|
|
@ -195,48 +195,48 @@ print_src(gpir_codegen_src src, gp_unit unit, unsigned unit_src_num,
|
|||
case unit_acc_0:
|
||||
case unit_acc_1:
|
||||
if (unit_src_num == 1) {
|
||||
printf("0");
|
||||
fprintf(fp, "0");
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case unit_mul_0:
|
||||
case unit_mul_1:
|
||||
if (unit_src_num == 1) {
|
||||
printf("1");
|
||||
fprintf(fp, "1");
|
||||
return;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
printf("^%d", cur_dest_index - 1 * num_units + unit_complex);
|
||||
fprintf(fp, "^%d", cur_dest_index - 1 * num_units + unit_complex);
|
||||
break;
|
||||
|
||||
case gpir_codegen_src_p2_pass:
|
||||
printf("^%d", cur_dest_index - 2 * num_units + unit_pass);
|
||||
fprintf(fp, "^%d", cur_dest_index - 2 * num_units + unit_pass);
|
||||
break;
|
||||
|
||||
case gpir_codegen_src_p2_acc_0:
|
||||
printf("^%d", cur_dest_index - 2 * num_units + unit_acc_0);
|
||||
fprintf(fp, "^%d", cur_dest_index - 2 * num_units + unit_acc_0);
|
||||
break;
|
||||
|
||||
case gpir_codegen_src_p2_acc_1:
|
||||
printf("^%d", cur_dest_index - 2 * num_units + unit_acc_1);
|
||||
fprintf(fp, "^%d", cur_dest_index - 2 * num_units + unit_acc_1);
|
||||
break;
|
||||
|
||||
case gpir_codegen_src_p2_mul_0:
|
||||
printf("^%d", cur_dest_index - 2 * num_units + unit_mul_0);
|
||||
fprintf(fp, "^%d", cur_dest_index - 2 * num_units + unit_mul_0);
|
||||
break;
|
||||
|
||||
case gpir_codegen_src_p2_mul_1:
|
||||
printf("^%d", cur_dest_index - 2 * num_units + unit_mul_1);
|
||||
fprintf(fp, "^%d", cur_dest_index - 2 * num_units + unit_mul_1);
|
||||
break;
|
||||
|
||||
case gpir_codegen_src_p1_attrib_x:
|
||||
case gpir_codegen_src_p1_attrib_y:
|
||||
case gpir_codegen_src_p1_attrib_z:
|
||||
case gpir_codegen_src_p1_attrib_w:
|
||||
printf("%c%d.%c", prev_instr->register0_attribute ? 'a' : '$',
|
||||
fprintf(fp, "%c%d.%c", prev_instr->register0_attribute ? 'a' : '$',
|
||||
prev_instr->register0_addr,
|
||||
"xyzw"[src - gpir_codegen_src_p1_attrib_x]);
|
||||
break;
|
||||
|
|
@ -245,7 +245,7 @@ print_src(gpir_codegen_src src, gp_unit unit, unsigned unit_src_num,
|
|||
|
||||
static bool
|
||||
print_mul(gpir_codegen_instr *instr, gpir_codegen_instr *prev_instr,
|
||||
unsigned cur_dest_index)
|
||||
unsigned cur_dest_index, FILE *fp)
|
||||
{
|
||||
bool printed = false;
|
||||
|
||||
|
|
@ -255,113 +255,113 @@ print_mul(gpir_codegen_instr *instr, gpir_codegen_instr *prev_instr,
|
|||
if (instr->mul0_src0 != gpir_codegen_src_unused &&
|
||||
instr->mul0_src1 != gpir_codegen_src_unused) {
|
||||
printed = true;
|
||||
printf("\t");
|
||||
fprintf(fp, "\t");
|
||||
if (instr->mul0_src1 == gpir_codegen_src_ident &&
|
||||
!instr->mul0_neg) {
|
||||
printf("mov.m0 ");
|
||||
print_dest(instr, unit_mul_0, cur_dest_index);
|
||||
printf(" ");
|
||||
fprintf(fp, "mov.m0 ");
|
||||
print_dest(instr, unit_mul_0, cur_dest_index, fp);
|
||||
fprintf(fp, " ");
|
||||
print_src(instr->mul0_src0, unit_mul_0, 0, instr, prev_instr,
|
||||
cur_dest_index);
|
||||
cur_dest_index, fp);
|
||||
} else {
|
||||
if (instr->mul_op == gpir_codegen_mul_op_complex2)
|
||||
printf("complex2.m0 ");
|
||||
fprintf(fp, "complex2.m0 ");
|
||||
else
|
||||
printf("mul.m0 ");
|
||||
fprintf(fp, "mul.m0 ");
|
||||
|
||||
print_dest(instr, unit_mul_0, cur_dest_index);
|
||||
printf(" ");
|
||||
print_dest(instr, unit_mul_0, cur_dest_index, fp);
|
||||
fprintf(fp, " ");
|
||||
print_src(instr->mul0_src0, unit_mul_0, 0, instr, prev_instr,
|
||||
cur_dest_index);
|
||||
printf(" ");
|
||||
cur_dest_index, fp);
|
||||
fprintf(fp, " ");
|
||||
if (instr->mul0_neg)
|
||||
printf("-");
|
||||
fprintf(fp, "-");
|
||||
print_src(instr->mul0_src1, unit_mul_0, 1, instr, prev_instr,
|
||||
cur_dest_index);
|
||||
cur_dest_index, fp);
|
||||
}
|
||||
|
||||
printf("\n");
|
||||
fprintf(fp, "\n");
|
||||
}
|
||||
|
||||
if (instr->mul1_src0 != gpir_codegen_src_unused &&
|
||||
instr->mul1_src1 != gpir_codegen_src_unused) {
|
||||
printed = true;
|
||||
printf("\t");
|
||||
fprintf(fp, "\t");
|
||||
if (instr->mul1_src1 == gpir_codegen_src_ident &&
|
||||
!instr->mul1_neg) {
|
||||
printf("mov.m1 ");
|
||||
print_dest(instr, unit_mul_1, cur_dest_index);
|
||||
printf(" ");
|
||||
fprintf(fp, "mov.m1 ");
|
||||
print_dest(instr, unit_mul_1, cur_dest_index, fp);
|
||||
fprintf(fp, " ");
|
||||
print_src(instr->mul1_src0, unit_mul_1, 0, instr, prev_instr,
|
||||
cur_dest_index);
|
||||
cur_dest_index, fp);
|
||||
} else {
|
||||
printf("mul.m1 ");
|
||||
print_dest(instr, unit_mul_1, cur_dest_index);
|
||||
printf(" ");
|
||||
fprintf(fp, "mul.m1 ");
|
||||
print_dest(instr, unit_mul_1, cur_dest_index, fp);
|
||||
fprintf(fp, " ");
|
||||
print_src(instr->mul1_src0, unit_mul_1, 0, instr, prev_instr,
|
||||
cur_dest_index);
|
||||
printf(" ");
|
||||
cur_dest_index, fp);
|
||||
fprintf(fp, " ");
|
||||
if (instr->mul1_neg)
|
||||
printf("-");
|
||||
fprintf(fp, "-");
|
||||
print_src(instr->mul1_src1, unit_mul_0, 1, instr, prev_instr,
|
||||
cur_dest_index);
|
||||
cur_dest_index, fp);
|
||||
}
|
||||
printf("\n");
|
||||
fprintf(fp, "\n");
|
||||
}
|
||||
|
||||
break;
|
||||
case gpir_codegen_mul_op_complex1:
|
||||
printed = true;
|
||||
printf("\tcomplex1.m01 ");
|
||||
print_dest(instr, unit_mul_0, cur_dest_index);
|
||||
printf(" ");
|
||||
fprintf(fp, "\tcomplex1.m01 ");
|
||||
print_dest(instr, unit_mul_0, cur_dest_index, fp);
|
||||
fprintf(fp, " ");
|
||||
print_src(instr->mul0_src0, unit_mul_0, 0, instr, prev_instr,
|
||||
cur_dest_index);
|
||||
printf(" ");
|
||||
cur_dest_index, fp);
|
||||
fprintf(fp, " ");
|
||||
print_src(instr->mul0_src1, unit_mul_0, 1, instr, prev_instr,
|
||||
cur_dest_index);
|
||||
printf(" ");
|
||||
cur_dest_index, fp);
|
||||
fprintf(fp, " ");
|
||||
print_src(instr->mul1_src0, unit_mul_1, 0, instr, prev_instr,
|
||||
cur_dest_index);
|
||||
printf(" ");
|
||||
cur_dest_index, fp);
|
||||
fprintf(fp, " ");
|
||||
print_src(instr->mul1_src1, unit_mul_1, 1, instr, prev_instr,
|
||||
cur_dest_index);
|
||||
printf("\n");
|
||||
cur_dest_index, fp);
|
||||
fprintf(fp, "\n");
|
||||
break;
|
||||
|
||||
case gpir_codegen_mul_op_select:
|
||||
printed = true;
|
||||
printf("\tsel.m01 ");
|
||||
print_dest(instr, unit_mul_0, cur_dest_index);
|
||||
printf(" ");
|
||||
fprintf(fp, "\tsel.m01 ");
|
||||
print_dest(instr, unit_mul_0, cur_dest_index, fp);
|
||||
fprintf(fp, " ");
|
||||
print_src(instr->mul0_src1, unit_mul_0, 1, instr, prev_instr,
|
||||
cur_dest_index);
|
||||
printf(" ");
|
||||
cur_dest_index, fp);
|
||||
fprintf(fp, " ");
|
||||
print_src(instr->mul0_src0, unit_mul_0, 0, instr, prev_instr,
|
||||
cur_dest_index);
|
||||
printf(" ");
|
||||
cur_dest_index, fp);
|
||||
fprintf(fp, " ");
|
||||
print_src(instr->mul1_src0, unit_mul_1, 0, instr, prev_instr,
|
||||
cur_dest_index);
|
||||
printf("\n");
|
||||
cur_dest_index, fp);
|
||||
fprintf(fp, "\n");
|
||||
break;
|
||||
|
||||
default:
|
||||
printed = true;
|
||||
printf("\tunknown%u.m01 ", instr->mul_op);
|
||||
print_dest(instr, unit_mul_0, cur_dest_index);
|
||||
printf(" ");
|
||||
fprintf(fp, "\tunknown%u.m01 ", instr->mul_op);
|
||||
print_dest(instr, unit_mul_0, cur_dest_index, fp);
|
||||
fprintf(fp, " ");
|
||||
print_src(instr->mul0_src0, unit_mul_0, 0, instr, prev_instr,
|
||||
cur_dest_index);
|
||||
printf(" ");
|
||||
cur_dest_index, fp);
|
||||
fprintf(fp, " ");
|
||||
print_src(instr->mul0_src1, unit_mul_0, 1, instr, prev_instr,
|
||||
cur_dest_index);
|
||||
printf(" ");
|
||||
cur_dest_index, fp);
|
||||
fprintf(fp, " ");
|
||||
print_src(instr->mul1_src0, unit_mul_1, 0, instr, prev_instr,
|
||||
cur_dest_index);
|
||||
printf(" ");
|
||||
cur_dest_index, fp);
|
||||
fprintf(fp, " ");
|
||||
print_src(instr->mul1_src1, unit_mul_1, 1, instr, prev_instr,
|
||||
cur_dest_index);
|
||||
printf("\n");
|
||||
cur_dest_index, fp);
|
||||
fprintf(fp, "\n");
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -393,14 +393,14 @@ static const acc_op_info acc_op_infos[8] = {
|
|||
|
||||
static bool
|
||||
print_acc(gpir_codegen_instr *instr, gpir_codegen_instr *prev_instr,
|
||||
unsigned cur_dest_index)
|
||||
unsigned cur_dest_index, FILE *fp)
|
||||
{
|
||||
bool printed = false;
|
||||
const acc_op_info op = acc_op_infos[instr->acc_op];
|
||||
|
||||
if (instr->acc0_src0 != gpir_codegen_src_unused) {
|
||||
printed = true;
|
||||
printf("\t");
|
||||
fprintf(fp, "\t");
|
||||
acc_op_info acc0_op = op;
|
||||
if (instr->acc0_src1 == gpir_codegen_src_ident &&
|
||||
instr->acc0_src1_neg) {
|
||||
|
|
@ -410,30 +410,30 @@ print_acc(gpir_codegen_instr *instr, gpir_codegen_instr *prev_instr,
|
|||
}
|
||||
|
||||
if (acc0_op.name)
|
||||
printf("%s.a0 ", acc0_op.name);
|
||||
fprintf(fp, "%s.a0 ", acc0_op.name);
|
||||
else
|
||||
printf("op%u.a0 ", instr->acc_op);
|
||||
fprintf(fp, "op%u.a0 ", instr->acc_op);
|
||||
|
||||
print_dest(instr, unit_acc_0, cur_dest_index);
|
||||
printf(" ");
|
||||
print_dest(instr, unit_acc_0, cur_dest_index, fp);
|
||||
fprintf(fp, " ");
|
||||
if (instr->acc0_src0_neg)
|
||||
printf("-");
|
||||
fprintf(fp, "-");
|
||||
print_src(instr->acc0_src0, unit_acc_0, 0, instr, prev_instr,
|
||||
cur_dest_index);
|
||||
cur_dest_index, fp);
|
||||
if (acc0_op.srcs > 1) {
|
||||
printf(" ");
|
||||
fprintf(fp, " ");
|
||||
if (instr->acc0_src1_neg)
|
||||
printf("-");
|
||||
fprintf(fp, "-");
|
||||
print_src(instr->acc0_src1, unit_acc_0, 1, instr, prev_instr,
|
||||
cur_dest_index);
|
||||
cur_dest_index, fp);
|
||||
}
|
||||
|
||||
printf("\n");
|
||||
fprintf(fp, "\n");
|
||||
}
|
||||
|
||||
if (instr->acc1_src0 != gpir_codegen_src_unused) {
|
||||
printed = true;
|
||||
printf("\t");
|
||||
fprintf(fp, "\t");
|
||||
acc_op_info acc1_op = op;
|
||||
if (instr->acc1_src1 == gpir_codegen_src_ident &&
|
||||
instr->acc1_src1_neg) {
|
||||
|
|
@ -443,25 +443,25 @@ print_acc(gpir_codegen_instr *instr, gpir_codegen_instr *prev_instr,
|
|||
}
|
||||
|
||||
if (acc1_op.name)
|
||||
printf("%s.a1 ", acc1_op.name);
|
||||
fprintf(fp, "%s.a1 ", acc1_op.name);
|
||||
else
|
||||
printf("op%u.a1 ", instr->acc_op);
|
||||
fprintf(fp, "op%u.a1 ", instr->acc_op);
|
||||
|
||||
print_dest(instr, unit_acc_1, cur_dest_index);
|
||||
printf(" ");
|
||||
print_dest(instr, unit_acc_1, cur_dest_index, fp);
|
||||
fprintf(fp, " ");
|
||||
if (instr->acc1_src0_neg)
|
||||
printf("-");
|
||||
fprintf(fp, "-");
|
||||
print_src(instr->acc1_src0, unit_acc_1, 0, instr, prev_instr,
|
||||
cur_dest_index);
|
||||
cur_dest_index, fp);
|
||||
if (acc1_op.srcs > 1) {
|
||||
printf(" ");
|
||||
fprintf(fp, " ");
|
||||
if (instr->acc1_src1_neg)
|
||||
printf("-");
|
||||
fprintf(fp, "-");
|
||||
print_src(instr->acc1_src1, unit_acc_1, 1, instr, prev_instr,
|
||||
cur_dest_index);
|
||||
cur_dest_index, fp);
|
||||
}
|
||||
|
||||
printf("\n");
|
||||
fprintf(fp, "\n");
|
||||
}
|
||||
|
||||
return printed;
|
||||
|
|
@ -469,131 +469,129 @@ print_acc(gpir_codegen_instr *instr, gpir_codegen_instr *prev_instr,
|
|||
|
||||
static bool
|
||||
print_pass(gpir_codegen_instr *instr, gpir_codegen_instr *prev_instr,
|
||||
unsigned cur_dest_index)
|
||||
unsigned cur_dest_index, FILE *fp)
|
||||
{
|
||||
if (instr->pass_src == gpir_codegen_src_unused)
|
||||
return false;
|
||||
|
||||
printf("\t");
|
||||
fprintf(fp, "\t");
|
||||
|
||||
switch (instr->pass_op) {
|
||||
case gpir_codegen_pass_op_pass:
|
||||
printf("mov.p ");
|
||||
fprintf(fp, "mov.p ");
|
||||
break;
|
||||
case gpir_codegen_pass_op_preexp2:
|
||||
printf("preexp2.p ");
|
||||
fprintf(fp, "preexp2.p ");
|
||||
break;
|
||||
case gpir_codegen_pass_op_postlog2:
|
||||
printf("postlog2.p ");
|
||||
fprintf(fp, "postlog2.p ");
|
||||
break;
|
||||
case gpir_codegen_pass_op_clamp:
|
||||
printf("clamp.p ");
|
||||
fprintf(fp, "clamp.p ");
|
||||
break;
|
||||
default:
|
||||
printf("unk%u.p ", instr->pass_op);
|
||||
fprintf(fp, "unk%u.p ", instr->pass_op);
|
||||
}
|
||||
|
||||
print_dest(instr, unit_pass, cur_dest_index);
|
||||
printf(" ");
|
||||
print_dest(instr, unit_pass, cur_dest_index, fp);
|
||||
fprintf(fp, " ");
|
||||
print_src(instr->pass_src, unit_pass, 0, instr, prev_instr,
|
||||
cur_dest_index);
|
||||
cur_dest_index, fp);
|
||||
|
||||
if (instr->pass_op == gpir_codegen_pass_op_clamp) {
|
||||
printf(" ");
|
||||
fprintf(fp, " ");
|
||||
print_src(gpir_codegen_src_load_x, unit_pass, 1, instr, prev_instr,
|
||||
cur_dest_index);
|
||||
printf(" ");
|
||||
cur_dest_index, fp);
|
||||
fprintf(fp, " ");
|
||||
print_src(gpir_codegen_src_load_y, unit_pass, 2, instr, prev_instr,
|
||||
cur_dest_index);
|
||||
cur_dest_index, fp);
|
||||
}
|
||||
|
||||
printf("\n");
|
||||
fprintf(fp, "\n");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool
|
||||
print_complex(gpir_codegen_instr *instr, gpir_codegen_instr *prev_instr,
|
||||
unsigned cur_dest_index)
|
||||
unsigned cur_dest_index, FILE *fp)
|
||||
{
|
||||
if (instr->complex_src == gpir_codegen_src_unused)
|
||||
return false;
|
||||
|
||||
printf("\t");
|
||||
fprintf(fp, "\t");
|
||||
|
||||
switch (instr->complex_op) {
|
||||
case gpir_codegen_complex_op_nop:
|
||||
return false;
|
||||
|
||||
case gpir_codegen_complex_op_exp2:
|
||||
printf("exp2.c ");
|
||||
fprintf(fp, "exp2.c ");
|
||||
break;
|
||||
case gpir_codegen_complex_op_log2:
|
||||
printf("log2.c ");
|
||||
fprintf(fp, "log2.c ");
|
||||
break;
|
||||
case gpir_codegen_complex_op_rsqrt:
|
||||
printf("rsqrt.c ");
|
||||
fprintf(fp, "rsqrt.c ");
|
||||
break;
|
||||
case gpir_codegen_complex_op_rcp:
|
||||
printf("rcp.c ");
|
||||
fprintf(fp, "rcp.c ");
|
||||
break;
|
||||
case gpir_codegen_complex_op_pass:
|
||||
case gpir_codegen_complex_op_temp_store_addr:
|
||||
case gpir_codegen_complex_op_temp_load_addr_0:
|
||||
case gpir_codegen_complex_op_temp_load_addr_1:
|
||||
case gpir_codegen_complex_op_temp_load_addr_2:
|
||||
printf("mov.c ");
|
||||
fprintf(fp, "mov.c ");
|
||||
break;
|
||||
default:
|
||||
printf("unk%u.c ", instr->complex_op);
|
||||
fprintf(fp, "unk%u.c ", instr->complex_op);
|
||||
}
|
||||
|
||||
print_dest(instr, unit_complex, cur_dest_index);
|
||||
printf(" ");
|
||||
print_dest(instr, unit_complex, cur_dest_index, fp);
|
||||
fprintf(fp, " ");
|
||||
print_src(instr->complex_src, unit_complex, 0, instr, prev_instr,
|
||||
cur_dest_index);
|
||||
printf("\n");
|
||||
cur_dest_index, fp);
|
||||
fprintf(fp, "\n");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static void
|
||||
print_instr(gpir_codegen_instr *instr, gpir_codegen_instr *prev_instr,
|
||||
unsigned instr_number, unsigned cur_dest_index)
|
||||
unsigned instr_number, unsigned cur_dest_index, FILE *fp)
|
||||
{
|
||||
bool printed = false;
|
||||
printf("%03d:", instr_number);
|
||||
printed |= print_acc(instr, prev_instr, cur_dest_index);
|
||||
printed |= print_mul(instr, prev_instr, cur_dest_index);
|
||||
printed |= print_complex(instr, prev_instr, cur_dest_index);
|
||||
printed |= print_pass(instr, prev_instr, cur_dest_index);
|
||||
fprintf(fp, "%03d:", instr_number);
|
||||
printed |= print_acc(instr, prev_instr, cur_dest_index, fp);
|
||||
printed |= print_mul(instr, prev_instr, cur_dest_index, fp);
|
||||
printed |= print_complex(instr, prev_instr, cur_dest_index, fp);
|
||||
printed |= print_pass(instr, prev_instr, cur_dest_index, fp);
|
||||
|
||||
if (instr->branch) {
|
||||
printed = true;
|
||||
/* The branch condition is taken from the current pass unit result */
|
||||
printf("\tbranch ^%d %03d\n", cur_dest_index + unit_pass,
|
||||
fprintf(fp, "\tbranch ^%d %03d\n", cur_dest_index + unit_pass,
|
||||
instr->branch_target + (instr->branch_target_lo ? 0 : 0x100));
|
||||
}
|
||||
|
||||
if (instr->unknown_1 != 0) {
|
||||
printed = true;
|
||||
printf("\tunknown_1 %u\n", instr->unknown_1);
|
||||
fprintf(fp, "\tunknown_1 %u\n", instr->unknown_1);
|
||||
}
|
||||
|
||||
if (!printed)
|
||||
printf("\tnop\n");
|
||||
fprintf(fp, "\tnop\n");
|
||||
}
|
||||
|
||||
void
|
||||
gpir_disassemble_program(gpir_codegen_instr *code, unsigned num_instr)
|
||||
gpir_disassemble_program(gpir_codegen_instr *code, unsigned num_instr, FILE *fp)
|
||||
{
|
||||
printf("=======disassembly:=======\n");
|
||||
|
||||
unsigned cur_dest_index = 0;
|
||||
unsigned cur_instr = 0;
|
||||
for (gpir_codegen_instr *instr = code; cur_instr < num_instr;
|
||||
instr++, cur_instr++, cur_dest_index += num_units) {
|
||||
print_instr(instr, instr - 1, cur_instr, cur_dest_index);
|
||||
print_instr(instr, instr - 1, cur_instr, cur_dest_index, fp);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -778,7 +778,7 @@ static void ppir_codegen_print_prog(ppir_compiler *comp)
|
|||
printf("%08x ", prog[i]);
|
||||
}
|
||||
printf("\n");
|
||||
ppir_disassemble_instr(prog, offset);
|
||||
ppir_disassemble_instr(prog, offset, stdout);
|
||||
prog += n;
|
||||
offset += n;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -355,6 +355,6 @@ typedef union __attribute__((__packed__)) {
|
|||
} discard;
|
||||
} ppir_codegen_field_branch;
|
||||
|
||||
void ppir_disassemble_instr(uint32_t *instr, unsigned offset);
|
||||
void ppir_disassemble_instr(uint32_t *instr, unsigned offset, FILE *fp);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -35,51 +35,51 @@ typedef struct {
|
|||
} asm_op;
|
||||
|
||||
static void
|
||||
print_swizzle(uint8_t swizzle)
|
||||
print_swizzle(uint8_t swizzle, FILE *fp)
|
||||
{
|
||||
if (swizzle == 0xE4)
|
||||
return;
|
||||
|
||||
printf(".");
|
||||
fprintf(fp, ".");
|
||||
for (unsigned i = 0; i < 4; i++, swizzle >>= 2)
|
||||
printf("%c", "xyzw"[swizzle & 3]);
|
||||
fprintf(fp, "%c", "xyzw"[swizzle & 3]);
|
||||
}
|
||||
|
||||
static void
|
||||
print_mask(uint8_t mask)
|
||||
print_mask(uint8_t mask, FILE *fp)
|
||||
{
|
||||
if (mask == 0xF)
|
||||
return;
|
||||
|
||||
printf(".");
|
||||
if (mask & 1) printf("x");
|
||||
if (mask & 2) printf("y");
|
||||
if (mask & 4) printf("z");
|
||||
if (mask & 8) printf("w");
|
||||
fprintf(fp, ".");
|
||||
if (mask & 1) fprintf(fp, "x");
|
||||
if (mask & 2) fprintf(fp, "y");
|
||||
if (mask & 4) fprintf(fp, "z");
|
||||
if (mask & 8) fprintf(fp, "w");
|
||||
}
|
||||
|
||||
static void
|
||||
print_reg(ppir_codegen_vec4_reg reg, const char *special)
|
||||
print_reg(ppir_codegen_vec4_reg reg, const char *special, FILE *fp)
|
||||
{
|
||||
if (special) {
|
||||
printf("%s", special);
|
||||
fprintf(fp, "%s", special);
|
||||
} else {
|
||||
switch (reg)
|
||||
{
|
||||
case ppir_codegen_vec4_reg_constant0:
|
||||
printf("^const0");
|
||||
fprintf(fp, "^const0");
|
||||
break;
|
||||
case ppir_codegen_vec4_reg_constant1:
|
||||
printf("^const1");
|
||||
fprintf(fp, "^const1");
|
||||
break;
|
||||
case ppir_codegen_vec4_reg_texture:
|
||||
printf("^texture");
|
||||
fprintf(fp, "^texture");
|
||||
break;
|
||||
case ppir_codegen_vec4_reg_uniform:
|
||||
printf("^uniform");
|
||||
fprintf(fp, "^uniform");
|
||||
break;
|
||||
default:
|
||||
printf("$%u", reg);
|
||||
fprintf(fp, "$%u", reg);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -87,75 +87,75 @@ print_reg(ppir_codegen_vec4_reg reg, const char *special)
|
|||
|
||||
static void
|
||||
print_vector_source(ppir_codegen_vec4_reg reg, const char *special,
|
||||
uint8_t swizzle, bool abs, bool neg)
|
||||
uint8_t swizzle, bool abs, bool neg, FILE *fp)
|
||||
{
|
||||
if (neg)
|
||||
printf("-");
|
||||
fprintf(fp, "-");
|
||||
if (abs)
|
||||
printf("abs(");
|
||||
fprintf(fp, "abs(");
|
||||
|
||||
print_reg(reg, special);
|
||||
print_swizzle(swizzle);
|
||||
print_reg(reg, special, fp);
|
||||
print_swizzle(swizzle, fp);
|
||||
|
||||
if (abs)
|
||||
printf(")");
|
||||
fprintf(fp, ")");
|
||||
}
|
||||
|
||||
static void
|
||||
print_source_scalar(unsigned reg, const char *special, bool abs, bool neg)
|
||||
print_source_scalar(unsigned reg, const char *special, bool abs, bool neg, FILE *fp)
|
||||
{
|
||||
if (neg)
|
||||
printf("-");
|
||||
fprintf(fp, "-");
|
||||
if (abs)
|
||||
printf("abs(");
|
||||
fprintf(fp, "abs(");
|
||||
|
||||
print_reg(reg >> 2, special);
|
||||
print_reg(reg >> 2, special, fp);
|
||||
if (!special)
|
||||
printf(".%c", "xyzw"[reg & 3]);
|
||||
fprintf(fp, ".%c", "xyzw"[reg & 3]);
|
||||
|
||||
if (abs)
|
||||
printf(")");
|
||||
fprintf(fp, ")");
|
||||
}
|
||||
|
||||
static void
|
||||
print_varying_source(ppir_codegen_field_varying *varying)
|
||||
print_varying_source(ppir_codegen_field_varying *varying, FILE *fp)
|
||||
{
|
||||
switch (varying->imm.alignment) {
|
||||
case 0:
|
||||
printf("%u.%c", varying->imm.index >> 2,
|
||||
fprintf(fp, "%u.%c", varying->imm.index >> 2,
|
||||
"xyzw"[varying->imm.index & 3]);
|
||||
break;
|
||||
case 1: {
|
||||
const char *c[2] = {"xy", "zw"};
|
||||
printf("%u.%s", varying->imm.index >> 1, c[varying->imm.index & 1]);
|
||||
fprintf(fp, "%u.%s", varying->imm.index >> 1, c[varying->imm.index & 1]);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
printf("%u", varying->imm.index);
|
||||
fprintf(fp, "%u", varying->imm.index);
|
||||
break;
|
||||
}
|
||||
|
||||
if (varying->imm.offset_vector != 15) {
|
||||
unsigned reg = (varying->imm.offset_vector << 2) +
|
||||
varying->imm.offset_scalar;
|
||||
printf("+");
|
||||
print_source_scalar(reg, NULL, false, false);
|
||||
fprintf(fp, "+");
|
||||
print_source_scalar(reg, NULL, false, false, fp);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
print_outmod(ppir_codegen_outmod modifier)
|
||||
print_outmod(ppir_codegen_outmod modifier, FILE *fp)
|
||||
{
|
||||
switch (modifier)
|
||||
{
|
||||
case ppir_codegen_outmod_clamp_fraction:
|
||||
printf(".sat");
|
||||
fprintf(fp, ".sat");
|
||||
break;
|
||||
case ppir_codegen_outmod_clamp_positive:
|
||||
printf(".pos");
|
||||
fprintf(fp, ".pos");
|
||||
break;
|
||||
case ppir_codegen_outmod_round:
|
||||
printf(".int");
|
||||
fprintf(fp, ".int");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
|
@ -163,190 +163,190 @@ print_outmod(ppir_codegen_outmod modifier)
|
|||
}
|
||||
|
||||
static void
|
||||
print_dest_scalar(unsigned reg)
|
||||
print_dest_scalar(unsigned reg, FILE *fp)
|
||||
{
|
||||
printf("$%u", reg >> 2);
|
||||
printf(".%c ", "xyzw"[reg & 3]);
|
||||
fprintf(fp, "$%u", reg >> 2);
|
||||
fprintf(fp, ".%c ", "xyzw"[reg & 3]);
|
||||
}
|
||||
|
||||
static void
|
||||
print_const(unsigned const_num, uint16_t *val)
|
||||
print_const(unsigned const_num, uint16_t *val, FILE *fp)
|
||||
{
|
||||
printf("const%u", const_num);
|
||||
fprintf(fp, "const%u", const_num);
|
||||
for (unsigned i = 0; i < 4; i++)
|
||||
printf(" %f", _mesa_half_to_float(val[i]));
|
||||
fprintf(fp, " %f", _mesa_half_to_float(val[i]));
|
||||
}
|
||||
|
||||
static void
|
||||
print_const0(void *code, unsigned offset)
|
||||
print_const0(void *code, unsigned offset, FILE *fp)
|
||||
{
|
||||
(void) offset;
|
||||
|
||||
print_const(0, code);
|
||||
print_const(0, code, fp);
|
||||
}
|
||||
|
||||
static void
|
||||
print_const1(void *code, unsigned offset)
|
||||
print_const1(void *code, unsigned offset, FILE *fp)
|
||||
{
|
||||
(void) offset;
|
||||
|
||||
print_const(1, code);
|
||||
print_const(1, code, fp);
|
||||
}
|
||||
|
||||
static void
|
||||
print_varying(void *code, unsigned offset)
|
||||
print_varying(void *code, unsigned offset, FILE *fp)
|
||||
{
|
||||
(void) offset;
|
||||
ppir_codegen_field_varying *varying = code;
|
||||
|
||||
printf("load");
|
||||
fprintf(fp, "load");
|
||||
|
||||
bool perspective = varying->imm.source_type < 2 && varying->imm.perspective;
|
||||
if (perspective)
|
||||
{
|
||||
printf(".perspective");
|
||||
fprintf(fp, ".perspective");
|
||||
switch (varying->imm.perspective)
|
||||
{
|
||||
case 2:
|
||||
printf(".z");
|
||||
fprintf(fp, ".z");
|
||||
break;
|
||||
case 3:
|
||||
printf(".w");
|
||||
fprintf(fp, ".w");
|
||||
break;
|
||||
default:
|
||||
printf(".unknown");
|
||||
fprintf(fp, ".unknown");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
printf(".v ");
|
||||
fprintf(fp, ".v ");
|
||||
|
||||
switch (varying->imm.dest)
|
||||
{
|
||||
case ppir_codegen_vec4_reg_discard:
|
||||
printf("^discard");
|
||||
fprintf(fp, "^discard");
|
||||
break;
|
||||
default:
|
||||
printf("$%u", varying->imm.dest);
|
||||
fprintf(fp, "$%u", varying->imm.dest);
|
||||
break;
|
||||
}
|
||||
print_mask(varying->imm.mask);
|
||||
printf(" ");
|
||||
print_mask(varying->imm.mask, fp);
|
||||
fprintf(fp, " ");
|
||||
|
||||
switch (varying->imm.source_type) {
|
||||
case 1:
|
||||
print_vector_source(varying->reg.source, NULL, varying->reg.swizzle,
|
||||
varying->reg.absolute, varying->reg.negate);
|
||||
varying->reg.absolute, varying->reg.negate, fp);
|
||||
break;
|
||||
case 2:
|
||||
switch (varying->imm.perspective) {
|
||||
case 0:
|
||||
printf("cube(");
|
||||
print_varying_source(varying);
|
||||
printf(")");
|
||||
fprintf(fp, "cube(");
|
||||
print_varying_source(varying, fp);
|
||||
fprintf(fp, ")");
|
||||
break;
|
||||
case 1:
|
||||
printf("cube(");
|
||||
fprintf(fp, "cube(");
|
||||
print_vector_source(varying->reg.source, NULL, varying->reg.swizzle,
|
||||
varying->reg.absolute, varying->reg.negate);
|
||||
printf(")");
|
||||
varying->reg.absolute, varying->reg.negate, fp);
|
||||
fprintf(fp, ")");
|
||||
break;
|
||||
case 2:
|
||||
printf("normalize(");
|
||||
fprintf(fp, "normalize(");
|
||||
print_vector_source(varying->reg.source, NULL, varying->reg.swizzle,
|
||||
varying->reg.absolute, varying->reg.negate);
|
||||
printf(")");
|
||||
varying->reg.absolute, varying->reg.negate, fp);
|
||||
fprintf(fp, ")");
|
||||
break;
|
||||
default:
|
||||
printf("gl_FragCoord");
|
||||
fprintf(fp, "gl_FragCoord");
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
if (varying->imm.perspective)
|
||||
printf("gl_FrontFacing");
|
||||
fprintf(fp, "gl_FrontFacing");
|
||||
else
|
||||
printf("gl_PointCoord");
|
||||
fprintf(fp, "gl_PointCoord");
|
||||
break;
|
||||
default:
|
||||
print_varying_source(varying);
|
||||
print_varying_source(varying, fp);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
print_sampler(void *code, unsigned offset)
|
||||
print_sampler(void *code, unsigned offset, FILE *fp)
|
||||
{
|
||||
(void) offset;
|
||||
ppir_codegen_field_sampler *sampler = code;
|
||||
|
||||
printf("texld");
|
||||
fprintf(fp, "texld");
|
||||
if (sampler->lod_bias_en)
|
||||
printf(".b");
|
||||
fprintf(fp, ".b");
|
||||
|
||||
switch (sampler->type) {
|
||||
case ppir_codegen_sampler_type_2d:
|
||||
printf(".2d");
|
||||
fprintf(fp, ".2d");
|
||||
break;
|
||||
case ppir_codegen_sampler_type_cube:
|
||||
printf(".cube");
|
||||
fprintf(fp, ".cube");
|
||||
break;
|
||||
default:
|
||||
printf("_t%u", sampler->type);
|
||||
fprintf(fp, "_t%u", sampler->type);
|
||||
break;
|
||||
}
|
||||
|
||||
printf(" %u", sampler->index);
|
||||
fprintf(fp, " %u", sampler->index);
|
||||
|
||||
if (sampler->offset_en)
|
||||
{
|
||||
printf("+");
|
||||
print_source_scalar(sampler->index_offset, NULL, false, false);
|
||||
fprintf(fp, "+");
|
||||
print_source_scalar(sampler->index_offset, NULL, false, false, fp);
|
||||
}
|
||||
|
||||
if (sampler->lod_bias_en)
|
||||
{
|
||||
printf(" ");
|
||||
print_source_scalar(sampler->lod_bias, NULL, false, false);
|
||||
fprintf(fp, " ");
|
||||
print_source_scalar(sampler->lod_bias, NULL, false, false, fp);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
print_uniform(void *code, unsigned offset)
|
||||
print_uniform(void *code, unsigned offset, FILE *fp)
|
||||
{
|
||||
(void) offset;
|
||||
ppir_codegen_field_uniform *uniform = code;
|
||||
|
||||
printf("load.");
|
||||
fprintf(fp, "load.");
|
||||
|
||||
switch (uniform->source) {
|
||||
case ppir_codegen_uniform_src_uniform:
|
||||
printf("u");
|
||||
fprintf(fp, "u");
|
||||
break;
|
||||
case ppir_codegen_uniform_src_temporary:
|
||||
printf("t");
|
||||
fprintf(fp, "t");
|
||||
break;
|
||||
default:
|
||||
printf(".u%u", uniform->source);
|
||||
fprintf(fp, ".u%u", uniform->source);
|
||||
break;
|
||||
}
|
||||
|
||||
int16_t index = uniform->index;
|
||||
switch (uniform->alignment) {
|
||||
case 2:
|
||||
printf(" %d", index);
|
||||
fprintf(fp, " %d", index);
|
||||
break;
|
||||
case 1:
|
||||
printf(" %d.%s", index / 2, (index & 1) ? "zw" : "xy");
|
||||
fprintf(fp, " %d.%s", index / 2, (index & 1) ? "zw" : "xy");
|
||||
break;
|
||||
default:
|
||||
printf(" %d.%c", index / 4, "xyzw"[index & 3]);
|
||||
fprintf(fp, " %d.%c", index / 4, "xyzw"[index & 3]);
|
||||
break;
|
||||
}
|
||||
|
||||
if (uniform->offset_en) {
|
||||
printf("+");
|
||||
print_source_scalar(uniform->offset_reg, NULL, false, false);
|
||||
fprintf(fp, "+");
|
||||
print_source_scalar(uniform->offset_reg, NULL, false, false, fp);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -377,7 +377,7 @@ static const asm_op vec4_mul_ops[] = {
|
|||
#undef CASE
|
||||
|
||||
static void
|
||||
print_vec4_mul(void *code, unsigned offset)
|
||||
print_vec4_mul(void *code, unsigned offset, FILE *fp)
|
||||
{
|
||||
(void) offset;
|
||||
ppir_codegen_field_vec4_mul *vec4_mul = code;
|
||||
|
|
@ -385,34 +385,34 @@ print_vec4_mul(void *code, unsigned offset)
|
|||
asm_op op = vec4_mul_ops[vec4_mul->op];
|
||||
|
||||
if (op.name)
|
||||
printf("%s", op.name);
|
||||
fprintf(fp, "%s", op.name);
|
||||
else
|
||||
printf("op%u", vec4_mul->op);
|
||||
print_outmod(vec4_mul->dest_modifier);
|
||||
printf(".v0 ");
|
||||
fprintf(fp, "op%u", vec4_mul->op);
|
||||
print_outmod(vec4_mul->dest_modifier, fp);
|
||||
fprintf(fp, ".v0 ");
|
||||
|
||||
if (vec4_mul->mask) {
|
||||
printf("$%u", vec4_mul->dest);
|
||||
print_mask(vec4_mul->mask);
|
||||
printf(" ");
|
||||
fprintf(fp, "$%u", vec4_mul->dest);
|
||||
print_mask(vec4_mul->mask, fp);
|
||||
fprintf(fp, " ");
|
||||
}
|
||||
|
||||
print_vector_source(vec4_mul->arg0_source, NULL,
|
||||
vec4_mul->arg0_swizzle,
|
||||
vec4_mul->arg0_absolute,
|
||||
vec4_mul->arg0_negate);
|
||||
vec4_mul->arg0_negate, fp);
|
||||
|
||||
if (vec4_mul->op < 8 && vec4_mul->op != 0) {
|
||||
printf("<<%u", vec4_mul->op);
|
||||
fprintf(fp, "<<%u", vec4_mul->op);
|
||||
}
|
||||
|
||||
printf(" ");
|
||||
fprintf(fp, " ");
|
||||
|
||||
if (op.srcs > 1) {
|
||||
print_vector_source(vec4_mul->arg1_source, NULL,
|
||||
vec4_mul->arg1_swizzle,
|
||||
vec4_mul->arg1_absolute,
|
||||
vec4_mul->arg1_negate);
|
||||
vec4_mul->arg1_negate, fp);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -444,7 +444,7 @@ static const asm_op vec4_acc_ops[] = {
|
|||
#undef CASE
|
||||
|
||||
static void
|
||||
print_vec4_acc(void *code, unsigned offset)
|
||||
print_vec4_acc(void *code, unsigned offset, FILE *fp)
|
||||
{
|
||||
(void) offset;
|
||||
ppir_codegen_field_vec4_acc *vec4_acc = code;
|
||||
|
|
@ -452,29 +452,29 @@ print_vec4_acc(void *code, unsigned offset)
|
|||
asm_op op = vec4_acc_ops[vec4_acc->op];
|
||||
|
||||
if (op.name)
|
||||
printf("%s", op.name);
|
||||
fprintf(fp, "%s", op.name);
|
||||
else
|
||||
printf("op%u", vec4_acc->op);
|
||||
print_outmod(vec4_acc->dest_modifier);
|
||||
printf(".v1 ");
|
||||
fprintf(fp, "op%u", vec4_acc->op);
|
||||
print_outmod(vec4_acc->dest_modifier, fp);
|
||||
fprintf(fp, ".v1 ");
|
||||
|
||||
if (vec4_acc->mask) {
|
||||
printf("$%u", vec4_acc->dest);
|
||||
print_mask(vec4_acc->mask);
|
||||
printf(" ");
|
||||
fprintf(fp, "$%u", vec4_acc->dest);
|
||||
print_mask(vec4_acc->mask, fp);
|
||||
fprintf(fp, " ");
|
||||
}
|
||||
|
||||
print_vector_source(vec4_acc->arg0_source, vec4_acc->mul_in ? "^v0" : NULL,
|
||||
vec4_acc->arg0_swizzle,
|
||||
vec4_acc->arg0_absolute,
|
||||
vec4_acc->arg0_negate);
|
||||
vec4_acc->arg0_negate, fp);
|
||||
|
||||
if (op.srcs > 1) {
|
||||
printf(" ");
|
||||
fprintf(fp, " ");
|
||||
print_vector_source(vec4_acc->arg1_source, NULL,
|
||||
vec4_acc->arg1_swizzle,
|
||||
vec4_acc->arg1_absolute,
|
||||
vec4_acc->arg1_negate);
|
||||
vec4_acc->arg1_negate, fp);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -505,7 +505,7 @@ static const asm_op float_mul_ops[] = {
|
|||
#undef CASE
|
||||
|
||||
static void
|
||||
print_float_mul(void *code, unsigned offset)
|
||||
print_float_mul(void *code, unsigned offset, FILE *fp)
|
||||
{
|
||||
(void) offset;
|
||||
ppir_codegen_field_float_mul *float_mul = code;
|
||||
|
|
@ -513,29 +513,29 @@ print_float_mul(void *code, unsigned offset)
|
|||
asm_op op = float_mul_ops[float_mul->op];
|
||||
|
||||
if (op.name)
|
||||
printf("%s", op.name);
|
||||
fprintf(fp, "%s", op.name);
|
||||
else
|
||||
printf("op%u", float_mul->op);
|
||||
print_outmod(float_mul->dest_modifier);
|
||||
printf(".s0 ");
|
||||
fprintf(fp, "op%u", float_mul->op);
|
||||
print_outmod(float_mul->dest_modifier, fp);
|
||||
fprintf(fp, ".s0 ");
|
||||
|
||||
if (float_mul->output_en)
|
||||
print_dest_scalar(float_mul->dest);
|
||||
print_dest_scalar(float_mul->dest, fp);
|
||||
|
||||
print_source_scalar(float_mul->arg0_source, NULL,
|
||||
float_mul->arg0_absolute,
|
||||
float_mul->arg0_negate);
|
||||
float_mul->arg0_negate, fp);
|
||||
|
||||
if (float_mul->op < 8 && float_mul->op != 0) {
|
||||
printf("<<%u", float_mul->op);
|
||||
fprintf(fp, "<<%u", float_mul->op);
|
||||
}
|
||||
|
||||
if (op.srcs > 1) {
|
||||
printf(" ");
|
||||
fprintf(fp, " ");
|
||||
|
||||
print_source_scalar(float_mul->arg1_source, NULL,
|
||||
float_mul->arg1_absolute,
|
||||
float_mul->arg1_negate);
|
||||
float_mul->arg1_negate, fp);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -565,7 +565,7 @@ static const asm_op float_acc_ops[] = {
|
|||
#undef CASE
|
||||
|
||||
static void
|
||||
print_float_acc(void *code, unsigned offset)
|
||||
print_float_acc(void *code, unsigned offset, FILE *fp)
|
||||
{
|
||||
(void) offset;
|
||||
ppir_codegen_field_float_acc *float_acc = code;
|
||||
|
|
@ -573,24 +573,24 @@ print_float_acc(void *code, unsigned offset)
|
|||
asm_op op = float_acc_ops[float_acc->op];
|
||||
|
||||
if (op.name)
|
||||
printf("%s", op.name);
|
||||
fprintf(fp, "%s", op.name);
|
||||
else
|
||||
printf("op%u", float_acc->op);
|
||||
print_outmod(float_acc->dest_modifier);
|
||||
printf(".s1 ");
|
||||
fprintf(fp, "op%u", float_acc->op);
|
||||
print_outmod(float_acc->dest_modifier, fp);
|
||||
fprintf(fp, ".s1 ");
|
||||
|
||||
if (float_acc->output_en)
|
||||
print_dest_scalar(float_acc->dest);
|
||||
print_dest_scalar(float_acc->dest, fp);
|
||||
|
||||
print_source_scalar(float_acc->arg0_source, float_acc->mul_in ? "^s0" : NULL,
|
||||
float_acc->arg0_absolute,
|
||||
float_acc->arg0_negate);
|
||||
float_acc->arg0_negate, fp);
|
||||
|
||||
if (op.srcs > 1) {
|
||||
printf(" ");
|
||||
fprintf(fp, " ");
|
||||
print_source_scalar(float_acc->arg1_source, NULL,
|
||||
float_acc->arg1_absolute,
|
||||
float_acc->arg1_negate);
|
||||
float_acc->arg1_negate, fp);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -616,7 +616,7 @@ static const asm_op combine_ops[] = {
|
|||
#undef CASE
|
||||
|
||||
static void
|
||||
print_combine(void *code, unsigned offset)
|
||||
print_combine(void *code, unsigned offset, FILE *fp)
|
||||
{
|
||||
(void) offset;
|
||||
ppir_codegen_field_combine *combine = code;
|
||||
|
|
@ -626,105 +626,104 @@ print_combine(void *code, unsigned offset)
|
|||
/* This particular combination can only be valid for scalar * vector
|
||||
* multiplies, and the opcode field is reused for something else.
|
||||
*/
|
||||
printf("mul");
|
||||
fprintf(fp, "mul");
|
||||
} else {
|
||||
asm_op op = combine_ops[combine->scalar.op];
|
||||
|
||||
if (op.name)
|
||||
printf("%s", op.name);
|
||||
fprintf(fp, "%s", op.name);
|
||||
else
|
||||
printf("op%u", combine->scalar.op);
|
||||
fprintf(fp, "op%u", combine->scalar.op);
|
||||
}
|
||||
|
||||
if (!combine->scalar.dest_vec)
|
||||
print_outmod(combine->scalar.dest_modifier);
|
||||
printf(".s2 ");
|
||||
print_outmod(combine->scalar.dest_modifier, fp);
|
||||
fprintf(fp, ".s2 ");
|
||||
|
||||
if (combine->scalar.dest_vec) {
|
||||
printf("$%u", combine->vector.dest);
|
||||
print_mask(combine->vector.mask);
|
||||
fprintf(fp, "$%u", combine->vector.dest);
|
||||
print_mask(combine->vector.mask, fp);
|
||||
} else {
|
||||
print_dest_scalar(combine->scalar.dest);
|
||||
print_dest_scalar(combine->scalar.dest, fp);
|
||||
}
|
||||
printf(" ");
|
||||
fprintf(fp, " ");
|
||||
|
||||
print_source_scalar(combine->scalar.arg0_src, NULL,
|
||||
combine->scalar.arg0_absolute,
|
||||
combine->scalar.arg0_negate);
|
||||
printf(" ");
|
||||
combine->scalar.arg0_negate, fp);
|
||||
fprintf(fp, " ");
|
||||
|
||||
if (combine->scalar.arg1_en) {
|
||||
if (combine->scalar.dest_vec) {
|
||||
print_vector_source(combine->vector.arg1_source, NULL,
|
||||
combine->vector.arg1_swizzle,
|
||||
false, false);
|
||||
false, false, fp);
|
||||
} else {
|
||||
print_source_scalar(combine->scalar.arg1_src, NULL,
|
||||
combine->scalar.arg1_absolute,
|
||||
combine->scalar.arg1_negate);
|
||||
combine->scalar.arg1_negate, fp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
print_temp_write(void *code, unsigned offset)
|
||||
print_temp_write(void *code, unsigned offset, FILE *fp)
|
||||
{
|
||||
(void) offset;
|
||||
ppir_codegen_field_temp_write *temp_write = code;
|
||||
|
||||
if (temp_write->fb_read.unknown_0 == 0x7) {
|
||||
if (temp_write->fb_read.source)
|
||||
printf("fb_color");
|
||||
fprintf(fp, "fb_color");
|
||||
else
|
||||
printf("fb_depth");
|
||||
printf(" $%u", temp_write->fb_read.dest);
|
||||
fprintf(fp, "fb_depth");
|
||||
fprintf(fp, " $%u", temp_write->fb_read.dest);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
printf("store.t");
|
||||
fprintf(fp, "store.t");
|
||||
|
||||
int16_t index = temp_write->temp_write.index;
|
||||
switch (temp_write->temp_write.alignment) {
|
||||
case 2:
|
||||
printf(" %d", index);
|
||||
fprintf(fp, " %d", index);
|
||||
break;
|
||||
case 1:
|
||||
printf(" %d.%s", index / 2, (index & 1) ? "zw" : "xy");
|
||||
fprintf(fp, " %d.%s", index / 2, (index & 1) ? "zw" : "xy");
|
||||
break;
|
||||
default:
|
||||
printf(" %d.%c", index / 4, "xyzw"[index & 3]);
|
||||
fprintf(fp, " %d.%c", index / 4, "xyzw"[index & 3]);
|
||||
break;
|
||||
}
|
||||
|
||||
if (temp_write->temp_write.offset_en) {
|
||||
printf("+");
|
||||
fprintf(fp, "+");
|
||||
print_source_scalar(temp_write->temp_write.offset_reg,
|
||||
NULL, false, false);
|
||||
NULL, false, false, fp);
|
||||
}
|
||||
|
||||
printf(" ");
|
||||
fprintf(fp, " ");
|
||||
|
||||
if (temp_write->temp_write.alignment) {
|
||||
print_reg(temp_write->temp_write.source >> 2, NULL);
|
||||
print_reg(temp_write->temp_write.source >> 2, NULL, fp);
|
||||
} else {
|
||||
print_source_scalar(temp_write->temp_write.source, NULL, false, false);
|
||||
print_source_scalar(temp_write->temp_write.source, NULL, false, false, fp);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
print_branch(void *code, unsigned offset)
|
||||
{
|
||||
print_branch(void *code, unsigned offset, FILE *fp)
|
||||
{
|
||||
ppir_codegen_field_branch *branch = code;
|
||||
|
||||
if (branch->discard.word0 == PPIR_CODEGEN_DISCARD_WORD0 &&
|
||||
branch->discard.word1 == PPIR_CODEGEN_DISCARD_WORD1 &&
|
||||
branch->discard.word2 == PPIR_CODEGEN_DISCARD_WORD2) {
|
||||
printf("discard");
|
||||
fprintf(fp, "discard");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
const char* cond[] = {
|
||||
"nv", "lt", "eq", "le",
|
||||
"gt", "ne", "ge", "" ,
|
||||
|
|
@ -734,18 +733,18 @@ print_branch(void *code, unsigned offset)
|
|||
cond_mask |= (branch->branch.cond_lt ? 1 : 0);
|
||||
cond_mask |= (branch->branch.cond_eq ? 2 : 0);
|
||||
cond_mask |= (branch->branch.cond_gt ? 4 : 0);
|
||||
printf("branch");
|
||||
fprintf(fp, "branch");
|
||||
if (cond_mask != 0x7) {
|
||||
printf(".%s ", cond[cond_mask]);
|
||||
print_source_scalar(branch->branch.arg0_source, NULL, false, false);
|
||||
printf(" ");
|
||||
print_source_scalar(branch->branch.arg1_source, NULL, false, false);
|
||||
fprintf(fp, ".%s ", cond[cond_mask]);
|
||||
print_source_scalar(branch->branch.arg0_source, NULL, false, false, fp);
|
||||
fprintf(fp, " ");
|
||||
print_source_scalar(branch->branch.arg1_source, NULL, false, false, fp);
|
||||
}
|
||||
|
||||
printf(" %d", branch->branch.target + offset);
|
||||
fprintf(fp, " %d", branch->branch.target + offset);
|
||||
}
|
||||
|
||||
typedef void (*print_field_func)(void *, unsigned);
|
||||
typedef void (*print_field_func)(void *, unsigned, FILE *);
|
||||
|
||||
static const print_field_func print_field[ppir_codegen_field_shift_count] = {
|
||||
[ppir_codegen_field_shift_varying] = print_varying,
|
||||
|
|
@ -781,7 +780,7 @@ bitcopy(char *src, char *dst, unsigned bits, unsigned src_offset)
|
|||
}
|
||||
|
||||
void
|
||||
ppir_disassemble_instr(uint32_t *instr, unsigned offset)
|
||||
ppir_disassemble_instr(uint32_t *instr, unsigned offset, FILE *fp)
|
||||
{
|
||||
ppir_codegen_ctrl *ctrl = (ppir_codegen_ctrl *) instr;
|
||||
|
||||
|
|
@ -800,18 +799,18 @@ ppir_disassemble_instr(uint32_t *instr, unsigned offset)
|
|||
if (first)
|
||||
first = false;
|
||||
else
|
||||
printf(", ");
|
||||
fprintf(fp, ", ");
|
||||
|
||||
print_field[i](code, offset);
|
||||
print_field[i](code, offset, fp);
|
||||
|
||||
bit_offset += bits;
|
||||
}
|
||||
|
||||
if (ctrl->sync)
|
||||
printf(", sync");
|
||||
fprintf(fp, ", sync");
|
||||
if (ctrl->stop)
|
||||
printf(", stop");
|
||||
fprintf(fp, ", stop");
|
||||
|
||||
printf("\n");
|
||||
fprintf(fp, "\n");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1180,10 +1180,12 @@ lima_draw_vbo(struct pipe_context *pctx,
|
|||
lima_dump_command_stream_print(
|
||||
job->dump, ctx->vs->bo->map, ctx->vs->state.shader_size, false,
|
||||
"add vs at va %x\n", ctx->vs->bo->va);
|
||||
lima_dump_shader(job->dump, ctx->vs->bo->map, ctx->vs->state.shader_size, false);
|
||||
|
||||
lima_dump_command_stream_print(
|
||||
job->dump, ctx->fs->bo->map, ctx->fs->state.shader_size, false,
|
||||
"add fs at va %x\n", ctx->fs->bo->va);
|
||||
lima_dump_shader(job->dump, ctx->fs->bo->map, ctx->fs->state.shader_size, true);
|
||||
|
||||
lima_job_add_bo(job, LIMA_PIPE_GP, ctx->vs->bo, LIMA_SUBMIT_BO_READ);
|
||||
lima_job_add_bo(job, LIMA_PIPE_PP, ctx->fs->bo, LIMA_SUBMIT_BO_READ);
|
||||
|
|
|
|||
|
|
@ -32,6 +32,9 @@
|
|||
#include "lima_parser.h"
|
||||
#include "lima_texture.h"
|
||||
|
||||
#include "lima/ir/gp/codegen.h"
|
||||
#include "lima/ir/pp/codegen.h"
|
||||
|
||||
typedef struct {
|
||||
char *info;
|
||||
} render_state_info;
|
||||
|
|
@ -433,6 +436,35 @@ lima_parse_plbu(FILE *fp, uint32_t *data, int size, uint32_t start)
|
|||
fprintf(fp, "\n");
|
||||
}
|
||||
|
||||
void
|
||||
lima_parse_shader(FILE *fp, uint32_t *data, int size, bool is_frag)
|
||||
{
|
||||
uint32_t *value = &data[0];
|
||||
|
||||
if (is_frag) {
|
||||
uint32_t *bin = value;
|
||||
uint32_t offt = 0;
|
||||
uint32_t next_instr_length = 0;
|
||||
|
||||
fprintf(fp, "/* ============ FS DISASSEMBLY BEGIN ============== */\n");
|
||||
|
||||
do {
|
||||
ppir_codegen_ctrl *ctrl = (ppir_codegen_ctrl *)bin;
|
||||
fprintf(fp, "@%6d: ", offt);
|
||||
ppir_disassemble_instr(bin, offt, fp);
|
||||
bin += ctrl->count;
|
||||
offt += ctrl->count;
|
||||
next_instr_length = ctrl->next_count;
|
||||
} while (next_instr_length);
|
||||
|
||||
fprintf(fp, "/* ============ FS DISASSEMBLY END ================= */\n");
|
||||
} else {
|
||||
fprintf(fp, "/* ============ VS DISASSEMBLY BEGIN ============== */\n");
|
||||
gpir_disassemble_program((gpir_codegen_instr *)value, size / sizeof(gpir_codegen_instr), fp);
|
||||
fprintf(fp, "/* ============ VS DISASSEMBLY END ================= */\n");
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
parse_rsw(FILE *fp, uint32_t *value, int i, uint32_t *helper)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -118,6 +118,7 @@ static inline const char
|
|||
return "UNKNOWN";
|
||||
}
|
||||
|
||||
void lima_parse_shader(FILE *fp, uint32_t *data, int size, bool is_frag);
|
||||
void lima_parse_vs(FILE *fp, uint32_t *data, int size, uint32_t start);
|
||||
void lima_parse_plbu(FILE *fp, uint32_t *data, int size, uint32_t start);
|
||||
void lima_parse_render_state(FILE *fp, uint32_t *data, int size, uint32_t start);
|
||||
|
|
|
|||
|
|
@ -78,6 +78,13 @@ lima_dump_blob(FILE *fp, void *data, int size, bool is_float)
|
|||
fprintf(fp, "}\n");
|
||||
}
|
||||
|
||||
void
|
||||
lima_dump_shader(struct lima_dump *dump, void *data, int size, bool is_frag)
|
||||
{
|
||||
if (dump)
|
||||
lima_parse_shader(dump->fp, (uint32_t *)data, size, is_frag);
|
||||
}
|
||||
|
||||
void
|
||||
lima_dump_vs_command_stream_print(struct lima_dump *dump, void *data,
|
||||
int size, uint32_t start)
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ struct lima_dump *lima_dump_create(void);
|
|||
struct lima_dump *lima_dump_next(struct lima_dump *dump);
|
||||
void lima_dump_free(struct lima_dump *dump);
|
||||
|
||||
void lima_dump_shader(struct lima_dump *dump, void *data, int size, bool is_frag);
|
||||
void lima_dump_vs_command_stream_print(struct lima_dump *dump, void *data,
|
||||
int size, uint32_t start);
|
||||
void lima_dump_plbu_command_stream_print(struct lima_dump *dump, void *data,
|
||||
|
|
|
|||
|
|
@ -183,13 +183,13 @@ main(int argc, char **argv)
|
|||
do {
|
||||
ppir_codegen_ctrl *ctrl = (ppir_codegen_ctrl *)bin;
|
||||
printf("@%6d: ", offset);
|
||||
ppir_disassemble_instr(bin, offset);
|
||||
ppir_disassemble_instr(bin, offset, stdout);
|
||||
bin += ctrl->count;
|
||||
offset += ctrl->count;
|
||||
size -= ctrl->count;
|
||||
} while (size);
|
||||
} else {
|
||||
gpir_disassemble_program((gpir_codegen_instr *)prog, size / (sizeof(gpir_codegen_instr)));
|
||||
gpir_disassemble_program((gpir_codegen_instr *)prog, size / (sizeof(gpir_codegen_instr)), stdout);
|
||||
}
|
||||
|
||||
ralloc_free(prog);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue