OSDN Git Service

mesa/es: Validate glPixelStore pname in Mesa code rather than the ES wrapper
authorIan Romanick <ian.d.romanick@intel.com>
Fri, 27 Jul 2012 19:11:32 +0000 (12:11 -0700)
committerIan Romanick <ian.d.romanick@intel.com>
Wed, 29 Aug 2012 22:09:35 +0000 (15:09 -0700)
v2: Add proper core-profile and GLES3 filtering.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
src/mesa/main/APIspec.xml
src/mesa/main/pixelstore.c

index 55e418a..f1dae65 100644 (file)
                <param name="pname" type="GLenum"/>
                <param name="param" type="GLtype"/>
        </proto>
-
-       <desc name="pname">
-               <value name="GL_PACK_ALIGNMENT"/>
-               <desc name="param" error="GL_INVALID_VALUE">
-                       <value name="1"/>
-                       <value name="2"/>
-                       <value name="4"/>
-                       <value name="8"/>
-               </desc>
-       </desc>
-
-       <desc name="pname">
-               <value name="GL_UNPACK_ALIGNMENT"/>
-               <desc name="param" error="GL_INVALID_VALUE">
-                       <value name="1"/>
-                       <value name="2"/>
-                       <value name="4"/>
-                       <value name="8"/>
-               </desc>
-       </desc>
-
-       <desc name="pname" category="EXT_unpack_subimage">
-               <value name="GL_UNPACK_ROW_LENGTH"/>
-               <value name="GL_UNPACK_SKIP_PIXELS"/>
-               <value name="GL_UNPACK_SKIP_ROWS"/>
-       </desc>
-
 </template>
 
 <template name="ReadPixels" direction="get">
