a lot of casting elsewhere.
Use _mesa_lookup_texture() in tdfx driver, use _mesa_lookup_bufferobj() in r300
driver.
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);
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);
}
}
#include "tdfx_context.h"
#include "tdfx_tex.h"
#include "tdfx_texman.h"
+#include "texobj.h"
#include "hash.h"
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) {
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) {
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 &&
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);
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;
* 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;
}
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);
_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;
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;
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 );
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");
_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;
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;
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;
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;
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)");
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;
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;
/*
* Mesa 3-D graphics library
- * Version: 6.5
+ * Version: 6.5.1
*
* Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
*
}
+/**
+ * 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 */
}
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);
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]);
}
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;
/*
* Mesa 3-D graphics library
- * Version: 6.5
+ * Version: 6.5.1
*
* Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
*
extern void
_mesa_delete_program(GLcontext *ctx, struct gl_program *prog);
+extern struct gl_program *
+_mesa_lookup_program(GLcontext *ctx, GLuint id);
/**