On Fri, Jun 15, 2012 at 2:43 PM, Kristian Høgsberg <k...@bitplanet.net> wrote: > On Fri, Jun 15, 2012 at 4:31 PM, Brian Paul <brian.e.p...@gmail.com> wrote: >> On Fri, Jun 15, 2012 at 1:44 PM, Kristian Høgsberg <k...@bitplanet.net> >> wrote: >>> This lets us select the front buffer for reading under GLES2. >>> --- >>> src/mapi/glapi/gen/es_EXT.xml | 7 +++++++ >>> src/mapi/glapi/gen/gles_api.py | 2 ++ >>> src/mesa/main/APIspec.xml | 13 +++++++++++++ >>> src/mesa/main/extensions.c | 1 + >>> src/mesa/main/get.c | 20 +++++++++++++++++++- >>> src/mesa/main/mtypes.h | 1 + >>> 6 files changed, 43 insertions(+), 1 deletion(-) >>> >>> diff --git a/src/mapi/glapi/gen/es_EXT.xml b/src/mapi/glapi/gen/es_EXT.xml >>> index c7e7d07..b26cac5 100644 >>> --- a/src/mapi/glapi/gen/es_EXT.xml >>> +++ b/src/mapi/glapi/gen/es_EXT.xml >>> @@ -627,4 +627,11 @@ >>> <enum name="REQUIRED_TEXTURE_IMAGE_UNITS_OES" value="0x8D68"/> >>> </category> >>> >>> +<!-- 93. GL_NV_read_buffer --> >>> +<category name="NV_read_buffer"> >>> + <function name="ReadBufferNV" offset="assign"> >>> + <param name="mode" type="GLenum"/> >>> + </function> >>> +</category> >>> + >>> </OpenGLAPI> >>> diff --git a/src/mapi/glapi/gen/gles_api.py b/src/mapi/glapi/gen/gles_api.py >>> index 0116ba4..70ae2e3 100644 >>> --- a/src/mapi/glapi/gen/gles_api.py >>> +++ b/src/mapi/glapi/gen/gles_api.py >>> @@ -451,4 +451,6 @@ es2_api = es2_core + ( >>> 'ProgramBinaryOES', >>> # GL_NV_draw_buffers >>> 'DrawBuffersNV', >>> + # GL_NV_read_buffer >>> + 'ReadBufferNV', >>> ) >>> diff --git a/src/mesa/main/APIspec.xml b/src/mesa/main/APIspec.xml >>> index f23857a..64e666e 100644 >>> --- a/src/mesa/main/APIspec.xml >>> +++ b/src/mesa/main/APIspec.xml >>> @@ -3534,6 +3534,13 @@ >>> </proto> >>> </template> >>> >>> +<template name="ReadBuffer"> >>> + <proto> >>> + <return type="void"/> >>> + <param name="mode" type="GLenum"/> >>> + </proto> >>> +</template> >>> + >>> <api name="mesa" implementation="true"> >>> <category name="MESA"/> >>> >>> @@ -3810,6 +3817,9 @@ >>> <function name="EGLImageTargetRenderbufferStorageOES" >>> template="EGLImageTargetRenderbufferStorage"/> >>> >>> <function name="DrawBuffersARB" template="DrawBuffers"/> >>> + >>> + <function name="ReadBuffer" template="ReadBuffer"/> >>> + >>> </api> >>> >>> <api name="GLES1.1"> >>> @@ -4150,7 +4160,10 @@ >>> <category name="EXT_unpack_subimage"/> >>> >>> <category name="NV_draw_buffers"/> >>> + <category name="NV_read_buffer"/> >>> + >>> <function name="DrawBuffersNV" template="DrawBuffers"/> >>> + <function name="ReadBufferNV" template="ReadBuffer"/> >>> >>> <function name="CullFace" template="CullFace"/> >>> >>> diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c >>> index 2688f7a..0e81783 100644 >>> --- a/src/mesa/main/extensions.c >>> +++ b/src/mesa/main/extensions.c >>> @@ -300,6 +300,7 @@ static const struct extension extension_table[] = { >>> { "GL_NV_packed_depth_stencil", >>> o(EXT_packed_depth_stencil), GL, 2000 }, >>> { "GL_NV_point_sprite", o(NV_point_sprite), >>> GL, 2001 }, >>> { "GL_NV_primitive_restart", o(NV_primitive_restart), >>> GL, 2002 }, >>> + { "GL_NV_read_buffer", o(dummy_true), >>> ES2, 2011 }, >>> { "GL_NV_texgen_reflection", o(NV_texgen_reflection), >>> GL, 1999 }, >>> { "GL_NV_texture_barrier", o(NV_texture_barrier), >>> GL, 2009 }, >>> { "GL_NV_texture_env_combine4", >>> o(NV_texture_env_combine4), GL, 1999 }, >>> diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c >>> index a8e1d86..969b55b 100644 >>> --- a/src/mesa/main/get.c >>> +++ b/src/mesa/main/get.c >>> @@ -131,6 +131,7 @@ enum value_extra { >>> EXTRA_VERSION_30, >>> EXTRA_VERSION_31, >>> EXTRA_VERSION_32, >>> + EXTRA_API_GL, >>> EXTRA_API_ES2, >>> EXTRA_NEW_BUFFERS, >>> EXTRA_NEW_FRAG_CLAMP, >>> @@ -369,6 +370,13 @@ extra_ARB_vertex_program_api_es2[] = { >>> EXTRA_END >>> }; >>> >>> +static const int >>> +extra_NV_read_buffer_api_gl[] = { >>> + EXT(NV_read_buffer), >>> + EXTRA_API_GL, >> >> Is that right? See below. >> >> >>> + EXTRA_END >>> +}; >>> + >>> #define API_OPENGL_BIT (1 << API_OPENGL) >>> #define API_OPENGLES_BIT (1 << API_OPENGLES) >>> #define API_OPENGLES2_BIT (1 << API_OPENGLES2) >>> @@ -750,6 +758,11 @@ static const struct value_desc values[] = { >>> /* GL_ARB_fragment_program/OES_standard_derivatives */ >>> { GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB, >>> CONTEXT_ENUM(Hint.FragmentShaderDerivative), extra_ARB_fragment_shader >>> }, >>> + >>> + /* GL_NV_read_buffer */ >>> + { GL_READ_BUFFER, >>> + LOC_CUSTOM, TYPE_ENUM, NO_OFFSET, extra_NV_read_buffer_api_gl }, >>> + >>> #endif /* FEATURE_GL || FEATURE_ES2 */ >>> >>> #if FEATURE_ES2 >>> @@ -884,7 +897,6 @@ static const struct value_desc values[] = { >>> { GL_POLYGON_SMOOTH, CONTEXT_BOOL(Polygon.SmoothFlag), NO_EXTRA }, >>> { GL_POLYGON_SMOOTH_HINT, CONTEXT_ENUM(Hint.PolygonSmooth), NO_EXTRA }, >>> { GL_POLYGON_STIPPLE, CONTEXT_BOOL(Polygon.StippleFlag), NO_EXTRA }, >>> - { GL_READ_BUFFER, LOC_CUSTOM, TYPE_ENUM, NO_OFFSET, NO_EXTRA }, >>> { GL_RED_BIAS, CONTEXT_FLOAT(Pixel.RedBias), NO_EXTRA }, >>> { GL_RED_SCALE, CONTEXT_FLOAT(Pixel.RedScale), NO_EXTRA }, >>> { GL_RENDER_MODE, CONTEXT_ENUM(RenderMode), NO_EXTRA }, >>> @@ -1814,6 +1826,12 @@ check_extra(struct gl_context *ctx, const char >>> *func, const struct value_desc *d >>> enabled++; >>> } >>> break; >>> + case EXTRA_API_GL: >>> + if (ctx->API == API_OPENGL) { >>> + total++; >>> + enabled++; >>> + } >>> + break; >>> case EXTRA_NEW_BUFFERS: >>> if (ctx->NewState & _NEW_BUFFERS) >>> _mesa_update_state(ctx); >>> diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h >>> index ea40ffc..3d18b7c 100644 >>> --- a/src/mesa/main/mtypes.h >>> +++ b/src/mesa/main/mtypes.h >>> @@ -2995,6 +2995,7 @@ struct gl_extensions >>> GLboolean NV_light_max_exponent; >>> GLboolean NV_point_sprite; >>> GLboolean NV_primitive_restart; >>> + GLboolean NV_read_buffer; >>> GLboolean NV_texture_barrier; >>> GLboolean NV_texgen_reflection; >>> GLboolean NV_texture_env_combine4; >> >> I'm a little confused by the 'get' code. GL_NV_read_buffer is an ES2 >> extension but you're testing if the current API is OpenGL, not ES2. > > Yeah, it can be a little hard to follow. The GL_READ_BUFFER token > used to be in the GL-only section of the big table, meaning that the > token was only valid in desktop GL. The patch moves it into the "GL > or GLES2" section, which means we'll add it to the get hash for both > GL and GLES2 APIs. The "extra" checks are conditions that is checked > at run-time and at least one must be true for the get to be valid. > What's counter-intuitive is that no conditions means "always true", I > guess. > > In this case we're adding two conditions: either the API must be GL > (EXTRA_API_GL) or we must have the extension enabled > (EXT(NV_read_buffer)).
OK, thanks. Maybe you could add a brief comment explaining that where you declare extra_NV_read_buffer_api_gl Otherwise, Reviewed-by: Brian Paul <bri...@vmware.com> _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev