vc4: Extend dumping of uniforms in QIR and in the command stream.
authorEric Anholt <eric@anholt.net>
Tue, 7 Aug 2018 20:38:36 +0000 (13:38 -0700)
committerEric Anholt <eric@anholt.net>
Wed, 8 Aug 2018 00:00:22 +0000 (17:00 -0700)
Similar to what I did for V3D, provide some description of the uniforms.

src/gallium/drivers/vc4/vc4_qir.c
src/gallium/drivers/vc4/vc4_qir.h
src/gallium/drivers/vc4/vc4_uniforms.c

index c829e7f93b765da2ed8d1b6968f962e07f638a4a..71f06aebfa04503eb88bae47c42283badda87455 100644 (file)
@@ -343,13 +343,57 @@ qir_channels_written(struct qinst *inst)
         unreachable("Bad pack field");
 }
 
+char *
+qir_describe_uniform(enum quniform_contents contents, uint32_t data,
+                     const uint32_t *uniforms)
+{
+        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",
+                [QUNIFORM_TEXTURE_CONFIG_P0] = "tex_p0",
+                [QUNIFORM_TEXTURE_CONFIG_P1] = "tex_p1",
+                [QUNIFORM_TEXTURE_CONFIG_P2] = "tex_p2",
+                [QUNIFORM_TEXTURE_FIRST_LEVEL] = "tex_first_level",
+        };
+
+        switch (contents) {
+        case QUNIFORM_CONSTANT:
+                return ralloc_asprintf(NULL, "0x%08x / %f", data, uif(data));
+        case QUNIFORM_UNIFORM:
+                if (uniforms) {
+                        uint32_t unif = uniforms[data];
+                        return ralloc_asprintf(NULL, "unif[%d] = 0x%08x / %f",
+                                               data, unif, uif(unif));
+                } else {
+                        return ralloc_asprintf(NULL, "unif[%d]", data);
+                }
+
+        case QUNIFORM_TEXTURE_CONFIG_P0:
+        case QUNIFORM_TEXTURE_CONFIG_P1:
+        case QUNIFORM_TEXTURE_CONFIG_P2:
+        case QUNIFORM_TEXTURE_FIRST_LEVEL:
+                return ralloc_asprintf(NULL, "%s[%d]",
+                                       quniform_names[contents], data);
+
+        default:
+                if (contents < ARRAY_SIZE(quniform_names) &&
+                    quniform_names[contents]) {
+                        return ralloc_asprintf(NULL, "%s",
+                                               quniform_names[contents]);
+                } else {
+                        return ralloc_asprintf(NULL, "??? %d", contents);
+                }
+        }
+}
+
 static void
 qir_print_reg(struct vc4_compile *c, struct qreg reg, bool write)
 {
         static const char *files[] = {
                 [QFILE_TEMP] = "t",
                 [QFILE_VARY] = "v",
-                [QFILE_UNIF] = "u",
                 [QFILE_TLB_COLOR_WRITE] = "tlb_c",
                 [QFILE_TLB_COLOR_WRITE_MS] = "tlb_c_ms",
                 [QFILE_TLB_Z_WRITE] = "tlb_z",
@@ -403,16 +447,18 @@ qir_print_reg(struct vc4_compile *c, struct qreg reg, bool write)
                 fprintf(stderr, "%s", files[reg.file]);
                 break;
 
-        default:
-                fprintf(stderr, "%s%d", files[reg.file], reg.index);
+        case QFILE_UNIF: {
+                char *desc = qir_describe_uniform(c->uniform_contents[reg.index],
+                                                  c->uniform_data[reg.index],
+                                                  NULL);
+                fprintf(stderr, "u%d (%s)", reg.index, desc);
+                ralloc_free(desc);
                 break;
         }
 
-        if (reg.file == QFILE_UNIF &&
-            c->uniform_contents[reg.index] == QUNIFORM_CONSTANT) {
-                fprintf(stderr, " (0x%08x / %f)",
-                        c->uniform_data[reg.index],
-                        uif(c->uniform_data[reg.index]));
+        default:
+                fprintf(stderr, "%s%d", files[reg.file], reg.index);
+                break;
         }
 }
 
index 3afa98a66af1b4e735a1c9295835f76b00e6196f..1aa5f652fbc2ac132ae253dd9c216f3491707493 100644 (file)
@@ -592,6 +592,8 @@ uint8_t qir_channels_written(struct qinst *inst);
 
 void qir_dump(struct vc4_compile *c);
 void qir_dump_inst(struct vc4_compile *c, struct qinst *inst);
+char *qir_describe_uniform(enum quniform_contents contents, uint32_t data,
+                           const uint32_t *uniforms);
 const char *qir_get_stage_name(enum qstage stage);
 
 void qir_validate(struct vc4_compile *c);
index e66654361cc7d52c2fd5264be334d429bacf7bc8..3801fbc8f6b7845be9bdf2c481dec5bea8e790d6 100644 (file)
@@ -360,11 +360,18 @@ vc4_write_uniforms(struct vc4_context *vc4, struct vc4_compiled_shader *shader,
                         cl_aligned_u32(&uniforms, 0xd0d0d0d0);
                         break;
                 }
-#if 0
-                uint32_t written_val = *((uint32_t *)uniforms - 1);
-                fprintf(stderr, "%p: %d / 0x%08x (%f)\n",
-                        shader, i, written_val, uif(written_val));
-#endif
+
+                if (false) {
+                        uint32_t written_val = *((uint32_t *)uniforms - 1);
+                        char *desc = qir_describe_uniform(uinfo->contents[i],
+                                                          uinfo->data[i],
+                                                          gallium_uniforms);
+
+                        fprintf(stderr, "%p/%d: 0x%08x %s\n",
+                                shader, i, written_val, desc);
+
+                        ralloc_free(desc);
+                }
         }
 
         cl_end(&job->uniforms, uniforms);