From 394553b02e248069cc232aabf983b79288d744d0 Mon Sep 17 00:00:00 2001 From: Yunchao He Date: Fri, 20 Sep 2019 23:04:47 +0000 Subject: [PATCH] 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 Commit-Queue: Yunchao He --- src/dawn_native/d3d12/ShaderModuleD3D12.cpp | 1 - src/dawn_native/metal/ShaderModuleMTL.mm | 4 ---- src/dawn_native/opengl/ShaderModuleGL.cpp | 1 + src/dawn_native/vulkan/AdapterVk.cpp | 6 ++++++ src/dawn_native/vulkan/CommandBufferVk.cpp | 8 ++++---- src/dawn_native/vulkan/DeviceVk.cpp | 4 ++++ src/dawn_native/vulkan/VulkanInfo.cpp | 4 ++++ src/dawn_native/vulkan/VulkanInfo.h | 2 ++ src/fuzzers/DawnSPIRVCrossHLSLFastFuzzer.cpp | 1 - src/fuzzers/DawnSPIRVCrossMSLFastFuzzer.cpp | 1 - src/tests/end2end/BindGroupTests.cpp | 8 ++++---- src/tests/end2end/ClipSpaceTests.cpp | 12 +++++------ .../end2end/CompressedTextureFormatTests.cpp | 8 ++++---- src/tests/end2end/CullingTests.cpp | 12 +++++------ src/tests/end2end/DestroyTests.cpp | 2 +- .../end2end/DrawIndexedIndirectTests.cpp | 4 ++-- src/tests/end2end/DrawIndexedTests.cpp | 8 ++++---- src/tests/end2end/DrawIndirectTests.cpp | 4 ++-- src/tests/end2end/DrawTests.cpp | 4 ++-- .../end2end/DynamicBufferOffsetTests.cpp | 2 +- src/tests/end2end/IndexFormatTests.cpp | 20 +++++++++---------- src/tests/end2end/PrimitiveTopologyTests.cpp | 12 +++++------ src/tests/end2end/RenderBundleTests.cpp | 4 ++-- src/tests/end2end/RenderPassTests.cpp | 2 +- src/tests/end2end/VertexFormatTests.cpp | 4 ++-- src/tests/end2end/VertexInputTests.cpp | 3 ++- .../end2end/ViewportOrientationTests.cpp | 2 +- src/tests/end2end/ViewportTests.cpp | 12 +++++------ 28 files changed, 83 insertions(+), 72 deletions(-) diff --git a/src/dawn_native/d3d12/ShaderModuleD3D12.cpp b/src/dawn_native/d3d12/ShaderModuleD3D12.cpp index 4698459b3a..872e3971ec 100644 --- a/src/dawn_native/d3d12/ShaderModuleD3D12.cpp +++ b/src/dawn_native/d3d12/ShaderModuleD3D12.cpp @@ -37,7 +37,6 @@ namespace dawn_native { namespace d3d12 { // 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 69c96333bd..316be5408e 100644 --- a/src/dawn_native/metal/ShaderModuleMTL.mm +++ b/src/dawn_native/metal/ShaderModuleMTL.mm @@ -54,10 +54,6 @@ namespace dawn_native { namespace metal { // 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 e7e2d33e53..e4e8b8fb9c 100644 --- a/src/dawn_native/opengl/ShaderModuleGL.cpp +++ b/src/dawn_native/opengl/ShaderModuleGL.cpp @@ -58,6 +58,7 @@ namespace dawn_native { namespace opengl { // 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 d86a3bb0af..dd9341f71c 100644 --- a/src/dawn_native/vulkan/AdapterVk.cpp +++ b/src/dawn_native/vulkan/AdapterVk.cpp @@ -39,6 +39,12 @@ namespace dawn_native { namespace vulkan { 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 71584faa91..772928610a 100644 --- a/src/dawn_native/vulkan/CommandBufferVk.cpp +++ b/src/dawn_native/vulkan/CommandBufferVk.cpp @@ -659,9 +659,9 @@ namespace dawn_native { namespace vulkan { // 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(renderPassCmd->height); viewport.width = static_cast(renderPassCmd->width); - viewport.height = static_cast(renderPassCmd->height); + viewport.height = -static_cast(renderPassCmd->height); viewport.minDepth = 0.0f; viewport.maxDepth = 1.0f; device->fn.CmdSetViewport(commands, 0, 1, &viewport); @@ -853,9 +853,9 @@ namespace dawn_native { namespace vulkan { SetViewportCmd* cmd = mCommands.NextCommand(); 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 d1ec330b3d..123aabfea3 100644 --- a/src/dawn_native/vulkan/DeviceVk.cpp +++ b/src/dawn_native/vulkan/DeviceVk.cpp @@ -380,6 +380,10 @@ namespace dawn_native { namespace vulkan { 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 675e132ad3..18cefb272c 100644 --- a/src/dawn_native/vulkan/VulkanInfo.cpp +++ b/src/dawn_native/vulkan/VulkanInfo.cpp @@ -74,6 +74,7 @@ namespace dawn_native { namespace vulkan { 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 GatherGlobalInfo(const Backend& backend) { VulkanGlobalInfo info = {}; @@ -301,6 +302,9 @@ namespace dawn_native { namespace vulkan { 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 9c61525f6d..2da3466ba2 100644 --- a/src/dawn_native/vulkan/VulkanInfo.h +++ b/src/dawn_native/vulkan/VulkanInfo.h @@ -49,6 +49,7 @@ namespace dawn_native { namespace vulkan { 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 @@ namespace dawn_native { namespace vulkan { 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 dd044cfaed..6ebe67d1d9 100644 --- a/src/fuzzers/DawnSPIRVCrossHLSLFastFuzzer.cpp +++ b/src/fuzzers/DawnSPIRVCrossHLSLFastFuzzer.cpp @@ -32,7 +32,6 @@ namespace { 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 13c8391352..36bb0c423a 100644 --- a/src/fuzzers/DawnSPIRVCrossMSLFastFuzzer.cpp +++ b/src/fuzzers/DawnSPIRVCrossMSLFastFuzzer.cpp @@ -32,7 +32,6 @@ namespace { 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 df2251c63a..b70b1a1694 100644 --- a/src/tests/end2end/BindGroupTests.cpp +++ b/src/tests/end2end/BindGroupTests.cpp @@ -49,7 +49,7 @@ protected: 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 @@ TEST_P(BindGroupTests, ReusedUBO) { 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 @@ TEST_P(BindGroupTests, UBOSamplerAndTexture) { 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 @@ TEST_P(BindGroupTests, MultipleBindLayouts) { 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 439f0d3cd1..6d5e9da9a9 100644 --- a/src/tests/end2end/ClipSpaceTests.cpp +++ b/src/tests/end2end/ClipSpaceTests.cpp @@ -27,12 +27,12 @@ class ClipSpaceTest : public DawnTest { // 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 84ed2d95b1..216eca5de2 100644 --- a/src/tests/end2end/CompressedTextureFormatTests.cpp +++ b/src/tests/end2end/CompressedTextureFormatTests.cpp @@ -145,12 +145,12 @@ class CompressedTextureBCFormatTest : public DawnTest { 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 7745348f97..b1788d7f5e 100644 --- a/src/tests/end2end/CullingTests.cpp +++ b/src/tests/end2end/CullingTests.cpp @@ -27,12 +27,12 @@ class CullingTest : public DawnTest { // 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 98a2cca72b..f9dfc3be27 100644 --- a/src/tests/end2end/DestroyTests.cpp +++ b/src/tests/end2end/DestroyTests.cpp @@ -57,7 +57,7 @@ class DestroyTest : public DawnTest { vertexBuffer = utils::CreateBufferFromData( 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 5f7395ba8f..c0e68b1433 100644 --- a/src/tests/end2end/DrawIndexedIndirectTests.cpp +++ b/src/tests/end2end/DrawIndexedIndirectTests.cpp @@ -57,11 +57,11 @@ class DrawIndexedIndirectTest : public DawnTest { vertexBuffer = utils::CreateBufferFromData( 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( device, dawn::BufferUsage::Index, diff --git a/src/tests/end2end/DrawIndexedTests.cpp b/src/tests/end2end/DrawIndexedTests.cpp index 6d28857fb2..159f1efe09 100644 --- a/src/tests/end2end/DrawIndexedTests.cpp +++ b/src/tests/end2end/DrawIndexedTests.cpp @@ -57,12 +57,12 @@ class DrawIndexedTest : public DawnTest { vertexBuffer = utils::CreateBufferFromData( 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( 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 21e0c27b85..8a89146f96 100644 --- a/src/tests/end2end/DrawIndirectTests.cpp +++ b/src/tests/end2end/DrawIndirectTests.cpp @@ -57,10 +57,10 @@ class DrawIndirectTest : public DawnTest { vertexBuffer = utils::CreateBufferFromData( 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 f73773b0c2..30e48b8943 100644 --- a/src/tests/end2end/DrawTests.cpp +++ b/src/tests/end2end/DrawTests.cpp @@ -57,10 +57,10 @@ class DrawTest : public DawnTest { vertexBuffer = utils::CreateBufferFromData( 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 52958f755b..bf0457eaf1 100644 --- a/src/tests/end2end/DynamicBufferOffsetTests.cpp +++ b/src/tests/end2end/DynamicBufferOffsetTests.cpp @@ -97,7 +97,7 @@ class DynamicBufferOffsetTests : public DawnTest { 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 d6eba864c4..0791b0b817 100644 --- a/src/tests/end2end/IndexFormatTests.cpp +++ b/src/tests/end2end/IndexFormatTests.cpp @@ -68,8 +68,8 @@ TEST_P(IndexFormatTest, Uint32) { dawn::Buffer vertexBuffer = utils::CreateBufferFromData( 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(device, dawn::BufferUsage::Index, {1, 2, 3}); @@ -97,7 +97,7 @@ TEST_P(IndexFormatTest, Uint16) { dawn::Buffer vertexBuffer = utils::CreateBufferFromData( 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(device, dawn::BufferUsage::Index, {1, 2, 0, 0, 0, 0}); @@ -138,8 +138,8 @@ TEST_P(IndexFormatTest, Uint32PrimitiveRestart) { dawn::Buffer vertexBuffer = utils::CreateBufferFromData( 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(device, dawn::BufferUsage::Index, @@ -179,8 +179,8 @@ TEST_P(IndexFormatTest, Uint16PrimitiveRestart) { dawn::Buffer vertexBuffer = utils::CreateBufferFromData( 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(device, dawn::BufferUsage::Index, @@ -226,8 +226,8 @@ TEST_P(IndexFormatTest, ChangePipelineAfterSetIndexBuffer) { dawn::Buffer vertexBuffer = utils::CreateBufferFromData( 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(device, dawn::BufferUsage::Index, {1, 2, 3}); @@ -260,7 +260,7 @@ TEST_P(IndexFormatTest, DISABLED_SetIndexBufferBeforeSetPipeline) { dawn::Buffer vertexBuffer = utils::CreateBufferFromData( 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(device, dawn::BufferUsage::Index, {0, 1, 2}); diff --git a/src/tests/end2end/PrimitiveTopologyTests.cpp b/src/tests/end2end/PrimitiveTopologyTests.cpp index ccd9cd3ffb..8bec36600c 100644 --- a/src/tests/end2end/PrimitiveTopologyTests.cpp +++ b/src/tests/end2end/PrimitiveTopologyTests.cpp @@ -134,12 +134,12 @@ constexpr static TestLocation kTriangleStripTestLocations[] = { constexpr static float kRTSizef = static_cast(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 3a104edb06..84f79f9886 100644 --- a/src/tests/end2end/RenderBundleTests.cpp +++ b/src/tests/end2end/RenderBundleTests.cpp @@ -88,10 +88,10 @@ class RenderBundleTest : public DawnTest { vertexBuffer = utils::CreateBufferFromData( 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 506bc11d57..1111c07cec 100644 --- a/src/tests/end2end/RenderPassTests.cpp +++ b/src/tests/end2end/RenderPassTests.cpp @@ -31,7 +31,7 @@ protected: #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 2ba760f74e..edcefec084 100644 --- a/src/tests/end2end/VertexFormatTests.cpp +++ b/src/tests/end2end/VertexFormatTests.cpp @@ -263,8 +263,8 @@ class VertexFormatTest : public DawnTest { 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 d6ccdc6241..2a36479f33 100644 --- a/src/tests/end2end/VertexInputTests.cpp +++ b/src/tests/end2end/VertexInputTests.cpp @@ -87,7 +87,8 @@ class VertexInputTest : public DawnTest { "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 153d639c2b..7a870b6131 100644 --- a/src/tests/end2end/ViewportOrientationTests.cpp +++ b/src/tests/end2end/ViewportOrientationTests.cpp @@ -27,7 +27,7 @@ TEST_P(ViewportOrientationTests, OriginAt0x0) { 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 fe672d86cc..9257fe641f 100644 --- a/src/tests/end2end/ViewportTests.cpp +++ b/src/tests/end2end/ViewportTests.cpp @@ -30,12 +30,12 @@ class ViewportTest : public DawnTest { 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) {