diff options
author | Brian Paul <brianp@vmware.com> | 2009-11-18 16:56:33 -0700 |
---|---|---|
committer | Brian Paul <brianp@vmware.com> | 2009-11-18 16:56:33 -0700 |
commit | f454df0087c03b32dcb6165ac44e650f3835fc85 (patch) | |
tree | e0888b4a9750b26a55de674822ebb784d07d29a0 | |
parent | d94800ac2dc96d655f9a084e31db49d43b93f00c (diff) |
mesa: add _mesa_map/unmap_current_textures()
-rw-r--r-- | src/mesa/main/texmem.c | 61 | ||||
-rw-r--r-- | src/mesa/main/texmem.h | 9 |
2 files changed, 70 insertions, 0 deletions
diff --git a/src/mesa/main/texmem.c b/src/mesa/main/texmem.c index f0170c60fe..166e6480e6 100644 --- a/src/mesa/main/texmem.c +++ b/src/mesa/main/texmem.c @@ -137,3 +137,64 @@ _mesa_unmap_texture_image(GLcontext *ctx, struct gl_texture_object *tObj, struct gl_texture_image *texImage = tObj->Image[face][level]; texImage->Map.Data = NULL; } + + + +/** + * Map all current texture object images. + * Typically called prior to software rendering. + */ +void +_mesa_map_current_textures(GLcontext *ctx) +{ + GLuint u; + + if (!ctx->Texture._EnabledUnits) { + /* no textures enabled, or no way to validate images! */ + return; + } + + if (!ctx->Driver.MapTexture) + return; + + for (u = 0; u < ctx->Const.MaxTextureImageUnits; u++) { + if (ctx->Texture.Unit[u]._ReallyEnabled) { + struct gl_texture_object *texObj = ctx->Texture.Unit[u]._Current; + ASSERT(texObj); + if (texObj) { + /* Map read/write in case of render to texture */ + ctx->Driver.MapTexture(ctx, texObj, GL_READ_WRITE); + } + } + } +} + + +/** + * Unmap all current texture object images. + * Typically called after software rendering is finished. + */ +void +_mesa_unmap_current_textures(GLcontext *ctx) +{ + GLuint u; + + if (!ctx->Texture._EnabledUnits) { + /* no textures enabled */ + return; + } + + if (!ctx->Driver.UnmapTexture) + return; + + for (u = 0; u < ctx->Const.MaxTextureImageUnits; u++) { + if (ctx->Texture.Unit[u]._ReallyEnabled) { + struct gl_texture_object *texObj = ctx->Texture.Unit[u]._Current; + ASSERT(texObj); + if (texObj) { + ctx->Driver.UnmapTexture(ctx, texObj); + } + } + } +} + diff --git a/src/mesa/main/texmem.h b/src/mesa/main/texmem.h index fe90750b63..681d9700ed 100644 --- a/src/mesa/main/texmem.h +++ b/src/mesa/main/texmem.h @@ -35,12 +35,14 @@ extern void _mesa_free_texture_image_data( GLcontext *ctx, struct gl_texture_image *texImage ); + extern void _mesa_map_texture(GLcontext *ctx, struct gl_texture_object *tObj, GLenum mode); extern void _mesa_unmap_texture(GLcontext *ctx, struct gl_texture_object *tObj); + extern void _mesa_map_texture_image(GLcontext *ctx, struct gl_texture_object *tObj, GLuint level, GLuint face, GLenum mode); @@ -50,4 +52,11 @@ _mesa_unmap_texture_image(GLcontext *ctx, struct gl_texture_object *tObj, GLuint level, GLuint face); +extern void +_mesa_map_current_textures(GLcontext *ctx); + +extern void +_mesa_unmap_current_textures(GLcontext *ctx); + + #endif /* TEXMEM_H */ |