[Mesa-dev] [PATCH v2 1/2] i965: NULL check prog on shader compilation failure.

Matt Turner mattst88 at gmail.com
Thu Apr 11 10:54:30 PDT 2013


Also change if (shader) to if (prog) for consistency.
---
 src/mesa/drivers/dri/i965/brw_fs.cpp   |   12 +++++++-----
 src/mesa/drivers/dri/i965/brw_vec4.cpp |    8 +++++---
 2 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp
index 4338ae6..2b6208c 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs.cpp
@@ -2885,7 +2885,7 @@ brw_wm_fs_emit(struct brw_context *brw, struct brw_wm_compile *c,
       shader = (brw_shader *) prog->_LinkedShaders[MESA_SHADER_FRAGMENT];
 
    if (unlikely(INTEL_DEBUG & DEBUG_WM)) {
-      if (shader) {
+      if (prog) {
          printf("GLSL IR for native fragment shader %d:\n", prog->Name);
          _mesa_print_ir(shader->ir, NULL);
          printf("\n\n");
@@ -2900,11 +2900,13 @@ brw_wm_fs_emit(struct brw_context *brw, struct brw_wm_compile *c,
     */
    fs_visitor v(brw, c, prog, fp, 8);
    if (!v.run()) {
-      prog->LinkStatus = false;
-      ralloc_strcat(&prog->InfoLog, v.fail_msg);
+      if (prog) {
+         prog->LinkStatus = false;
+         ralloc_strcat(&prog->InfoLog, v.fail_msg);
 
-      _mesa_problem(NULL, "Failed to compile fragment shader: %s\n",
-		    v.fail_msg);
+         _mesa_problem(NULL, "Failed to compile fragment shader: %s\n",
+                       v.fail_msg);
+      }
 
       return NULL;
    }
diff --git a/src/mesa/drivers/dri/i965/brw_vec4.cpp b/src/mesa/drivers/dri/i965/brw_vec4.cpp
index b6d454f..4f7b8c0 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4.cpp
@@ -1531,7 +1531,7 @@ brw_vs_emit(struct brw_context *brw,
       shader = (brw_shader *) prog->_LinkedShaders[MESA_SHADER_VERTEX];
 
    if (unlikely(INTEL_DEBUG & DEBUG_VS)) {
-      if (shader) {
+      if (prog) {
          printf("GLSL IR for native vertex shader %d:\n", prog->Name);
          _mesa_print_ir(shader->ir, NULL);
          printf("\n\n");
@@ -1544,8 +1544,10 @@ brw_vs_emit(struct brw_context *brw,
 
    vec4_vs_visitor v(brw, c, prog_data, prog, shader, mem_ctx);
    if (!v.run()) {
-      prog->LinkStatus = false;
-      ralloc_strcat(&prog->InfoLog, v.fail_msg);
+      if (prog) {
+         prog->LinkStatus = false;
+         ralloc_strcat(&prog->InfoLog, v.fail_msg);
+      }
       return NULL;
    }
 
-- 
1.7.8.6



More information about the mesa-dev mailing list