[Mesa-dev] [PATCH 1/2] mesa: only look up base-format once

Erik Faye-Lund kusmabite at gmail.com
Mon Aug 24 14:02:16 PDT 2015


There's no point in repeatedly looking up the base-format of an
internalformat. So let's cache it in a variable instead.

Signed-off-by: Erik Faye-Lund <kusmabite at gmail.com>
---
 src/mesa/main/teximage.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
index 253e881..7605d1b 100644
--- a/src/mesa/main/teximage.c
+++ b/src/mesa/main/teximage.c
@@ -2004,9 +2004,10 @@ _mesa_legal_texture_base_format_for_target(struct gl_context *ctx,
                                            unsigned dimensions,
                                            const char *caller)
 {
-   if (_mesa_base_tex_format(ctx, internalFormat) == GL_DEPTH_COMPONENT
-       || _mesa_base_tex_format(ctx, internalFormat) == GL_DEPTH_STENCIL
-       || _mesa_base_tex_format(ctx, internalFormat) == GL_STENCIL_INDEX) {
+   GLint baseFormat = _mesa_base_tex_format(ctx, internalFormat);
+   if (baseFormat == GL_DEPTH_COMPONENT
+       || baseFormat == GL_DEPTH_STENCIL
+       || baseFormat == GL_STENCIL_INDEX) {
       /* Section 3.8.3 (Texture Image Specification) of the OpenGL 3.3 Core
        * Profile spec says:
        *
-- 
2.1.4



More information about the mesa-dev mailing list