[Mesa-dev] [PATCH 11/11] i965: provide shader cache assemblies to KHR_debug

Mark Janes mark.a.janes at intel.com
Fri Dec 7 00:35:52 UTC 2018


---
 src/mesa/drivers/dri/i965/brw_disk_cache.c | 23 ++++++++++++++++++----
 1 file changed, 19 insertions(+), 4 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_disk_cache.c b/src/mesa/drivers/dri/i965/brw_disk_cache.c
index 65fcab24b7f..0acbef4f20e 100644
--- a/src/mesa/drivers/dri/i965/brw_disk_cache.c
+++ b/src/mesa/drivers/dri/i965/brw_disk_cache.c
@@ -199,16 +199,31 @@ read_and_upload(struct brw_context *brw, struct disk_cache *cache,
    brw_alloc_stage_scratch(brw, stage_state, prog_data->total_scratch);
 
    if (unlikely(debug_enabled_for_stage(stage))) {
-      fprintf(stderr, "NIR for %s program %d loaded from disk shader cache:\n",
+      char *buf;
+      size_t buf_size;
+      FILE * log_fp = open_memstream(&buf, &buf_size);
+      fprintf(log_fp, "NIR for %s program %d loaded from disk shader cache:\n",
               _mesa_shader_stage_to_abbrev(stage), brw_program(prog)->id);
       brw_program_deserialize_driver_blob(&brw->ctx, prog, stage);
       nir_shader *nir = prog->nir;
-      nir_print_shader(nir, stderr);
-      fprintf(stderr, "Native code for %s %s shader %s from disk cache:\n",
+      nir_print_shader(nir, log_fp);
+      fclose(log_fp);
+      static GLuint nir_msg_id = 0;
+      shader_debug_log_mesa(brw, &nir_msg_id, buf);
+      fputs(buf, stderr);
+      free(buf);
+
+      log_fp = open_memstream(&buf, &buf_size);
+      fprintf(log_fp, "Native code for %s %s shader %s from disk cache:\n",
               nir->info.label ? nir->info.label : "unnamed",
               _mesa_shader_stage_to_string(nir->info.stage), nir->info.name);
       brw_disassemble(&brw->screen->devinfo, program, 0,
-                      prog_data->program_size, stderr);
+                      prog_data->program_size, log_fp);
+      fclose(log_fp);
+      static GLuint native_msg_id = 0;
+      shader_debug_log_mesa(brw, &native_msg_id, buf);
+      fputs(buf, stderr);
+      free(buf);
    }
 
    brw_upload_cache(&brw->cache, cache_id, &prog_key, brw_prog_key_size(stage),
-- 
2.19.2



More information about the mesa-dev mailing list