[Mesa-dev] [PATCH 4/5] mesa: simplify some code with new _mesa_cube_face_target() function
Brian Paul
brianp at vmware.com
Thu Feb 11 15:35:05 UTC 2016
---
src/mesa/main/mipmap.c | 7 +------
src/mesa/main/texobj.c | 7 +------
src/mesa/main/textureview.c | 9 ++-------
3 files changed, 4 insertions(+), 19 deletions(-)
diff --git a/src/mesa/main/mipmap.c b/src/mesa/main/mipmap.c
index 7fd6fbf..5a02780 100644
--- a/src/mesa/main/mipmap.c
+++ b/src/mesa/main/mipmap.c
@@ -1838,12 +1838,7 @@ _mesa_prepare_mipmap_level(struct gl_context *ctx,
for (face = 0; face < numFaces; face++) {
struct gl_texture_image *dstImage;
- GLenum target;
-
- if (numFaces == 1)
- target = texObj->Target;
- else
- target = GL_TEXTURE_CUBE_MAP_POSITIVE_X + face;
+ const GLenum target = _mesa_cube_face_target(texObj->Target, face);
dstImage = _mesa_get_tex_image(ctx, texObj, target, level);
if (!dstImage) {
diff --git a/src/mesa/main/texobj.c b/src/mesa/main/texobj.c
index c63d443..d8407f0 100644
--- a/src/mesa/main/texobj.c
+++ b/src/mesa/main/texobj.c
@@ -1036,12 +1036,7 @@ _mesa_get_fallback_texture(struct gl_context *ctx, gl_texture_index tex)
/* need a loop here just for cube maps */
for (face = 0; face < numFaces; face++) {
- GLenum faceTarget;
-
- if (target == GL_TEXTURE_CUBE_MAP)
- faceTarget = GL_TEXTURE_CUBE_MAP_POSITIVE_X + face;
- else
- faceTarget = target;
+ const GLenum faceTarget = _mesa_cube_face_target(target, face);
/* initialize level[0] texture image */
texImage = _mesa_get_tex_image(ctx, texObj, faceTarget, 0);
diff --git a/src/mesa/main/textureview.c b/src/mesa/main/textureview.c
index 04b7d73..316d828 100644
--- a/src/mesa/main/textureview.c
+++ b/src/mesa/main/textureview.c
@@ -211,10 +211,7 @@ initialize_texture_fields(struct gl_context *ctx,
for (level = 0; level < levels; level++) {
for (face = 0; face < numFaces; face++) {
struct gl_texture_image *texImage;
- GLenum faceTarget = target;
-
- if (target == GL_TEXTURE_CUBE_MAP)
- faceTarget = GL_TEXTURE_CUBE_MAP_POSITIVE_X + face;
+ const GLenum faceTarget = _mesa_cube_face_target(target, face);
texImage = _mesa_get_tex_image(ctx, texObj, faceTarget, level);
@@ -536,9 +533,7 @@ _mesa_TextureView(GLuint texture, GLenum target, GLuint origtexture,
newViewNumLevels = MIN2(numlevels, origTexObj->NumLevels - minlevel);
newViewNumLayers = MIN2(numlayers, origTexObj->NumLayers - minlayer);
- faceTarget = origTexObj->Target;
- if (faceTarget == GL_TEXTURE_CUBE_MAP)
- faceTarget = GL_TEXTURE_CUBE_MAP_POSITIVE_X + minlayer;
+ faceTarget = _mesa_cube_face_target(origTexObj->Target, minlayer);
/* Get a reference to what will become this View's base level */
origTexImage = _mesa_select_tex_image(origTexObj, faceTarget, minlevel);
--
1.9.1
More information about the mesa-dev
mailing list