ir_to_mesa: Respect the driver if it rejects a shader.
authorEric Anholt <eric@anholt.net>
Wed, 28 Jul 2010 22:42:35 +0000 (15:42 -0700)
committerEric Anholt <eric@anholt.net>
Wed, 28 Jul 2010 22:51:36 +0000 (15:51 -0700)
src/mesa/drivers/dri/i965/brw_program.c
src/mesa/program/ir_to_mesa.cpp

index 4b08d2599bc0b1c49546856366f437a6dc80cb15..c6d11fed064e2156b9db6ccb913a89c8ca67408e 100644 (file)
@@ -36,6 +36,7 @@
 #include "program/program.h"
 #include "program/programopt.h"
 #include "tnl/tnl.h"
+#include "talloc.h"
 
 #include "brw_context.h"
 #include "brw_wm.h"
@@ -114,10 +115,7 @@ shader_error(GLcontext *ctx, struct gl_program *prog, const char *msg)
    shader = _mesa_lookup_shader_program(ctx, prog->Id);
 
    if (shader) {
-      if (shader->InfoLog) {
-        free(shader->InfoLog);
-      }
-      shader->InfoLog = _mesa_strdup(msg);
+      shader->InfoLog = talloc_strdup_append(shader->InfoLog, msg);
       shader->LinkStatus = GL_FALSE;
    }
 }
index a3019cc650af4565065e9d8e640ec6e5e66b053d..3a28c566d4d2e078e53a0e9736f98b289015e510 100644 (file)
@@ -2320,7 +2320,7 @@ get_mesa_program(GLcontext *ctx, struct gl_shader_program *shader_program,
 
    validate_ir_tree(shader->ir);
 
-   prog = ctx->Driver.NewProgram(ctx, target, 1);
+   prog = ctx->Driver.NewProgram(ctx, target, shader_program->Name);
    if (!prog)
       return NULL;
    prog->Parameters = _mesa_new_parameter_list();
@@ -2536,6 +2536,7 @@ _mesa_glsl_link_shader(GLcontext *ctx, struct gl_shader_program *prog)
    if (prog->LinkStatus) {
       for (i = 0; i < prog->_NumLinkedShaders; i++) {
         struct gl_program *linked_prog;
+        bool ok = true;
 
         linked_prog = get_mesa_program(ctx, prog,
                                        prog->_LinkedShaders[i]);
@@ -2547,16 +2548,19 @@ _mesa_glsl_link_shader(GLcontext *ctx, struct gl_shader_program *prog)
         case GL_VERTEX_SHADER:
            _mesa_reference_vertprog(ctx, &prog->VertexProgram,
                                     (struct gl_vertex_program *)linked_prog);
-           ctx->Driver.ProgramStringNotify(ctx, GL_VERTEX_PROGRAM_ARB,
-                                           linked_prog);
+           ok = ctx->Driver.ProgramStringNotify(ctx, GL_VERTEX_PROGRAM_ARB,
+                                                linked_prog);
            break;
         case GL_FRAGMENT_SHADER:
            _mesa_reference_fragprog(ctx, &prog->FragmentProgram,
                                     (struct gl_fragment_program *)linked_prog);
-           ctx->Driver.ProgramStringNotify(ctx, GL_FRAGMENT_PROGRAM_ARB,
-                                           linked_prog);
+           ok = ctx->Driver.ProgramStringNotify(ctx, GL_FRAGMENT_PROGRAM_ARB,
+                                                linked_prog);
            break;
         }
+        if (!ok) {
+           prog->LinkStatus = GL_FALSE;
+        }
       }
    }
 }