Set y-axis up in normalized coordinate system.

BUG=dawn:224

Change-Id: I6bb4946e87b593f1d62a13b3b8ab38f21d3e9ffb
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/10201
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Yunchao He <yunchao.he@intel.com>
diff --git a/src/dawn_native/d3d12/ShaderModuleD3D12.cpp b/src/dawn_native/d3d12/ShaderModuleD3D12.cpp
index 4698459..872e397 100644
--- a/src/dawn_native/d3d12/ShaderModuleD3D12.cpp
+++ b/src/dawn_native/d3d12/ShaderModuleD3D12.cpp
@@ -37,7 +37,6 @@
         // If these options are changed, the values in DawnSPIRVCrossHLSLFastFuzzer.cpp need to be
         // updated.
         spirv_cross::CompilerGLSL::Options options_glsl;
-        options_glsl.vertex.flip_vert_y = true;
         compiler.set_common_options(options_glsl);
 
         spirv_cross::CompilerHLSL::Options options_hlsl;
diff --git a/src/dawn_native/metal/ShaderModuleMTL.mm b/src/dawn_native/metal/ShaderModuleMTL.mm
index 69c9633..316be54 100644
--- a/src/dawn_native/metal/ShaderModuleMTL.mm
+++ b/src/dawn_native/metal/ShaderModuleMTL.mm
@@ -54,10 +54,6 @@
 
         // If these options are changed, the values in DawnSPIRVCrossMSLFastFuzzer.cpp need to be
         // updated.
-        spirv_cross::CompilerGLSL::Options options_glsl;
-        options_glsl.vertex.flip_vert_y = true;
-        compiler.spirv_cross::CompilerGLSL::set_common_options(options_glsl);
-
         spirv_cross::CompilerMSL::Options options_msl;
 
         // Disable PointSize builtin for https://bugs.chromium.org/p/dawn/issues/detail?id=146
diff --git a/src/dawn_native/opengl/ShaderModuleGL.cpp b/src/dawn_native/opengl/ShaderModuleGL.cpp
index e7e2d33..e4e8b8f 100644
--- a/src/dawn_native/opengl/ShaderModuleGL.cpp
+++ b/src/dawn_native/opengl/ShaderModuleGL.cpp
@@ -58,6 +58,7 @@
         // in D3D12, Metal and Vulkan, so we should normalize it in shaders in all backends.
         // See the documentation of spirv_cross::CompilerGLSL::Options::vertex::fixup_clipspace for
         // more details.
+        options.vertex.flip_vert_y = true;
         options.vertex.fixup_clipspace = true;
 
         // TODO(cwallez@chromium.org): discover the backing context version and use that.
diff --git a/src/dawn_native/vulkan/AdapterVk.cpp b/src/dawn_native/vulkan/AdapterVk.cpp
index d86a3bb..dd9341f 100644
--- a/src/dawn_native/vulkan/AdapterVk.cpp
+++ b/src/dawn_native/vulkan/AdapterVk.cpp
@@ -39,6 +39,12 @@
 
     MaybeError Adapter::Initialize() {
         DAWN_TRY_ASSIGN(mDeviceInfo, GatherDeviceInfo(*this));
+        if (!mDeviceInfo.maintenance1 &&
+            mDeviceInfo.properties.apiVersion < VK_MAKE_VERSION(1, 1, 0)) {
+            return DAWN_DEVICE_LOST_ERROR(
+                "Dawn requires Vulkan 1.1 or Vulkan 1.0 with KHR_Maintenance1 in order to support "
+                "viewport flipY");
+        }
 
         InitializeSupportedExtensions();
 
diff --git a/src/dawn_native/vulkan/CommandBufferVk.cpp b/src/dawn_native/vulkan/CommandBufferVk.cpp
index 71584fa..7729286 100644
--- a/src/dawn_native/vulkan/CommandBufferVk.cpp
+++ b/src/dawn_native/vulkan/CommandBufferVk.cpp
@@ -659,9 +659,9 @@
             // The viewport and scissor default to cover all of the attachments
             VkViewport viewport;
             viewport.x = 0.0f;
-            viewport.y = 0.0f;
+            viewport.y = static_cast<float>(renderPassCmd->height);
             viewport.width = static_cast<float>(renderPassCmd->width);
-            viewport.height = static_cast<float>(renderPassCmd->height);
+            viewport.height = -static_cast<float>(renderPassCmd->height);
             viewport.minDepth = 0.0f;
             viewport.maxDepth = 1.0f;
             device->fn.CmdSetViewport(commands, 0, 1, &viewport);
@@ -853,9 +853,9 @@
                     SetViewportCmd* cmd = mCommands.NextCommand<SetViewportCmd>();
                     VkViewport viewport;
                     viewport.x = cmd->x;
-                    viewport.y = cmd->y;
+                    viewport.y = cmd->y + cmd->height;
                     viewport.width = cmd->width;
-                    viewport.height = cmd->height;
+                    viewport.height = -cmd->height;
                     viewport.minDepth = cmd->minDepth;
                     viewport.maxDepth = cmd->maxDepth;
 
diff --git a/src/dawn_native/vulkan/DeviceVk.cpp b/src/dawn_native/vulkan/DeviceVk.cpp
index d1ec330..123aabf 100644
--- a/src/dawn_native/vulkan/DeviceVk.cpp
+++ b/src/dawn_native/vulkan/DeviceVk.cpp
@@ -380,6 +380,10 @@
             extensionsToRequest.push_back(kExtensionNameKhrSwapchain);
             usedKnobs.swapchain = true;
         }
