Module: Mesa
Branch: main
Commit: 47e7b49c61ed72141b20ee9061a320bd259b3e0d
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=47e7b49c61ed72141b20ee9061a320bd259b3e0d

Author: volodymyr.o <[email protected]>
Date:   Mon Feb 27 15:19:30 2023 +0200

mesa ctx->API --> _mesa_is_foo(ctx)

replaces direct API checks with _mesa_is_...() checks

Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/8340

Signed-off-by: Volodymyr Obohzyn [email protected]

Reviewed-by: Erik Faye-Lund <[email protected]>

Reviewed-by: Eric Engestrom <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21556>

---

 src/compiler/glsl/glsl_parser_extras.cpp    |  6 +++---
 src/compiler/glsl/linker.cpp                |  3 ++-
 src/mapi/glapi/gen/api_beginend_init_h.py   |  4 ++--
 src/mapi/glapi/gen/apiexec.py               | 18 +++++++++---------
 src/mesa/main/arrayobj.c                    |  6 +++---
 src/mesa/main/attrib.c                      |  4 ++--
 src/mesa/main/clear.c                       |  2 +-
 src/mesa/main/dlist.c                       |  2 +-
 src/mesa/main/draw.c                        |  8 ++++----
 src/mesa/main/draw_validate.c               |  2 +-
 src/mesa/main/getstring.c                   |  2 +-
 src/mesa/main/glthread_draw.c               |  8 ++++----
 src/mesa/main/hint.c                        |  2 +-
 src/mesa/main/light.c                       |  6 +++---
 src/mesa/main/lines.c                       |  2 +-
 src/mesa/main/matrix.c                      |  2 +-
 src/mesa/main/multisample.c                 |  2 +-
 src/mesa/main/points.c                      |  8 ++++----
 src/mesa/main/polygon.c                     |  4 ++--
 src/mesa/main/state.c                       | 10 +++++-----
 src/mesa/main/texenv.c                      | 16 ++++++++--------
 src/mesa/main/texgen.c                      |  2 +-
 src/mesa/main/uniform_query.cpp             |  2 +-
 src/mesa/program/program.c                  |  2 +-
 src/mesa/state_tracker/st_atom_rasterizer.c |  3 ++-
 src/mesa/state_tracker/st_context.c         |  4 ++--
 src/mesa/state_tracker/st_program.c         |  2 +-
 src/mesa/state_tracker/st_util.h            |  5 +++--
 src/mesa/vbo/vbo_context.c                  |  5 +++--
 src/mesa/vbo/vbo_exec_api.c                 |  4 ++--
 30 files changed, 75 insertions(+), 71 deletions(-)

