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@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13938>
This commit is contained in:
Alejandro Piñeiro 2021-11-23 00:46:48 +01:00 committed by Marge Bot
parent 6c78ec4eac
commit a9b4aef0f2
3 changed files with 15 additions and 9 deletions

View file

@ -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);

View file

@ -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);

View file

@ -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.
*