Merge no-flip-rows r1142 to trunk.
Review URL: https://codereview.appspot.com/6304052

git-svn-id: https://angleproject.googlecode.com/svn/trunk@1162 736b8ea6-26fd-11df-bfd4-992fa37f6226
diff --git a/src/compiler/OutputHLSL.cpp b/src/compiler/OutputHLSL.cpp
index 7e00cb6..4a69d73 100644
--- a/src/compiler/OutputHLSL.cpp
+++ b/src/compiler/OutputHLSL.cpp
@@ -219,25 +219,11 @@
         out <<  uniforms;
         out << "\n";
 
-        // The texture fetch functions "flip" the Y coordinate in one way or another. This is because textures are stored
-        // according to the OpenGL convention, i.e. (0, 0) is "bottom left", rather than the D3D convention where (0, 0)
-        // is "top left". Since the HLSL texture fetch functions expect textures to be stored according to the D3D
-        // convention, the Y coordinate passed to these functions is adjusted to compensate.
-        //
-        // The simplest case is texture2D where the mapping is Y -> 1-Y, which maps [0, 1] -> [1, 0].
-        //
-        // The texture2DProj functions are more complicated because the projection divides by either Z or W. For the vec3
-        // case, the mapping is Y -> Z-Y or Y/Z -> 1-Y/Z, which again maps [0, 1] -> [1, 0].
-        //
-        // For cube textures the mapping is Y -> -Y, which maps [-1, 1] -> [1, -1]. This is not sufficient on its own for the
-        // +Y and -Y faces, which are now on the "wrong sides" of the cube. This is compensated for by exchanging the
-        // +Y and -Y faces everywhere else throughout the code.
-        
         if (mUsesTexture2D)
         {
             out << "float4 gl_texture2D(sampler2D s, float2 t)\n"
                    "{\n"
-                   "    return tex2D(s, float2(t.x, 1 - t.y));\n"
+                   "    return tex2D(s, t);\n"
                    "}\n"
                    "\n";
         }
@@ -246,7 +232,7 @@
         {
             out << "float4 gl_texture2D(sampler2D s, float2 t, float bias)\n"
                    "{\n"
-                   "    return tex2Dbias(s, float4(t.x, 1 - t.y, 0, bias));\n"
+                   "    return tex2Dbias(s, float4(t.x, t.y, 0, bias));\n"
                    "}\n"
                    "\n";
         }
@@ -255,12 +241,12 @@
         {
             out << "float4 gl_texture2DProj(sampler2D s, float3 t)\n"
                    "{\n"
-                   "    return tex2Dproj(s, float4(t.x, t.z - t.y, 0, t.z));\n"
+                   "    return tex2Dproj(s, float4(t.x, t.y, 0, t.z));\n"
                    "}\n"
                    "\n"
                    "float4 gl_texture2DProj(sampler2D s, float4 t)\n"
                    "{\n"
-                   "    return tex2Dproj(s, float4(t.x, t.w - t.y, t.z, t.w));\n"
+                   "    return tex2Dproj(s, t);\n"
                    "}\n"
                    "\n";
         }
@@ -269,12 +255,12 @@
         {
             out << "float4 gl_texture2DProj(sampler2D s, float3 t, float bias)\n"
                    "{\n"
-                   "    return tex2Dbias(s, float4(t.x / t.z, 1 - (t.y / t.z), 0, bias));\n"
+                   "    return tex2Dbias(s, float4(t.x / t.z, t.y / t.z, 0, bias));\n"
                    "}\n"
                    "\n"
                    "float4 gl_texture2DProj(sampler2D s, float4 t, float bias)\n"
                    "{\n"
-                   "    return tex2Dbias(s, float4(t.x / t.w, 1 - (t.y / t.w), 0, bias));\n"
+                   "    return tex2Dbias(s, float4(t.x / t.w, t.y / t.w, 0, bias));\n"
                    "}\n"
                    "\n";
         }
