[Mesa-dev] [PATCH 1/4] mesa/es: Validate buffer object targets in Mesa code rather than the ES wrapper

Ian Romanick idr at freedesktop.org
Fri Aug 24 08:45:32 PDT 2012


From: Ian Romanick <ian.d.romanick at intel.com>

v2: Add proper core-profile and GLES3 filtering.

Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
---
 src/mesa/main/APIspec.xml |   35 -----------------------------------
 src/mesa/main/bufferobj.c |    9 ++++++++-
 2 files changed, 8 insertions(+), 36 deletions(-)

diff --git a/src/mesa/main/APIspec.xml b/src/mesa/main/APIspec.xml
index d19a2b0..f15e8ee 100644
--- a/src/mesa/main/APIspec.xml
+++ b/src/mesa/main/APIspec.xml
@@ -1806,11 +1806,6 @@
 		<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">
@@ -1820,11 +1815,6 @@
 		<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>
@@ -1835,11 +1825,6 @@
 		<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">
@@ -1848,11 +1833,6 @@
 		<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">
@@ -1864,11 +1844,6 @@
 		<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"/>
@@ -1884,11 +1859,6 @@
 		<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">
@@ -1915,11 +1885,6 @@
 		<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"/>
diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c
index df55982..6cdf211 100644
--- a/src/mesa/main/bufferobj.c
+++ b/src/mesa/main/bufferobj.c
@@ -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;
-- 
1.7.6.5



More information about the mesa-dev mailing list