OSDN Git Service

mesa: Expose texel offset limits in GLES3.
[android-x86/external-mesa.git] / src / mesa / main / get.c
index 09022bc..223d885 100644 (file)
@@ -36,6 +36,7 @@
 #include "texcompress.h"
 #include "framebuffer.h"
 #include "samplerobj.h"
+#include "stencil.h"
 
 /* This is a table driven implemetation of the glGet*v() functions.
  * The basic idea is that most getters just look up an int somewhere
@@ -141,6 +142,7 @@ enum value_extra {
    EXTRA_VALID_CLIP_DISTANCE,
    EXTRA_FLUSH_CURRENT,
    EXTRA_GLSL_130,
+   EXTRA_EXT_UBO_GS4,
 };
 
 #define NO_EXTRA NULL
@@ -226,7 +228,13 @@ union value {
  * extensions or specific gl versions) or actions (flush current, new
  * buffers) that we need to do before looking up an enum.  We need to
  * declare them all up front so we can refer to them in the value_desc
- * structs below. */
+ * structs below.
+ *
+ * Each EXTRA_ will be executed.  For EXTRA_* enums of extensions and API
+ * versions, listing multiple ones in an array means an error will be thrown
+ * only if none of them are available.  If you need to check for "AND"
+ * behavior, you would need to make a custom EXTRA_ enum.
+ */
 
 static const int extra_new_buffers[] = {
    EXTRA_NEW_BUFFERS,
@@ -287,8 +295,9 @@ static const int extra_EXT_texture_integer_and_new_buffers[] = {
    EXTRA_END
 };
 
-static const int extra_GLSL_130[] = {
+static const int extra_GLSL_130_es3[] = {
    EXTRA_GLSL_130,
+   EXTRA_API_ES3,
    EXTRA_END
 };
 
@@ -306,8 +315,7 @@ static const int extra_ARB_transform_feedback2_api_es3[] = {
 };
 
 static const int extra_ARB_uniform_buffer_object_and_geometry_shader[] = {
-   EXT(ARB_uniform_buffer_object),
-   EXT(ARB_geometry_shader4),
+   EXTRA_EXT_UBO_GS4,
    EXTRA_END
 };
 
@@ -669,7 +677,10 @@ find_custom_value(struct gl_context *ctx, const struct value_desc *d, union valu
       v->value_enum = ctx->Stencil.ZPassFunc[ctx->Stencil.ActiveFace];
       break;
    case GL_STENCIL_REF:
-      v->value_int = ctx->Stencil.Ref[ctx->Stencil.ActiveFace];
+      v->value_int = _mesa_get_stencil_ref(ctx, ctx->Stencil.ActiveFace);
+      break;
+   case GL_STENCIL_BACK_REF:
+      v->value_int = _mesa_get_stencil_ref(ctx, 1);
       break;
    case GL_STENCIL_VALUE_MASK:
       v->value_int = ctx->Stencil.ValueMask[ctx->Stencil.ActiveFace];
@@ -905,53 +916,46 @@ check_extra(struct gl_context *ctx, const char *func, const struct value_desc *d
    GLboolean api_found = GL_FALSE;
    const int *e;
 
-   for (e = d->extra; *e != EXTRA_END; e++)
+   for (e = d->extra; *e != EXTRA_END; e++) {
       switch (*e) {
       case EXTRA_VERSION_30:
-        if (version >= 30) {
-           api_check = GL_TRUE;
-           api_found = GL_TRUE;
-        }
+         api_check = GL_TRUE;
+         if (version >= 30)
+            api_found = GL_TRUE;
         break;
       case EXTRA_VERSION_31:
-        if (version >= 31) {
-           api_check = GL_TRUE;
-           api_found = GL_TRUE;
-        }
+         api_check = GL_TRUE;
+         if (version >= 31)
+            api_found = GL_TRUE;
         break;
       case EXTRA_VERSION_32:
-        if (version >= 32) {
-           api_check = GL_TRUE;
-           api_found = GL_TRUE;
-        }
+         api_check = GL_TRUE;
+         if (version >= 32)
+            api_found = GL_TRUE;
         break;
       case EXTRA_NEW_FRAG_CLAMP:
          if (ctx->NewState & (_NEW_BUFFERS | _NEW_FRAG_CLAMP))
             _mesa_update_state(ctx);
          break;
       case EXTRA_API_ES2:
-        if (ctx->API == API_OPENGLES2) {
-           api_check = GL_TRUE;
-           api_found = GL_TRUE;
-        }
+         api_check = GL_TRUE;
+         if (ctx->API == API_OPENGLES2)
+            api_found = GL_TRUE;
         break;
       case EXTRA_API_ES3:
-        if (_mesa_is_gles3(ctx)) {
-           api_check = GL_TRUE;
-           api_found = GL_TRUE;
-        }
+         api_check = GL_TRUE;
+         if (_mesa_is_gles3(ctx))
+            api_found = GL_TRUE;
         break;
       case EXTRA_API_GL:
-        if (_mesa_is_desktop_gl(ctx)) {
-           api_check = GL_TRUE;
-           api_found = GL_TRUE;
-        }
+         api_check = GL_TRUE;
+         if (_mesa_is_desktop_gl(ctx))
+            api_found = GL_TRUE;
         break;
       case EXTRA_API_GL_CORE:
-        if (ctx->API == API_OPENGL_CORE) {
-           api_check = GL_TRUE;
-           api_found = GL_TRUE;
-        }
+         api_check = GL_TRUE;
+         if (ctx->API == API_OPENGL_CORE)
+            api_found = GL_TRUE;
         break;
       case EXTRA_NEW_BUFFERS:
         if (ctx->NewState & _NEW_BUFFERS)
@@ -982,11 +986,15 @@ check_extra(struct gl_context *ctx, const char *func, const struct value_desc *d
         }
         break;
       case EXTRA_GLSL_130:
-        if (ctx->Const.GLSLVersion >= 130) {
-           api_check = GL_TRUE;
-           api_found = GL_TRUE;
-        }
+         api_check = GL_TRUE;
+         if (ctx->Const.GLSLVersion >= 130)
+            api_found = GL_TRUE;
         break;
+      case EXTRA_EXT_UBO_GS4:
+         api_check = GL_TRUE;
+         api_found = (ctx->Extensions.ARB_uniform_buffer_object &&
+                      ctx->Extensions.ARB_geometry_shader4);
+         break;
       case EXTRA_END:
         break;
       default: /* *e is a offset into the extension struct */
@@ -995,6 +1003,7 @@ check_extra(struct gl_context *ctx, const char *func, const struct value_desc *d
            api_found = GL_TRUE;
         break;
       }
+   }
 
    if (api_check && !api_found) {
       _mesa_error(ctx, GL_INVALID_ENUM, "%s(pname=%s)", func,