New st_init_*_functions() to initialize the driver functions table.

We need to do these initializations before initializing the Mesa context
because context init involves creating texture/program/etc objects.
This commit is contained in:
Brian
2007-08-06 20:53:28 +01:00
parent 8ebf91d15e
commit 6da9234fd4
14 changed files with 60 additions and 87 deletions

View File

@@ -192,15 +192,13 @@ st_bufferobj_unmap(GLcontext *ctx,
void
st_init_cb_bufferobjects( struct st_context *st )
st_init_bufferobject_functions(struct dd_function_table *functions)
{
GLcontext *ctx = st->ctx;
ctx->Driver.NewBufferObject = st_bufferobj_alloc;
ctx->Driver.DeleteBuffer = st_bufferobj_free;
ctx->Driver.BufferData = st_bufferobj_data;
ctx->Driver.BufferSubData = st_bufferobj_subdata;
ctx->Driver.GetBufferSubData = st_bufferobj_get_subdata;
ctx->Driver.MapBuffer = st_bufferobj_map;
ctx->Driver.UnmapBuffer = st_bufferobj_unmap;
functions->NewBufferObject = st_bufferobj_alloc;
functions->DeleteBuffer = st_bufferobj_free;
functions->BufferData = st_bufferobj_data;
functions->BufferSubData = st_bufferobj_subdata;
functions->GetBufferSubData = st_bufferobj_get_subdata;
functions->MapBuffer = st_bufferobj_map;
functions->UnmapBuffer = st_bufferobj_unmap;
}

View File

@@ -43,11 +43,6 @@ struct st_buffer_object
};
/* Hook the bufferobject implementation into mesa:
*/
void st_init_cb_bufferobjects( struct st_context *st );
/* Are the obj->Name tests necessary? Unfortunately yes, mesa
* allocates a couple of gl_buffer_object structs statically, and the
* Name == 0 test is the only way to identify them and avoid casting
@@ -63,4 +58,8 @@ st_buffer_object(struct gl_buffer_object *obj)
}
extern void
st_init_bufferobject_functions(struct dd_function_table *functions);
#endif

View File

@@ -418,15 +418,7 @@ static void st_clear(GLcontext *ctx, GLbitfield mask)
}
void st_init_cb_clear( struct st_context *st )
void st_init_clear_functions(struct dd_function_table *functions)
{
struct dd_function_table *functions = &st->ctx->Driver;
functions->Clear = st_clear;
}
void st_destroy_cb_clear( struct st_context *st )
{
}

View File

@@ -29,9 +29,10 @@
#ifndef ST_CB_CLEAR_H
#define ST_CB_CLEAR_H
extern void st_init_cb_clear( struct st_context *st );
extern void st_destroy_cb_clear( struct st_context *st );
extern void
st_init_clear_functions(struct dd_function_table *functions);
#endif /* ST_CB_CLEAR_H */

View File

@@ -262,14 +262,8 @@ st_drawpixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height,
}
void st_init_cb_drawpixels( struct st_context *st )
void st_init_drawpixels_functions(struct dd_function_table *functions)
{
struct dd_function_table *functions = &st->ctx->Driver;
functions->DrawPixels = st_drawpixels;
}
void st_destroy_cb_drawpixels( struct st_context *st )
{
}

View File

@@ -30,9 +30,7 @@
#define ST_CB_DRAWPIXELS_H
void st_init_cb_drawpixels( struct st_context *st );
void st_destroy_cb_drawpixels( struct st_context *st );
extern void st_init_drawpixels_functions(struct dd_function_table *functions);
#endif /* ST_CB_DRAWPIXELS_H */

View File