+        if (mDeviceInfo.maintenance1) {
+            extensionsToRequest.push_back(kExtensionNameKhrMaintenance1);
+            usedKnobs.maintenance1 = true;
+        }
 
         // Always require independentBlend because it is a core Dawn feature
         usedKnobs.features.independentBlend = VK_TRUE;
diff --git a/src/dawn_native/vulkan/VulkanInfo.cpp b/src/dawn_native/vulkan/VulkanInfo.cpp
index 675e132..18cefb2 100644
--- a/src/dawn_native/vulkan/VulkanInfo.cpp
+++ b/src/dawn_native/vulkan/VulkanInfo.cpp
@@ -74,6 +74,7 @@
     const char kExtensionNameKhrXcbSurface[] = "VK_KHR_xcb_surface";
     const char kExtensionNameKhrXlibSurface[] = "VK_KHR_xlib_surface";
     const char kExtensionNameFuchsiaImagePipeSurface[] = "VK_FUCHSIA_imagepipe_surface";
+    const char kExtensionNameKhrMaintenance1[] = "VK_KHR_maintenance1";
 
     ResultOrError<VulkanGlobalInfo> GatherGlobalInfo(const Backend& backend) {
         VulkanGlobalInfo info = {};
@@ -301,6 +302,9 @@
                 if (IsExtensionName(extension, kExtensionNameKhrSwapchain)) {
                     info.swapchain = true;
                 }
+                if (IsExtensionName(extension, kExtensionNameKhrMaintenance1)) {
+                    info.maintenance1 = true;
+                }
             }
         }
 
diff --git a/src/dawn_native/vulkan/VulkanInfo.h b/src/dawn_native/vulkan/VulkanInfo.h
index 9c61525..2da3466 100644
--- a/src/dawn_native/vulkan/VulkanInfo.h
+++ b/src/dawn_native/vulkan/VulkanInfo.h
@@ -49,6 +49,7 @@
     extern const char kExtensionNameKhrXcbSurface[];
     extern const char kExtensionNameKhrXlibSurface[];
     extern const char kExtensionNameFuchsiaImagePipeSurface[];
+    extern const char kExtensionNameKhrMaintenance1[];
 
     // Global information - gathered before the instance is created
     struct VulkanGlobalKnobs {
@@ -92,6 +93,7 @@
         bool externalSemaphoreFD = false;
         bool externalSemaphoreZirconHandle = false;
         bool swapchain = false;
+        bool maintenance1 = false;
     };
 
     struct VulkanDeviceInfo : VulkanDeviceKnobs {
diff --git a/src/fuzzers/DawnSPIRVCrossHLSLFastFuzzer.cpp b/src/fuzzers/DawnSPIRVCrossHLSLFastFuzzer.cpp
index dd044cf..6ebe67d 100644
--- a/src/fuzzers/DawnSPIRVCrossHLSLFastFuzzer.cpp
+++ b/src/fuzzers/DawnSPIRVCrossHLSLFastFuzzer.cpp
@@ -32,7 +32,6 @@
             options.SetTargetEnvironment(shaderc_target_env_vulkan, shaderc_env_version_vulkan_1_1);
 
             // Using the options that are used by Dawn, they appear in ShaderModuleD3D12.cpp
-            options.SetFlipVertY(true);
             options.SetHLSLShaderModel(51);
             // TODO (hao.x.li@intel.com): The HLSLPointCoordCompat and HLSLPointSizeCompat are
             // required temporarily for https://bugs.chromium.org/p/dawn/issues/detail?id=146,
diff --git a/src/fuzzers/DawnSPIRVCrossMSLFastFuzzer.cpp b/src/fuzzers/DawnSPIRVCrossMSLFastFuzzer.cpp
index 13c8391..36bb0c4 100644
--- a/src/fuzzers/DawnSPIRVCrossMSLFastFuzzer.cpp
+++ b/src/fuzzers/DawnSPIRVCrossMSLFastFuzzer.cpp
@@ -32,7 +32,6 @@
             options.SetTargetEnvironment(shaderc_target_env_vulkan, shaderc_env_version_vulkan_1_1);
 
             // Using the options that are used by Dawn, they appear in ShaderModuleMTL.mm
-            options.SetFlipVertY(true);
             compiler.CompileSpvToMsl(input.data(), input.size(), options);
         });
 
