glsl: don't crash when dumping shaders if some come from cache
authorTimothy Arceri <timothy.arceri@collabora.com>
Sun, 27 Mar 2016 05:25:12 +0000 (16:25 +1100)
committerTimothy Arceri <timothy.arceri@collabora.com>
Wed, 28 Sep 2016 00:43:15 +0000 (10:43 +1000)
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
src/mesa/drivers/dri/i965/brw_link.cpp
src/mesa/main/shaderapi.c

index e528411f75635db0a8966b0da628e1aef8d65156..02151d681ebb9bd3739858881030f11102190dd1 100644 (file)
@@ -183,10 +183,16 @@ process_glsl_ir(struct brw_context *brw,
 
    if (ctx->_Shader->Flags & GLSL_DUMP) {
       fprintf(stderr, "\n");
-      fprintf(stderr, "GLSL IR for linked %s program %d:\n",
-              _mesa_shader_stage_to_string(shader->Stage),
-              shader_prog->Name);
-      _mesa_print_ir(stderr, shader->ir, NULL);
+      if (shader->ir) {
+         fprintf(stderr, "GLSL IR for linked %s program %d:\n",
+                 _mesa_shader_stage_to_string(shader->Stage),
+                 shader_prog->Name);
+         _mesa_print_ir(stderr, shader->ir, NULL);
+      } else {
+         fprintf(stderr, "No GLSL IR for linked %s program %d (shader may be "
+                 "from cache)\n", _mesa_shader_stage_to_string(shader->Stage),
+                 shader_prog->Name);
+      }
       fprintf(stderr, "\n");
    }
 }
index 4ebc39febbb9b23d1b212f240ef18e87ed66f3d1..1af1c3f57948caf7c520de0fd6dd3da6de9d7518 100644 (file)
@@ -1039,8 +1039,13 @@ _mesa_compile_shader(struct gl_context *ctx, struct gl_shader *sh)
 
       if (ctx->_Shader->Flags & GLSL_DUMP) {
          if (sh->CompileStatus) {
-            _mesa_log("GLSL IR for shader %d:\n", sh->Name);
-            _mesa_print_ir(_mesa_get_log_file(), sh->ir, NULL);
+            if (sh->ir) {
+               _mesa_log("GLSL IR for shader %d:\n", sh->Name);
+               _mesa_print_ir(_mesa_get_log_file(), sh->ir, NULL);
+            } else {
+               _mesa_log("No GLSL IR for shader %d (shader may be from "
+                         "cache)\n", sh->Name);
+            }
             _mesa_log("\n\n");
          } else {
             _mesa_log("GLSL shader %d failed to compile.\n", sh->Name);