[Mesa-dev] [PATCH] mesa: Correctly set base and max texture levels in glTexparameterf

Anuj Phogat anuj.phogat at gmail.com
Wed Jan 2 07:38:18 PST 2013


gles3 conformance sgis_texture_lod_basic_getter.test expects base
and max texture levels to be rounded to nearest integer. e.g. round
2.3 to 2 and 2.6 to 3. OpenGL 3.0 and OpenGL ES 3.0 specifications
suggest similar rounding to select level when filtering mode is
GL_NEAREST.

This patch makes sgis_texture_lod_basic_getter.test pass.

Signed-off-by: Anuj Phogat <anuj.phogat at gmail.com>
---
 src/mesa/main/texparam.c |   24 ++++++++++++++++++++++--
 1 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/src/mesa/main/texparam.c b/src/mesa/main/texparam.c
index ca5a21f..f3f97ca 100644
--- a/src/mesa/main/texparam.c
+++ b/src/mesa/main/texparam.c
@@ -654,8 +654,6 @@ _mesa_TexParameterf(GLenum target, GLenum pname, GLfloat param)
    case GL_TEXTURE_WRAP_S:
    case GL_TEXTURE_WRAP_T:
    case GL_TEXTURE_WRAP_R:
-   case GL_TEXTURE_BASE_LEVEL:
-   case GL_TEXTURE_MAX_LEVEL:
    case GL_GENERATE_MIPMAP_SGIS:
    case GL_TEXTURE_COMPARE_MODE_ARB:
    case GL_TEXTURE_COMPARE_FUNC_ARB:
@@ -670,6 +668,28 @@ _mesa_TexParameterf(GLenum target, GLenum pname, GLfloat param)
          need_update = set_tex_parameteri(ctx, texObj, pname, p);
       }
       break;
+   case GL_TEXTURE_BASE_LEVEL:
+   case GL_TEXTURE_MAX_LEVEL:
+      {
+         GLint p[4];
+         /* Check if param exceeds maximum value an integer can hold */
+         if (param > 2147483647.0f) {
+            p[0] = (GLint) 2147483647.0f;
+         }
+         else if (param < 0.0f) {
+            p[0] = 0;
+	 }
+         else {
+            /* Round float param to nearest integer. e.g round 2.3 to 2
+             * and 2.8 to 3.
+             */
+            p[0] = (GLint) (param + 0.5);
+         }
+
+	 p[1] = p[2] = p[3] = 0;
+         need_update = set_tex_parameteri(ctx, texObj, pname, p);
+      }
+      break;
    case GL_TEXTURE_SWIZZLE_R_EXT:
    case GL_TEXTURE_SWIZZLE_G_EXT:
    case GL_TEXTURE_SWIZZLE_B_EXT:
-- 
1.7.7.6



More information about the mesa-dev mailing list