summaryrefslogtreecommitdiffstats
path: root/src/mesa/shader
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2006-08-23 23:10:14 +0000
committerBrian Paul <[email protected]>2006-08-23 23:10:14 +0000
commit4d12a05e6c11ca8d7325503131b2594dfe304164 (patch)
treeddfec24494574b8d9a24fdfdefc5c94b3b105a39 /src/mesa/shader
parent261a806f9e26347d756bddeae81f4e98325b8e84 (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')
-rw-r--r--src/mesa/shader/nvprogram.c18
-rw-r--r--src/mesa/shader/program.c23
-rw-r--r--src/mesa/shader/program.h4
3 files changed, 29 insertions, 16 deletions
diff --git a/src/mesa/shader/nvprogram.c b/src/mesa/shader/nvprogram.c
index 46bc5b35f82..4e29e0b3f88 100644
--- a/src/mesa/shader/nvprogram.c
+++ b/src/mesa/shader/nvprogram.c
@@ -70,8 +70,7 @@ _mesa_ExecuteProgramNV(GLenum target, GLuint id, const GLfloat *params)
FLUSH_VERTICES(ctx, _NEW_PROGRAM);
- vprog = (struct gl_vertex_program *)
- _mesa_HashLookup(ctx->Shared->Programs, id);
+ vprog = (struct gl_vertex_program *) _mesa_lookup_program(ctx, id);
if (!vprog || vprog->Base.Target != GL_VERTEX_STATE_PROGRAM_NV) {
_mesa_error(ctx, GL_INVALID_OPERATION, "glExecuteProgramNV");
@@ -109,8 +108,7 @@ GLboolean GLAPIENTRY _mesa_AreProgramsResidentNV(GLsizei n, const GLuint *ids,
_mesa_error(ctx, GL_INVALID_VALUE, "glAreProgramsResidentNV");
return GL_FALSE;
}
- prog = (const struct gl_program *)
- _mesa_HashLookup(ctx->Shared->Programs, ids[i]);
+ prog = _mesa_lookup_program(ctx, ids[i]);
if (!prog) {
_mesa_error(ctx, GL_INVALID_VALUE, "glAreProgramsResidentNV");
return GL_FALSE;
@@ -158,7 +156,7 @@ _mesa_RequestResidentProgramsNV(GLsizei n, const GLuint *ids)
return;
}
- prog = (struct gl_program *) _mesa_HashLookup(ctx->Shared->Programs, ids[i]);
+ prog = _mesa_lookup_program(ctx, ids[i]);
if (!prog) {
_mesa_error(ctx, GL_INVALID_VALUE, "glRequestResidentProgramsNV(id)");
return;
@@ -254,7 +252,7 @@ _mesa_GetProgramivNV(GLuint id, GLenum pname, GLint *params)
if (!ctx->_CurrentProgram)
ASSERT_OUTSIDE_BEGIN_END(ctx);
- prog = (struct gl_program *) _mesa_HashLookup(ctx->Shared->Programs, id);
+ prog = _mesa_lookup_program(ctx, id);
if (!prog) {
_mesa_error(ctx, GL_INVALID_OPERATION, "glGetProgramivNV");
return;
@@ -296,7 +294,7 @@ _mesa_GetProgramStringNV(GLuint id, GLenum pname, GLubyte *program)
return;
}
- prog = (struct gl_program *) _mesa_HashLookup(ctx->Shared->Programs, id);
+ prog = _mesa_lookup_program(ctx, id);
if (!prog) {
_mesa_error(ctx, GL_INVALID_OPERATION, "glGetProgramStringNV");
return;
@@ -522,7 +520,7 @@ _mesa_LoadProgramNV(GLenum target, GLuint id, GLsizei len,
FLUSH_VERTICES(ctx, _NEW_PROGRAM);
- prog = (struct gl_program *) _mesa_HashLookup(ctx->Shared->Programs, id);
+ prog = _mesa_lookup_program(ctx, id);
if (prog && prog->Target != 0 && prog->Target != target) {
_mesa_error(ctx, GL_INVALID_OPERATION, "glLoadProgramNV(target)");
@@ -773,7 +771,7 @@ _mesa_ProgramNamedParameter4fNV(GLuint id, GLsizei len, const GLubyte *name,
FLUSH_VERTICES(ctx, _NEW_PROGRAM);
- prog = (struct gl_program *) _mesa_HashLookup(ctx->Shared->Programs, id);
+ prog = _mesa_lookup_program(ctx, id);
if (!prog || prog->Target != GL_FRAGMENT_PROGRAM_NV) {
_mesa_error(ctx, GL_INVALID_OPERATION, "glProgramNamedParameterNV");
return;
@@ -839,7 +837,7 @@ _mesa_GetProgramNamedParameterfvNV(GLuint id, GLsizei len, const GLubyte *name,
if (!ctx->_CurrentProgram)
ASSERT_OUTSIDE_BEGIN_END(ctx);
- prog = (struct gl_program *) _mesa_HashLookup(ctx->Shared->Programs, id);
+ prog = _mesa_lookup_program(ctx, id);
if (!prog || prog->Target != GL_FRAGMENT_PROGRAM_NV) {
_mesa_error(ctx, GL_INVALID_OPERATION, "glGetProgramNamedParameterNV");
return;
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;
diff --git a/src/mesa/shader/program.h b/src/mesa/shader/program.h
index 3d50c23b4ed..1d91e63af50 100644
--- a/src/mesa/shader/program.h
+++ b/src/mesa/shader/program.h
@@ -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.
*
@@ -111,6 +111,8 @@ _mesa_new_program(GLcontext *ctx, GLenum target, GLuint id);
extern void
_mesa_delete_program(GLcontext *ctx, struct gl_program *prog);
+extern struct gl_program *
+_mesa_lookup_program(GLcontext *ctx, GLuint id);
/**