From 61fbc816570820757afdbc3cd04cd475b337ad4f Mon Sep 17 00:00:00 2001 From: Brian Date: Thu, 29 Nov 2007 08:12:33 -0700 Subject: [PATCH] New ctx->Driver.Map/UnmapTexture() functions for accessing textures from t_vb_program.c --- src/mesa/drivers/common/driverfuncs.c | 2 ++ src/mesa/main/config.h | 2 +- src/mesa/main/dd.h | 5 ++++ src/mesa/tnl/t_vb_program.c | 48 +++++++++++++++++++++++++++++++++++ 4 files changed, 56 insertions(+), 1 deletion(-) diff --git a/src/mesa/drivers/common/driverfuncs.c b/src/mesa/drivers/common/driverfuncs.c index 1e7c279..03fbab6 100644 --- a/src/mesa/drivers/common/driverfuncs.c +++ b/src/mesa/drivers/common/driverfuncs.c @@ -112,6 +112,8 @@ _mesa_init_driver_functions(struct dd_function_table *driver) driver->DeleteTexture = _mesa_delete_texture_object; driver->NewTextureImage = _mesa_new_texture_image; driver->FreeTexImageData = _mesa_free_texture_image_data; + driver->MapTexture = NULL; + driver->UnmapTexture = NULL; driver->TextureMemCpy = _mesa_memcpy; driver->IsTextureResident = NULL; driver->PrioritizeTexture = NULL; diff --git a/src/mesa/main/config.h b/src/mesa/main/config.h index 8eb02be..ab0f035 100644 --- a/src/mesa/main/config.h +++ b/src/mesa/main/config.h @@ -213,7 +213,7 @@ /** For GL_ARB_vertex_shader */ /*@{*/ #define MAX_VERTEX_ATTRIBS 16 -#define MAX_VERTEX_TEXTURE_IMAGE_UNITS 0 +#define MAX_VERTEX_TEXTURE_IMAGE_UNITS MAX_TEXTURE_UNITS #define MAX_COMBINED_TEXTURE_IMAGE_UNITS (MAX_TEXTURE_IMAGE_UNITS + MAX_VERTEX_TEXTURE_IMAGE_UNITS) /*@}*/ diff --git a/src/mesa/main/dd.h b/src/mesa/main/dd.h index caa50dd..77d27bb 100644 --- a/src/mesa/main/dd.h +++ b/src/mesa/main/dd.h @@ -493,6 +493,11 @@ struct dd_function_table { */ void (*FreeTexImageData)( GLcontext *ctx, struct gl_texture_image *tImage ); + /** Map texture image data into user space */ + void (*MapTexture)( GLcontext *ctx, struct gl_texture_object *tObj ); + /** Unmap texture images from user space */ + void (*UnmapTexture)( GLcontext *ctx, struct gl_texture_object *tObj ); + /** * Note: no context argument. This function doesn't initially look * like it belongs here, except that the driver is the only entity diff --git a/src/mesa/tnl/t_vb_program.c b/src/mesa/tnl/t_vb_program.c index cd49e9b..addaf76 100644 --- a/src/mesa/tnl/t_vb_program.c +++ b/src/mesa/tnl/t_vb_program.c @@ -246,6 +246,50 @@ init_machine(GLcontext *ctx, struct gl_program_machine *machine) /** + * Map the texture images which the vertex program will access (if any). + */ +static void +map_textures(GLcontext *ctx, const struct gl_vertex_program *vp) +{ + GLuint u; + + if (!ctx->Driver.MapTexture) + return; + + for (u = 0; u < ctx->Const.MaxVertexTextureImageUnits; u++) { + if (vp->Base.TexturesUsed[u]) { + /* Note: _Current *should* correspond to the target indicated + * in TexturesUsed[u]. + */ + ctx->Driver.MapTexture(ctx, ctx->Texture.Unit[u]._Current); + } + } +} + + +/** + * Unmap the texture images which were used by the vertex program (if any). + */ +static void +unmap_textures(GLcontext *ctx, const struct gl_vertex_program *vp) +{ + GLuint u; + + if (!ctx->Driver.MapTexture) + return; + + for (u = 0; u < ctx->Const.MaxVertexTextureImageUnits; u++) { + if (vp->Base.TexturesUsed[u]) { + /* Note: _Current *should* correspond to the target indicated + * in TexturesUsed[u]. + */ + ctx->Driver.UnmapTexture(ctx, ctx->Texture.Unit[u]._Current); + } + } +} + + +/** * This function executes vertex programs */ static GLboolean @@ -278,6 +322,8 @@ run_vp( GLcontext *ctx, struct tnl_pipeline_stage *stage ) } } + map_textures(ctx, program); + for (i = 0; i < VB->Count; i++) { GLuint attr; @@ -329,6 +375,8 @@ run_vp( GLcontext *ctx, struct tnl_pipeline_stage *stage ) #endif } + unmap_textures(ctx, program); + /* Fixup fog and point size results if needed */ if (program->IsNVProgram) { if (ctx->Fog.Enabled && -- 2.7.4