From ef84d93f3dabfa7e5bca82cfff05e836545a01ea Mon Sep 17 00:00:00 2001 From: Pierre-Eric Pelloux-Prayer Date: Mon, 29 Apr 2019 17:39:49 +0200 Subject: [PATCH] mesa: add EXT_dsa indexed texture commands functions 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 | 20 +++++++++++ src/mapi/glapi/gen/static_data.py | 2 ++ src/mesa/main/enable.c | 46 ++++++++++++++++++++++++++ src/mesa/main/enable.h | 6 ++++ src/mesa/main/tests/dispatch_sanity.cpp | 4 +-- 5 files changed, 76 insertions(+), 2 deletions(-) diff --git a/src/mapi/glapi/gen/EXT_direct_state_access.xml b/src/mapi/glapi/gen/EXT_direct_state_access.xml index ddefa07..be1ddba 100644 --- a/src/mapi/glapi/gen/EXT_direct_state_access.xml +++ b/src/mapi/glapi/gen/EXT_direct_state_access.xml @@ -313,6 +313,16 @@ + + + + + + + + + + @@ -476,5 +486,15 @@ + + + + + + + + + + diff --git a/src/mapi/glapi/gen/static_data.py b/src/mapi/glapi/gen/static_data.py index 696ba60..4ce68fc 100644 --- a/src/mapi/glapi/gen/static_data.py +++ b/src/mapi/glapi/gen/static_data.py @@ -1514,6 +1514,8 @@ offsets = { "NamedFramebufferTexture3DEXT": 1478, "NamedFramebufferRenderbufferEXT": 1479, "GetNamedFramebufferAttachmentParameterivEXT": 1480, + "EnableClientStateiEXT": 1481, + "DisableClientStateiEXT": 1482, } diff --git a/src/mesa/main/enable.c b/src/mesa/main/enable.c index ffdd3d8..418fc75 100644 --- a/src/mesa/main/enable.c +++ b/src/mesa/main/enable.c @@ -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) { \ diff --git a/src/mesa/main/enable.h b/src/mesa/main/enable.h index 10755e5..fa569ed 100644 --- a/src/mesa/main/enable.h +++ b/src/mesa/main/enable.h @@ -65,8 +65,14 @@ 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); diff --git a/src/mesa/main/tests/dispatch_sanity.cpp b/src/mesa/main/tests/dispatch_sanity.cpp index 3e0e273..cecca5e 100644 --- a/src/mesa/main/tests/dispatch_sanity.cpp +++ b/src/mesa/main/tests/dispatch_sanity.cpp @@ -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 }, -- 2.7.4