[Mesa-dev] [PATCH 20/41] main: Added entry point for glTextureParameteri.

Laura Ekstrand laura at jlekstrand.net
Mon Dec 15 17:22:35 PST 2014


---
 src/mapi/glapi/gen/ARB_direct_state_access.xml |  6 +++
 src/mesa/main/texparam.c                       | 54 ++++++++++++++++++++------
 src/mesa/main/texparam.h                       |  8 ++++
 3 files changed, 57 insertions(+), 11 deletions(-)

diff --git a/src/mapi/glapi/gen/ARB_direct_state_access.xml b/src/mapi/glapi/gen/ARB_direct_state_access.xml
index 8279ad2..68c6ebe 100644
--- a/src/mapi/glapi/gen/ARB_direct_state_access.xml
+++ b/src/mapi/glapi/gen/ARB_direct_state_access.xml
@@ -87,6 +87,12 @@
       <param name="param" type="const GLfloat *" />
    </function>
 
+   <function name="TextureParameteri" offset="assign">
+      <param name="texture" type="GLuint" />
+      <param name="pname" type="GLenum" />
+      <param name="param" type="GLint" />
+   </function>
+
    <function name="BindTextureUnit" offset="assign">
       <param name="unit" type="GLuint" />
       <param name="texture" type="GLuint" />
diff --git a/src/mesa/main/texparam.c b/src/mesa/main/texparam.c
index b19e4f1..a2b806f 100644
--- a/src/mesa/main/texparam.c
+++ b/src/mesa/main/texparam.c
@@ -885,17 +885,12 @@ _mesa_texture_parameterfv( struct gl_context *ctx,
 }
 
 
-void GLAPIENTRY
-_mesa_TexParameteri(GLenum target, GLenum pname, GLint param)
+void
+_mesa_texture_parameteri(struct gl_context *ctx,
+                         struct gl_texture_object *texObj,
+                         GLenum pname, GLint param, bool dsa)
 {
    GLboolean need_update;
-   struct gl_texture_object *texObj;
-   GET_CURRENT_CONTEXT(ctx);
-
-   texObj = get_texobj(ctx, target, GL_FALSE);
-   if (!texObj)
-      return;
-
    switch (pname) {
    case GL_TEXTURE_MIN_LOD:
    case GL_TEXTURE_MAX_LOD:
@@ -908,16 +903,24 @@ _mesa_TexParameteri(GLenum target, GLenum pname, GLint param)
          fparam[0] = (GLfloat) param;
          fparam[1] = fparam[2] = fparam[3] = 0.0F;
          /* convert int param to float */
-         need_update = set_tex_parameterf(ctx, texObj, pname, fparam, false);
+         need_update = set_tex_parameterf(ctx, texObj, pname, fparam, dsa);
       }
       break;
+   case GL_TEXTURE_BORDER_COLOR:
+   case GL_TEXTURE_SWIZZLE_RGBA:
+      {
+         _mesa_error(ctx, GL_INVALID_ENUM,
+                     "glTex%sParameteri(non-scalar pname)",
+                     dsa ? "ture" : "");
+         return;
+      }
    default:
       /* this will generate an error if pname is illegal */
       {
          GLint iparam[4];
          iparam[0] = param;
          iparam[1] = iparam[2] = iparam[3] = 0;
-         need_update = set_tex_parameteri(ctx, texObj, pname, iparam, false);
+         need_update = set_tex_parameteri(ctx, texObj, pname, iparam, dsa);
       }
    }
 
@@ -1010,6 +1013,19 @@ _mesa_TexParameterfv(GLenum target, GLenum pname, const GLfloat *params)
    _mesa_texture_parameterfv(ctx, texObj, pname, params, false);
 }
 
+void GLAPIENTRY
+_mesa_TexParameteri(GLenum target, GLenum pname, GLint param)
+{
+   struct gl_texture_object *texObj;
+   GET_CURRENT_CONTEXT(ctx);
+
+   texObj = get_texobj(ctx, target, GL_FALSE);
+   if (!texObj)
+      return;
+
+   _mesa_texture_parameteri(ctx, texObj, pname, param, false);
+}
+
 /**
  * Set tex parameter to integer value(s).  Primarily intended to set
  * integer-valued texture border color (for integer-valued textures).
@@ -1101,6 +1117,22 @@ _mesa_TextureParameterf( GLuint texture, GLenum pname, GLfloat param )
    _mesa_texture_parameterf(ctx, texObj, pname, param, true);
 }
 
+void GLAPIENTRY
+_mesa_TextureParameteri(GLuint texture, GLenum pname, GLint param)
+{
+   struct gl_texture_object *texObj;
+   GET_CURRENT_CONTEXT(ctx);
+
+   texObj = get_texobj_by_name(ctx, texture, GL_FALSE);
+   if (!texObj) {
+      /* User passed a non-generated name. */
+      _mesa_error(ctx, GL_INVALID_OPERATION, "glTextureParameteri(texture)");
+      return;
+   }
+
+   _mesa_texture_parameteri(ctx, texObj, pname, param, true);
+}
+
 static GLboolean
 legal_get_tex_level_parameter_target(struct gl_context *ctx, GLenum target)
 {
diff --git a/src/mesa/main/texparam.h b/src/mesa/main/texparam.h
index 1514f42..641d9a3 100644
--- a/src/mesa/main/texparam.h
+++ b/src/mesa/main/texparam.h
@@ -43,6 +43,12 @@ extern void
 _mesa_texture_parameterfv( struct gl_context *ctx,
                            struct gl_texture_object *texObj,
                            GLenum pname, const GLfloat *params, bool dsa );
+
+extern void
+_mesa_texture_parameteri( struct gl_context *ctx,
+                          struct gl_texture_object *texObj,
+                          GLenum pname, GLint param, bool dsa );
+
 /*@}*/
 
 /**
@@ -99,5 +105,7 @@ _mesa_TextureParameterfv( GLuint texture, GLenum pname,
 extern void GLAPIENTRY
 _mesa_TextureParameterf( GLuint texture, GLenum pname, GLfloat param );
 
+extern void GLAPIENTRY
+_mesa_TextureParameteri( GLuint texture, GLenum pname, GLint param );
 
 #endif /* TEXPARAM_H */
-- 
2.1.0



More information about the mesa-dev mailing list