Mesa (main): broadcom/compiler: make shaderdb debug output compatible with shaderdb's report tool

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Nov 24 13:28:26 UTC 2021


Module: Mesa
Branch: main
Commit: a9b4aef0f247408487074c0136c170b0e57bece2
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=a9b4aef0f247408487074c0136c170b0e57bece2

Author: Alejandro Piñeiro <apinheiro at igalia.com>
Date:   Tue Nov 23 00:46:48 2021 +0100

broadcom/compiler: make shaderdb debug output compatible with shaderdb's report tool

Even although the option is called shaderdb, it is not really used by
shaderdb (for V3D shaderdb uses the debug option "precompile"). And in
fact, right now the output format is not compatible with shaderdb.

This commit tries to fix that, and as we are here, also try to make
the option more useful for the Vulkan case, as that debug option also
works with v3dv.

We can't really fully imitate shaderdb use with OpenGL (run with a set
of glsl shader tests), but we can at least assign a unique name (the
pipeline sha1 in text format) so we can compare executions of the same
vulkan application. For that remember to disable the on-disk cache.

Reviewed-by: Iago Toral Quiroga <itoral at igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13938>

---

 src/broadcom/compiler/vir.c         |  2 +-
 src/broadcom/vulkan/v3dv_pipeline.c | 19 +++++++++++--------
 src/broadcom/vulkan/v3dv_private.h  |  3 +++
 3 files changed, 15 insertions(+), 9 deletions(-)

diff --git a/src/broadcom/compiler/vir.c b/src/broadcom/compiler/vir.c
index 127709d1de3..764000b9eba 100644
--- a/src/broadcom/compiler/vir.c
+++ b/src/broadcom/compiler/vir.c
@@ -1766,7 +1766,7 @@ uint64_t *v3d_compile(const struct v3d_compiler *compiler,
         int ret = v3d_shaderdb_dump(c, &shaderdb);
         if (ret >= 0) {
                 if (V3D_DEBUG & V3D_DEBUG_SHADERDB)
-                        fprintf(stderr, "SHADER-DB: %s\n", shaderdb);
+                        fprintf(stderr, "SHADER-DB-%s - %s\n", s->info.name, shaderdb);
 
                 c->debug_output(shaderdb, c->debug_output_data);
                 free(shaderdb);
diff --git a/src/broadcom/vulkan/v3dv_pipeline.c b/src/broadcom/vulkan/v3dv_pipeline.c
index 742f96c2bb6..5eb3bdb8cc5 100644
--- a/src/broadcom/vulkan/v3dv_pipeline.c
+++ b/src/broadcom/vulkan/v3dv_pipeline.c
@@ -452,6 +452,11 @@ shader_module_compile_to_nir(struct v3dv_device *device,
       assert(nir);
       nir_validate_shader(nir, "after spirv_to_nir");
       free(spec_entries);
+      if (unlikely(V3D_DEBUG & V3D_DEBUG_SHADERDB)) {
+            char sha1buf[41];
+            _mesa_sha1_format(sha1buf, stage->pipeline->sha1);
+            nir->info.name = ralloc_strdup(nir, sha1buf);
+      }
    } else {
       /* For NIR modules created by the driver we can't consume the NIR
        * directly, we need to clone it first, since ownership of the NIR code
@@ -2496,14 +2501,13 @@ pipeline_compile_graphics(struct v3dv_pipeline *pipeline,
    /* First we try to get the variants from the pipeline cache */
    struct v3dv_pipeline_key pipeline_key;
    pipeline_populate_graphics_key(pipeline, &pipeline_key, pCreateInfo);
-   unsigned char pipeline_sha1[20];
-   pipeline_hash_graphics(pipeline, &pipeline_key, pipeline_sha1);
+   pipeline_hash_graphics(pipeline, &pipeline_key, pipeline->sha1);
 
    bool cache_hit = false;
 
    pipeline->shared_data =
       v3dv_pipeline_cache_search_for_pipeline(cache,
-                                              pipeline_sha1,
+                                              pipeline->sha1,
                                               &cache_hit);
 
    if (pipeline->shared_data != NULL) {
@@ -2530,7 +2534,7 @@ pipeline_compile_graphics(struct v3dv_pipeline *pipeline,
     * shader or the pipeline cache) and compile.
     */
    pipeline->shared_data =
-      v3dv_pipeline_shared_data_new_empty(pipeline_sha1, pipeline, true);
+      v3dv_pipeline_shared_data_new_empty(pipeline->sha1, pipeline, true);
 
    pipeline->vs->feedback.flags |=
       VK_PIPELINE_CREATION_FEEDBACK_VALID_BIT_EXT;
@@ -3188,12 +3192,11 @@ pipeline_compile_compute(struct v3dv_pipeline *pipeline,
 
    struct v3dv_pipeline_key pipeline_key;
    pipeline_populate_compute_key(pipeline, &pipeline_key, info);
-   unsigned char pipeline_sha1[20];
-   pipeline_hash_compute(pipeline, &pipeline_key, pipeline_sha1);
+   pipeline_hash_compute(pipeline, &pipeline_key, pipeline->sha1);
 
    bool cache_hit = false;
    pipeline->shared_data =
-      v3dv_pipeline_cache_search_for_pipeline(cache, pipeline_sha1, &cache_hit);
+      v3dv_pipeline_cache_search_for_pipeline(cache, pipeline->sha1, &cache_hit);
 
    if (pipeline->shared_data != NULL) {
       assert(pipeline->shared_data->variants[BROADCOM_SHADER_COMPUTE]);
@@ -3207,7 +3210,7 @@ pipeline_compile_compute(struct v3dv_pipeline *pipeline,
    if (info->flags & VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT)
       return VK_PIPELINE_COMPILE_REQUIRED_EXT;
 
-   pipeline->shared_data = v3dv_pipeline_shared_data_new_empty(pipeline_sha1,
+   pipeline->shared_data = v3dv_pipeline_shared_data_new_empty(pipeline->sha1,
                                                                pipeline,
                                                                false);
 
diff --git a/src/broadcom/vulkan/v3dv_private.h b/src/broadcom/vulkan/v3dv_private.h
index a3c3354c397..9636c3f2c47 100644
--- a/src/broadcom/vulkan/v3dv_private.h
+++ b/src/broadcom/vulkan/v3dv_private.h
@@ -1810,6 +1810,9 @@ struct v3dv_pipeline {
 
    struct v3dv_pipeline_shared_data *shared_data;
 
+   /* It is the combined stages sha1, plus the pipeline key sha1. */
+   unsigned char sha1[20];
+
    /* In general we can reuse v3dv_device->default_attribute_float, so note
     * that the following can be NULL.
     *



More information about the mesa-commit mailing list