summaryrefslogtreecommitdiffstats
path: root/src/mesa/main
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2012-08-21 20:22:27 -0600
committerBrian Paul <[email protected]>2012-08-24 06:18:41 -0600
commit46751edca9a95baff81771aa69986fa6e2422ed6 (patch)
treec0022e06d939d20f8e2fd48eace419fbebcc9e9b /src/mesa/main
parent8a935d71ff4ded6f3cdd8e06dcd1a5e3de3d3cc0 (diff)
mesa: new _mesa_num_tex_faces() helper
Not a real big help now, but will be useful for the GL_ARB_texture_cube_map_array extension in the future.
Diffstat (limited to 'src/mesa/main')
-rw-r--r--src/mesa/main/mipmap.c3
-rw-r--r--src/mesa/main/texobj.c4
-rw-r--r--src/mesa/main/texobj.h11
-rw-r--r--src/mesa/main/texstorage.c5
4 files changed, 18 insertions, 5 deletions
diff --git a/src/mesa/main/mipmap.c b/src/mesa/main/mipmap.c
index 00d3e8f9ed6..15373ba69b0 100644
--- a/src/mesa/main/mipmap.c
+++ b/src/mesa/main/mipmap.c
@@ -33,6 +33,7 @@
#include "mipmap.h"
#include "mtypes.h"
#include "teximage.h"
+#include "texobj.h"
#include "texstore.h"
#include "image.h"
#include "macros.h"
@@ -1817,7 +1818,7 @@ _mesa_prepare_mipmap_level(struct gl_context *ctx,
GLsizei width, GLsizei height, GLsizei depth,
GLsizei border, GLenum intFormat, gl_format format)
{
- const GLuint numFaces = texObj->Target == GL_TEXTURE_CUBE_MAP ? 6 : 1;
+ const GLuint numFaces = _mesa_num_tex_faces(texObj->Target);
GLuint face;
if (texObj->Immutable) {
diff --git a/src/mesa/main/texobj.c b/src/mesa/main/texobj.c
index 77cd4f9625f..2b2dccfbc1f 100644
--- a/src/mesa/main/texobj.c
+++ b/src/mesa/main/texobj.c
@@ -577,7 +577,7 @@ _mesa_test_texobj_completeness( const struct gl_context *ctx,
GLint i;
const GLint minLevel = baseLevel;
const GLint maxLevel = t->_MaxLevel;
- const GLuint numFaces = t->Target == GL_TEXTURE_CUBE_MAP ? 6 : 1;
+ const GLuint numFaces = _mesa_num_tex_faces(t->Target);
GLuint width, height, depth, face;
if (minLevel > maxLevel) {
@@ -826,7 +826,7 @@ _mesa_get_fallback_texture(struct gl_context *ctx, gl_texture_index tex)
static GLuint
texture_size(const struct gl_texture_object *texObj)
{
- const GLuint numFaces = texObj->Target == GL_TEXTURE_CUBE_MAP ? 6 : 1;
+ const GLuint numFaces = _mesa_num_tex_faces(texObj->Target);
GLuint face, level, size = 0;
for (face = 0; face < numFaces; face++) {
diff --git a/src/mesa/main/texobj.h b/src/mesa/main/texobj.h
index 93e0d77382e..a6f1d3a14ff 100644
--- a/src/mesa/main/texobj.h
+++ b/src/mesa/main/texobj.h
@@ -78,6 +78,17 @@ _mesa_reference_texobj(struct gl_texture_object **ptr,
}
+/**
+ * Return number of faces for a texture target. This will be 6 for
+ * cube maps (and cube map arrays) and 1 otherwise.
+ */
+static inline GLuint
+_mesa_num_tex_faces(GLenum target)
+{
+ return target == GL_TEXTURE_CUBE_MAP ? 6 : 1;
+}
+
+
/** Is the texture "complete" with respect to the given sampler state? */
static inline GLboolean
_mesa_is_texture_complete(const struct gl_texture_object *texObj,
diff --git a/src/mesa/main/texstorage.c b/src/mesa/main/texstorage.c
index 5e1f31a9377..f8af8bf012b 100644
--- a/src/mesa/main/texstorage.c
+++ b/src/mesa/main/texstorage.c
@@ -36,6 +36,7 @@
#include "macros.h"
#include "mfeatures.h"
#include "teximage.h"
+#include "texobj.h"
#include "texstorage.h"
#include "mtypes.h"
@@ -128,7 +129,7 @@ setup_texstorage(struct gl_context *ctx,
GLsizei width, GLsizei height, GLsizei depth)
{
const GLenum target = texObj->Target;
- const GLuint numFaces = (target == GL_TEXTURE_CUBE_MAP) ? 6 : 1;
+ const GLuint numFaces = _mesa_num_tex_faces(target);
gl_format texFormat;
GLint level, levelWidth = width, levelHeight = height, levelDepth = depth;
GLuint face;
@@ -206,7 +207,7 @@ clear_image_fields(struct gl_context *ctx,
struct gl_texture_object *texObj)
{
const GLenum target = texObj->Target;
- const GLuint numFaces = (target == GL_TEXTURE_CUBE_MAP) ? 6 : 1;
+ const GLuint numFaces = _mesa_num_tex_faces(target);
GLint level;
GLuint face;