diff --git a/src/tests/end2end/BindGroupTests.cpp b/src/tests/end2end/BindGroupTests.cpp
index df2251c..b70b1a1 100644
--- a/src/tests/end2end/BindGroupTests.cpp
+++ b/src/tests/end2end/BindGroupTests.cpp
@@ -49,7 +49,7 @@
         return utils::CreateShaderModule(device, utils::SingleShaderStage::Vertex, R"(
         #version 450
         void main() {
-            const vec2 pos[3] = vec2[3](vec2(-1.f, -1.f), vec2(1.f, -1.f), vec2(-1.f, 1.f));
+            const vec2 pos[3] = vec2[3](vec2(-1.f, 1.f), vec2(1.f, 1.f), vec2(-1.f, -1.f));
             gl_Position = vec4(pos[gl_VertexIndex], 0.f, 1.f);
         })");
     }
@@ -167,7 +167,7 @@
             mat2 transform;
         };
         void main() {
-            const vec2 pos[3] = vec2[3](vec2(-1.f, -1.f), vec2(1.f, -1.f), vec2(-1.f, 1.f));
+            const vec2 pos[3] = vec2[3](vec2(-1.f, 1.f), vec2(1.f, 1.f), vec2(-1.f, -1.f));
             gl_Position = vec4(transform * pos[gl_VertexIndex], 0.f, 1.f);
         })");
 
@@ -248,7 +248,7 @@
             mat2 transform;
         };
         void main() {
-            const vec2 pos[3] = vec2[3](vec2(-1.f, -1.f), vec2(1.f, -1.f), vec2(-1.f, 1.f));
+            const vec2 pos[3] = vec2[3](vec2(-1.f, 1.f), vec2(1.f, 1.f), vec2(-1.f, -1.f));
             gl_Position = vec4(transform * pos[gl_VertexIndex], 0.f, 1.f);
         })");
 
@@ -368,7 +368,7 @@
             mat2 transform2;
         };
         void main() {
-            const vec2 pos[3] = vec2[3](vec2(-1.f, -1.f), vec2(1.f, -1.f), vec2(-1.f, 1.f));
+            const vec2 pos[3] = vec2[3](vec2(-1.f, 1.f), vec2(1.f, 1.f), vec2(-1.f, -1.f));
             gl_Position = vec4((transform1 + transform2) * pos[gl_VertexIndex], 0.f, 1.f);
         })");
 
diff --git a/src/tests/end2end/ClipSpaceTests.cpp b/src/tests/end2end/ClipSpaceTests.cpp
index 439f0d3..6d5e9da 100644
--- a/src/tests/end2end/ClipSpaceTests.cpp
+++ b/src/tests/end2end/ClipSpaceTests.cpp
@@ -27,12 +27,12 @@
         // 2. The depth value of the bottom-right one is <= 0.5
         const char* vs =
             R"(#version 450
-            const vec3 pos[6] = vec3[6](vec3(-1.0f, -1.0f, 1.0f),
-                                    vec3(-1.0f,  1.0f, 0.5f),
-                                    vec3( 1.0f, -1.0f, 0.5f),
-                                    vec3( 1.0f, -1.0f, 0.5f),
-                                    vec3(-1.0f,  1.0f, 0.5f),
-                                    vec3( 1.0f,  1.0f, 0.0f));
+            const vec3 pos[6] = vec3[6](vec3(-1.0f,  1.0f, 1.0f),
+                                        vec3(-1.0f, -1.0f, 0.5f),
+                                        vec3( 1.0f,  1.0f, 0.5f),
+                                        vec3( 1.0f,  1.0f, 0.5f),
+                                        vec3(-1.0f, -1.0f, 0.5f),
+                                        vec3( 1.0f, -1.0f, 0.0f));
             void main() {
                 gl_Position = vec4(pos[gl_VertexIndex], 1.0);
             })";
