[Mesa-dev] [PATCH 4/6] main: assert(texImage) in ARB_DSA texture cube map functions.

Laura Ekstrand laura at jlekstrand.net
Wed Mar 4 15:44:10 PST 2015


ARB_direct_state_access functions that deal with texture cube
maps need to make sure that texture images are not NULL before operating on
them. In the following cases, the error check functions already throw an
error if texImage == NULL, so an assert can be raised instead.

v2: Review from Anuj Phogat
   - Replace redundant "if (!texImage) return;" statements with
     assert(texImage)
---
 src/mesa/main/texgetimage.c | 5 +++--
 src/mesa/main/teximage.c    | 5 +++--
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/mesa/main/texgetimage.c b/src/mesa/main/texgetimage.c
index 0287ebf..9411db8 100644
--- a/src/mesa/main/texgetimage.c
+++ b/src/mesa/main/texgetimage.c
@@ -1101,6 +1101,8 @@ _mesa_GetTextureImage(GLuint texture, GLint level, GLenum format,
       /* Copy each face. */
       for (i = 0; i < 6; ++i) {
          texImage = texObj->Image[i][level];
+         assert(texImage);
+
          _mesa_get_texture_image(ctx, texObj, texImage, texObj->Target, level,
                                  format, type, bufSize, pixels, true);
 
@@ -1306,8 +1308,7 @@ _mesa_GetCompressedTextureImage(GLuint texture, GLint level,
       /* Copy each face. */
       for (i = 0; i < 6; ++i) {
          texImage = texObj->Image[i][level];
-         if (!texImage)
-            return;
+         assert(texImage);
 
          _mesa_get_compressed_texture_image(ctx, texObj, texImage,
                                             texObj->Target, level,
diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
index cb1c81a..92e2371 100644
--- a/src/mesa/main/teximage.c
+++ b/src/mesa/main/teximage.c
@@ -3677,6 +3677,8 @@ texturesubimage(struct gl_context *ctx, GLuint dims,
       /* Copy in each face. */
       for (i = 0; i < 6; ++i) {
          texImage = texObj->Image[i][level];
+         assert(texImage);
+
          _mesa_texture_sub_image(ctx, 3, texObj, texImage, texObj->Target,
                                  level, xoffset, yoffset, zoffset,
                                  width, height, 1, format,
@@ -3686,8 +3688,7 @@ texturesubimage(struct gl_context *ctx, GLuint dims,
    }
    else {
       texImage = _mesa_select_tex_image(texObj, texObj->Target, level);
-      if (!texImage)
-         return;
+      assert(texImage);
 
       _mesa_texture_sub_image(ctx, dims, texObj, texImage, texObj->Target,
                               level, xoffset, yoffset, zoffset,
-- 
2.1.0



More information about the mesa-dev mailing list