[Mesa-dev] [PATCH 3/3] intel: aubinator: print field values if available
Lionel Landwerlin
llandwerlin at gmail.com
Mon Oct 17 20:57:17 UTC 2016
Turning this :
sampler state 0
Sampler Disable: false
Texture Border Color Mode: 0
LOD PreClamp Enable: 1
Base Mip Level: 0.000000
Mip Mode Filter: 0
Mag Mode Filter: 1
Min Mode Filter: 1
Texture LOD Bias: foo
Anisotropic Algorithm: 0
into this :
sampler state 0
Sampler Disable: false
Texture Border Color Mode: 0 (DX10/OGL)
LOD PreClamp Enable: 1 (OGL)
Base Mip Level: 0.000000
Mip Mode Filter: 0 (NONE)
Mag Mode Filter: 1 (LINEAR)
Min Mode Filter: 1 (LINEAR)
Texture LOD Bias: foo
Anisotropic Algorithm: 0 (LEGACY)
Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
---
src/intel/tools/aubinator.c | 7 ++++++-
src/intel/tools/decoder.c | 31 +++++++++++++++++++++++++++----
src/intel/tools/decoder.h | 1 +
3 files changed, 34 insertions(+), 5 deletions(-)
diff --git a/src/intel/tools/aubinator.c b/src/intel/tools/aubinator.c
index 01941b2..44de6f4 100644
--- a/src/intel/tools/aubinator.c
+++ b/src/intel/tools/aubinator.c
@@ -111,7 +111,12 @@ print_iterator_values(struct gen_field_iterator *iter, int *idx)
{
char *token = NULL;
if (strstr(iter->value, "struct") == NULL) {
- printf(" %s: %s\n", iter->name, iter->value);
+ if (strlen(iter->description) > 0) {
+ printf(" %s: %s (%s)\n",
+ iter->name, iter->value, iter->description);
+ } else {
+ printf(" %s: %s\n", iter->name, iter->value);
+ }
} else {
token = strtok(iter->value, " ");
if (token != NULL) {
diff --git a/src/intel/tools/decoder.c b/src/intel/tools/decoder.c
index 88ba5c0..361c9c5 100644
--- a/src/intel/tools/decoder.c
+++ b/src/intel/tools/decoder.c
@@ -635,6 +635,19 @@ gen_field_iterator_init(struct gen_field_iterator *iter,
iter->print_colors = print_colors;
}
+static void
+gen_field_write_value(char *str, size_t max_length,
+ struct gen_field *field,
+ uint64_t value)
+{
+ for (int i = 0; i < field->n_values; i++) {
+ if (field->values[i]->value == value) {
+ snprintf(str, max_length, field->values[i]->name);
+ return;
+ }
+ }
+}
+
bool
gen_field_iterator_next(struct gen_field_iterator *iter)
{
@@ -656,16 +669,26 @@ gen_field_iterator_next(struct gen_field_iterator *iter)
else
v.qw = iter->p[index];
+ iter->description[0] = '\0';
+
switch (f->type.kind) {
case GEN_TYPE_UNKNOWN:
- case GEN_TYPE_INT:
+ case GEN_TYPE_INT: {
+ uint64_t value = field(v.qw, f->start, f->end);
snprintf(iter->value, sizeof(iter->value),
- "%"PRId64, field(v.qw, f->start, f->end));
+ "%"PRId64, value);
+ gen_field_write_value(iter->description, sizeof(iter->description),
+ f, value);
break;
- case GEN_TYPE_UINT:
+ }
+ case GEN_TYPE_UINT: {
+ uint64_t value = field(v.qw, f->start, f->end);
snprintf(iter->value, sizeof(iter->value),
- "%"PRIu64, field(v.qw, f->start, f->end));
+ "%"PRIu64, value);
+ gen_field_write_value(iter->description, sizeof(iter->description),
+ f, value);
break;
+ }
case GEN_TYPE_BOOL: {
const char *true_string =
iter->print_colors ? "\e[0;35mtrue\e[0m" : "true";
diff --git a/src/intel/tools/decoder.h b/src/intel/tools/decoder.h
index ecc9ff1..b28e603 100644
--- a/src/intel/tools/decoder.h
+++ b/src/intel/tools/decoder.h
@@ -53,6 +53,7 @@ struct gen_field_iterator {
struct gen_group *group;
const char *name;
char value[128];
+ char description[128];
const uint32_t *p;
int i;
bool print_colors;
--
2.9.3
More information about the mesa-dev
mailing list