diff --git a/src/tests/end2end/CompressedTextureFormatTests.cpp b/src/tests/end2end/CompressedTextureFormatTests.cpp
index 84ed2d9..216eca5 100644
--- a/src/tests/end2end/CompressedTextureFormatTests.cpp
+++ b/src/tests/end2end/CompressedTextureFormatTests.cpp
@@ -145,12 +145,12 @@
             layout(location=0) out vec2 texCoord;
             void main() {
                 const vec2 pos[3] = vec2[3](
-                    vec2(-3.0f, -1.0f),
-                    vec2( 3.0f, -1.0f),
-                    vec2( 0.0f,  2.0f)
+                    vec2(-3.0f,  1.0f),
+                    vec2( 3.0f,  1.0f),
+                    vec2( 0.0f, -2.0f)
                 );
                 gl_Position = vec4(pos[gl_VertexIndex], 0.0f, 1.0f);
-                texCoord = gl_Position.xy / 2.0f + vec2(0.5f);
+                texCoord = vec2(gl_Position.x / 2.0f, -gl_Position.y / 2.0f) + vec2(0.5f);
             })");
         dawn::ShaderModule fsModule =
             utils::CreateShaderModule(device, utils::SingleShaderStage::Fragment, R"(
diff --git a/src/tests/end2end/CullingTests.cpp b/src/tests/end2end/CullingTests.cpp
index 7745348..b1788d7 100644
--- a/src/tests/end2end/CullingTests.cpp
+++ b/src/tests/end2end/CullingTests.cpp
@@ -27,12 +27,12 @@
         // 2. The bottom-right one is clockwise (CW)
         const char* vs =
             R"(#version 450
-            const vec2 pos[6] = vec2[6](vec2(-1.0f, -1.0f),
-                                    vec2(-1.0f,  0.0f),
-                                    vec2( 0.0f, -1.0f),
-                                    vec2( 0.0f,  1.0f),
-                                    vec2( 1.0f,  0.0f),
-                                    vec2( 1.0f,  1.0f));
+            const vec2 pos[6] = vec2[6](vec2(-1.0f,  1.0f),
+                                        vec2(-1.0f,  0.0f),
+                                        vec2( 0.0f,  1.0f),
+                                        vec2( 0.0f, -1.0f),
+                                        vec2( 1.0f,  0.0f),
+                                        vec2( 1.0f, -1.0f));
             void main() {
                 gl_Position = vec4(pos[gl_VertexIndex], 0.0, 1.0);
             })";
diff --git a/src/tests/end2end/DestroyTests.cpp b/src/tests/end2end/DestroyTests.cpp
index 98a2cca..f9dfc3b 100644
--- a/src/tests/end2end/DestroyTests.cpp
+++ b/src/tests/end2end/DestroyTests.cpp
@@ -57,7 +57,7 @@
         vertexBuffer = utils::CreateBufferFromData<float>(
             device, dawn::BufferUsage::Vertex,
             {// The bottom left triangle
-             -1.0f, -1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, -1.0f, 1.0f, 0.0f, 1.0f});
+             -1.0f, 1.0f, 0.0f, 1.0f, 1.0f, -1.0f, 0.0f, 1.0f, -1.0f, -1.0f, 0.0f, 1.0f});
 
         dawn::CommandEncoder encoder = device.CreateCommandEncoder();
         encoder.BeginRenderPass(&renderPass.renderPassInfo).EndPass();
