mesa/es: Validate buffer object targets in Mesa code rather than the ES wrapper
authorIan Romanick <ian.d.romanick@intel.com>
Wed, 25 Jul 2012 22:29:48 +0000 (15:29 -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.

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 d19a2b02bd1786c800d423700b0afae250cbe706..f15e8ee78796da7e228f15438b05a65604bfaa11 100644 (file)
                <param name="pname" type="GLenum"/>
                <vector name="params" type="GLvoid **" size="dynamic"/>
        </proto>
-
-       <desc name="target">
-               <value name="GL_ARRAY_BUFFER"/>
-               <value name="GL_ELEMENT_ARRAY_BUFFER"/>
-       </desc>
 </template>
 
 <template name="MapBuffer" direction="get">
                <param name="access" type="GLenum"/>
        </proto>
 
-       <desc name="target">
-               <value name="GL_ARRAY_BUFFER"/>
-               <value name="GL_ELEMENT_ARRAY_BUFFER"/>
-       </desc>
-
        <desc name="access">
                <value name="GL_WRITE_ONLY_OES"/>
        </desc>
                <return type="GLboolean"/>
                <param name="target" type="GLenum"/>
        </proto>
-
-       <desc name="target">
-               <value name="GL_ARRAY_BUFFER"/>
-               <value name="GL_ELEMENT_ARRAY_BUFFER"/>
-       </desc>
 </template>
 
 <template name="BindBuffer">
                <param name="target" type="GLenum"/>
                <param name="buffer" type="GLuint"/>
        </proto>
-
-       <desc name="target">
-               <value name="GL_ARRAY_BUFFER"/>
-               <value name="GL_ELEMENT_ARRAY_BUFFER"/>
-       </desc>
 </template>
 
 <template name="BufferData">
                <param name="usage" type="GLenum"/>
        </proto>
 
-       <desc name="target">
-               <value name="GL_ARRAY_BUFFER"/>
-               <value name="GL_ELEMENT_ARRAY_BUFFER"/>
-       </desc>
-
        <desc name="usage">
                <value name="GL_STATIC_DRAW"/>
                <value name="GL_DYNAMIC_DRAW"/>
                <param name="size" type="GLsizeiptr"/>
                <param name="data" type="const GLvoid *"/>
        </proto>
-
-       <desc name="target">
-               <value name="GL_ARRAY_BUFFER"/>
-               <value name="GL_ELEMENT_ARRAY_BUFFER"/>
-       </desc>
 </template>
 
 <template name="DeleteBuffers">
                <vector name="params" type="GLtype *" size="dynamic"/>
        </proto>
 
-       <desc name="target">
-               <value name="GL_ARRAY_BUFFER"/>
-               <value name="GL_ELEMENT_ARRAY_BUFFER"/>
-       </desc>
-
        <desc name="pname">
                <value name="GL_BUFFER_SIZE"/>
                <value name="GL_BUFFER_USAGE"/>
index df559821cc1f3add6bc41747bc72eeaa698fe2ad..6cdf21167236fdd24ffb54a3d1d174189991400a 100644 (file)
@@ -68,6 +68,12 @@ static struct gl_buffer_object DummyBufferObject;
 static inline struct gl_buffer_object **
 get_buffer_target(struct gl_context *ctx, GLenum target)
 {
+   /* Other targets are only supported in desktop OpenGL and OpenGL ES 3.0.
+    */
+   if (!_mesa_is_desktop_gl(ctx) && !_mesa_is_gles3(ctx)
+       && target != GL_ARRAY_BUFFER && target != GL_ELEMENT_ARRAY_BUFFER)
+      return NULL;
+
    switch (target) {
    case GL_ARRAY_BUFFER_ARB:
       return &ctx->Array.ArrayBufferObj;
@@ -89,7 +95,8 @@ get_buffer_target(struct gl_context *ctx, GLenum target)
       break;
 #endif
    case GL_TEXTURE_BUFFER:
-      if (ctx->Extensions.ARB_texture_buffer_object) {
+      if (_mesa_is_desktop_gl(ctx)
+          && ctx->Extensions.ARB_texture_buffer_object) {
          return &ctx->Texture.BufferObject;
       }
       break;