diff options
author | Brian Paul <brian.paul@tungstengraphics.com> | 2006-08-23 23:10:14 +0000 |
---|---|---|
committer | Brian Paul <brian.paul@tungstengraphics.com> | 2006-08-23 23:10:14 +0000 |
commit | 4d12a05e6c11ca8d7325503131b2594dfe304164 (patch) | |
tree | ddfec24494574b8d9a24fdfdefc5c94b3b105a39 /src/mesa/shader/program.c | |
parent | 261a806f9e26347d756bddeae81f4e98325b8e84 (diff) |
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.
Diffstat (limited to 'src/mesa/shader/program.c')
-rw-r--r-- | src/mesa/shader/program.c | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/src/mesa/shader/program.c b/src/mesa/shader/program.c index 352ed93465..371500304f 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; |