diff --git a/src/tests/end2end/DrawIndexedIndirectTests.cpp b/src/tests/end2end/DrawIndexedIndirectTests.cpp
index 5f7395b..c0e68b1 100644
--- a/src/tests/end2end/DrawIndexedIndirectTests.cpp
+++ b/src/tests/end2end/DrawIndexedIndirectTests.cpp
@@ -57,11 +57,11 @@
         vertexBuffer = utils::CreateBufferFromData<float>(
             device, dawn::BufferUsage::Vertex,
             {// First quad: the first 3 vertices represent the bottom left triangle
-             -1.0f, -1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, -1.0f, 1.0f, 0.0f, 1.0f, 1.0f, -1.0f,
+             -1.0f, 1.0f, 0.0f, 1.0f, 1.0f, -1.0f, 0.0f, 1.0f, -1.0f, -1.0f, 0.0f, 1.0f, 1.0f, 1.0f,
              0.0f, 1.0f,
 
              // Second quad: the first 3 vertices represent the top right triangle
-             -1.0f, -1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, 1.0f, -1.0f, 0.0f, 1.0f, -1.0f, 1.0f,
+             -1.0f, 1.0f, 0.0f, 1.0f, 1.0f, -1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, -1.0f, -1.0f,
              0.0f, 1.0f});
         indexBuffer = utils::CreateBufferFromData<uint32_t>(
             device, dawn::BufferUsage::Index,
diff --git a/src/tests/end2end/DrawIndexedTests.cpp b/src/tests/end2end/DrawIndexedTests.cpp
index 6d28857..159f1ef 100644
--- a/src/tests/end2end/DrawIndexedTests.cpp
+++ b/src/tests/end2end/DrawIndexedTests.cpp
@@ -57,12 +57,12 @@
             vertexBuffer = utils::CreateBufferFromData<float>(
                 device, dawn::BufferUsage::Vertex,
                 {// First quad: the first 3 vertices represent the bottom left triangle
-                 -1.0f, -1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, -1.0f, 1.0f, 0.0f, 1.0f, 1.0f,
-                 -1.0f, 0.0f, 1.0f,
+                 -1.0f, 1.0f, 0.0f, 1.0f, 1.0f, -1.0f, 0.0f, 1.0f, -1.0f, -1.0f, 0.0f, 1.0f, 1.0f,
+                 1.0f, 0.0f, 1.0f,
 
                  // Second quad: the first 3 vertices represent the top right triangle
-                 -1.0f, -1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, 1.0f, -1.0f, 0.0f, 1.0f, -1.0f,
-                 1.0f, 0.0f, 1.0f});
+                 -1.0f, 1.0f, 0.0f, 1.0f, 1.0f, -1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, -1.0f,
+                 -1.0f, 0.0f, 1.0f});
             indexBuffer = utils::CreateBufferFromData<uint32_t>(
                 device, dawn::BufferUsage::Index,
                 {0, 1, 2, 0, 3, 1,
diff --git a/src/tests/end2end/DrawIndirectTests.cpp b/src/tests/end2end/DrawIndirectTests.cpp
index 21e0c27..8a89146 100644
--- a/src/tests/end2end/DrawIndirectTests.cpp
+++ b/src/tests/end2end/DrawIndirectTests.cpp
@@ -57,10 +57,10 @@
         vertexBuffer = utils::CreateBufferFromData<float>(
             device, dawn::BufferUsage::Vertex,
             {// The bottom left triangle
-             -1.0f, -1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, -1.0f, 1.0f, 0.0f, 1.0f,
+             -1.0f, 1.0f, 0.0f, 1.0f, 1.0f, -1.0f, 0.0f, 1.0f, -1.0f, -1.0f, 0.0f, 1.0f,
 
              // The top right triangle
-             -1.0f, -1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, 1.0f, -1.0f, 0.0f, 1.0f});
+             -1.0f, 1.0f, 0.0f, 1.0f, 1.0f, -1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f});
     }
 
     utils::BasicRenderPass renderPass;
diff --git a/src/tests/end2end/DrawTests.cpp b/src/tests/end2end/DrawTests.cpp
index f73773b..30e48b8 100644
--- a/src/tests/end2end/DrawTests.cpp
+++ b/src/tests/end2end/DrawTests.cpp
@@ -57,10 +57,10 @@
         vertexBuffer = utils::CreateBufferFromData<float>(
             device, dawn::BufferUsage::Vertex,
             {// The bottom left triangle
-             -1.0f, -1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, -1.0f, 1.0f, 0.0f, 1.0f,
+             -1.0f, 1.0f, 0.0f, 1.0f, 1.0f, -1.0f, 0.0f, 1.0f, -1.0f, -1.0f, 0.0f, 1.0f,
 
              // The top right triangle
-             -1.0f, -1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, 1.0f, -1.0f, 0.0f, 1.0f});
+             -1.0f, 1.0f, 0.0f, 1.0f, 1.0f, -1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f});
     }
 
     utils::BasicRenderPass renderPass;
diff --git a/src/tests/end2end/DynamicBufferOffsetTests.cpp b/src/tests/end2end/DynamicBufferOffsetTests.cpp
index 52958f7..bf0457e 100644
--- a/src/tests/end2end/DynamicBufferOffsetTests.cpp
+++ b/src/tests/end2end/DynamicBufferOffsetTests.cpp
@@ -97,7 +97,7 @@
             utils::CreateShaderModule(device, utils::SingleShaderStage::Vertex, R"(
                 #version 450
                 void main() {
-                    const vec2 pos[3] = vec2[3](vec2(-1.0f, 0.0f), vec2(-1.0f, -1.0f), vec2(0.0f, -1.0f));
+                    const vec2 pos[3] = vec2[3](vec2(-1.0f, 0.0f), vec2(-1.0f, 1.0f), vec2(0.0f, 1.0f));
                     gl_Position = vec4(pos[gl_VertexIndex], 0.0, 1.0);
                 })");
 
