summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Paul <brianp@vmware.com>2009-11-18 12:43:07 -0700
committerBrian Paul <brianp@vmware.com>2009-11-18 16:52:26 -0700
commitb1f980862a7f32e8ec4a565b0feeb4397b0e6624 (patch)
tree70ff154d0f2988c2044df45c8f80066d407bf614
parente72df5a9e73020b9227d384ffe8043cd17857a70 (diff)
mesa: initial sw/fallback texture map/unmap functions
-rw-r--r--src/mesa/main/texmem.c65
-rw-r--r--src/mesa/main/texmem.h14
2 files changed, 79 insertions, 0 deletions
diff --git a/src/mesa/main/texmem.c b/src/mesa/main/texmem.c
index a1848a9cc1..f0170c60fe 100644
--- a/src/mesa/main/texmem.c
+++ b/src/mesa/main/texmem.c
@@ -72,3 +72,68 @@ _mesa_free_texture_image_data(GLcontext *ctx,
texImage->Map.Data = NULL;
}
+
+
+/**
+ * Default/fallback for ctx->Driver.MapTexture()
+ * Map all images in a texture.
+ */
+void
+_mesa_map_texture(GLcontext *ctx, struct gl_texture_object *tObj, GLenum mode)
+{
+ const GLuint numFaces = tObj->Target == GL_TEXTURE_CUBE_MAP ? 6 : 1;
+ GLuint face, level;
+
+ for (face = 0; face < numFaces; face++) {
+ for (level = tObj->BaseLevel; level <= tObj->MaxLevel; level++) {
+ ctx->Driver.MapTextureImage(ctx, tObj, level, face, mode);
+ }
+ }
+}
+
+
+/**
+ * Default/fallback for ctx->Driver.UnmapTexture()
+ * Unmap all images in a texture.
+ */
+void
+_mesa_unmap_texture(GLcontext *ctx, struct gl_texture_object *tObj)
+{
+ const GLuint numFaces = tObj->Target == GL_TEXTURE_CUBE_MAP ? 6 : 1;
+ GLuint face, level;
+
+ for (face = 0; face < numFaces; face++) {
+ for (level = tObj->BaseLevel; level <= tObj->MaxLevel; level++) {
+ ctx->Driver.UnmapTextureImage(ctx, tObj, level, face);
+ }
+ }
+}
+
+
+/**
+ * Default/fallback for ctx->Driver.MapTextureImage()
+ * Map a single image in a texture.
+ * This function should only be used by software drivers that store
+ * the actual texture image data off the DriverData pointer.
+ */
+void
+_mesa_map_texture_image(GLcontext *ctx, struct gl_texture_object *tObj,
+ GLuint level, GLuint face, GLenum mode)
+{
+ struct gl_texture_image *texImage = tObj->Image[face][level];
+ texImage->Map.Data = texImage->DriverData;
+ ASSERT(texImage->Map.RowStride > 0);
+}
+
+
+/**
+ * Default/fallback for ctx->Driver.UnmapTextureImage()
+ * Unmap a single image in a texture.
+ */
+void
+_mesa_unmap_texture_image(GLcontext *ctx, struct gl_texture_object *tObj,
+ GLuint level, GLuint face)
+{
+ struct gl_texture_image *texImage = tObj->Image[face][level];
+ texImage->Map.Data = NULL;
+}
diff --git a/src/mesa/main/texmem.h b/src/mesa/main/texmem.h
index 69bae31446..fe90750b63 100644
--- a/src/mesa/main/texmem.h
+++ b/src/mesa/main/texmem.h
@@ -35,5 +35,19 @@ 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);
+
+extern void
+_mesa_unmap_texture_image(GLcontext *ctx, struct gl_texture_object *tObj,
+ GLuint level, GLuint face);
+
#endif /* TEXMEM_H */