mesa/es: Validate glFramebufferTexture2D textarget in Mesa code rather than the ES wrapper

v2: Add proper core-profile and GLES3 filtering.

v3: Change !_mesa_is_desktop_gl tests to _mesa_is_gles test.  The test
around GL_TEXTURE_2D_ARRAY got some other changes because that enum is
also available with GLES3 (which uses API_OPENGLES2).  Based on review
feedback from Eric Anholt.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
index 792a92d..5fba3a1 100644
--- a/src/mesa/main/fbobject.c
+++ b/src/mesa/main/fbobject.c
@@ -2137,7 +2137,8 @@
          error = GL_FALSE;
          break;
       case GL_TEXTURE_RECTANGLE:
-         error = !ctx->Extensions.NV_texture_rectangle;
+         error = _mesa_is_gles(ctx)
+            || !ctx->Extensions.NV_texture_rectangle;
          break;
       case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
       case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
@@ -2148,7 +2149,8 @@
          error = !ctx->Extensions.ARB_texture_cube_map;
          break;
       case GL_TEXTURE_2D_ARRAY:
-         error = !ctx->Extensions.EXT_texture_array;
+         error = (_mesa_is_gles(ctx) && ctx->Version < 30)
+            || !ctx->Extensions.EXT_texture_array;
          break;
       default:
          error = GL_TRUE;