#include "imports.h"
#include "buffers.h"
#include "context.h"
+#include "program.h"
#include "texformat.h"
#include "teximage.h"
#include "texobj.h"
driver->CopyConvolutionFilter1D = _swrast_CopyConvolutionFilter1D;
driver->CopyConvolutionFilter2D = _swrast_CopyConvolutionFilter2D;
+ /* Vertex/fragment programs */
+ driver->BindProgram = NULL;
+ driver->NewProgram = _mesa_new_program;
+ driver->DeleteProgram = _mesa_delete_program;
+
/* simple state commands */
driver->AlphaFunc = NULL;
driver->BlendColor = NULL;
/*
* Mesa 3-D graphics library
- * Version: 5.1
+ * Version: 6.1
*
- * Copyright (C) 1999-2002 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
#endif
#if FEATURE_ARB_vertex_program
- ss->DefaultVertexProgram = _mesa_alloc_program(ctx, GL_VERTEX_PROGRAM_ARB, 0);
+ ss->DefaultVertexProgram = ctx->Driver.NewProgram(ctx, GL_VERTEX_PROGRAM_ARB, 0);
if (!ss->DefaultVertexProgram)
goto cleanup;
#endif
#if FEATURE_ARB_fragment_program
- ss->DefaultFragmentProgram = _mesa_alloc_program(ctx, GL_FRAGMENT_PROGRAM_ARB, 0);
+ ss->DefaultFragmentProgram = ctx->Driver.NewProgram(ctx, GL_FRAGMENT_PROGRAM_ARB, 0);
if (!ss->DefaultFragmentProgram)
goto cleanup;
#endif
#endif
#if FEATURE_ARB_vertex_program
if (ss->DefaultVertexProgram)
- _mesa_delete_program(ctx, ss->DefaultVertexProgram);
+ ctx->Driver.DeleteProgram(ctx, ss->DefaultVertexProgram);
#endif
#if FEATURE_ARB_fragment_program
if (ss->DefaultFragmentProgram)
- _mesa_delete_program(ctx, ss->DefaultFragmentProgram);
+ ctx->Driver.DeleteProgram(ctx, ss->DefaultFragmentProgram);
#endif
if (ss->BufferObjects)
_mesa_DeleteHashTable(ss->BufferObjects);
struct program *p = (struct program *) _mesa_HashLookup(ss->Programs,
prog);
ASSERT(p);
- _mesa_delete_program(ctx, p);
+ ctx->Driver.DeleteProgram(ctx, p);
_mesa_HashRemove(ss->Programs, prog);
}
else {
}
-static void _mesa_init_current( GLcontext *ctx )
+/**
+ * Initialize fields of gl_current_attrib (aka ctx->Current.*)
+ */
+static void
+_mesa_init_current( GLcontext *ctx )
{
int i;
}
+/**
+ * Initialize fields of gl_constants (aka ctx->Const.*).
+ * Use defaults from config.h. The device drivers will often override
+ * some of these values (such as number of texture units).
+ */
static void
_mesa_init_constants( GLcontext *ctx )
{
ASSERT(ctx->Const.MaxTextureUnits == MAX2(ctx->Const.MaxTextureImageUnits, ctx->Const.MaxTextureCoordUnits));
}
+
/**
* Initialize the attribute groups in a GL context.
*
if (ctx->VertexProgram.Current) {
ctx->VertexProgram.Current->Base.RefCount--;
if (ctx->VertexProgram.Current->Base.RefCount <= 0)
- _mesa_delete_program(ctx, &(ctx->VertexProgram.Current->Base));
+ ctx->Driver.DeleteProgram(ctx, &(ctx->VertexProgram.Current->Base));
}
#endif
#if FEATURE_NV_fragment_program
if (ctx->FragmentProgram.Current) {
ctx->FragmentProgram.Current->Base.RefCount--;
if (ctx->FragmentProgram.Current->Base.RefCount <= 0)
- _mesa_delete_program(ctx, &(ctx->FragmentProgram.Current->Base));
+ ctx->Driver.DeleteProgram(ctx, &(ctx->FragmentProgram.Current->Base));
}
#endif
/*@}*/
+ /**
+ * \name Vertex/fragment program functions
+ */
+ /*@{*/
+ /** Bind a vertex/fragment program */
+ void (*BindProgram)(GLcontext *ctx, GLenum target, struct program *prog);
+ /** Allocate a new program */
+ struct program * (*NewProgram)(GLcontext *ctx, GLenum target, GLuint id);
+ /** Delete a program */
+ void (*DeleteProgram)(GLcontext *ctx, struct program *prog);
+ /*@}*/
+
+
/**
* \name State-changing functions.
*
/**
- * Allocate and initialize a new fragment/vertex program object
+ * Allocate and initialize a new fragment/vertex program object but don't
+ * put it into the program hash table.
+ * Called via ctx->Driver.NewProgram. May be wrapped (OO deriviation)
+ * by a device driver function.
* \param ctx context
* \param id program id/number
* \param target program target/type
* \return pointer to new program object
*/
struct program *
-_mesa_alloc_program(GLcontext *ctx, GLenum target, GLuint id)
+_mesa_new_program(GLcontext *ctx, GLenum target, GLuint id)
{
struct program *prog;
prog = &(fprog->Base);
}
else {
- _mesa_problem(ctx, "bad target in _mesa_alloc_program");
+ _mesa_problem(ctx, "bad target in _mesa_new_program");
return NULL;
}
prog->Id = id;
/**
* Delete a program and remove it from the hash table, ignoring the
* reference count.
+ * Called via ctx->Driver.DeleteProgram. May be wrapped (OO deriviation)
+ * by a device driver function.
*/
void
_mesa_delete_program(GLcontext *ctx, struct program *prog)
ctx->VertexProgram.Current->Base.RefCount--;
/* and delete if refcount goes below one */
if (ctx->VertexProgram.Current->Base.RefCount <= 0) {
- _mesa_delete_program(ctx, &(ctx->VertexProgram.Current->Base));
+ ctx->Driver.DeleteProgram(ctx, &(ctx->VertexProgram.Current->Base));
_mesa_HashRemove(ctx->Shared->Programs, id);
}
}
ctx->FragmentProgram.Current->Base.RefCount--;
/* and delete if refcount goes below one */
if (ctx->FragmentProgram.Current->Base.RefCount <= 0) {
- _mesa_delete_program(ctx, &(ctx->FragmentProgram.Current->Base));
+ ctx->Driver.DeleteProgram(ctx, &(ctx->FragmentProgram.Current->Base));
_mesa_HashRemove(ctx->Shared->Programs, id);
}
}
}
else {
/* allocate a new program now */
- prog = _mesa_alloc_program(ctx, target, id);
+ prog = ctx->Driver.NewProgram(ctx, target, id);
if (!prog) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glBindProgramNV/ARB");
return;
if (prog)
prog->RefCount++;
+
+ if (ctx->Driver.BindProgram)
+ ctx->Driver.BindProgram(ctx, target, prog);
}
}
prog->RefCount--;
if (prog->RefCount <= 0) {
- _mesa_delete_program(ctx, prog);
+ ctx->Driver.DeleteProgram(ctx, prog);
}
}
}
GLint *line, GLint *col);
extern struct program *
-_mesa_alloc_program(GLcontext *ctx, GLenum target, GLuint id);
+_mesa_new_program(GLcontext *ctx, GLenum target, GLuint id);
extern void
_mesa_delete_program(GLcontext *ctx, struct program *prog);