From: Timothy Arceri Date: Sun, 27 Mar 2016 05:25:12 +0000 (+1100) Subject: glsl: don't crash when dumping shaders if some come from cache X-Git-Tag: upstream/17.1.0~6132 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3eb0baeecfed7a2de2b323e1b5d90e2b14dfc803;p=platform%2Fupstream%2Fmesa.git glsl: don't crash when dumping shaders if some come from cache Reviewed-by: Kenneth Graunke --- diff --git a/src/mesa/drivers/dri/i965/brw_link.cpp b/src/mesa/drivers/dri/i965/brw_link.cpp index e528411..02151d6 100644 --- a/src/mesa/drivers/dri/i965/brw_link.cpp +++ b/src/mesa/drivers/dri/i965/brw_link.cpp @@ -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"); } } diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c index 4ebc39f..1af1c3f 100644 --- a/src/mesa/main/shaderapi.c +++ b/src/mesa/main/shaderapi.c @@ -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);