mesa: add EXT_dsa indexed texture commands functions
authorPierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Mon, 29 Apr 2019 15:39:49 +0000 (17:39 +0200)
committerMarek Olšák <marek.olsak@amd.com>
Wed, 31 Jul 2019 02:04:26 +0000 (22:04 -0400)
Added functions:
  - EnableClientStateIndexedEXT
  - DisableClientStateIndexedEXT
  - EnableClientStateiEXT
  - DisableClientStateiEXT

Implemented using the idiom provided by the spec:

        if (array == TEXTURE_COORD_ARRAY) {
          int savedClientActiveTexture;

          GetIntegerv(CLIENT_ACTIVE_TEXTURE, &savedClientActiveTexture);
          ClientActiveTexture(TEXTURE0+index);
          XXX(array);
          ClientActiveTexture(savedActiveTexture);
        } else {
          // Invalid enum
        }

src/mapi/glapi/gen/EXT_direct_state_access.xml
src/mapi/glapi/gen/static_data.py
src/mesa/main/enable.c
src/mesa/main/enable.h
src/mesa/main/tests/dispatch_sanity.cpp

index ddefa07de00f4c6d15d9886d2c3ea21c28060607..be1ddbafe592be6446b5ab6546d1868e369753cf 100644 (file)
       <param name="texture" type="GLuint" />
    </function>
 
+  <function name="EnableClientStateIndexedEXT" alias="EnableClientStateiEXT">
+      <param name="array" type="GLenum" />
+      <param name="index" type="GLuint" />
+   </function>
+
+  <function name="DisableClientStateIndexedEXT" alias="DisableClientStateiEXT">
+      <param name="array" type="GLenum" />
+      <param name="index" type="GLuint" />
+   </function>
+
    <!-- OpenGL 1.3 -->
 
    <function name="MatrixLoadTransposefEXT" offset="assign">
       <param name="pname" type="GLenum" />
       <param name="params" type="GLint *" />
    </function>
+
+   <function name="EnableClientStateiEXT">
+      <param name="array" type="GLenum" />
+      <param name="index" type="GLuint" />
+   </function>
+
+   <function name="DisableClientStateiEXT">
+      <param name="array" type="GLenum" />
+      <param name="index" type="GLuint" />
+   </function>
 </category>
 </OpenGLAPI>
index 696ba60fa89854a810d799e48ecf2d030a318ba4..4ce68fc01e89c047f97adaf2ae525d82afb92a0e 100644 (file)
@@ -1514,6 +1514,8 @@ offsets = {
     "NamedFramebufferTexture3DEXT": 1478,
     "NamedFramebufferRenderbufferEXT": 1479,
     "GetNamedFramebufferAttachmentParameterivEXT": 1480,
+    "EnableClientStateiEXT": 1481,
+    "DisableClientStateiEXT": 1482,
 
 }
 
index ffdd3d8783a4e793816eaf96aff0bd80e01acf2c..418fc75c72443f8b645413ac5eb75ed5212f83d2 100644 (file)
@@ -133,6 +133,38 @@ invalid_enum_error:
 }
 
 
+/* Helper for GL_EXT_direct_state_access following functions:
+ *   - EnableClientStateIndexedEXT
+ *   - EnableClientStateiEXT
+ *   - DisableClientStateIndexedEXT
+ *   - DisableClientStateiEXT
+ */
+static void
+client_state_i(struct gl_context *ctx, GLenum cap, GLuint index, GLboolean state)
+{
+   int saved_active;
+
+   if (cap != GL_TEXTURE_COORD_ARRAY) {
+      _mesa_error(ctx, GL_INVALID_ENUM, "gl%sClientStateiEXT(cap=%s)",
+         state ? "Enable" : "Disable",
+         _mesa_enum_to_string(cap));
+      return;
+   }
+
+   if (index >= ctx->Const.MaxTextureCoordUnits) {
+      _mesa_error(ctx, GL_INVALID_VALUE, "gl%sClientStateiEXT(index=%d)",
+         state ? "Enable" : "Disable",
+         index);
+      return;
+   }
+
+   saved_active = ctx->Array.ActiveTexture;
+   _mesa_ClientActiveTexture(GL_TEXTURE0 + index);
+   client_state(ctx, cap, state);
+   _mesa_ClientActiveTexture(GL_TEXTURE0 + saved_active);
+}
+
+
 /**
  * Enable GL capability.
  * \param cap  state to enable/disable.
@@ -148,6 +180,14 @@ _mesa_EnableClientState( GLenum cap )
 }
 
 
+void GLAPIENTRY
+_mesa_EnableClientStateiEXT( GLenum cap, GLuint index )
+{
+   GET_CURRENT_CONTEXT(ctx);
+   client_state_i(ctx, cap, index, GL_TRUE);
+}
+
+
 /**
  * Disable GL capability.
  * \param cap  state to enable/disable.
@@ -162,6 +202,12 @@ _mesa_DisableClientState( GLenum cap )
    client_state( ctx, cap, GL_FALSE );
 }
 
+void GLAPIENTRY
+_mesa_DisableClientStateiEXT( GLenum cap, GLuint index )
+{
+   GET_CURRENT_CONTEXT(ctx);
+   client_state_i(ctx, cap, index, GL_FALSE);
+}
 
 #define CHECK_EXTENSION(EXTNAME)                                       \
    if (!ctx->Extensions.EXTNAME) {                                     \
index 10755e549d37be9286b0e492026983ba5b84730a..fa569edadd28a21de1fccb1c18fbe8856c04cc89 100644 (file)
@@ -64,9 +64,15 @@ _mesa_IsEnabledi( GLenum cap, GLuint index );
 extern void GLAPIENTRY
 _mesa_EnableClientState( GLenum cap );
 
+extern void GLAPIENTRY
+_mesa_EnableClientStateiEXT( GLenum cap, GLuint index );
+
 extern void GLAPIENTRY
 _mesa_DisableClientState( GLenum cap );
 
+extern void GLAPIENTRY
+_mesa_DisableClientStateiEXT( GLenum cap, GLuint index );
+
 extern void
 _mesa_set_multisample(struct gl_context *ctx, GLboolean state);
 
index 3e0e273dd04c2b6c07c2729edb09be92c49c79a6..cecca5e0aa91d1fcd3b01cf799016038a0f14423 100644 (file)
@@ -1092,8 +1092,8 @@ const struct function common_desktop_functions_possible[] = {
    //{ "glMultiTexImage3DEXT", 12, -1 },
    //{ "glMultiTexSubImage3DEXT", 12, -1 },
    //{ "glCopyMultiTexSubImage3DEXT", 12, -1 },
-   //{ "glEnableClientStateIndexedEXT", 12, -1 },
-   //{ "glDisableClientStateIndexedEXT", 12, -1 },
+   { "glEnableClientStateIndexedEXT", 12, -1 },
+   { "glDisableClientStateIndexedEXT", 12, -1 },
    //{ "glGetPointerIndexedvEXT", 12, -1 },
    /* GL_EXT_direct_state_access - ARB_vertex_program */
    //{ "glNamedProgramStringEXT", 10, -1 },