@@ -322,10 +322,8 @@ st_finish_render_texture(GLcontext *ctx,
void st_init_cb_fbo( struct st_context *st )
void st_init_fbo_functions(struct dd_function_table *functions)
{
struct dd_function_table *functions = &st->ctx->Driver;
functions->NewFramebuffer = st_new_framebuffer;
functions->NewRenderbuffer = st_new_renderbuffer;
functions->BindFramebuffer = st_bind_framebuffer;
@@ -336,8 +334,3 @@ void st_init_cb_fbo( struct st_context *st )
functions->ResizeBuffers = st_resize_buffers;
*/
}
void st_destroy_cb_fbo( struct st_context *st )
{
}

View File

@@ -30,9 +30,8 @@
#define ST_CB_FBO_H
extern void st_init_cb_fbo( struct st_context *st );
extern void st_destroy_cb_fbo( struct st_context *st );
extern void
st_init_fbo_functions(struct dd_function_table *functions);
#endif /* ST_CB_FBO_H */

View File

@@ -32,7 +32,6 @@
#include "st_context.h"
#include "st_program.h"
#include "glheader.h"
#include "macros.h"
#include "enums.h"
@@ -44,6 +43,11 @@
#include "pipe/tgsi/mesa/tgsi_mesa.h"
/* Counter to track program string changes:
*/
static GLuint program_id = 0;
static void st_bind_program( GLcontext *ctx,
GLenum target,
struct gl_program *prog )
@@ -70,7 +74,7 @@ static struct gl_program *st_new_program( GLcontext *ctx,
case GL_VERTEX_PROGRAM_ARB: {
struct st_vertex_program *prog = CALLOC_STRUCT(st_vertex_program);
prog->id = st->program_id++;
prog->id = program_id++;
prog->dirty = 1;
return _mesa_init_vertex_program( ctx,
@@ -84,7 +88,7 @@ static struct gl_program *st_new_program( GLcontext *ctx,
{
struct st_fragment_program *prog = CALLOC_STRUCT(st_fragment_program);
prog->id = st->program_id++;
prog->id = program_id++;
prog->dirty = 1;
return _mesa_init_fragment_program( ctx,
@@ -124,7 +128,7 @@ static void st_program_string_notify( GLcontext *ctx,
if (prog == &ctx->FragmentProgram._Current->Base)
st->dirty.st |= ST_NEW_FRAGMENT_PROGRAM;
p->id = st->program_id++;
p->id = program_id++;
p->param_state = p->Base.Base.Parameters->StateFlags;
}
else if (target == GL_VERTEX_PROGRAM_ARB) {
@@ -133,7 +137,7 @@ static void st_program_string_notify( GLcontext *ctx,
if (prog == &ctx->VertexProgram._Current->Base)
st->dirty.st |= ST_NEW_VERTEX_PROGRAM;
p->id = st->program_id++;
p->id = program_id++;
p->param_state = p->Base.Base.Parameters->StateFlags;
/* Also tell tnl about it:
@@ -144,15 +148,8 @@ static void st_program_string_notify( GLcontext *ctx,
void st_init_cb_program( struct st_context *st )
void st_init_program_functions(struct dd_function_table *functions)
{
struct dd_function_table *functions = &st->ctx->Driver;
/* Need these flags:
*/
st->ctx->FragmentProgram._MaintainTexEnvProgram = GL_TRUE;
st->ctx->FragmentProgram._UseTexEnvProgram = GL_TRUE;
#if 0
assert(functions->ProgramStringNotify == _tnl_program_string);
#endif
@@ -162,9 +159,3 @@ void st_init_cb_program( struct st_context *st )
functions->IsProgramNative = st_is_program_native;
functions->ProgramStringNotify = st_program_string_notify;
}
void st_destroy_cb_program( struct st_context *st )
{
}

View File

@@ -1241,7 +1241,7 @@ do_copy_texsubimage(GLcontext *ctx,
get_teximage_source(ctx, internalFormat);
if (!stImage->mt || !src) {
DBG("%s fail %p %p\n", __FUNCTION__, stImage->mt, src);
DBG("%s fail %p %p\n", __FUNCTION__, (void *) stImage->mt, (void *) src);
return GL_FALSE;
}
@@ -1726,10 +1726,9 @@ st_tex_unmap_images(struct pipe_context *pipe,
void st_init_cb_texture( struct st_context *st )
void
st_init_texture_functions(struct dd_function_table *functions)
{
struct dd_function_table *functions = &st->ctx->Driver;
functions->ChooseTextureFormat = st_ChooseTextureFormat;
functions->TexImage1D = st_TexImage1D;
functions->TexImage2D = st_TexImage2D;
@@ -1756,8 +1755,3 @@ void st_init_cb_texture( struct st_context *st )
functions->TextureMemCpy = do_memcpy;
}
void st_destroy_cb_texture( struct st_context *st )
{
}

View File

@@ -9,11 +9,7 @@ st_finalize_mipmap_tree(GLcontext *ctx,
extern void
st_init_cb_texture( struct st_context *st );
extern void
st_destroy_cb_texture( struct st_context *st );
st_init_texture_functions(struct dd_function_table *functions);
#endif /* ST_CB_TEXTURE_H */

View File

@@ -28,6 +28,7 @@
#include "imports.h"
#include "st_public.h"
#include "st_context.h"
#include "st_cb_bufferobjects.h"
#include "st_cb_clear.h"
#include "st_cb_drawpixels.h"
#include "st_cb_texture.h"
@@ -61,10 +62,17 @@ struct st_context *st_create_context( GLcontext *ctx,
st_init_atoms( st );
st_init_draw( st );
/* Need these flags:
*/
st->ctx->FragmentProgram._MaintainTexEnvProgram = GL_TRUE;
st->ctx->FragmentProgram._UseTexEnvProgram = GL_TRUE;
#if 0
st_init_cb_clear( st );
st_init_cb_program( st );
st_init_cb_drawpixels( st );
st_init_cb_texture( st );
#endif
return st;
}
@@ -75,11 +83,13 @@ void st_destroy_context( struct st_context *st )
st_destroy_atoms( st );
st_destroy_draw( st );
#if 0
st_destroy_cb_clear( st );
st_destroy_cb_program( st );
st_destroy_cb_drawpixels( st );
/*st_destroy_cb_teximage( st );*/
st_destroy_cb_texture( st );
#endif
st->pipe->destroy( st->pipe );
FREE( st );
@@ -87,3 +97,11 @@ void st_destroy_context( struct st_context *st )
void st_init_driver_functions(struct dd_function_table *functions)
{
st_init_bufferobject_functions(functions);
st_init_clear_functions(functions);
st_init_drawpixels_functions(functions);
st_init_program_functions(functions);
st_init_texture_functions(functions);
}

View File

@@ -97,10 +97,6 @@ struct st_context
struct st_state_flags dirty;
/* Counter to track program string changes:
*/
GLuint program_id;
GLfloat polygon_offset_scale; /* ?? */
};
@@ -113,4 +109,7 @@ static INLINE struct st_context *st_context(GLcontext *ctx)
}
extern void st_init_driver_functions(struct dd_function_table *functions);
#endif

View File

@@ -87,8 +87,9 @@ struct st_vertex_program
GLuint param_state;
};
void st_init_cb_program( struct st_context *st );
void st_destroy_cb_program( struct st_context *st );
extern void st_init_program_functions(struct dd_function_table *functions);
static inline struct st_fragment_program *
st_fragment_program( struct gl_fragment_program *fp )