X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fmesa%2Fmain%2Fget.c;h=8224c15627c0eca8fed39c1add024b676323fd6a;hb=746b602fbdd6e7955e076c0c0d39e86b01bd3dfd;hp=1cb6cffb6a60571a4c68c2f3006d96e154148782;hpb=ffd2bc3dfbcccd3c38ff93ac107027a5a5764eb5;p=mesa.git diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c index 1cb6cffb6a6..8224c15627c 100644 --- a/src/mesa/main/get.c +++ b/src/mesa/main/get.c @@ -36,17 +36,17 @@ /* This is a table driven implemetation of the glGet*v() functions. * The basic idea is that most getters just look up an int somewhere - * in GLcontext and then convert it to a bool or float according to + * in struct gl_context and then convert it to a bool or float according to * which of glGetIntegerv() glGetBooleanv() etc is being called. * Instead of generating code to do this, we can just record the enum - * value and the offset into GLcontext in an array of structs. Then + * value and the offset into struct gl_context in an array of structs. Then * in glGet*(), we lookup the struct for the enum in question, and use * the offset to get the int we need. * * Sometimes we need to look up a float, a boolean, a bit in a * bitfield, a matrix or other types instead, so we need to track the - * type of the value in GLcontext. And sometimes the value isn't in - * GLcontext but in the drawbuffer, the array object, current texture + * type of the value in struct gl_context. And sometimes the value isn't in + * struct gl_context but in the drawbuffer, the array object, current texture * unit, or maybe it's a computed value. So we need to also track * where or how to find the value. Finally, we sometimes need to * check that one of a number of extensions are enabled, the GL @@ -128,6 +128,7 @@ enum value_extra { EXTRA_VERSION_30, EXTRA_VERSION_31, EXTRA_VERSION_32, + EXTRA_VERSION_ES2, EXTRA_NEW_BUFFERS, EXTRA_VALID_DRAW_BUFFER, EXTRA_VALID_TEXTURE_UNIT, @@ -164,7 +165,7 @@ union value { #define BUFFER_FIELD(field, type) \ LOC_BUFFER, type, offsetof(struct gl_framebuffer, field) #define CONTEXT_FIELD(field, type) \ - LOC_CONTEXT, type, offsetof(GLcontext, field) + LOC_CONTEXT, type, offsetof(struct gl_context, field) #define ARRAY_FIELD(field, type) \ LOC_ARRAY, type, offsetof(struct gl_array_object, field) #define CONST(value) \ @@ -275,9 +276,6 @@ EXTRA_EXT(NV_fragment_program); EXTRA_EXT(NV_texture_rectangle); EXTRA_EXT(EXT_stencil_two_side); EXTRA_EXT(NV_light_max_exponent); -EXTRA_EXT(EXT_convolution); -EXTRA_EXT(EXT_histogram); -EXTRA_EXT(SGI_color_table); EXTRA_EXT(SGI_texture_color_table); EXTRA_EXT(EXT_depth_bounds_test); EXTRA_EXT(ARB_depth_clamp); @@ -303,6 +301,7 @@ EXTRA_EXT2(ARB_fragment_program, NV_fragment_program); EXTRA_EXT2(ARB_vertex_program, NV_vertex_program); EXTRA_EXT2(ARB_vertex_program, ARB_fragment_program); EXTRA_EXT(ARB_vertex_buffer_object); +EXTRA_EXT(ARB_geometry_shader4); static const int extra_ARB_vertex_program_ARB_fragment_program_NV_vertex_program[] = { @@ -325,6 +324,13 @@ static const int extra_version_30[] = { EXTRA_VERSION_30, EXTRA_END }; static const int extra_version_31[] = { EXTRA_VERSION_31, EXTRA_END }; static const int extra_version_32[] = { EXTRA_VERSION_32, EXTRA_END }; +static const int +extra_ARB_vertex_program_version_es2[] = { + EXT(ARB_vertex_program), + EXTRA_VERSION_ES2, + EXTRA_END +}; + #define API_OPENGL_BIT (1 << API_OPENGL) #define API_OPENGLES_BIT (1 << API_OPENGLES) #define API_OPENGLES2_BIT (1 << API_OPENGLES2) @@ -365,7 +371,7 @@ static const struct value_desc values[] = { { GL_MAX_ELEMENTS_VERTICES, CONTEXT_INT(Const.MaxArrayLockSize), NO_EXTRA }, { GL_MAX_ELEMENTS_INDICES, CONTEXT_INT(Const.MaxArrayLockSize), NO_EXTRA }, { GL_MAX_TEXTURE_SIZE, LOC_CUSTOM, TYPE_INT, - offsetof(GLcontext, Const.MaxTextureLevels), NO_EXTRA }, + offsetof(struct gl_context, Const.MaxTextureLevels), NO_EXTRA }, { GL_MAX_VIEWPORT_DIMS, CONTEXT_INT2(Const.MaxViewportWidth), NO_EXTRA }, { GL_PACK_ALIGNMENT, CONTEXT_INT(Pack.Alignment), NO_EXTRA }, { GL_ALIASED_POINT_SIZE_RANGE, CONTEXT_FLOAT2(Const.MinPointSize), NO_EXTRA }, @@ -404,7 +410,7 @@ static const struct value_desc values[] = { { GL_TEXTURE_BINDING_CUBE_MAP_ARB, LOC_CUSTOM, TYPE_INT, TEXTURE_CUBE_INDEX, extra_ARB_texture_cube_map }, { GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB, LOC_CUSTOM, TYPE_INT, - offsetof(GLcontext, Const.MaxCubeTextureLevels), + offsetof(struct gl_context, Const.MaxCubeTextureLevels), extra_ARB_texture_cube_map }, /* XXX: OES_texture_cube_map */ /* XXX: OES_blend_subtract */ @@ -516,7 +522,7 @@ static const struct value_desc values[] = { { GL_MAX_TEXTURE_STACK_DEPTH, CONST(MAX_TEXTURE_STACK_DEPTH), NO_EXTRA }, { GL_MODELVIEW_MATRIX, CONTEXT_MATRIX(ModelviewMatrixStack.Top), NO_EXTRA }, { GL_MODELVIEW_STACK_DEPTH, LOC_CUSTOM, TYPE_INT, - offsetof(GLcontext, ModelviewMatrixStack.Depth), NO_EXTRA }, + offsetof(struct gl_context, ModelviewMatrixStack.Depth), NO_EXTRA }, { GL_NORMALIZE, CONTEXT_BOOL(Transform.Normalize), NO_EXTRA }, { GL_PACK_SKIP_IMAGES_EXT, CONTEXT_INT(Pack.SkipImages), NO_EXTRA }, { GL_PERSPECTIVE_CORRECTION_HINT, CONTEXT_ENUM(Hint.PerspectiveCorrection), NO_EXTRA }, @@ -529,7 +535,7 @@ static const struct value_desc values[] = { { GL_POINT_FADE_THRESHOLD_SIZE_EXT, CONTEXT_FLOAT(Point.Threshold), NO_EXTRA }, { GL_PROJECTION_MATRIX, CONTEXT_MATRIX(ProjectionMatrixStack.Top), NO_EXTRA }, { GL_PROJECTION_STACK_DEPTH, LOC_CUSTOM, TYPE_INT, - offsetof(GLcontext, ProjectionMatrixStack.Depth), NO_EXTRA }, + offsetof(struct gl_context, ProjectionMatrixStack.Depth), NO_EXTRA }, { GL_RESCALE_NORMAL, CONTEXT_BOOL(Transform.RescaleNormals), NO_EXTRA }, { GL_SHADE_MODEL, CONTEXT_ENUM(Light.ShadeModel), NO_EXTRA }, { GL_TEXTURE_2D, LOC_CUSTOM, TYPE_BOOLEAN, 0, NO_EXTRA }, @@ -660,28 +666,29 @@ static const struct value_desc values[] = { { GL_STENCIL_BACK_PASS_DEPTH_PASS, CONTEXT_ENUM(Stencil.ZPassFunc[1]), NO_EXTRA }, { GL_MAX_VERTEX_ATTRIBS_ARB, - CONTEXT_INT(Const.VertexProgram.MaxAttribs), extra_ARB_vertex_program }, + CONTEXT_INT(Const.VertexProgram.MaxAttribs), + extra_ARB_vertex_program_version_es2 }, /* OES_texture_3D */ { GL_TEXTURE_BINDING_3D, LOC_CUSTOM, TYPE_INT, TEXTURE_3D_INDEX, NO_EXTRA }, { GL_MAX_3D_TEXTURE_SIZE, LOC_CUSTOM, TYPE_INT, - offsetof(GLcontext, Const.Max3DTextureLevels), NO_EXTRA }, + offsetof(struct gl_context, Const.Max3DTextureLevels), NO_EXTRA }, - /* GL_ARB_fragment_shader/OES_standard_derivatives */ + /* GL_ARB_fragment_program/OES_standard_derivatives */ { GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB, CONTEXT_ENUM(Hint.FragmentShaderDerivative), extra_ARB_fragment_shader }, #endif /* FEATURE_GL || FEATURE_ES2 */ #if FEATURE_ES2 /* Enums unique to OpenGL ES 2.0 */ - { 0, 0, TYPE_API_MASK, API_OPENGLES2_BIT, NO_OFFSET, NO_EXTRA }, + { 0, 0, TYPE_API_MASK, API_OPENGLES2_BIT, NO_EXTRA }, { GL_MAX_FRAGMENT_UNIFORM_VECTORS, LOC_CUSTOM, TYPE_INT, - offsetof(GLcontext, Const.FragmentProgram.MaxUniformComponents), NO_EXTRA }, + offsetof(struct gl_context, Const.FragmentProgram.MaxUniformComponents), NO_EXTRA }, { GL_MAX_VARYING_VECTORS, LOC_CUSTOM, TYPE_INT, - offsetof(GLcontext, Const.MaxVarying), NO_EXTRA }, + offsetof(struct gl_context, Const.MaxVarying), NO_EXTRA }, { GL_MAX_VERTEX_UNIFORM_VECTORS, LOC_CUSTOM, TYPE_INT, - offsetof(GLcontext, Const.VertexProgram.MaxUniformComponents), NO_EXTRA }, - { GL_SHADER_COMPILER, CONST(1), NO_EXTRA, NO_EXTRA }, + offsetof(struct gl_context, Const.VertexProgram.MaxUniformComponents), NO_EXTRA }, + { GL_SHADER_COMPILER, CONST(1), NO_EXTRA }, /* OES_get_program_binary */ { GL_NUM_SHADER_BINARY_FORMATS, CONST(0), NO_EXTRA }, { GL_SHADER_BINARY_FORMATS, CONST(0), NO_EXTRA }, @@ -866,84 +873,12 @@ static const struct value_desc values[] = { extra_EXT_compiled_vertex_array }, /* GL_ARB_transpose_matrix */ - { GL_TRANSPOSE_COLOR_MATRIX_ARB, CONTEXT_MATRIX_T(ColorMatrixStack.Top), NO_EXTRA }, { GL_TRANSPOSE_MODELVIEW_MATRIX_ARB, CONTEXT_MATRIX_T(ModelviewMatrixStack), NO_EXTRA }, { GL_TRANSPOSE_PROJECTION_MATRIX_ARB, CONTEXT_MATRIX_T(ProjectionMatrixStack.Top), NO_EXTRA }, { GL_TRANSPOSE_TEXTURE_MATRIX_ARB, CONTEXT_MATRIX_T(TextureMatrixStack), NO_EXTRA }, - /* GL_SGI_color_matrix (also in 1.2 imaging) */ - { GL_COLOR_MATRIX_SGI, CONTEXT_MATRIX(ColorMatrixStack.Top), NO_EXTRA }, - { GL_COLOR_MATRIX_STACK_DEPTH_SGI, LOC_CUSTOM, TYPE_INT, - offsetof(GLcontext, ColorMatrixStack.Depth), NO_EXTRA }, - { GL_MAX_COLOR_MATRIX_STACK_DEPTH_SGI, - CONST(MAX_COLOR_STACK_DEPTH), NO_EXTRA }, - { GL_POST_COLOR_MATRIX_RED_SCALE_SGI, - CONTEXT_FLOAT(Pixel.PostColorMatrixScale[0]), NO_EXTRA }, - { GL_POST_COLOR_MATRIX_GREEN_SCALE_SGI, - CONTEXT_FLOAT(Pixel.PostColorMatrixScale[1]), NO_EXTRA }, - { GL_POST_COLOR_MATRIX_BLUE_SCALE_SGI, - CONTEXT_FLOAT(Pixel.PostColorMatrixScale[2]), NO_EXTRA }, - { GL_POST_COLOR_MATRIX_ALPHA_SCALE_SGI, - CONTEXT_FLOAT(Pixel.PostColorMatrixScale[3]), NO_EXTRA }, - { GL_POST_COLOR_MATRIX_RED_BIAS_SGI, - CONTEXT_FLOAT(Pixel.PostColorMatrixBias[0]), NO_EXTRA }, - { GL_POST_COLOR_MATRIX_GREEN_BIAS_SGI, - CONTEXT_FLOAT(Pixel.PostColorMatrixBias[1]), NO_EXTRA }, - { GL_POST_COLOR_MATRIX_BLUE_BIAS_SGI, - CONTEXT_FLOAT(Pixel.PostColorMatrixBias[2]), NO_EXTRA }, - { GL_POST_COLOR_MATRIX_ALPHA_BIAS_SGI, - CONTEXT_FLOAT(Pixel.PostColorMatrixBias[3]), NO_EXTRA }, - - /* GL_EXT_convolution (also in 1.2 imaging) */ - { GL_CONVOLUTION_1D_EXT, CONTEXT_BOOL(Pixel.Convolution1DEnabled), - extra_EXT_convolution }, - { GL_CONVOLUTION_2D_EXT, CONTEXT_BOOL(Pixel.Convolution2DEnabled), - extra_EXT_convolution }, - { GL_SEPARABLE_2D_EXT, CONTEXT_BOOL(Pixel.Separable2DEnabled), - extra_EXT_convolution }, - { GL_POST_CONVOLUTION_RED_SCALE_EXT, - CONTEXT_FLOAT(Pixel.PostConvolutionScale[0]), - extra_EXT_convolution }, - { GL_POST_CONVOLUTION_GREEN_SCALE_EXT, - CONTEXT_FLOAT(Pixel.PostConvolutionScale[1]), - extra_EXT_convolution }, - { GL_POST_CONVOLUTION_BLUE_SCALE_EXT, - CONTEXT_FLOAT(Pixel.PostConvolutionScale[2]), - extra_EXT_convolution }, - { GL_POST_CONVOLUTION_ALPHA_SCALE_EXT, - CONTEXT_FLOAT(Pixel.PostConvolutionScale[3]), - extra_EXT_convolution }, - { GL_POST_CONVOLUTION_RED_BIAS_EXT, - CONTEXT_FLOAT(Pixel.PostConvolutionBias[0]), - extra_EXT_convolution }, - { GL_POST_CONVOLUTION_GREEN_BIAS_EXT, - CONTEXT_FLOAT(Pixel.PostConvolutionBias[1]), - extra_EXT_convolution }, - { GL_POST_CONVOLUTION_BLUE_BIAS_EXT, - CONTEXT_FLOAT(Pixel.PostConvolutionBias[2]), - extra_EXT_convolution }, - { GL_POST_CONVOLUTION_ALPHA_BIAS_EXT, - CONTEXT_FLOAT(Pixel.PostConvolutionBias[3]), - extra_EXT_convolution }, - - /* GL_EXT_histogram / GL_ARB_imaging */ - { GL_HISTOGRAM, CONTEXT_BOOL(Pixel.HistogramEnabled), - extra_EXT_histogram }, - { GL_MINMAX, CONTEXT_BOOL(Pixel.MinMaxEnabled), extra_EXT_histogram }, - - /* GL_SGI_color_table / GL_ARB_imaging */ - { GL_COLOR_TABLE_SGI, - CONTEXT_BOOL(Pixel.ColorTableEnabled[COLORTABLE_PRECONVOLUTION]), - extra_SGI_color_table }, - { GL_POST_CONVOLUTION_COLOR_TABLE_SGI, - CONTEXT_BOOL(Pixel.ColorTableEnabled[COLORTABLE_POSTCONVOLUTION]), - extra_SGI_color_table }, - { GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI, - CONTEXT_BOOL(Pixel.ColorTableEnabled[COLORTABLE_POSTCOLORMATRIX]), - extra_SGI_color_table }, - /* GL_SGI_texture_color_table */ { GL_TEXTURE_COLOR_TABLE_SGI, LOC_TEXUNIT, TYPE_BOOLEAN, offsetof(struct gl_texture_unit, ColorTableEnabled), @@ -1220,6 +1155,26 @@ static const struct value_desc values[] = { { GL_TRANSFORM_FEEDBACK_BINDING, LOC_CUSTOM, TYPE_INT, 0, extra_ARB_transform_feedback2 }, + /* GL_ARB_geometry_shader4 */ + { GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_ARB, + CONTEXT_INT(Const.GeometryProgram.MaxGeometryTextureImageUnits), + extra_ARB_geometry_shader4 }, + { GL_MAX_GEOMETRY_OUTPUT_VERTICES_ARB, + CONTEXT_INT(Const.GeometryProgram.MaxGeometryOutputVertices), + extra_ARB_geometry_shader4 }, + { GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_ARB, + CONTEXT_INT(Const.GeometryProgram.MaxGeometryTotalOutputComponents), + extra_ARB_geometry_shader4 }, + { GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_ARB, + CONTEXT_INT(Const.GeometryProgram.MaxGeometryUniformComponents), + extra_ARB_geometry_shader4 }, + { GL_MAX_GEOMETRY_VARYING_COMPONENTS_ARB, + CONTEXT_INT(Const.GeometryProgram.MaxGeometryVaryingComponents), + extra_ARB_geometry_shader4 }, + { GL_MAX_VERTEX_VARYING_COMPONENTS_ARB, + CONTEXT_INT(Const.GeometryProgram.MaxVertexVaryingComponents), + extra_ARB_geometry_shader4 }, + /* GL 3.0 */ { GL_NUM_EXTENSIONS, LOC_CUSTOM, TYPE_INT, 0, extra_version_30 }, { GL_MAJOR_VERSION, CONTEXT_INT(VersionMajor), extra_version_30 }, @@ -1301,7 +1256,7 @@ print_table_stats(void) * * \param the current context, for determining the API in question */ -void _mesa_init_get_hash(GLcontext *ctx) +void _mesa_init_get_hash(struct gl_context *ctx) { int i, hash, index, mask; int api_mask = 0, api_bit; @@ -1350,7 +1305,7 @@ void _mesa_init_get_hash(GLcontext *ctx) * \param v pointer to the tmp declared in the calling glGet*v() function */ static void -find_custom_value(GLcontext *ctx, const struct value_desc *d, union value *v) +find_custom_value(struct gl_context *ctx, const struct value_desc *d, union value *v) { struct gl_buffer_object *buffer_obj; struct gl_client_array *array; @@ -1437,7 +1392,6 @@ find_custom_value(GLcontext *ctx, const struct value_desc *d, union value *v) case GL_MODELVIEW_STACK_DEPTH: case GL_PROJECTION_STACK_DEPTH: - case GL_COLOR_MATRIX_STACK_DEPTH_SGI: v->value_int = *(GLint *) ((char *) ctx + d->offset) + 1; break; @@ -1629,7 +1583,7 @@ find_custom_value(GLcontext *ctx, const struct value_desc *d, union value *v) * otherwise GL_TRUE. */ static GLboolean -check_extra(GLcontext *ctx, const char *func, const struct value_desc *d) +check_extra(struct gl_context *ctx, const char *func, const struct value_desc *d) { const GLuint version = ctx->VersionMajor * 10 + ctx->VersionMinor; int total, enabled; @@ -1640,16 +1594,28 @@ check_extra(GLcontext *ctx, const char *func, const struct value_desc *d) for (e = d->extra; *e != EXTRA_END; e++) switch (*e) { case EXTRA_VERSION_30: - if (version < 30) - return GL_FALSE; + if (version >= 30) { + total++; + enabled++; + } break; case EXTRA_VERSION_31: - if (version < 31) - return GL_FALSE; + if (version >= 31) { + total++; + enabled++; + } break; case EXTRA_VERSION_32: - if (version < 32) - return GL_FALSE; + if (version >= 32) { + total++; + enabled++; + } + break; + case EXTRA_VERSION_ES2: + if (ctx->API == API_OPENGLES2) { + total++; + enabled++; + } break; case EXTRA_NEW_BUFFERS: if (ctx->NewState & _NEW_BUFFERS)