diff --git a/src/tests/end2end/IndexFormatTests.cpp b/src/tests/end2end/IndexFormatTests.cpp
index d6eba86..0791b0b 100644
--- a/src/tests/end2end/IndexFormatTests.cpp
+++ b/src/tests/end2end/IndexFormatTests.cpp
@@ -68,8 +68,8 @@
 
     dawn::Buffer vertexBuffer = utils::CreateBufferFromData<float>(
         device, dawn::BufferUsage::Vertex,
-        {-1.0f, 1.0f, 0.0f, 1.0f,  // Note Vertices[0] = Vertices[1]
-         -1.0f, 1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, -1.0f, -1.0f, 0.0f, 1.0f});
+        {-1.0f, -1.0f, 0.0f, 1.0f,  // Note Vertices[0] = Vertices[1]
+         -1.0f, -1.0f, 0.0f, 1.0f, 1.0f, -1.0f, 0.0f, 1.0f, -1.0f, 1.0f, 0.0f, 1.0f});
     // If this is interpreted as Uint16, then it would be 0, 1, 0, ... and would draw nothing.
     dawn::Buffer indexBuffer =
         utils::CreateBufferFromData<uint32_t>(device, dawn::BufferUsage::Index, {1, 2, 3});
@@ -97,7 +97,7 @@
 
     dawn::Buffer vertexBuffer = utils::CreateBufferFromData<float>(
         device, dawn::BufferUsage::Vertex,
-        {-1.0f, 1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, -1.0f, -1.0f, 0.0f, 1.0f});
+        {-1.0f, -1.0f, 0.0f, 1.0f, 1.0f, -1.0f, 0.0f, 1.0f, -1.0f, 1.0f, 0.0f, 1.0f});
     // If this is interpreted as uint32, it will have index 1 and 2 be both 0 and render nothing
     dawn::Buffer indexBuffer =
         utils::CreateBufferFromData<uint16_t>(device, dawn::BufferUsage::Index, {1, 2, 0, 0, 0, 0});
@@ -138,8 +138,8 @@
     dawn::Buffer vertexBuffer = utils::CreateBufferFromData<float>(
         device, dawn::BufferUsage::Vertex,
         {
-            0.0f, 1.0f, 0.0f, 1.0f,  1.0f, 0.0f, 0.0f,  1.0f,  0.0f, 0.0f,
-            0.0f, 1.0f, 0.0f, -1.0f, 0.0f, 1.0f, -1.0f, -1.0f, 0.0f, 1.0f,
+            0.0f, -1.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f,  1.0f, 0.0f, 0.0f,
+            0.0f, 1.0f,  0.0f, 1.0f, 0.0f, 1.0f, -1.0f, 1.0f, 0.0f, 1.0f,
         });
     dawn::Buffer indexBuffer =
         utils::CreateBufferFromData<uint32_t>(device, dawn::BufferUsage::Index,
@@ -179,8 +179,8 @@
     dawn::Buffer vertexBuffer = utils::CreateBufferFromData<float>(
         device, dawn::BufferUsage::Vertex,
         {
-            0.0f, 1.0f, 0.0f, 1.0f,  1.0f, 0.0f, 0.0f,  1.0f,  0.0f, 0.0f,
-            0.0f, 1.0f, 0.0f, -1.0f, 0.0f, 1.0f, -1.0f, -1.0f, 0.0f, 1.0f,
+            0.0f, -1.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f,  1.0f, 0.0f, 0.0f,
+            0.0f, 1.0f,  0.0f, 1.0f, 0.0f, 1.0f, -1.0f, 1.0f, 0.0f, 1.0f,
         });
     dawn::Buffer indexBuffer =
         utils::CreateBufferFromData<uint16_t>(device, dawn::BufferUsage::Index,
@@ -226,8 +226,8 @@
 
     dawn::Buffer vertexBuffer = utils::CreateBufferFromData<float>(
         device, dawn::BufferUsage::Vertex,
-        {-1.0f, 1.0f, 0.0f, 1.0f,  // Note Vertices[0] = Vertices[1]
-         -1.0f, 1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, -1.0f, -1.0f, 0.0f, 1.0f});
+        {-1.0f, -1.0f, 0.0f, 1.0f,  // Note Vertices[0] = Vertices[1]
+         -1.0f, -1.0f, 0.0f, 1.0f, 1.0f, -1.0f, 0.0f, 1.0f, -1.0f, 1.0f, 0.0f, 1.0f});
     // If this is interpreted as Uint16, then it would be 0, 1, 0, ... and would draw nothing.
     dawn::Buffer indexBuffer =
         utils::CreateBufferFromData<uint32_t>(device, dawn::BufferUsage::Index, {1, 2, 3});
@@ -260,7 +260,7 @@
 
     dawn::Buffer vertexBuffer = utils::CreateBufferFromData<float>(
         device, dawn::BufferUsage::Vertex,
-        {-1.0f, 1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, -1.0f, -1.0f, 0.0f, 1.0f});
+        {-1.0f, -1.0f, 0.0f, 1.0f, 1.0f, -1.0f, 0.0f, 1.0f, -1.0f, 1.0f, 0.0f, 1.0f});
     dawn::Buffer indexBuffer =
         utils::CreateBufferFromData<uint32_t>(device, dawn::BufferUsage::Index, {0, 1, 2});
 
