/**
* 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 */
else if ((*ptr)->Target == MESA_GEOMETRY_PROGRAM)
ASSERT(prog->Target == MESA_GEOMETRY_PROGRAM);
}
- if (*ptr == prog) {
- return; /* no change */
- }
+#endif
+
if (*ptr) {
GLboolean deleteFlag;
_mesa_lookup_program(struct gl_context *ctx, GLuint id);
extern void
+_mesa_reference_program_(struct gl_context *ctx,
+ struct gl_program **ptr,
+ struct gl_program *prog);
+
+static INLINE void
_mesa_reference_program(struct gl_context *ctx,
struct gl_program **ptr,
- struct gl_program *prog);
+ struct gl_program *prog)
+{
+ if (*ptr != prog)
+ _mesa_reference_program_(ctx, ptr, prog);
+}
static INLINE void
_mesa_reference_vertprog(struct gl_context *ctx,