gles2: Add GL_NV_read_buffer extension
authorKristian Høgsberg <krh@bitplanet.net>
Fri, 15 Jun 2012 13:40:41 +0000 (09:40 -0400)
committerKristian Høgsberg <krh@bitplanet.net>
Mon, 18 Jun 2012 15:53:18 +0000 (11:53 -0400)
This lets us select the front buffer for reading under GLES2.

Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
src/mapi/glapi/gen/es_EXT.xml
src/mapi/glapi/gen/gles_api.py
src/mesa/main/APIspec.xml
src/mesa/main/extensions.c
src/mesa/main/get.c
src/mesa/main/mtypes.h

index c7e7d07e3cc382a38f8ce227f15032253f0685fa..b26cac54b792dc4658be1395605b4ff2e48d44ac 100644 (file)
     <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>
index 0116ba47406d1aa70359f356787168272d99a72f..70ae2e300ea17a75676a6c9fbc5a4f7e18cb4355 100644 (file)
@@ -451,4 +451,6 @@ es2_api = es2_core + (
         'ProgramBinaryOES',
         # GL_NV_draw_buffers
         'DrawBuffersNV',
+        # GL_NV_read_buffer
+        'ReadBufferNV',
 )
index f23857ad2f45bc51871af05a6547c599397f058e..64e666effd603b483466520432a0ff109c6fecc0 100644 (file)
        </proto>
 </template>
 
+<template name="ReadBuffer">
+       <proto>
+               <return type="void"/>
+               <param name="mode" type="GLenum"/>
+       </proto>
+</template>
+
 <api name="mesa" implementation="true">
        <category name="MESA"/>
 
         <function name="EGLImageTargetRenderbufferStorageOES" template="EGLImageTargetRenderbufferStorage"/>
 
        <function name="DrawBuffersARB" template="DrawBuffers"/>
+
+       <function name="ReadBuffer" template="ReadBuffer"/>
+
 </api>
 
 <api name="GLES1.1">
         <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"/>
 
index 2688f7acedcfeaaae71356166290898191c80606..0e8178397d9e90a5825fc3f0274faa530da5d3b7 100644 (file)
@@ -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 },
index a8e1d8681c52cca9559bfeb93c20e1d848c0b6d7..8dc47306f90516d8f29720bccbec0e37e8f2aec1 100644 (file)
@@ -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,15 @@ extra_ARB_vertex_program_api_es2[] = {
    EXTRA_END
 };
 
+/* The ReadBuffer get token is valid under either full GL or under
+ * GLES2 if the NV_read_buffer extension is available. */
+static const int
+extra_NV_read_buffer_api_gl[] = {
+   EXT(NV_read_buffer),
+   EXTRA_API_GL,
+   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 +760,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 +899,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 +1828,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);
index ea40ffc9c06c96c7ff1aa03c6d5fb5d2125f5d63..3d18b7c4869ab9fdeb6789009b12fa9188adcdb5 100644 (file)
@@ -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;