index 8147449..d1e96aa 100644 (file)
@@ -45,18 +45,24 @@ _mesa_PixelStorei( GLenum pname, GLint param )
 
    switch (pname) {
       case GL_PACK_SWAP_BYTES:
+         if (!_mesa_is_desktop_gl(ctx))
+            goto invalid_enum_error;
         if (param == (GLint)ctx->Pack.SwapBytes)
            return;
         FLUSH_VERTICES(ctx, _NEW_PACKUNPACK);
          ctx->Pack.SwapBytes = param ? GL_TRUE : GL_FALSE;
         break;
       case GL_PACK_LSB_FIRST:
+         if (!_mesa_is_desktop_gl(ctx))
+            goto invalid_enum_error;
         if (param == (GLint)ctx->Pack.LsbFirst)
            return;
         FLUSH_VERTICES(ctx, _NEW_PACKUNPACK);
          ctx->Pack.LsbFirst = param ? GL_TRUE : GL_FALSE;
         break;
       case GL_PACK_ROW_LENGTH:
+         if (!_mesa_is_desktop_gl(ctx) && !_mesa_is_gles3(ctx))
+            goto invalid_enum_error;
         if (param<0) {
            _mesa_error( ctx, GL_INVALID_VALUE, "glPixelStore(param)" );
            return;
@@ -67,6 +73,8 @@ _mesa_PixelStorei( GLenum pname, GLint param )
         ctx->Pack.RowLength = param;
         break;
       case GL_PACK_IMAGE_HEIGHT:
+         if (!_mesa_is_desktop_gl(ctx) && !_mesa_is_gles3(ctx))
+            goto invalid_enum_error;
          if (param<0) {
             _mesa_error( ctx, GL_INVALID_VALUE, "glPixelStore(param)" );
            return;
@@ -77,6 +85,8 @@ _mesa_PixelStorei( GLenum pname, GLint param )
         ctx->Pack.ImageHeight = param;
          break;
       case GL_PACK_SKIP_PIXELS:
+         if (!_mesa_is_desktop_gl(ctx) && !_mesa_is_gles3(ctx))
+            goto invalid_enum_error;
         if (param<0) {
            _mesa_error( ctx, GL_INVALID_VALUE, "glPixelStore(param)" );
            return;
@@ -87,6 +97,8 @@ _mesa_PixelStorei( GLenum pname, GLint param )
         ctx->Pack.SkipPixels = param;
         break;
       case GL_PACK_SKIP_ROWS:
+         if (!_mesa_is_desktop_gl(ctx) && !_mesa_is_gles3(ctx))
+            goto invalid_enum_error;
         if (param<0) {
            _mesa_error( ctx, GL_INVALID_VALUE, "glPixelStore(param)" );
            return;
@@ -97,6 +109,8 @@ _mesa_PixelStorei( GLenum pname, GLint param )
         ctx->Pack.SkipRows = param;
         break;
       case GL_PACK_SKIP_IMAGES:
+         if (!_mesa_is_desktop_gl(ctx) && !_mesa_is_gles3(ctx))
+            goto invalid_enum_error;
         if (param<0) {
            _mesa_error( ctx, GL_INVALID_VALUE, "glPixelStore(param)" );
            return;
@@ -117,6 +131,8 @@ _mesa_PixelStorei( GLenum pname, GLint param )
         ctx->Pack.Alignment = param;
         break;
       case GL_PACK_INVERT_MESA:
+         if (!_mesa_is_desktop_gl(ctx))
+            goto invalid_enum_error;
          if (!ctx->Extensions.MESA_pack_invert) {
             _mesa_error( ctx, GL_INVALID_ENUM, "glPixelstore(pname)" );
             return;
@@ -128,6 +144,8 @@ _mesa_PixelStorei( GLenum pname, GLint param )
          break;
 
       case GL_UNPACK_SWAP_BYTES:
+         if (!_mesa_is_desktop_gl(ctx))
+            goto invalid_enum_error;
         if (param == (GLint)ctx->Unpack.SwapBytes)
            return;
         if ((GLint)ctx->Unpack.SwapBytes == param)
@@ -136,6 +154,8 @@ _mesa_PixelStorei( GLenum pname, GLint param )
         ctx->Unpack.SwapBytes = param ? GL_TRUE : GL_FALSE;
          break;
       case GL_UNPACK_LSB_FIRST:
+         if (!_mesa_is_desktop_gl(ctx))
+            goto invalid_enum_error;
         if (param == (GLint)ctx->Unpack.LsbFirst)
            return;
         if ((GLint)ctx->Unpack.LsbFirst == param)
@@ -144,6 +164,8 @@ _mesa_PixelStorei( GLenum pname, GLint param )
         ctx->Unpack.LsbFirst = param ? GL_TRUE : GL_FALSE;
         break;
       case GL_UNPACK_ROW_LENGTH:
+         if (ctx->API == API_OPENGLES)
+            goto invalid_enum_error;
         if (param<0) {
            _mesa_error( ctx, GL_INVALID_VALUE, "glPixelStore(param)" );
            return;
@@ -154,6 +176,8 @@ _mesa_PixelStorei( GLenum pname, GLint param )
         ctx->Unpack.RowLength = param;
         break;
       case GL_UNPACK_IMAGE_HEIGHT:
+         if (!_mesa_is_desktop_gl(ctx) && !_mesa_is_gles3(ctx))
+            goto invalid_enum_error;
          if (param<0) {
             _mesa_error( ctx, GL_INVALID_VALUE, "glPixelStore(param)" );
            return;
@@ -165,6 +189,8 @@ _mesa_PixelStorei( GLenum pname, GLint param )
         ctx->Unpack.ImageHeight = param;
          break;
       case GL_UNPACK_SKIP_PIXELS:
+         if (ctx->API == API_OPENGLES)
+            goto invalid_enum_error;
         if (param<0) {
            _mesa_error( ctx, GL_INVALID_VALUE, "glPixelStore(param)" );
            return;
@@ -175,6 +201,8 @@ _mesa_PixelStorei( GLenum pname, GLint param )
         ctx->Unpack.SkipPixels = param;
         break;
       case GL_UNPACK_SKIP_ROWS:
+         if (ctx->API == API_OPENGLES)
+            goto invalid_enum_error;
         if (param<0) {
            _mesa_error( ctx, GL_INVALID_VALUE, "glPixelStore(param)" );
            return;
@@ -185,6 +213,8 @@ _mesa_PixelStorei( GLenum pname, GLint param )
         ctx->Unpack.SkipRows = param;
         break;
       case GL_UNPACK_SKIP_IMAGES:
+         if (!_mesa_is_desktop_gl(ctx) && !_mesa_is_gles3(ctx))
+            goto invalid_enum_error;
         if (param < 0) {
            _mesa_error( ctx, GL_INVALID_VALUE, "glPixelStore(param)" );
            return;
@@ -205,9 +235,14 @@ _mesa_PixelStorei( GLenum pname, GLint param )
         ctx->Unpack.Alignment = param;
         break;
       default:
-        _mesa_error( ctx, GL_INVALID_ENUM, "glPixelStore" );
-        return;
+         goto invalid_enum_error;
    }
+
+   return;
+
+invalid_enum_error:
+   _mesa_error( ctx, GL_INVALID_ENUM, "glPixelStore" );
+   return;
 }