summaryrefslogtreecommitdiffstats
path: root/src/mesa/main/teximage.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/main/teximage.h')
-rw-r--r--src/mesa/main/teximage.h60
1 files changed, 55 insertions, 5 deletions
diff --git a/src/mesa/main/teximage.h b/src/mesa/main/teximage.h
index 5df36c59a28..17f2c908ecc 100644
--- a/src/mesa/main/teximage.h
+++ b/src/mesa/main/teximage.h
@@ -43,10 +43,63 @@ extern "C" {
static inline GLboolean
_mesa_is_cube_face(GLenum target)
{
- return (target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB &&
- target <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB);
+ return (target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X &&
+ target <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z);
}
+
+/**
+ * Return number of faces for a texture target. This will be 6 for
+ * cube maps and 1 otherwise.
+ * NOTE: this function is not used for cube map arrays which operate
+ * more like 2D arrays than cube maps.
+ */
+static inline GLuint
+_mesa_num_tex_faces(GLenum target)
+{
+ switch (target) {
+ case GL_TEXTURE_CUBE_MAP:
+ case GL_PROXY_TEXTURE_CUBE_MAP:
+ return 6;
+ default:
+ return 1;
+ }
+}
+
+
+/**
+ * If the target is GL_TEXTURE_CUBE_MAP, return one of the
+ * GL_TEXTURE_CUBE_MAP_POSITIVE/NEGATIVE_X/Y/Z targets corresponding to
+ * the face parameter.
+ * Else, return target as-is.
+ */
+static inline GLenum
+_mesa_cube_face_target(GLenum target, unsigned face)
+{
+ if (target == GL_TEXTURE_CUBE_MAP) {
+ assert(face < 6);
+ return GL_TEXTURE_CUBE_MAP_POSITIVE_X + face;
+ }
+ else {
+ return target;
+ }
+}
+
+
+/**
+ * For cube map faces, return a face index in [0,5].
+ * For other targets return 0;
+ */
+static inline GLuint
+_mesa_tex_target_to_face(GLenum target)
+{
+ if (_mesa_is_cube_face(target))
+ return (GLuint) target - (GLuint) GL_TEXTURE_CUBE_MAP_POSITIVE_X;
+ else
+ return 0;
+}
+
+
/** Are any of the dimensions of given texture equal to zero? */
static inline GLboolean
_mesa_is_zero_size_texture(const struct gl_texture_image *texImage)
@@ -131,9 +184,6 @@ extern GLboolean
_mesa_target_can_be_compressed(const struct gl_context *ctx, GLenum target,
GLenum intFormat, GLenum *error);
-extern GLuint
-_mesa_tex_target_to_face(GLenum target);
-
extern GLint
_mesa_get_texture_dimensions(GLenum target);