From 4d12a05e6c11ca8d7325503131b2594dfe304164 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 23 Aug 2006 23:10:14 +0000 Subject: Added _mesa_lookup_program() and _mesa_lookup_bufferobj() functions to avoid a lot of casting elsewhere. Use _mesa_lookup_texture() in tdfx driver, use _mesa_lookup_bufferobj() in r300 driver. --- src/mesa/shader/program.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'src/mesa/shader/program.c') diff --git a/src/mesa/shader/program.c b/src/mesa/shader/program.c index 352ed93465e..371500304f4 100644 --- a/src/mesa/shader/program.c +++ b/src/mesa/shader/program.c @@ -1,6 +1,6 @@ /* * Mesa 3-D graphics library - * Version: 6.5 + * Version: 6.5.1 * * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. * @@ -304,6 +304,20 @@ _mesa_delete_program(GLcontext *ctx, struct gl_program *prog) } +/** + * Return the gl_program object for a given ID. + * Basically just a wrapper for _mesa_HashLookup() to avoid a lot of + * casts elsewhere. + */ +struct gl_program * +_mesa_lookup_program(GLcontext *ctx, GLuint id) +{ + if (id) + return (struct gl_program *) _mesa_HashLookup(ctx->Shared->Programs, id); + else + return NULL; +} + /**********************************************************************/ /* Program parameter functions */ @@ -1753,7 +1767,7 @@ _mesa_BindProgram(GLenum target, GLuint id) } else { /* Bind user program */ - prog = (struct gl_program *) _mesa_HashLookup(ctx->Shared->Programs, id); + prog = _mesa_lookup_program(ctx, id); if (!prog || prog == &_mesa_DummyProgram) { /* allocate a new program now */ prog = ctx->Driver.NewProgram(ctx, target, id); @@ -1809,8 +1823,7 @@ _mesa_DeletePrograms(GLsizei n, const GLuint *ids) for (i = 0; i < n; i++) { if (ids[i] != 0) { - struct gl_program *prog = (struct gl_program *) - _mesa_HashLookup(ctx->Shared->Programs, ids[i]); + struct gl_program *prog = _mesa_lookup_program(ctx, ids[i]); if (prog == &_mesa_DummyProgram) { _mesa_HashRemove(ctx->Shared->Programs, ids[i]); } @@ -1899,7 +1912,7 @@ _mesa_IsProgram(GLuint id) if (id == 0) return GL_FALSE; - if (_mesa_HashLookup(ctx->Shared->Programs, id)) + if (_mesa_lookup_program(ctx, id)) return GL_TRUE; else return GL_FALSE; -- cgit v1.2.3