diff --git a/src/tests/end2end/PrimitiveTopologyTests.cpp b/src/tests/end2end/PrimitiveTopologyTests.cpp
index ccd9cd3f..8bec366 100644
--- a/src/tests/end2end/PrimitiveTopologyTests.cpp
+++ b/src/tests/end2end/PrimitiveTopologyTests.cpp
@@ -134,12 +134,12 @@
 
 constexpr static float kRTSizef = static_cast<float>(kRTSize);
 constexpr static float kVertices[] = {
-    2.f * (kPointTestLocations[0].x + 0.5f) / kRTSizef - 1.f, 2.f * (kPointTestLocations[0].y + 0.5f) / kRTSizef - 1.0f, 0.f, 1.f,
-    2.f * (kPointTestLocations[1].x + 0.5f) / kRTSizef - 1.f, 2.f * (kPointTestLocations[1].y + 0.5f) / kRTSizef - 1.0f, 0.f, 1.f,
-    2.f * (kPointTestLocations[2].x + 0.5f) / kRTSizef - 1.f, 2.f * (kPointTestLocations[2].y + 0.5f) / kRTSizef - 1.0f, 0.f, 1.f,
-    2.f * (kPointTestLocations[3].x + 0.5f) / kRTSizef - 1.f, 2.f * (kPointTestLocations[3].y + 0.5f) / kRTSizef - 1.0f, 0.f, 1.f,
-    2.f * (kPointTestLocations[4].x + 0.5f) / kRTSizef - 1.f, 2.f * (kPointTestLocations[4].y + 0.5f) / kRTSizef - 1.0f, 0.f, 1.f,
-    2.f * (kPointTestLocations[5].x + 0.5f) / kRTSizef - 1.f, 2.f * (kPointTestLocations[5].y + 0.5f) / kRTSizef - 1.0f, 0.f, 1.f,
+    2.f * (kPointTestLocations[0].x + 0.5f) / kRTSizef - 1.f, -2.f * (kPointTestLocations[0].y + 0.5f) / kRTSizef + 1.0f, 0.f, 1.f,
+    2.f * (kPointTestLocations[1].x + 0.5f) / kRTSizef - 1.f, -2.f * (kPointTestLocations[1].y + 0.5f) / kRTSizef + 1.0f, 0.f, 1.f,
+    2.f * (kPointTestLocations[2].x + 0.5f) / kRTSizef - 1.f, -2.f * (kPointTestLocations[2].y + 0.5f) / kRTSizef + 1.0f, 0.f, 1.f,
+    2.f * (kPointTestLocations[3].x + 0.5f) / kRTSizef - 1.f, -2.f * (kPointTestLocations[3].y + 0.5f) / kRTSizef + 1.0f, 0.f, 1.f,
+    2.f * (kPointTestLocations[4].x + 0.5f) / kRTSizef - 1.f, -2.f * (kPointTestLocations[4].y + 0.5f) / kRTSizef + 1.0f, 0.f, 1.f,
+    2.f * (kPointTestLocations[5].x + 0.5f) / kRTSizef - 1.f, -2.f * (kPointTestLocations[5].y + 0.5f) / kRTSizef + 1.0f, 0.f, 1.f,
 };
 // clang-format on
 
diff --git a/src/tests/end2end/RenderBundleTests.cpp b/src/tests/end2end/RenderBundleTests.cpp
index 3a104ed..84f79f9 100644
--- a/src/tests/end2end/RenderBundleTests.cpp
+++ b/src/tests/end2end/RenderBundleTests.cpp
@@ -88,10 +88,10 @@
         vertexBuffer = utils::CreateBufferFromData<float>(
             device, dawn::BufferUsage::Vertex,
             {// The bottom left triangle
-             -1.0f, -1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, -1.0f, 1.0f, 0.0f, 1.0f,
+             -1.0f, 1.0f, 0.0f, 1.0f, 1.0f, -1.0f, 0.0f, 1.0f, -1.0f, -1.0f, 0.0f, 1.0f,
 
              // The top right triangle
-             -1.0f, -1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, 1.0f, -1.0f, 0.0f, 1.0f});
+             -1.0f, 1.0f, 0.0f, 1.0f, 1.0f, -1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f});
     }
 
     utils::BasicRenderPass renderPass;
