Mesa (master): mesa/es: Validate glBufferData usage in Mesa code rather than the ES wrapper

Ian Romanick idr at kemper.freedesktop.org
Sat Aug 25 02:15:08 UTC 2012


Module: Mesa
Branch: master
Commit: bd4e5dd3553c5d7152af419f8b12ce228aba2dd2
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=bd4e5dd3553c5d7152af419f8b12ce228aba2dd2

Author: Ian Romanick <ian.d.romanick at intel.com>
Date:   Wed Jul 25 16:08:12 2012 -0700

mesa/es: Validate glBufferData usage in Mesa code rather than the ES wrapper

v2: 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 at intel.com>
Reviewed-by: Eric Anholt <eric at anholt.net>

---

 src/mesa/main/APIspec.xml |    6 ------
 src/mesa/main/bufferobj.c |   23 ++++++++++++++++++-----
 2 files changed, 18 insertions(+), 11 deletions(-)

diff --git a/src/mesa/main/APIspec.xml b/src/mesa/main/APIspec.xml
index f15e8ee..3d47624 100644
--- a/src/mesa/main/APIspec.xml
+++ b/src/mesa/main/APIspec.xml
@@ -1843,12 +1843,6 @@
 		<param name="data" type="const GLvoid *"/>
 		<param name="usage" type="GLenum"/>
 	</proto>
-
-	<desc name="usage">
-		<value name="GL_STATIC_DRAW"/>
-		<value name="GL_DYNAMIC_DRAW"/>
-		<value name="GL_STREAM_DRAW" category="GLES2.0"/>
-	</desc>
 </template>
 
 <template name="BufferSubData">
diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c
index 6cdf211..a5c2a7a 100644
--- a/src/mesa/main/bufferobj.c
+++ b/src/mesa/main/bufferobj.c
@@ -30,7 +30,7 @@
  * \author Brian Paul, Ian Romanick
  */
 
-
+#include <stdbool.h>
 #include "glheader.h"
 #include "enums.h"
 #include "hash.h"
@@ -1009,6 +1009,7 @@ _mesa_BufferDataARB(GLenum target, GLsizeiptrARB size,
 {
    GET_CURRENT_CONTEXT(ctx);
    struct gl_buffer_object *bufObj;
+   bool valid_usage;
    ASSERT_OUTSIDE_BEGIN_END(ctx);
 
    if (MESA_VERBOSE & VERBOSE_API)
@@ -1024,18 +1025,30 @@ _mesa_BufferDataARB(GLenum target, GLsizeiptrARB size,
 
    switch (usage) {
    case GL_STREAM_DRAW_ARB:
+      valid_usage = (ctx->API != API_OPENGLES);
+      break;
+
+   case GL_STATIC_DRAW_ARB:
+   case GL_DYNAMIC_DRAW_ARB:
+      valid_usage = true;
+      break;
+
    case GL_STREAM_READ_ARB:
    case GL_STREAM_COPY_ARB:
-   case GL_STATIC_DRAW_ARB:
    case GL_STATIC_READ_ARB:
    case GL_STATIC_COPY_ARB:
-   case GL_DYNAMIC_DRAW_ARB:
    case GL_DYNAMIC_READ_ARB:
    case GL_DYNAMIC_COPY_ARB:
-      /* OK */
+      valid_usage = _mesa_is_desktop_gl(ctx) || _mesa_is_gles3(ctx);
       break;
+
    default:
-      _mesa_error(ctx, GL_INVALID_ENUM, "glBufferDataARB(usage)");
+      valid_usage = false;
+      break;
+   }
+
+   if (!valid_usage) {
+      _mesa_error(ctx, GL_INVALID_ENUM, "glBufferData(usage)");
       return;
    }
 




More information about the mesa-commit mailing list