diff options
author | Eric Anholt <[email protected]> | 2018-12-11 22:31:41 -0800 |
---|---|---|
committer | Eric Anholt <[email protected]> | 2018-12-14 17:48:01 -0800 |
commit | 532b6c5671507feb72a4eb5056284d83a0f58366 (patch) | |
tree | 69d7cdc99825ff470868b635740260125a2fce5b /src | |
parent | 78ef05bde45c936c63ec64d4b406cb6d13d532c0 (diff) |
v3d: Move uniform pretty-printing to its own helper function.
I want to reuse it in the QPU dump.
Diffstat (limited to 'src')
-rw-r--r-- | src/broadcom/compiler/v3d_compiler.h | 1 | ||||
-rw-r--r-- | src/broadcom/compiler/vir_dump.c | 147 |
2 files changed, 77 insertions, 71 deletions
diff --git a/src/broadcom/compiler/v3d_compiler.h b/src/broadcom/compiler/v3d_compiler.h index 6ab1176068d..3a2b9db1153 100644 --- a/src/broadcom/compiler/v3d_compiler.h +++ b/src/broadcom/compiler/v3d_compiler.h @@ -773,6 +773,7 @@ void vir_emit_thrsw(struct v3d_compile *c); void vir_dump(struct v3d_compile *c); void vir_dump_inst(struct v3d_compile *c, struct qinst *inst); +void vir_dump_uniform(enum quniform_contents contents, uint32_t data); void vir_validate(struct v3d_compile *c); diff --git a/src/broadcom/compiler/vir_dump.c b/src/broadcom/compiler/vir_dump.c index d1c343f773e..56960e6d7ab 100644 --- a/src/broadcom/compiler/vir_dump.c +++ b/src/broadcom/compiler/vir_dump.c @@ -24,6 +24,77 @@ #include "broadcom/common/v3d_device_info.h" #include "v3d_compiler.h" +/* Prints a human-readable description of the uniform reference. */ +void +vir_dump_uniform(enum quniform_contents contents, + uint32_t data) +{ + static const char *quniform_names[] = { + [QUNIFORM_VIEWPORT_X_SCALE] = "vp_x_scale", + [QUNIFORM_VIEWPORT_Y_SCALE] = "vp_y_scale", + [QUNIFORM_VIEWPORT_Z_OFFSET] = "vp_z_offset", + [QUNIFORM_VIEWPORT_Z_SCALE] = "vp_z_scale", + }; + + switch (contents) { + case QUNIFORM_CONSTANT: + fprintf(stderr, "0x%08x / %f", data, uif(data)); + break; + + case QUNIFORM_UNIFORM: + fprintf(stderr, "push[%d]", data); + break; + + case QUNIFORM_TEXTURE_CONFIG_P1: + fprintf(stderr, "tex[%d].p1", data); + break; + + case QUNIFORM_TMU_CONFIG_P0: + fprintf(stderr, "tex[%d].p0 | 0x%x", + v3d_tmu_config_data_get_unit(data), + v3d_tmu_config_data_get_value(data)); + break; + + case QUNIFORM_TMU_CONFIG_P1: + fprintf(stderr, "tex[%d].p1 | 0x%x", + v3d_tmu_config_data_get_unit(data), + v3d_tmu_config_data_get_value(data)); + break; + + case QUNIFORM_TEXTURE_WIDTH: + fprintf(stderr, "tex[%d].width", data); + break; + case QUNIFORM_TEXTURE_HEIGHT: + fprintf(stderr, "tex[%d].height", data); + break; + case QUNIFORM_TEXTURE_DEPTH: + fprintf(stderr, "tex[%d].depth", data); + break; + case QUNIFORM_TEXTURE_ARRAY_SIZE: + fprintf(stderr, "tex[%d].array_size", data); + break; + case QUNIFORM_TEXTURE_LEVELS: + fprintf(stderr, "tex[%d].levels", data); + break; + + case QUNIFORM_UBO_ADDR: + fprintf(stderr, "ubo[%d]", data); + break; + + default: + if (quniform_contents_is_texture_p0(contents)) { + fprintf(stderr, "tex[%d].p0: 0x%08x", + contents - QUNIFORM_TEXTURE_CONFIG_P0_0, + data); + } else if (contents < ARRAY_SIZE(quniform_names)) { + fprintf(stderr, "%s", + quniform_names[contents]); + } else { + fprintf(stderr, "%d / 0x%08x", contents, data); + } + } +} + static void vir_print_reg(struct v3d_compile *c, const struct qinst *inst, struct qreg reg) @@ -34,12 +105,6 @@ vir_print_reg(struct v3d_compile *c, const struct qinst *inst, [QFILE_TLB] = "tlb", [QFILE_TLBU] = "tlbu", }; - static const char *quniform_names[] = { - [QUNIFORM_VIEWPORT_X_SCALE] = "vp_x_scale", - [QUNIFORM_VIEWPORT_Y_SCALE] = "vp_y_scale", - [QUNIFORM_VIEWPORT_Z_OFFSET] = "vp_z_offset", - [QUNIFORM_VIEWPORT_Z_SCALE] = "vp_z_scale", - }; switch (reg.file) { @@ -84,73 +149,13 @@ vir_print_reg(struct v3d_compile *c, const struct qinst *inst, fprintf(stderr, "%s", files[reg.file]); break; - case QFILE_UNIF: { - enum quniform_contents contents = c->uniform_contents[reg.index]; - uint32_t data = c->uniform_data[reg.index]; - + case QFILE_UNIF: fprintf(stderr, "%s%d", files[reg.file], reg.index); - - switch (contents) { - case QUNIFORM_CONSTANT: - fprintf(stderr, " (0x%08x / %f)", data, uif(data)); - break; - - case QUNIFORM_UNIFORM: - fprintf(stderr, " (push[%d])", data); - break; - - case QUNIFORM_TEXTURE_CONFIG_P1: - fprintf(stderr, " (tex[%d].p1)", data); - break; - - case QUNIFORM_TMU_CONFIG_P0: - fprintf(stderr, " (tex[%d].p0 | 0x%x)", - v3d_tmu_config_data_get_unit(data), - v3d_tmu_config_data_get_value(data)); - break; - - case QUNIFORM_TMU_CONFIG_P1: - fprintf(stderr, " (tex[%d].p1 | 0x%x)", - v3d_tmu_config_data_get_unit(data), - v3d_tmu_config_data_get_value(data)); - break; - - case QUNIFORM_TEXTURE_WIDTH: - fprintf(stderr, " (tex[%d].width)", data); - break; - case QUNIFORM_TEXTURE_HEIGHT: - fprintf(stderr, " (tex[%d].height)", data); - break; - case QUNIFORM_TEXTURE_DEPTH: - fprintf(stderr, " (tex[%d].depth)", data); - break; - case QUNIFORM_TEXTURE_ARRAY_SIZE: - fprintf(stderr, " (tex[%d].array_size)", data); - break; - case QUNIFORM_TEXTURE_LEVELS: - fprintf(stderr, " (tex[%d].levels)", data); - break; - - case QUNIFORM_UBO_ADDR: - fprintf(stderr, " (ubo[%d])", data); - break; - - default: - if (quniform_contents_is_texture_p0(contents)) { - fprintf(stderr, " (tex[%d].p0: 0x%08x)", - contents - QUNIFORM_TEXTURE_CONFIG_P0_0, - c->uniform_data[reg.index]); - } else if (contents < ARRAY_SIZE(quniform_names)) { - fprintf(stderr, " (%s)", - quniform_names[contents]); - } else { - fprintf(stderr, " (%d / 0x%08x)", contents, - c->uniform_data[reg.index]); - } - } - + fprintf(stderr, " ("); + vir_dump_uniform(c->uniform_contents[reg.index], + c->uniform_data[reg.index]); + fprintf(stderr, ")"); break; - } default: fprintf(stderr, "%s%d", files[reg.file], reg.index); |