i965: Fix up and actually enable the NewShader and NewShaderProgram hooks.
authorEric Anholt <eric@anholt.net>
Thu, 26 Aug 2010 23:59:55 +0000 (16:59 -0700)
committerEric Anholt <eric@anholt.net>
Fri, 27 Aug 2010 00:00:30 +0000 (17:00 -0700)
src/mesa/drivers/dri/i965/brw_fs.cpp
src/mesa/drivers/dri/i965/brw_program.c

index 11c79b11bfc0e97d711b2ab9b057059cc72e6602..4a313a2e100c9975086647c7e2a2d297234c042f 100644 (file)
@@ -81,9 +81,9 @@ brw_new_shader(GLcontext *ctx, GLuint name, GLuint type)
    struct brw_shader *shader;
 
    shader = talloc_zero(NULL, struct brw_shader);
-   shader->base.Type = type;
-   shader->base.Name = name;
    if (shader) {
+      shader->base.Type = type;
+      shader->base.Name = name;
       _mesa_init_shader(ctx, &shader->base);
    }
 
@@ -96,6 +96,7 @@ brw_new_shader_program(GLcontext *ctx, GLuint name)
    struct brw_shader_program *prog;
    prog = talloc_zero(NULL, struct brw_shader_program);
    if (prog) {
+      prog->base.Name = name;
       _mesa_init_shader_program(ctx, &prog->base);
    }
    return &prog->base;
@@ -123,6 +124,8 @@ brw_link_shader(GLcontext *ctx, struct gl_shader_program *prog)
         void *mem_ctx = talloc_new(NULL);
         bool progress;
 
+        if (shader->ir)
+           talloc_free(shader->ir);
         shader->ir = new(shader) exec_list;
         clone_ir_list(mem_ctx, shader->ir, shader->base.ir);
 
@@ -140,7 +143,7 @@ brw_link_shader(GLcontext *ctx, struct gl_shader_program *prog)
            progress = do_common_optimization(shader->ir, true) || progress;
         } while (progress);
 
-        reparent_ir(shader->ir, shader);
+        reparent_ir(shader->ir, shader->ir);
         talloc_free(mem_ctx);
       }
    }
index b6cf6c000eb87d6e2a1c400e8f84fc58aeae8156..bc152204a42f5a5a31759ff24998eeea9de9afff 100644 (file)
@@ -232,6 +232,8 @@ void brwInitFragProgFuncs( struct dd_function_table *functions )
    functions->IsProgramNative = brwIsProgramNative;
    functions->ProgramStringNotify = brwProgramStringNotify;
 
+   functions->NewShader = brw_new_shader;
+   functions->NewShaderProgram = brw_new_shader_program;
    functions->CompileShader = brw_compile_shader;
    functions->LinkShader = brw_link_shader;
 }