diff options
Diffstat (limited to 'mesalib/src/mesa/main/get.c')
-rw-r--r-- | mesalib/src/mesa/main/get.c | 123 |
1 files changed, 74 insertions, 49 deletions
diff --git a/mesalib/src/mesa/main/get.c b/mesalib/src/mesa/main/get.c index 2ba868c0d..593c75be2 100644 --- a/mesalib/src/mesa/main/get.c +++ b/mesalib/src/mesa/main/get.c @@ -15,9 +15,10 @@ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. * * Author: Kristian Høgsberg <krh@bitplanet.net> */ @@ -30,12 +31,12 @@ #include "extensions.h" #include "get.h" #include "macros.h" -#include "mfeatures.h" #include "mtypes.h" #include "state.h" #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, @@ -281,6 +289,12 @@ static const int extra_EXT_texture_integer[] = { EXTRA_END }; +static const int extra_EXT_texture_integer_and_new_buffers[] = { + EXT(EXT_texture_integer), + EXTRA_NEW_BUFFERS, + EXTRA_END +}; + static const int extra_GLSL_130[] = { EXTRA_GLSL_130, EXTRA_END @@ -300,8 +314,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 }; @@ -317,6 +330,12 @@ static const int extra_ARB_ES3_compatibility_api_es3[] = { EXTRA_END }; +static const int extra_EXT_framebuffer_sRGB_and_new_buffers[] = { + EXT(EXT_framebuffer_sRGB), + EXTRA_NEW_BUFFERS, + EXTRA_END +}; + EXTRA_EXT(ARB_texture_cube_map); EXTRA_EXT(MESA_texture_array); EXTRA_EXT2(EXT_secondary_color, ARB_vertex_program); @@ -397,6 +416,13 @@ extra_NV_read_buffer_api_gl[] = { EXTRA_END }; +static const int extra_core_ARB_color_buffer_float_and_new_buffers[] = { + EXTRA_API_GL_CORE, + EXT(ARB_color_buffer_float), + EXTRA_NEW_BUFFERS, + EXTRA_END +}; + /* This is the big table describing all the enums we accept in * glGet*v(). The table is partitioned into six parts: enums * understood by all GL APIs (OpenGL, GLES and GLES2), enums shared @@ -404,8 +430,7 @@ extra_NV_read_buffer_api_gl[] = { * remaining combinations. To look up the enums valid in a given API * we will use a hash table specific to that API. These tables are in * turn generated at build time and included through get_hash.h. - * The different sections are guarded by #if FEATURE_GL etc to make - * sure we only compile in the enums we may need. */ + */ #include "get_hash.h" @@ -651,7 +676,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]; @@ -883,58 +911,50 @@ static GLboolean check_extra(struct gl_context *ctx, const char *func, const struct value_desc *d) { const GLuint version = ctx->Version; - int total, enabled; + GLboolean api_check = GL_FALSE; + GLboolean api_found = GL_FALSE; const int *e; - total = 0; - enabled = 0; - 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) { - total++; - enabled++; - } + api_check = GL_TRUE; + if (version >= 30) + api_found = GL_TRUE; break; case EXTRA_VERSION_31: - if (version >= 31) { - total++; - enabled++; - } + api_check = GL_TRUE; + if (version >= 31) + api_found = GL_TRUE; break; case EXTRA_VERSION_32: - if (version >= 32) { - total++; - enabled++; - } + 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) { - total++; - enabled++; - } + api_check = GL_TRUE; + if (ctx->API == API_OPENGLES2) + api_found = GL_TRUE; break; case EXTRA_API_ES3: - if (_mesa_is_gles3(ctx)) { - total++; - enabled++; - } + api_check = GL_TRUE; + if (_mesa_is_gles3(ctx)) + api_found = GL_TRUE; break; case EXTRA_API_GL: - if (_mesa_is_desktop_gl(ctx)) { - total++; - enabled++; - } + 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) { - total++; - enabled++; - } + api_check = GL_TRUE; + if (ctx->API == API_OPENGL_CORE) + api_found = GL_TRUE; break; case EXTRA_NEW_BUFFERS: if (ctx->NewState & _NEW_BUFFERS) @@ -965,21 +985,26 @@ check_extra(struct gl_context *ctx, const char *func, const struct value_desc *d } break; case EXTRA_GLSL_130: - if (ctx->Const.GLSLVersion >= 130) { - total++; - enabled++; - } + 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 */ - total++; + api_check = GL_TRUE; if (*(GLboolean *) ((char *) &ctx->Extensions + *e)) - enabled++; + api_found = GL_TRUE; break; } + } - if (total > 0 && enabled == 0) { + if (api_check && !api_found) { _mesa_error(ctx, GL_INVALID_ENUM, "%s(pname=%s)", func, _mesa_lookup_enum_by_nr(d->pname)); return GL_FALSE; |