diff options
author | Brian Paul <[email protected]> | 2006-08-23 23:10:14 +0000 |
---|---|---|
committer | Brian Paul <[email protected]> | 2006-08-23 23:10:14 +0000 |
commit | 4d12a05e6c11ca8d7325503131b2594dfe304164 (patch) | |
tree | ddfec24494574b8d9a24fdfdefc5c94b3b105a39 | |
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.
-rw-r--r-- | src/mesa/drivers/dri/r300/radeon_vtxfmt_a.c | 6 | ||||
-rw-r--r-- | src/mesa/drivers/dri/tdfx/tdfx_context.c | 2 | ||||
-rw-r--r-- | src/mesa/drivers/dri/tdfx/tdfx_texman.c | 13 | ||||
-rw-r--r-- | src/mesa/main/bufferobj.c | 10 | ||||
-rw-r--r-- | src/mesa/main/bufferobj.h | 3 | ||||
-rw-r--r-- | src/mesa/shader/nvprogram.c | 18 | ||||
-rw-r--r-- | src/mesa/shader/program.c | 23 | ||||
-rw-r--r-- | src/mesa/shader/program.h | 4 |
8 files changed, 48 insertions, 31 deletions
diff --git a/src/mesa/drivers/dri/r300/radeon_vtxfmt_a.c b/src/mesa/drivers/dri/r300/radeon_vtxfmt_a.c index a7db8dae63b..d3a4bfcd2f5 100644 --- a/src/mesa/drivers/dri/r300/radeon_vtxfmt_a.c +++ b/src/mesa/drivers/dri/r300/radeon_vtxfmt_a.c @@ -749,13 +749,13 @@ void r300_evict_vbos(GLcontext *ctx, int amount) r300ContextPtr rmesa = R300_CONTEXT(ctx); struct _mesa_HashTable *hash = ctx->Shared->BufferObjects; GLuint k = _mesa_HashFirstEntry(hash); - struct gl_buffer_object *obj; struct r300_buffer_object *r300_obj; GLvoid *data; while (amount > 0 && k) { - obj = (struct gl_buffer_object *) _mesa_HashLookup(hash, k); - r300_obj = (struct r300_buffer_object *) obj; + struct gl_buffer_object *obj = _mesa_lookup_bufferobj(ctx, k); + struct r300_buffer_object *r300_obj + = (struct r300_buffer_object *) obj; if (obj->OnCard && obj->Size) { obj->Data = _mesa_malloc(obj->Size); diff --git a/src/mesa/drivers/dri/tdfx/tdfx_context.c b/src/mesa/drivers/dri/tdfx/tdfx_context.c index 826a9f71dfe..8d8a629474c 100644 --- a/src/mesa/drivers/dri/tdfx/tdfx_context.c +++ b/src/mesa/drivers/dri/tdfx/tdfx_context.c @@ -602,7 +602,7 @@ tdfxDestroyContext( __DRIcontextPrivate *driContextPriv ) id; id = _mesa_HashNextEntry(textures, id)) { struct gl_texture_object *tObj - = (struct gl_texture_object *) _mesa_HashLookup(textures, id); + = _mesa_lookup_texture(fxMesa->glCtx, id); tdfxTMFreeTexture(fxMesa, tObj); } } diff --git a/src/mesa/drivers/dri/tdfx/tdfx_texman.c b/src/mesa/drivers/dri/tdfx/tdfx_texman.c index 63cae17e4e9..6f782f687f3 100644 --- a/src/mesa/drivers/dri/tdfx/tdfx_texman.c +++ b/src/mesa/drivers/dri/tdfx/tdfx_texman.c @@ -38,6 +38,7 @@ #include "tdfx_context.h" #include "tdfx_tex.h" #include "tdfx_texman.h" +#include "texobj.h" #include "hash.h" @@ -82,8 +83,8 @@ VerifyFreeList(tdfxContextPtr fxMesa, FxU32 tmu) for (id = _mesa_HashFirstEntry(textures); id; id = _mesa_HashNextEntry(textures, id)) { - struct gl_texture_object *tObj; - tObj = (struct gl_texture_object *) _mesa_HashLookup(textures, id); + struct gl_texture_object *tObj + = _mesa_lookup_texture(fxMesa->glCtx, id); tdfxTexInfo *ti = TDFX_TEXTURE_DATA(tObj); if (ti) { if (ti->isInTM) { @@ -122,7 +123,7 @@ dump_texmem(tdfxContextPtr fxMesa) id; id = _mesa_HashNextEntry(textures, id)) { struct gl_texture_object *obj - = (struct gl_texture_object *) _mesa_HashLookup(textures, id); + = _mesa_lookup_texture(fxMesa->glCtx, id); tdfxTexInfo *info = TDFX_TEXTURE_DATA(obj); if (info && info->isInTM) { @@ -404,7 +405,7 @@ FindOldestObject(tdfxContextPtr fxMesa, FxU32 tmu) id; id = _mesa_HashNextEntry(textures, id)) { struct gl_texture_object *obj - = (struct gl_texture_object *) _mesa_HashLookup(textures, id); + = _mesa_lookup_texture(fxMesa->glCtx, id); tdfxTexInfo *info = TDFX_TEXTURE_DATA(obj); if (info && info->isInTM && @@ -460,7 +461,7 @@ FlushTexMemory(tdfxContextPtr fxMesa) id; id = _mesa_HashNextEntry(textures, id)) { struct gl_texture_object *obj - = (struct gl_texture_object *) _mesa_HashLookup(textures, id); + = _mesa_lookup_texture(fxMesa->glCtx, id); if (obj->RefCount < 2) { /* don't flush currently bound textures */ tdfxTMMoveOutTM_NoLock(fxMesa, obj); @@ -972,7 +973,7 @@ void tdfxTMRestoreTextures_NoLock( tdfxContextPtr fxMesa ) id; id = _mesa_HashNextEntry(textures, id)) { struct gl_texture_object *tObj - = (struct gl_texture_object *) _mesa_HashLookup(textures, id); + = _mesa_lookup_texture(fxMesa->glCtx, id); tdfxTexInfo *ti = TDFX_TEXTURE_DATA( tObj ); if ( ti && ti->isInTM ) { int i; diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c index 366ffbb30ef..1d0f4b40679 100644 --- a/src/mesa/main/bufferobj.c +++ b/src/mesa/main/bufferobj.c @@ -469,8 +469,8 @@ _mesa_validate_pbo_access(GLuint dimensions, * Return the gl_buffer_object for the given ID. * Always return NULL for ID 0. */ -static INLINE struct gl_buffer_object * -lookup_bufferobj(GLcontext *ctx, GLuint buffer) +struct gl_buffer_object * +_mesa_lookup_bufferobj(GLcontext *ctx, GLuint buffer) { if (buffer == 0) return NULL; @@ -508,7 +508,7 @@ _mesa_BindBufferARB(GLenum target, GLuint buffer) } else { /* non-default buffer object */ - newBufObj = lookup_bufferobj(ctx, buffer); + newBufObj = _mesa_lookup_bufferobj(ctx, buffer); if (!newBufObj) { /* if this is a new buffer object id, allocate a buffer object now */ ASSERT(ctx->Driver.NewBufferObject); @@ -577,7 +577,7 @@ _mesa_DeleteBuffersARB(GLsizei n, const GLuint *ids) _glthread_LOCK_MUTEX(ctx->Shared->Mutex); for (i = 0; i < n; i++) { - struct gl_buffer_object *bufObj = lookup_bufferobj(ctx, ids[i]); + struct gl_buffer_object *bufObj = _mesa_lookup_bufferobj(ctx, ids[i]); if (bufObj) { /* unbind any vertex pointers bound to this buffer */ GLuint j; @@ -722,7 +722,7 @@ _mesa_IsBufferARB(GLuint id) ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE); _glthread_LOCK_MUTEX(ctx->Shared->Mutex); - bufObj = lookup_bufferobj(ctx, id); + bufObj = _mesa_lookup_bufferobj(ctx, id); _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex); return bufObj ? GL_TRUE : GL_FALSE; diff --git a/src/mesa/main/bufferobj.h b/src/mesa/main/bufferobj.h index 05e27c984ea..f54f9e9ff00 100644 --- a/src/mesa/main/bufferobj.h +++ b/src/mesa/main/bufferobj.h @@ -44,6 +44,9 @@ _mesa_new_buffer_object( GLcontext *ctx, GLuint name, GLenum target ); extern void _mesa_delete_buffer_object( GLcontext *ctx, struct gl_buffer_object *bufObj ); +extern struct gl_buffer_object * +_mesa_lookup_bufferobj(GLcontext *ctx, GLuint buffer); + extern void _mesa_initialize_buffer_object( struct gl_buffer_object *obj, GLuint name, GLenum target ); 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); /** |