diff --git a/src/tests/end2end/RenderPassTests.cpp b/src/tests/end2end/RenderPassTests.cpp
index 506bc11..1111c07 100644
--- a/src/tests/end2end/RenderPassTests.cpp
+++ b/src/tests/end2end/RenderPassTests.cpp
@@ -31,7 +31,7 @@
                 #version 450
                 void main() {
                     const vec2 pos[3] = vec2[3](
-                        vec2(-1.f, -1.f), vec2(1.f, 1.f), vec2(-1.f, 1.f));
+                        vec2(-1.f, 1.f), vec2(1.f, -1.f), vec2(-1.f, -1.f));
                     gl_Position = vec4(pos[gl_VertexIndex], 0.f, 1.f);
                  })");
 
diff --git a/src/tests/end2end/VertexFormatTests.cpp b/src/tests/end2end/VertexFormatTests.cpp
index 2ba760f..edcefec 100644
--- a/src/tests/end2end/VertexFormatTests.cpp
+++ b/src/tests/end2end/VertexFormatTests.cpp
@@ -263,8 +263,8 @@
         vs << "void main() {\n";
 
         // Hard code the triangle in the shader so that we don't have to add a vertex input for it.
-        vs << "    const vec2 pos[3] = vec2[3](vec2(-1.0f, 0.0f), vec2(-1.0f, -1.0f), vec2(0.0f, "
-              "-1.0f));\n";
+        vs << "    const vec2 pos[3] = vec2[3](vec2(-1.0f, 0.0f), vec2(-1.0f, 1.0f), vec2(0.0f, "
+              "1.0f));\n";
         vs << "    gl_Position = vec4(pos[gl_VertexIndex], 0.0, 1.0);\n";
 
         // Declare expected values.
diff --git a/src/tests/end2end/VertexInputTests.cpp b/src/tests/end2end/VertexInputTests.cpp
index d6ccdc6..2a36479 100644
--- a/src/tests/end2end/VertexInputTests.cpp
+++ b/src/tests/end2end/VertexInputTests.cpp
@@ -87,7 +87,8 @@
               "0.0f));\n";
         vs << "    vec2 offset = vec2(float(gl_VertexIndex / 3), float(gl_InstanceIndex));\n";
         vs << "    vec2 worldPos = pos[gl_VertexIndex % 3] + offset;\n";
-        vs << "    gl_Position = vec4(worldPos / 2 - vec2(1.0f), 0.0f, 1.0f);\n";
+        vs << "    vec4 position = vec4(worldPos / 2 - vec2(1.0f), 0.0f, 1.0f);\n";
+        vs << "    gl_Position = vec4(position.x, -position.y, position.z, position.w);\n";
 
         // Perform the checks by successively ANDing a boolean
         vs << "    bool success = true;\n";
diff --git a/src/tests/end2end/ViewportOrientationTests.cpp b/src/tests/end2end/ViewportOrientationTests.cpp
index 153d639..7a870b6 100644
--- a/src/tests/end2end/ViewportOrientationTests.cpp
+++ b/src/tests/end2end/ViewportOrientationTests.cpp
@@ -27,7 +27,7 @@
         utils::CreateShaderModule(device, utils::SingleShaderStage::Vertex, R"(
         #version 450
         void main() {
-            gl_Position = vec4(-0.5f, -0.5f, 0.0f, 1.0f);
+            gl_Position = vec4(-0.5f, 0.5f, 0.0f, 1.0f);
             gl_PointSize = 1.0;
         })");
 
diff --git a/src/tests/end2end/ViewportTests.cpp b/src/tests/end2end/ViewportTests.cpp
index fe672d8..9257fe6 100644
--- a/src/tests/end2end/ViewportTests.cpp
+++ b/src/tests/end2end/ViewportTests.cpp
@@ -30,12 +30,12 @@
         const char* vs =
             R"(#version 450
             layout(location = 0) out vec4 color;
-            const vec3 pos[6] = vec3[6](vec3(-1.0f, -1.0f, 1.0f),
-                                        vec3(-1.0f,  1.0f, 0.5f),
-                                        vec3( 1.0f, -1.0f, 0.5f),
-                                        vec3( 1.0f, -1.0f, 0.5f),
-                                        vec3(-1.0f,  1.0f, 0.5f),
-                                        vec3( 1.0f,  1.0f, 0.0f));
+            const vec3 pos[6] = vec3[6](vec3(-1.0f,  1.0f, 1.0f),
+                                        vec3(-1.0f, -1.0f, 0.5f),
+                                        vec3( 1.0f,  1.0f, 0.5f),
+                                        vec3( 1.0f,  1.0f, 0.5f),
+                                        vec3(-1.0f, -1.0f, 0.5f),
+                                        vec3( 1.0f, -1.0f, 0.0f));
             void main() {
                 gl_Position = vec4(pos[gl_VertexIndex], 1.0);
                 if (gl_VertexIndex < 3) {