@@ -283,7 +269,7 @@
         {
             out << "float4 gl_textureCube(samplerCUBE s, float3 t)\n"
                    "{\n"
-                   "    return texCUBE(s, float3(t.x, -t.y, t.z));\n"
+                   "    return texCUBE(s, t);\n"
                    "}\n"
                    "\n";
         }
@@ -292,7 +278,7 @@
         {
             out << "float4 gl_textureCube(samplerCUBE s, float3 t, float bias)\n"
                    "{\n"
-                   "    return texCUBEbias(s, float4(t.x, -t.y, t.z, bias));\n"
+                   "    return texCUBEbias(s, float4(t.x, t.y, t.z, bias));\n"
                    "}\n"
                    "\n";
         }
@@ -303,7 +289,7 @@
         {
             out << "float4 gl_texture2DLod0(sampler2D s, float2 t)\n"
                    "{\n"
-                   "    return tex2Dlod(s, float4(t.x, 1 - t.y, 0, 0));\n"
+                   "    return tex2Dlod(s, float4(t.x, t.y, 0, 0));\n"
                    "}\n"
                    "\n";
         }
@@ -312,7 +298,7 @@
         {
             out << "float4 gl_texture2DLod0(sampler2D s, float2 t, float bias)\n"
                    "{\n"
-                   "    return tex2Dlod(s, float4(t.x, 1 - t.y, 0, 0));\n"
+                   "    return tex2Dlod(s, float4(t.x, t.y, 0, 0));\n"
                    "}\n"
                    "\n";
         }
@@ -321,12 +307,12 @@
         {
             out << "float4 gl_texture2DProjLod0(sampler2D s, float3 t)\n"
                    "{\n"
-                   "    return tex2Dlod(s, float4(t.x / t.z, 1 - t.y / t.z, 0, 0));\n"
+                   "    return tex2Dlod(s, float4(t.x / t.z, t.y / t.z, 0, 0));\n"
                    "}\n"
                    "\n"
                    "float4 gl_texture2DProjLod(sampler2D s, float4 t)\n"
                    "{\n"
-                   "    return tex2Dlod(s, float4(t.x / t.w, 1 - t.y / t.w, 0, 0));\n"
+                   "    return tex2Dlod(s, float4(t.x / t.w, t.y / t.w, 0, 0));\n"
                    "}\n"
                    "\n";
         }
@@ -335,12 +321,12 @@
         {
             out << "float4 gl_texture2DProjLod0_bias(sampler2D s, float3 t, float bias)\n"
                    "{\n"
-                   "    return tex2Dlod(s, float4(t.x / t.z, 1 - t.y / t.z, 0, 0));\n"
+                   "    return tex2Dlod(s, float4(t.x / t.z, t.y / t.z, 0, 0));\n"
                    "}\n"
                    "\n"
                    "float4 gl_texture2DProjLod_bias(sampler2D s, float4 t, float bias)\n"
                    "{\n"
-                   "    return tex2Dlod(s, float4(t.x / t.w, 1 - t.y / t.w, 0, 0));\n"
+                   "    return tex2Dlod(s, float4(t.x / t.w, t.y / t.w, 0, 0));\n"
                    "}\n"
                    "\n";
         }
@@ -349,7 +335,7 @@
         {
             out << "float4 gl_textureCubeLod0(samplerCUBE s, float3 t)\n"
                    "{\n"
-                   "    return texCUBElod(s, float4(t.x, -t.y, t.z, 0));\n"
+                   "    return texCUBElod(s, float4(t.x, t.y, t.z, 0));\n"
                    "}\n"
                    "\n";
         }
@@ -358,7 +344,7 @@
         {
             out << "float4 gl_textureCubeLod0(samplerCUBE s, float3 t, float bias)\n"
                    "{\n"
-                   "    return texCUBElod(s, float4(t.x, -t.y, t.z, 0));\n"
+                   "    return texCUBElod(s, float4(t.x, t.y, t.z, 0));\n"
                    "}\n"
                    "\n";
         }
@@ -1232,7 +1218,7 @@
         }
         else
         {
-           outputTriplet(visit, "(-ddy(", "", "))");
+           outputTriplet(visit, "ddy(", "", ")");
         }
         break;
       case EOpFwidth: