[Mesa-dev] [PATCH 5/6] mesa: replace some API_OPENGL_CORE checks with _mesa_is_desktop_gl

Marek Olšák maraeo at gmail.com
Thu Feb 15 00:11:23 UTC 2018


From: Marek Olšák <marek.olsak at amd.com>

This is more accurate with respect to the compatibility profile.
---
 src/mesa/main/get.c           | 2 +-
 src/mesa/main/varray.c        | 6 +++---
 src/mesa/vbo/vbo_attrib_tmp.h | 4 ++--
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c
index 13d5e85..7c3b9dd 100644
--- a/src/mesa/main/get.c
+++ b/src/mesa/main/get.c
@@ -2548,21 +2548,21 @@ find_value_indexed(const char *func, GLenum pname, GLuint index, union value *v)
       if (index >= _mesa_max_tex_unit(ctx))
          goto invalid_value;
 
       v->value_int = ctx->Texture.Unit[index].CurrentTex[target]->Name;
       return TYPE_INT;
    }
 
    case GL_SAMPLER_BINDING: {
       struct gl_sampler_object *samp;
 
-      if (ctx->API != API_OPENGL_CORE)
+      if (!_mesa_is_desktop_gl(ctx) || ctx->Version < 33)
          goto invalid_enum;
       if (index >= _mesa_max_tex_unit(ctx))
          goto invalid_value;
 
       samp = ctx->Texture.Unit[index].Sampler;
       v->value_int = samp ? samp->Name : 0;
       return TYPE_INT;
    }
 
    case GL_MAX_COMPUTE_WORK_GROUP_COUNT:
diff --git a/src/mesa/main/varray.c b/src/mesa/main/varray.c
index d55f74e..d9c926b 100644
--- a/src/mesa/main/varray.c
+++ b/src/mesa/main/varray.c
@@ -512,21 +512,21 @@ validate_array(struct gl_context *ctx, const char *func,
       _mesa_error(ctx, GL_INVALID_OPERATION, "%s(no array object bound)",
                   func);
       return;
    }
 
    if (stride < 0) {
       _mesa_error( ctx, GL_INVALID_VALUE, "%s(stride=%d)", func, stride );
       return;
    }
 
-   if (ctx->API == API_OPENGL_CORE && ctx->Version >= 44 &&
+   if (_mesa_is_desktop_gl(ctx) && ctx->Version >= 44 &&
        stride > ctx->Const.MaxVertexAttribStride) {
       _mesa_error(ctx, GL_INVALID_VALUE, "%s(stride=%d > "
                   "GL_MAX_VERTEX_ATTRIB_STRIDE)", func, stride);
       return;
    }
 
    /* Page 29 (page 44 of the PDF) of the OpenGL 3.3 spec says:
     *
     *     "An INVALID_OPERATION error is generated under any of the following
     *     conditions:
@@ -2148,21 +2148,21 @@ vertex_array_vertex_buffer_err(struct gl_context *ctx,
                   func, (int64_t) offset);
       return;
    }
 
    if (stride < 0) {
       _mesa_error(ctx, GL_INVALID_VALUE,
                   "%s(stride=%d < 0)", func, stride);
       return;
    }
 
-   if (((ctx->API == API_OPENGL_CORE && ctx->Version >= 44) || _mesa_is_gles31(ctx)) &&
+   if (((_mesa_is_desktop_gl(ctx) && ctx->Version >= 44) || _mesa_is_gles31(ctx)) &&
        stride > ctx->Const.MaxVertexAttribStride) {
       _mesa_error(ctx, GL_INVALID_VALUE, "%s(stride=%d > "
                   "GL_MAX_VERTEX_ATTRIB_STRIDE)", func, stride);
       return;
    }
 
    vertex_array_vertex_buffer(ctx, vao, bindingIndex, buffer, offset,
                               stride, false, func);
 }
 
@@ -2302,21 +2302,21 @@ vertex_array_vertex_buffers(struct gl_context *ctx,
             continue;
          }
 
          if (strides[i] < 0) {
             _mesa_error(ctx, GL_INVALID_VALUE,
                         "%s(strides[%u]=%d < 0)",
                         func, i, strides[i]);
             continue;
          }
 
-         if (ctx->API == API_OPENGL_CORE && ctx->Version >= 44 &&
+         if (_mesa_is_desktop_gl(ctx) && ctx->Version >= 44 &&
              strides[i] > ctx->Const.MaxVertexAttribStride) {
             _mesa_error(ctx, GL_INVALID_VALUE,
                         "%s(strides[%u]=%d > "
                         "GL_MAX_VERTEX_ATTRIB_STRIDE)", func, i, strides[i]);
             continue;
          }
       }
 
       if (buffers[i]) {
          struct gl_vertex_buffer_binding *binding =
diff --git a/src/mesa/vbo/vbo_attrib_tmp.h b/src/mesa/vbo/vbo_attrib_tmp.h
index fd24e57..796b388 100644
--- a/src/mesa/vbo/vbo_attrib_tmp.h
+++ b/src/mesa/vbo/vbo_attrib_tmp.h
@@ -143,37 +143,37 @@ static inline float conv_i10_to_norm_float(const struct gl_context *ctx, int i10
     *
     *    f = max{c/(2^(b-1) - 1), -1.0}                         (2.3)
     *
     * Comments below this equation state: "In general, this representation is
     * used for signed normalized fixed-point texture or floating point values."
     *
     * OpenGL 4.2+ and ES 3.0 remedy this and state that equation 2.3 (above)
     * is used in every case.  They remove equation 2.2 completely.
     */
    if (_mesa_is_gles3(ctx) ||
-       (ctx->API == API_OPENGL_CORE && ctx->Version >= 42)) {
+       (_mesa_is_desktop_gl(ctx) && ctx->Version >= 42)) {
       /* Equation 2.3 above. */
       float f = ((float) val.x) / 511.0F;
       return MAX2(f, -1.0f);
    } else {
       /* Equation 2.2 above. */
       return (2.0F * (float)val.x + 1.0F) * (1.0F  / 1023.0F);
    }
 }
 
 static inline float conv_i2_to_norm_float(const struct gl_context *ctx, int i2)
 {
    struct attr_bits_2 val;
    val.x = i2;
 
    if (_mesa_is_gles3(ctx) ||
-       (ctx->API == API_OPENGL_CORE && ctx->Version >= 42)) {
+       (_mesa_is_desktop_gl(ctx) && ctx->Version >= 42)) {
       /* Equation 2.3 above. */
       float f = (float) val.x;
       return MAX2(f, -1.0f);
    } else {
       /* Equation 2.2 above. */
       return (2.0F * (float)val.x + 1.0F) * (1.0F / 3.0F);
    }
 }
 
 #define ATTRI10_1( A, I10 ) ATTRF( A, 1, conv_i10_to_i((I10) & 0x3ff), 0, 0, 1 )
-- 
2.7.4



More information about the mesa-dev mailing list