All surfaces follow D3D Y convention, i.e. (0, 0) is "top-left" rather than GL's "bottom-left". This eliminates the need to flip the default FBO to the D3D convention using additional blits when presenting and reduces VRAM usage for redundant window sized surfaces.

I took out the gl_Position.y flip from the vertex shader so FBOs are rendered
according to D3D conventions.

Texture lookups are flipped on Y to compensate. Cube map +Y and -Y faces are swapped. Y is now flipped in various other places, including uploading and reading back texture data from / to system memory, functions that take pixel space coordinates, winding order for culling, the implementation of ddy, the calculation of gl_Position and gl_FragCoord in fragment shaders and the flipping of compressed texture tiles.
Review URL: http://codereview.appspot.com/3265041

git-svn-id: https://angleproject.googlecode.com/svn/trunk@536 736b8ea6-26fd-11df-bfd4-992fa37f6226
diff --git a/src/libGLESv2/utilities.cpp b/src/libGLESv2/utilities.cpp
index a3f5243..a573025 100644
--- a/src/libGLESv2/utilities.cpp
+++ b/src/libGLESv2/utilities.cpp
@@ -189,18 +189,7 @@
 
 GLsizei ComputeCompressedPitch(GLsizei width, GLenum format)
 {
-    switch (format)
-    {
-      case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
-      case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
-        break;
-      default:
-        return 0;
-    }
-
-    ASSERT(width % 4 == 0);
-
-    return 8 * width / 4;
+    return ComputeCompressedSize(width, 1, format);
 }
 
 GLsizei ComputeCompressedSize(GLsizei width, GLsizei height, GLenum format)
@@ -528,6 +517,39 @@
     return cull;
 }
 
+D3DCUBEMAP_FACES ConvertCubeFace(GLenum cubeFace)
+{
+    D3DCUBEMAP_FACES face = D3DCUBEMAP_FACE_POSITIVE_X;
+
+    // Map a cube map texture target to the corresponding  D3D surface index. Note that the
+    // Y faces are swapped because the Y coordinate to the texture lookup intrinsic functions
+    // are negated in the pixel shader.
+    switch (cubeFace)
+    {
+      case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
+        face = D3DCUBEMAP_FACE_POSITIVE_X;
+        break;
+      case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
+        face = D3DCUBEMAP_FACE_NEGATIVE_X;
+        break;
+      case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
+        face = D3DCUBEMAP_FACE_NEGATIVE_Y;
+        break;
+      case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
+        face = D3DCUBEMAP_FACE_POSITIVE_Y;
+        break;
+      case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
+        face = D3DCUBEMAP_FACE_POSITIVE_Z;
+        break;
+      case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
+        face = D3DCUBEMAP_FACE_NEGATIVE_Z;
+        break;
+      default: UNREACHABLE();
+    }
+
+    return face;
+}
+
 DWORD ConvertColorMask(bool red, bool green, bool blue, bool alpha)
 {
     return (red   ? D3DCOLORWRITEENABLE_RED   : 0) |