diff --git a/src/compiler/glsl/glsl_parser_extras.cpp 
b/src/compiler/glsl/glsl_parser_extras.cpp
index 52e30f41b90..37b5554dffe 100644
--- a/src/compiler/glsl/glsl_parser_extras.cpp
+++ b/src/compiler/glsl/glsl_parser_extras.cpp
@@ -95,7 +95,7 @@ _mesa_glsl_parse_state::_mesa_glsl_parse_state(struct 
gl_context *_ctx,
    this->ARB_texture_rectangle_enable = true;
 
    /* OpenGL ES 2.0 has different defaults from desktop GL. */
-   if (ctx->API == API_OPENGLES2) {
+   if (_mesa_is_gles2(ctx)) {
       this->language_version = 100;
       this->es_shader = true;
       this->ARB_texture_rectangle_enable = false;
@@ -238,7 +238,7 @@ _mesa_glsl_parse_state::_mesa_glsl_parse_state(struct 
gl_context *_ctx,
          }
       }
    }
-   if (ctx->API == API_OPENGLES2 || ctx->Extensions.ARB_ES2_compatibility) {
+   if (_mesa_is_gles2(ctx) || ctx->Extensions.ARB_ES2_compatibility) {
       this->supported_versions[this->num_supported_versions].ver = 100;
       this->supported_versions[this->num_supported_versions].gl_ver = 20;
       this->supported_versions[this->num_supported_versions].es = true;
@@ -256,7 +256,7 @@ _mesa_glsl_parse_state::_mesa_glsl_parse_state(struct 
gl_context *_ctx,
       this->supported_versions[this->num_supported_versions].es = true;
       this->num_supported_versions++;
    }
-   if ((ctx->API == API_OPENGLES2 && ctx->Version >= 32) ||
+   if (_mesa_is_gles32(ctx) ||
        ctx->Extensions.ARB_ES3_2_compatibility) {
       this->supported_versions[this->num_supported_versions].ver = 320;
       this->supported_versions[this->num_supported_versions].gl_ver = 32;
diff --git a/src/compiler/glsl/linker.cpp b/src/compiler/glsl/linker.cpp
index 53197a04b93..34e73651886 100644
--- a/src/compiler/glsl/linker.cpp
+++ b/src/compiler/glsl/linker.cpp
@@ -91,6 +91,7 @@
 #include "main/shaderobj.h"
 #include "main/enums.h"
 #include "main/mtypes.h"
+#include "main/context.h"
 
 
 namespace {
@@ -3928,7 +3929,7 @@ link_shaders(struct gl_context *ctx, struct 
gl_shader_program *prog)
     *   always require a Vertex shader and hence a Fragment shader.
     * - Finally a Compute shader linked with any other stage is a link error.
     */
-   if (!prog->SeparateShader && ctx->API == API_OPENGLES2 &&
+   if (!prog->SeparateShader && _mesa_is_gles2(ctx) &&
        num_shaders[MESA_SHADER_COMPUTE] == 0) {
       if (prog->_LinkedShaders[MESA_SHADER_VERTEX] == NULL) {
          linker_error(prog, "program lacks a vertex shader\n");
diff --git a/src/mapi/glapi/gen/api_beginend_init_h.py 
b/src/mapi/glapi/gen/api_beginend_init_h.py
index b0aab7b5f81..f0a22e3630f 100644
--- a/src/mapi/glapi/gen/api_beginend_init_h.py
+++ b/src/mapi/glapi/gen/api_beginend_init_h.py
@@ -54,12 +54,12 @@ class PrintCode(gl_XML.gl_print_base):
             if not condition:
                 continue
 
-            if (condition == '_mesa_is_desktop_gl(ctx) || ctx->API == 
API_OPENGLES2' and
+            if (condition == '_mesa_is_desktop_gl(ctx) || _mesa_is_gles2(ctx)' 
and
                 re.match('VertexAttrib[1-4].*ARB', f.name)):
                 # These functions should map to an *ES callback for GLES2.
                 settings_by_condition['_mesa_is_desktop_gl(ctx)'].append(
                     'SET_{0}(tab, NAME({0}));'.format(f.name))
-                settings_by_condition['ctx->API == API_OPENGLES2'].append(
+                settings_by_condition['_mesa_is_gles2(ctx)'].append(
                     'SET_{0}(tab, NAME_ES({0}));'.format(f.name))
             else:
                 macro = ('NAME_CALLLIST' if f.name[0:8] == 'CallList' else
diff --git a/src/mapi/glapi/gen/apiexec.py b/src/mapi/glapi/gen/apiexec.py
index 21396fcb4f4..7247dae3dce 100644
--- a/src/mapi/glapi/gen/apiexec.py
+++ b/src/mapi/glapi/gen/apiexec.py
@@ -306,22 +306,22 @@ def get_api_condition(f):
         unconditional_count = 0
 
         if ex.compatibility is not None:
-            condition_parts.append('ctx->API == API_OPENGL_COMPAT')
+            condition_parts.append('_mesa_is_desktop_gl_compat(ctx)')
             unconditional_count += 1
 
         if ex.core is not None:
-            condition_parts.append('ctx->API == API_OPENGL_CORE')
+            condition_parts.append('_mesa_is_desktop_gl_core(ctx)')
             unconditional_count += 1
 
         if ex.es1 is not None:
-            condition_parts.append('ctx->API == API_OPENGLES')
+            condition_parts.append('_mesa_is_gles1(ctx)')
             unconditional_count += 1
 
         if ex.es2 is not None:
             if ex.es2 > 20:
-                condition_parts.append('(ctx->API == API_OPENGLES2 && 
ctx->Version >= {0})'.format(ex.es2))
+                condition_parts.append('(_mesa_is_gles2(ctx) && ctx->Version 
>= {0})'.format(ex.es2))
             else:
-                condition_parts.append('ctx->API == API_OPENGLES2')
+                condition_parts.append('_mesa_is_gles2(ctx)')
                 unconditional_count += 1
 
         # If the function is unconditionally available in all four
@@ -333,16 +333,16 @@ def get_api_condition(f):
     else:
         if f.desktop:
             if f.deprecated:
-                condition_parts.append('ctx->API == API_OPENGL_COMPAT')
+                condition_parts.append('_mesa_is_desktop_gl_compat(ctx)')
             else:
                 condition_parts.append('_mesa_is_desktop_gl(ctx)')
         if 'es1' in f.api_map:
-            condition_parts.append('ctx->API == API_OPENGLES')
+            condition_parts.append('_mesa_is_gles1(ctx)')
         if 'es2' in f.api_map:
             if f.api_map['es2'] > 2.0:
-                condition_parts.append('(ctx->API == API_OPENGLES2 && 
ctx->Version >= {0})'.format(int(f.api_map['es2'] * 10)))
+                condition_parts.append('(_mesa_is_gles2(ctx) && ctx->Version 
>= {0})'.format(int(f.api_map['es2'] * 10)))
             else:
-                condition_parts.append('ctx->API == API_OPENGLES2')
+                condition_parts.append('_mesa_is_gles2(ctx)')
 
     if not condition_parts:
         # This function does not exist in any API.
diff --git a/src/mesa/main/arrayobj.c b/src/mesa/main/arrayobj.c
index 02727917e54..33fbed678ac 100644
--- a/src/mesa/main/arrayobj.c
+++ b/src/mesa/main/arrayobj.c
@@ -206,7 +206,7 @@ _mesa_lookup_vao(struct gl_context *ctx, GLuint id)
     *     the name of the vertex array object."
     */
    if (id == 0) {
-      if (ctx->API == API_OPENGL_COMPAT)
+      if (_mesa_is_desktop_gl_compat(ctx))
          return ctx->Array.DefaultVAO;
 
       return NULL;
@@ -250,7 +250,7 @@ _mesa_lookup_vao_err(struct gl_context *ctx, GLuint id,
     *     the name of the vertex array object."
     */
    if (id == 0) {
-      if (is_ext_dsa || ctx->API == API_OPENGL_CORE) {
+      if (is_ext_dsa || _mesa_is_desktop_gl_core(ctx)) {
          _mesa_error(ctx, GL_INVALID_OPERATION,
                      "%s(zero is not valid vaobj name%s)",
                      caller,
@@ -936,7 +936,7 @@ bind_vertex_array(struct gl_context *ctx, GLuint id, bool 
no_error)
    /* Update the valid-to-render state if binding on unbinding default VAO
     * if drawing with the default VAO is invalid.
     */
-   if (ctx->API == API_OPENGL_CORE &&
+   if (_mesa_is_desktop_gl_core(ctx) &&
        (oldObj == ctx->Array.DefaultVAO) != (newObj == ctx->Array.DefaultVAO))
       _mesa_update_valid_to_render_state(ctx);
 }
diff --git a/src/mesa/main/attrib.c b/src/mesa/main/attrib.c
index af8816f1f05..276bb10de09 100644
--- a/src/mesa/main/attrib.c
+++ b/src/mesa/main/attrib.c
@@ -944,8 +944,8 @@ _mesa_PopAttrib(void)
       TEST_AND_UPDATE(ctx->Point.PointSprite, attr->Point.PointSprite,
                       GL_POINT_SPRITE);
 
-      if ((ctx->API == API_OPENGL_COMPAT && ctx->Version >= 20)
-          || ctx->API == API_OPENGL_CORE)
+      if ((_mesa_is_desktop_gl_compat(ctx) && ctx->Version >= 20)
+          || _mesa_is_desktop_gl_core(ctx))
          TEST_AND_CALL1_SEL(Point.SpriteOrigin, PointParameterf, 
GL_POINT_SPRITE_COORD_ORIGIN);
    }
 
diff --git a/src/mesa/main/clear.c b/src/mesa/main/clear.c
index 0837b253660..bb604224c9d 100644
--- a/src/mesa/main/clear.c
+++ b/src/mesa/main/clear.c
@@ -163,7 +163,7 @@ clear(struct gl_context *ctx, GLbitfield mask, bool 
no_error)
        * existed in OpenGL ES.
        */
       if ((mask & GL_ACCUM_BUFFER_BIT) != 0
-          && (ctx->API == API_OPENGL_CORE || _mesa_is_gles(ctx))) {
+          && (_mesa_is_desktop_gl_core(ctx) || _mesa_is_gles(ctx))) {
          _mesa_error( ctx, GL_INVALID_VALUE, "glClear(GL_ACCUM_BUFFER_BIT)");
          return;
       }
diff --git a/src/mesa/main/dlist.c b/src/mesa/main/dlist.c
index 9d60f9d3991..af1de7ffa41 100644
--- a/src/mesa/main/dlist.c
+++ b/src/mesa/main/dlist.c
@@ -14094,7 +14094,7 @@ void
 _mesa_init_dispatch_save_begin_end(struct gl_context *ctx)
 {
    struct _glapi_table *tab = ctx->Dispatch.Save;
-   assert(ctx->API == API_OPENGL_COMPAT);
+   assert(_mesa_is_desktop_gl_compat(ctx));
 
 #define NAME_AE(x) _mesa_##x
 #define NAME_CALLLIST(x) save_##x
diff --git a/src/mesa/main/draw.c b/src/mesa/main/draw.c
index d1a589d4a32..e58e65d27cc 100644
--- a/src/mesa/main/draw.c
+++ b/src/mesa/main/draw.c
@@ -2316,7 +2316,7 @@ _mesa_DrawArraysIndirect(GLenum mode, const GLvoid 
*indirect)
     *    DrawElementsIndirect are to source their arguments directly from the
     *    pointer passed as their <indirect> parameters."
     */
-   if (ctx->API == API_OPENGL_COMPAT &&
+   if (_mesa_is_desktop_gl_compat(ctx) &&
        !ctx->DrawIndirectBuffer) {
       DrawArraysIndirectCommand *cmd = (DrawArraysIndirectCommand *) indirect;
 
@@ -2351,7 +2351,7 @@ _mesa_DrawElementsIndirect(GLenum mode, GLenum type, 
const GLvoid *indirect)
     *    DrawElementsIndirect are to source their arguments directly from the
     *    pointer passed as their <indirect> parameters."
     */
-   if (ctx->API == API_OPENGL_COMPAT &&
+   if (_mesa_is_desktop_gl_compat(ctx) &&
        !ctx->DrawIndirectBuffer) {
       /*
        * Unlike regular DrawElementsInstancedBaseVertex commands, the indices
@@ -2416,7 +2416,7 @@ _mesa_MultiDrawArraysIndirect(GLenum mode, const GLvoid 
*indirect,
     *    DrawElementsIndirect are to source their arguments directly from the
     *    pointer passed as their <indirect> parameters."
     */
-   if (ctx->API == API_OPENGL_COMPAT &&
+   if (_mesa_is_desktop_gl_compat(ctx) &&
        !ctx->DrawIndirectBuffer) {
 
       if (!_mesa_is_no_error_enabled(ctx) &&
@@ -2489,7 +2489,7 @@ _mesa_MultiDrawElementsIndirect(GLenum mode, GLenum type,
     *    DrawElementsIndirect are to source their arguments directly from the
     *    pointer passed as their <indirect> parameters."
     */
-   if (ctx->API == API_OPENGL_COMPAT &&
+   if (_mesa_is_desktop_gl_compat(ctx) &&
        !ctx->DrawIndirectBuffer) {
       /*
        * Unlike regular DrawElementsInstancedBaseVertex commands, the indices
diff --git a/src/mesa/main/draw_validate.c b/src/mesa/main/draw_validate.c
index 7f41070cbf9..b8da3a46202 100644
--- a/src/mesa/main/draw_validate.c
+++ b/src/mesa/main/draw_validate.c
@@ -146,7 +146,7 @@ _mesa_update_valid_to_render_state(struct gl_context *ctx)
          return;
    }
 
-   if (ctx->API == API_OPENGL_COMPAT) {
+   if (_mesa_is_desktop_gl_compat(ctx)) {
       if (!shader->CurrentProgram[MESA_SHADER_FRAGMENT]) {
          if (ctx->FragmentProgram.Enabled &&
              !_mesa_arb_fragment_program_enabled(ctx))
diff --git a/src/mesa/main/getstring.c b/src/mesa/main/getstring.c
index 8e12809273d..45987488b84 100644
--- a/src/mesa/main/getstring.c
+++ b/src/mesa/main/getstring.c
@@ -162,7 +162,7 @@ _mesa_GetString( GLenum name )
             ctx->Extensions.String = _mesa_make_extension_string(ctx);
          return (const GLubyte *) ctx->Extensions.String;
       case GL_SHADING_LANGUAGE_VERSION:
-         if (ctx->API == API_OPENGLES)
+         if (_mesa_is_gles1(ctx))
             break;
         return shading_language_version(ctx);
       case GL_PROGRAM_ERROR_STRING_ARB:
diff --git a/src/mesa/main/glthread_draw.c b/src/mesa/main/glthread_draw.c
index c1094a313b2..61fb8bcbd96 100644
--- a/src/mesa/main/glthread_draw.c
+++ b/src/mesa/main/glthread_draw.c
@@ -436,7 +436,7 @@ draw_arrays(GLuint drawid, GLenum mode, GLint first, 
GLsizei count,
    }
 
    unsigned user_buffer_mask =
-      ctx->API == API_OPENGL_CORE ? 0 : get_user_buffer_mask(ctx);
+      _mesa_is_desktop_gl_core(ctx) ? 0 : get_user_buffer_mask(ctx);
 
    /* Fast path when nothing needs to be done.
     *
@@ -556,7 +556,7 @@ _mesa_marshal_MultiDrawArrays(GLenum mode, const GLint 
*first,
 
    struct glthread_attrib_binding buffers[VERT_ATTRIB_MAX];
    unsigned user_buffer_mask =
-      ctx->API == API_OPENGL_CORE || draw_count <= 0 ||
+      _mesa_is_desktop_gl_core(ctx) || draw_count <= 0 ||
       ctx->Dispatch.Current == ctx->Dispatch.ContextLost ||
       ctx->GLThread.inside_begin_end ? 0 : get_user_buffer_mask(ctx);
 
@@ -852,7 +852,7 @@ draw_elements(GLuint drawid, GLenum mode, GLsizei count, 
GLenum type,
 
    struct glthread_vao *vao = ctx->GLThread.CurrentVAO;
    unsigned user_buffer_mask =
-      ctx->API == API_OPENGL_CORE ? 0 : get_user_buffer_mask(ctx);
+      _mesa_is_desktop_gl_core(ctx) ? 0 : get_user_buffer_mask(ctx);
    bool has_user_indices = vao->CurrentElementBufferName == 0 && indices;
 
    /* Fast path when nothing needs to be done.
@@ -1136,7 +1136,7 @@ _mesa_marshal_MultiDrawElementsBaseVertex(GLenum mode, 
const GLsizei *count,
    if (draw_count > 0 && is_index_type_valid(type) &&
        ctx->Dispatch.Current != ctx->Dispatch.ContextLost &&
        !ctx->GLThread.inside_begin_end) {
-      user_buffer_mask = ctx->API == API_OPENGL_CORE ? 0 : 
get_user_buffer_mask(ctx);
+      user_buffer_mask = _mesa_is_desktop_gl_core(ctx) ? 0 : 
get_user_buffer_mask(ctx);
       has_user_indices = vao->CurrentElementBufferName == 0;
    }
 
diff --git a/src/mesa/main/hint.c b/src/mesa/main/hint.c
index d63d2677bdc..60be5358b22 100644
--- a/src/mesa/main/hint.c
+++ b/src/mesa/main/hint.c
@@ -113,7 +113,7 @@ _mesa_Hint( GLenum target, GLenum mode )
 
       /* GL_ARB_fragment_shader */
       case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB:
-         if (ctx->API == API_OPENGLES || !ctx->Extensions.ARB_fragment_shader)
+         if (_mesa_is_gles1(ctx) || !ctx->Extensions.ARB_fragment_shader)
             goto invalid_target;
          if (ctx->Hint.FragmentShaderDerivative == mode)
             return;
diff --git a/src/mesa/main/light.c b/src/mesa/main/light.c
index bb8d0526631..b1543f58f15 100644
--- a/src/mesa/main/light.c
+++ b/src/mesa/main/light.c
@@ -877,7 +877,7 @@ _mesa_GetMaterialiv( GLenum face, GLenum pname, GLint 
*params )
    GLuint f;
    GLfloat (*mat)[4] = ctx->Light.Material.Attrib;
 
-   assert(ctx->API == API_OPENGL_COMPAT);
+   assert(_mesa_is_desktop_gl_compat(ctx));
 
    FLUSH_VERTICES(ctx, 0, 0); /* update materials */
    FLUSH_CURRENT(ctx, 0); /* update ctx->Light.Material from vertex buffer */
@@ -1269,8 +1269,8 @@ _mesa_init_lighting( struct gl_context *ctx )
                                                NULL );
 
    ctx->Light.ColorMaterialEnabled = GL_FALSE;
-   ctx->Light.ClampVertexColor = ctx->API == API_OPENGL_COMPAT;
-   ctx->Light._ClampVertexColor = ctx->API == API_OPENGL_COMPAT;
+   ctx->Light.ClampVertexColor = _mesa_is_desktop_gl_compat(ctx);
+   ctx->Light._ClampVertexColor = _mesa_is_desktop_gl_compat(ctx);
 
    /* Miscellaneous */
    ctx->Light._NeedEyeCoords = GL_FALSE;
diff --git a/src/mesa/main/lines.c b/src/mesa/main/lines.c
index d4a67a78792..dc942f667d8 100644
--- a/src/mesa/main/lines.c
+++ b/src/mesa/main/lines.c
@@ -61,7 +61,7 @@ line_width(struct gl_context *ctx, GLfloat width, bool 
no_error)
     * *NOT* removed in a later spec.  Therefore, we only disallow this in a
     * forward compatible context.
     */
-   if (!no_error && ctx->API == API_OPENGL_CORE
+   if (!no_error && _mesa_is_desktop_gl_core(ctx)
        && ((ctx->Const.ContextFlags & GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT)
            != 0)
        && width > 1.0F) {
diff --git a/src/mesa/main/matrix.c b/src/mesa/main/matrix.c
index 768fddc344e..9b65863a163 100644
--- a/src/mesa/main/matrix.c
+++ b/src/mesa/main/matrix.c
@@ -81,7 +81,7 @@ get_named_matrix_stack(struct gl_context *ctx, GLenum mode, 
const char* caller)
    case GL_MATRIX5_ARB:
    case GL_MATRIX6_ARB:
    case GL_MATRIX7_ARB:
-      if (ctx->API == API_OPENGL_COMPAT
+      if (_mesa_is_desktop_gl_compat(ctx)
           && (ctx->Extensions.ARB_vertex_program ||
               ctx->Extensions.ARB_fragment_program)) {
          const GLuint m = mode - GL_MATRIX0_ARB;
diff --git a/src/mesa/main/multisample.c b/src/mesa/main/multisample.c
index 801a997bb5c..3a9aae44c37 100644
--- a/src/mesa/main/multisample.c
+++ b/src/mesa/main/multisample.c
@@ -242,7 +242,7 @@ _mesa_check_sample_count(struct gl_context *ctx, GLenum 
target,
     *
     * This restriction is relaxed for OpenGL ES 3.1.
     */
-   if ((ctx->API == API_OPENGLES2 && ctx->Version == 30) &&
+   if ((_mesa_is_gles2(ctx) && ctx->Version == 30) &&
        _mesa_is_enum_format_integer(internalFormat)
        && samples > 0) {
       return GL_INVALID_OPERATION;
diff --git a/src/mesa/main/points.c b/src/mesa/main/points.c
index 57a10ec8aee..29f2eb6f274 100644
--- a/src/mesa/main/points.c
+++ b/src/mesa/main/points.c
@@ -168,8 +168,8 @@ _mesa_PointParameterfv( GLenum pname, const GLfloat *params)
         /* GL_POINT_SPRITE_COORD_ORIGIN was added to point sprites when the
          * extension was merged into OpenGL 2.0.
          */
-         if ((ctx->API == API_OPENGL_COMPAT && ctx->Version >= 20)
-             || ctx->API == API_OPENGL_CORE) {
+         if ((_mesa_is_desktop_gl_compat(ctx) && ctx->Version >= 20)
+             || _mesa_is_desktop_gl_core(ctx)) {
             GLenum value = (GLenum) params[0];
             if (value != GL_LOWER_LEFT && value != GL_UPPER_LEFT) {
                _mesa_error(ctx, GL_INVALID_VALUE,
@@ -228,8 +228,8 @@ _mesa_init_point(struct gl_context *ctx)
     * In a core context, the state will default to true, and the setters and
     * getters are disabled.
     */
-   ctx->Point.PointSprite = (ctx->API == API_OPENGL_CORE ||
-                             ctx->API == API_OPENGLES2);
+   ctx->Point.PointSprite = (_mesa_is_desktop_gl_core(ctx) ||
+                             _mesa_is_gles2(ctx));
 
    ctx->Point.SpriteOrigin = GL_UPPER_LEFT; /* GL_ARB_point_sprite */
    ctx->Point.CoordReplace = 0; /* GL_ARB_point_sprite */
diff --git a/src/mesa/main/polygon.c b/src/mesa/main/polygon.c
index 1b19c48a2d5..d5a6879c24c 100644
--- a/src/mesa/main/polygon.c
+++ b/src/mesa/main/polygon.c
@@ -184,7 +184,7 @@ polygon_mode(struct gl_context *ctx, GLenum face, GLenum 
mode, bool no_error)
 
    switch (face) {
    case GL_FRONT:
-      if (!no_error && ctx->API == API_OPENGL_CORE) {
+      if (!no_error && _mesa_is_desktop_gl_core(ctx)) {
          _mesa_error( ctx, GL_INVALID_ENUM, "glPolygonMode(face)" );
          return;
       }
@@ -207,7 +207,7 @@ polygon_mode(struct gl_context *ctx, GLenum face, GLenum 
mode, bool no_error)
       _mesa_update_edgeflag_state_vao(ctx);
       break;
    case GL_BACK:
-      if (!no_error && ctx->API == API_OPENGL_CORE) {
+      if (!no_error && _mesa_is_desktop_gl_core(ctx)) {
          _mesa_error( ctx, GL_INVALID_ENUM, "glPolygonMode(face)" );
          return;
       }
diff --git a/src/mesa/main/state.c b/src/mesa/main/state.c
index 4946e072662..4935bb4b74b 100644
--- a/src/mesa/main/state.c
+++ b/src/mesa/main/state.c
@@ -94,7 +94,7 @@ _mesa_update_allow_draw_out_of_order(struct gl_context *ctx)
    if (!ctx->Const.AllowDrawOutOfOrder)
       return;
 
-   assert(ctx->API == API_OPENGL_COMPAT);
+   assert(_mesa_is_desktop_gl_compat(ctx));
 
    /* If all of these are NULL, GLSL is disabled. */
    struct gl_program *vs =
@@ -440,7 +440,7 @@ update_program_constants(struct gl_context *ctx)
       update_single_program_constants(ctx, ctx->FragmentProgram._Current,
                                       MESA_SHADER_FRAGMENT);
 
-   if (ctx->API == API_OPENGL_COMPAT &&
+   if (_mesa_is_desktop_gl_compat(ctx) &&
        ctx->Const.GLSLVersionCompat >= 150) {
       new_state |=
          update_single_program_constants(ctx, ctx->GeometryProgram._Current,
@@ -510,8 +510,8 @@ _mesa_update_state_locked( struct gl_context *ctx )
       _mesa_update_framebuffer(ctx, ctx->ReadBuffer, ctx->DrawBuffer);
 
    /* Handle Core and Compatibility contexts separately. */
-   if (ctx->API == API_OPENGL_COMPAT ||
-       ctx->API == API_OPENGLES) {
+   if (_mesa_is_desktop_gl_compat(ctx) ||
+       _mesa_is_gles1(ctx)) {
       /* Update derived state. */
       if (new_state & (_NEW_MODELVIEW|_NEW_PROJECTION))
          _mesa_update_modelview_project( ctx, new_state );
@@ -680,7 +680,7 @@ set_vertex_processing_mode(struct gl_context *ctx, 
gl_vertex_processing_mode m)
        * ES 2.0+ or OpenGL core profile, none of these arrays should ever
        * be enabled.
        */
-      if (ctx->API == API_OPENGL_COMPAT)
+      if (_mesa_is_desktop_gl_compat(ctx))
          ctx->VertexProgram._VPModeInputFilter = VERT_BIT_ALL;
       else
          ctx->VertexProgram._VPModeInputFilter = VERT_BIT_GENERIC_ALL;
diff --git a/src/mesa/main/texenv.c b/src/mesa/main/texenv.c
index b2a22ffb6f2..bd643bac5da 100644
--- a/src/mesa/main/texenv.c
+++ b/src/mesa/main/texenv.c
@@ -121,7 +121,7 @@ set_combiner_mode(struct gl_context *ctx,
       break;
    case GL_DOT3_RGB_EXT:
    case GL_DOT3_RGBA_EXT:
-      legal = (ctx->API == API_OPENGL_COMPAT &&
+      legal = (_mesa_is_desktop_gl_compat(ctx) &&
                ctx->Extensions.EXT_texture_env_dot3 &&
                pname == GL_COMBINE_RGB);
       break;
@@ -132,7 +132,7 @@ set_combiner_mode(struct gl_context *ctx,
    case GL_MODULATE_ADD_ATI:
    case GL_MODULATE_SIGNED_ADD_ATI:
    case GL_MODULATE_SUBTRACT_ATI:
-      legal = (ctx->API == API_OPENGL_COMPAT &&
+      legal = (_mesa_is_desktop_gl_compat(ctx) &&
                ctx->Extensions.ATI_texture_env_combine3);
       break;
    default:
@@ -231,12 +231,12 @@ set_combiner_source(struct gl_context *ctx,
       legal = (param - GL_TEXTURE0 < ctx->Const.MaxTextureUnits);
       break;
    case GL_ZERO:
-      legal = (ctx->API == API_OPENGL_COMPAT &&
+      legal = (_mesa_is_desktop_gl_compat(ctx) &&
                (ctx->Extensions.ATI_texture_env_combine3 ||
                 ctx->Extensions.NV_texture_env_combine4));
       break;
    case GL_ONE:
-      legal = (ctx->API == API_OPENGL_COMPAT &&
+      legal = (_mesa_is_desktop_gl_compat(ctx) &&
                ctx->Extensions.ATI_texture_env_combine3);
       break;
    default:
@@ -627,7 +627,7 @@ get_texenvi(struct gl_context *ctx,
       return texUnit->Combine.SourceRGB[rgb_idx];
    }
    case GL_SOURCE3_RGB_NV:
-      if (ctx->API == API_OPENGL_COMPAT && 
ctx->Extensions.NV_texture_env_combine4) {
+      if (_mesa_is_desktop_gl_compat(ctx) && 
ctx->Extensions.NV_texture_env_combine4) {
          return texUnit->Combine.SourceRGB[3];
       }
       else {
@@ -641,7 +641,7 @@ get_texenvi(struct gl_context *ctx,
       return texUnit->Combine.SourceA[alpha_idx];
    }
    case GL_SOURCE3_ALPHA_NV:
-      if (ctx->API == API_OPENGL_COMPAT && 
ctx->Extensions.NV_texture_env_combine4) {
+      if (_mesa_is_desktop_gl_compat(ctx) && 
ctx->Extensions.NV_texture_env_combine4) {
          return texUnit->Combine.SourceA[3];
       }
       else {
@@ -655,7 +655,7 @@ get_texenvi(struct gl_context *ctx,
       return texUnit->Combine.OperandRGB[op_rgb];
    }
    case GL_OPERAND3_RGB_NV:
-      if (ctx->API == API_OPENGL_COMPAT && 
ctx->Extensions.NV_texture_env_combine4) {
+      if (_mesa_is_desktop_gl_compat(ctx) && 
ctx->Extensions.NV_texture_env_combine4) {
          return texUnit->Combine.OperandRGB[3];
       }
       else {
@@ -669,7 +669,7 @@ get_texenvi(struct gl_context *ctx,
       return texUnit->Combine.OperandA[op_alpha];
    }
    case GL_OPERAND3_ALPHA_NV:
-      if (ctx->API == API_OPENGL_COMPAT && 
ctx->Extensions.NV_texture_env_combine4) {
+      if (_mesa_is_desktop_gl_compat(ctx) && 
ctx->Extensions.NV_texture_env_combine4) {
          return texUnit->Combine.OperandA[3];
       }
       else {
diff --git a/src/mesa/main/texgen.c b/src/mesa/main/texgen.c
index b757d7bbc25..f52b67ce1cd 100644
--- a/src/mesa/main/texgen.c
+++ b/src/mesa/main/texgen.c
@@ -55,7 +55,7 @@ get_texgen(struct gl_context *ctx, GLuint texunitIndex, 
GLenum coord, const char
 
    texUnit = _mesa_get_fixedfunc_tex_unit(ctx, texunitIndex);
 
-   if (ctx->API == API_OPENGLES) {
+   if (_mesa_is_gles1(ctx)) {
       return (coord == GL_TEXTURE_GEN_STR_OES)
          ? &texUnit->GenS : NULL;
    }
diff --git a/src/mesa/main/uniform_query.cpp b/src/mesa/main/uniform_query.cpp
index 70bf6816fca..ebf1f0db984 100644
--- a/src/mesa/main/uniform_query.cpp
+++ b/src/mesa/main/uniform_query.cpp
@@ -1854,7 +1854,7 @@ _mesa_uniform_matrix(GLint location, GLsizei count,
     * http://www.khronos.org/opengles/sdk/docs/man/xhtml/glUniform.xml
     */
    if (transpose) {
-      if (ctx->API == API_OPENGLES2 && ctx->Version < 30) {
+      if (_mesa_is_gles2(ctx) && ctx->Version < 30) {
          _mesa_error(ctx, GL_INVALID_VALUE,
                      "glUniformMatrix(matrix transpose is not GL_FALSE)");
          return;
diff --git a/src/mesa/program/program.c b/src/mesa/program/program.c
index 9fee9f050a7..6d47a60bce1 100644
--- a/src/mesa/program/program.c
+++ b/src/mesa/program/program.c
@@ -92,7 +92,7 @@ _mesa_init_program(struct gl_context *ctx)
    ctx->VertexProgram._VaryingInputs = VERT_BIT_ALL;
    ctx->VertexProgram.Enabled = GL_FALSE;
    ctx->VertexProgram.PointSizeEnabled =
-      (ctx->API == API_OPENGLES2) ? GL_TRUE : GL_FALSE;
+      _mesa_is_gles2(ctx) ? GL_TRUE : GL_FALSE;
    ctx->VertexProgram.TwoSideEnabled = GL_FALSE;
    _mesa_reference_program(ctx, &ctx->VertexProgram.Current,
                            ctx->Shared->DefaultVertexProgram);
diff --git a/src/mesa/state_tracker/st_atom_rasterizer.c 
b/src/mesa/state_tracker/st_atom_rasterizer.c
index fda7f36e506..497d1186ca6 100644
--- a/src/mesa/state_tracker/st_atom_rasterizer.c
+++ b/src/mesa/state_tracker/st_atom_rasterizer.c
@@ -41,6 +41,7 @@
 #include "pipe/p_context.h"
 #include "pipe/p_defines.h"
 #include "cso_cache/cso_context.h"
+#include "main/context.h"
 
 
 static GLuint
@@ -221,7 +222,7 @@ st_update_rasterizer(struct st_context *st)
 
       raster->point_quad_rasterization = 1;
 
-      raster->point_tri_clip = st->ctx->API == API_OPENGLES2;
+      raster->point_tri_clip = _mesa_is_gles2(st->ctx);
    }
 
    /* ST_NEW_VERTEX_PROGRAM
diff --git a/src/mesa/state_tracker/st_context.c 
b/src/mesa/state_tracker/st_context.c
index b1d111f145a..e7f0a2ef82d 100644
--- a/src/mesa/state_tracker/st_context.c
+++ b/src/mesa/state_tracker/st_context.c
@@ -154,7 +154,7 @@ st_invalidate_state(struct gl_context *ctx)
    /* Update the vertex shader if ctx->Light._ClampVertexColor was changed. */
    if (st->clamp_vert_color_in_shader && (new_state & _NEW_LIGHT_STATE)) {
       ctx->NewDriverState |= ST_NEW_VS_STATE;
-      if (st->ctx->API == API_OPENGL_COMPAT && ctx->Version >= 32) {
+      if (_mesa_is_desktop_gl_compat(st->ctx) && ctx->Version >= 32) {
          ctx->NewDriverState |= ST_NEW_GS_STATE | ST_NEW_TES_STATE;
       }
    }
@@ -684,7 +684,7 @@ st_create_context_priv(struct gl_context *ctx, struct 
pipe_context *pipe,
       /* For drivers which cannot do color clamping, it's better to just
        * disable ARB_color_buffer_float in the core profile, because
        * the clamping is deprecated there anyway. */
-      if (ctx->API == API_OPENGL_CORE &&
+      if (_mesa_is_desktop_gl_core(ctx) &&
           (st->clamp_frag_color_in_shader || st->clamp_vert_color_in_shader)) {
          st->clamp_vert_color_in_shader = GL_FALSE;
          st->clamp_frag_color_in_shader = GL_FALSE;
diff --git a/src/mesa/state_tracker/st_program.c 
b/src/mesa/state_tracker/st_program.c
index 75c00ae1fce..70eb85b3eb2 100644
--- a/src/mesa/state_tracker/st_program.c
+++ b/src/mesa/state_tracker/st_program.c
@@ -1262,7 +1262,7 @@ st_precompile_shader_variant(struct st_context *st,
 
       memset(&key, 0, sizeof(key));
 
-      if (st->ctx->API == API_OPENGL_COMPAT &&
+      if (_mesa_is_desktop_gl_compat(st->ctx) &&
           st->clamp_vert_color_in_shader &&
           (prog->info.outputs_written & (VARYING_SLOT_COL0 |
                                          VARYING_SLOT_COL1 |
diff --git a/src/mesa/state_tracker/st_util.h b/src/mesa/state_tracker/st_util.h
index 03761c65ee9..48d2d92f695 100644
--- a/src/mesa/state_tracker/st_util.h
+++ b/src/mesa/state_tracker/st_util.h
@@ -36,6 +36,7 @@
 
 
 #include "state_tracker/st_context.h"
+#include "main/context.h"
 
 
 #ifdef __cplusplus
@@ -67,8 +68,8 @@ st_invalidate_readpix_cache(struct st_context *st)
 static inline bool
 st_user_clip_planes_enabled(struct gl_context *ctx)
 {
-   return (ctx->API == API_OPENGL_COMPAT ||
-           ctx->API == API_OPENGLES) && /* only ES 1.x */
+   return (_mesa_is_desktop_gl_compat(ctx) ||
+           _mesa_is_gles1(ctx)) && /* only ES 1.x */
           ctx->Transform.ClipPlanesEnabled;
 }
 
diff --git a/src/mesa/vbo/vbo_context.c b/src/mesa/vbo/vbo_context.c
index c22bfdb7442..f0cf4992ea5 100644
--- a/src/mesa/vbo/vbo_context.c
+++ b/src/mesa/vbo/vbo_context.c
@@ -31,6 +31,7 @@
 #include "main/api_arrayelt.h"
 #include "main/arrayobj.h"
 #include "main/varray.h"
+#include "main/context.h"
 #include "util/u_memory.h"
 #include "vbo.h"
 #include "vbo_private.h"
@@ -163,7 +164,7 @@ _vbo_CreateContext(struct gl_context *ctx)
    STATIC_ASSERT(VBO_ATTRIB_MAX <= 255);
 
    vbo_exec_init(ctx);
-   if (ctx->API == API_OPENGL_COMPAT)
+   if (_mesa_is_desktop_gl_compat(ctx))
       vbo_save_init(ctx);
 
    vbo->VAO = _mesa_new_vao(ctx, ~((GLuint)0));
@@ -184,7 +185,7 @@ _vbo_DestroyContext(struct gl_context *ctx)
 
    if (vbo) {
       vbo_exec_destroy(ctx);
-      if (ctx->API == API_OPENGL_COMPAT)
+      if (_mesa_is_desktop_gl_compat(ctx))
          vbo_save_destroy(ctx);
       _mesa_reference_vao(ctx, &vbo->VAO, NULL);
    }
diff --git a/src/mesa/vbo/vbo_exec_api.c b/src/mesa/vbo/vbo_exec_api.c
index 11972a60207..a3a88e93a16 100644
--- a/src/mesa/vbo/vbo_exec_api.c
+++ b/src/mesa/vbo/vbo_exec_api.c
@@ -603,10 +603,10 @@ _mesa_Materialfv(GLenum face, GLenum pname, const GLfloat 
*params)
       updateMats = ALL_MATERIAL_BITS;
    }
 
-   if (ctx->API == API_OPENGL_COMPAT && face == GL_FRONT) {
+   if (_mesa_is_desktop_gl_compat(ctx) && face == GL_FRONT) {
       updateMats &= FRONT_MATERIAL_BITS;
    }
-   else if (ctx->API == API_OPENGL_COMPAT && face == GL_BACK) {
+   else if (_mesa_is_desktop_gl_compat(ctx) && face == GL_BACK) {
       updateMats &= BACK_MATERIAL_BITS;
    }
    else if (face != GL_FRONT_AND_BACK) {

Reply via email to