mesa/es: Validate glMapBuffer access in Mesa code rather than the ES wrapper
authorIan Romanick <ian.d.romanick@intel.com>
Wed, 25 Jul 2012 23:17:25 +0000 (16:17 -0700)
committerIan Romanick <ian.d.romanick@intel.com>
Sat, 25 Aug 2012 02:13:18 +0000 (19:13 -0700)
v2: Add proper core-profile and GLES3 filtering.

v3: *Really* add proper core-profile and GLES3 filtering based on review
feedback from Eric Anholt.  It looks like previously there was some
rebase / merge fail.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
src/mesa/main/APIspec.xml
src/mesa/main/bufferobj.c

index 3d47624c7fdd16f3dd5a56e9683424b6b694bab3..83a32d8e355d046a03d89bd73559f82b3617121d 100644 (file)
                <param name="target" type="GLenum"/>
                <param name="access" type="GLenum"/>
        </proto>
-
-       <desc name="access">
-               <value name="GL_WRITE_ONLY_OES"/>
-       </desc>
 </template>
 
 <template name="UnmapBuffer" direction="get">
index a5c2a7a1064ad6dc3137d2f14488ef60761e21f1..d800a4f0f96ae295e7fff0e1533253fdf77494c6 100644 (file)
@@ -1135,20 +1135,29 @@ _mesa_MapBufferARB(GLenum target, GLenum access)
    struct gl_buffer_object * bufObj;
    GLbitfield accessFlags;
    void *map;
+   bool valid_access;
 
    ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, NULL);
 
    switch (access) {
    case GL_READ_ONLY_ARB:
       accessFlags = GL_MAP_READ_BIT;
+      valid_access = _mesa_is_desktop_gl(ctx);
       break;
    case GL_WRITE_ONLY_ARB:
       accessFlags = GL_MAP_WRITE_BIT;
+      valid_access = true;
       break;
    case GL_READ_WRITE_ARB:
       accessFlags = GL_MAP_READ_BIT | GL_MAP_WRITE_BIT;
+      valid_access = _mesa_is_desktop_gl(ctx);
       break;
    default:
+      valid_access = false;
+      break;
+   }
+
+   if (!valid_access) {
       _mesa_error(ctx, GL_INVALID_ENUM, "glMapBufferARB(access)");
       return NULL;
    }