X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fmesa%2Fprogram%2Fprogram.c;h=ecff2344a4473d02b8aaf855111150daadba58fb;hb=2e71c7d4ffa439dace639bd9c66174544dcd02d7;hp=78efca9f122bb2b136073f21191a8655a67fbfdb;hpb=4d203a01e20dedcfaab09c18922e8ed9dcb39729;p=mesa.git diff --git a/src/mesa/program/program.c b/src/mesa/program/program.c index 78efca9f122..ecff2344a44 100644 --- a/src/mesa/program/program.c +++ b/src/mesa/program/program.c @@ -388,8 +388,9 @@ _mesa_delete_program(struct gl_context *ctx, struct gl_program *prog) if (prog->String) free(prog->String); - _mesa_free_instructions(prog->Instructions, prog->NumInstructions); - + if (prog->Instructions) { + _mesa_free_instructions(prog->Instructions, prog->NumInstructions); + } if (prog->Parameters) { _mesa_free_parameter_list(prog->Parameters); } @@ -421,12 +422,15 @@ _mesa_lookup_program(struct gl_context *ctx, GLuint id) /** * Reference counting for vertex/fragment programs + * This is normally only called from the _mesa_reference_program() macro + * when there's a real pointer change. */ void -_mesa_reference_program(struct gl_context *ctx, - struct gl_program **ptr, - struct gl_program *prog) +_mesa_reference_program_(struct gl_context *ctx, + struct gl_program **ptr, + struct gl_program *prog) { +#ifndef NDEBUG assert(ptr); if (*ptr && prog) { /* sanity check */ @@ -438,9 +442,8 @@ _mesa_reference_program(struct gl_context *ctx, else if ((*ptr)->Target == MESA_GEOMETRY_PROGRAM) ASSERT(prog->Target == MESA_GEOMETRY_PROGRAM); } - if (*ptr == prog) { - return; /* no change */ - } +#endif + if (*ptr) { GLboolean deleteFlag; @@ -1029,7 +1032,8 @@ _mesa_postprocess_program(struct gl_context *ctx, struct gl_program *prog) GLuint i; GLuint whiteSwizzle; GLint whiteIndex = _mesa_add_unnamed_constant(prog->Parameters, - white, 4, &whiteSwizzle); + (gl_constant_value *) white, + 4, &whiteSwizzle); (void) whiteIndex;