[Mesa-dev] [PATCH 2/6] mesa/st/glsl_to_tgsi: Correct debug output for indirect access
Gert Wollny
gw.fossdev at gmail.com
Wed Oct 4 09:45:26 UTC 2017
For arrays print the array ID, and with indirect access also print the
reladdr* registers. The reladdr* registers are always used in the
printout, even though the actual code may use an address register.
Specifically, a sequence involving src.reladdr = TEMP[2] and src.index=10
that emits the address register loading instruction will be printed like:
MOV ADDR[0].x, TEMP[2].xxxx
MOV TEMP[3], ARRAY(2)[TEMP[2].xxxx + 10]
The reason for this is, that there is currently no indication in the src
register on whether the address instruction was or must be emitted.
---
.../state_tracker/st_glsl_to_tgsi_temprename.cpp | 62 ++++++++++++----------
1 file changed, 34 insertions(+), 28 deletions(-)
diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi_temprename.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi_temprename.cpp
index 76c198e165..36ddd7a258 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi_temprename.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi_temprename.cpp
@@ -918,6 +918,31 @@ static const char *tgsi_file_names[PROGRAM_FILE_MAX] = {
"IMM", "BUF", "MEM", "IMAGE"
};
+static std::ostream& operator << (std::ostream& os, const st_src_reg& reg)
+{
+ os << tgsi_file_names[reg.file];
+ if (reg.file == PROGRAM_ARRAY)
+ os << "(" << reg.array_id << ")";
+
+ os << "[";
+ if (reg.reladdr)
+ os << *reg.reladdr << "+";
+ if (reg.reladdr2)
+ os << *reg.reladdr2 << "+";
+ os << "]";
+
+ if (reg.swizzle != SWIZZLE_XYZW) {
+ os << ".";
+ for (int idx = 0; idx < 4; ++idx) {
+ int swz = GET_SWZ(reg.swizzle, idx);
+ if (swz < 4) {
+ os << swizzle_txt[swz];
+ }
+ }
+ }
+ return os;
+}
+
static
void dump_instruction(int line, prog_scope *scope,
const glsl_to_tgsi_instruction& inst)
@@ -954,7 +979,12 @@ void dump_instruction(int line, prog_scope *scope,
if (dst.file == PROGRAM_ARRAY)
cerr << "(" << dst.array_id << ")";
- cerr << "[" << dst.index << "]";
+ cerr << "[";
+ if (dst.reladdr)
+ cerr << *dst.reladdr;
+ if (dst.reladdr2)
+ cerr << *dst.reladdr2;
+ cerr << dst.index << "]";
if (dst.writemask != TGSI_WRITEMASK_XYZW) {
cerr << ".";
@@ -970,19 +1000,7 @@ void dump_instruction(int line, prog_scope *scope,
for (unsigned j = 0; j < num_inst_src_regs(&inst); j++) {
if (j > 0)
cerr << ", ";
-
- const st_src_reg& src = inst.src[j];
- cerr << tgsi_file_names[src.file]
- << "[" << src.index << "]";
- if (src.swizzle != SWIZZLE_XYZW) {
- cerr << ".";
- for (int idx = 0; idx < 4; ++idx) {
- int swz = GET_SWZ(src.swizzle, idx);
- if (swz < 4) {
- cerr << swizzle_txt[swz];
- }
- }
- }
+ cerr << inst.src[j];
}
if (inst.tex_offset_num_offset > 0) {
@@ -990,21 +1008,9 @@ void dump_instruction(int line, prog_scope *scope,
for (unsigned j = 0; j < inst.tex_offset_num_offset; j++) {
if (j > 0)
cerr << ", ";
-
- const st_src_reg& src = inst.tex_offsets[j];
- cerr << tgsi_file_names[src.file]
- << "[" << src.index << "]";
- if (src.swizzle != SWIZZLE_XYZW) {
- cerr << ".";
- for (int idx = 0; idx < 4; ++idx) {
- int swz = GET_SWZ(src.swizzle, idx);
- if (swz < 4) {
- cerr << swizzle_txt[swz];
- }
- }
- }
+ cerr << inst.tex_offsets[j];
}
}
cerr << "\n";
}
-#endif
+#endif
\ No newline at end of file
--
2.13.6
More information about the mesa-dev
mailing list