From c34bb0c3c4de0e214d2cc7bbbebf5bc7ce046865 Mon Sep 17 00:00:00 2001 From: Stephen White Date: Thu, 3 Dec 2020 17:00:33 +0000 Subject: [PATCH] Enable viewport tests on OpenGL ES. Also implement a workaround for missing glViewportIndexedf(). BUG=dawn:580,dawn:597 Change-Id: I618161ae9750925c1c892123607db84563f0869c Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/34721 Commit-Queue: Stephen White Reviewed-by: Corentin Wallez --- src/dawn_native/opengl/CommandBufferGL.cpp | 10 +++++++++- src/tests/end2end/ViewportOrientationTests.cpp | 1 + src/tests/end2end/ViewportTests.cpp | 1 + 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/dawn_native/opengl/CommandBufferGL.cpp b/src/dawn_native/opengl/CommandBufferGL.cpp index 54d318530e..2ea7bac381 100644 --- a/src/dawn_native/opengl/CommandBufferGL.cpp +++ b/src/dawn_native/opengl/CommandBufferGL.cpp @@ -1173,7 +1173,15 @@ namespace dawn_native { namespace opengl { case Command::SetViewport: { SetViewportCmd* cmd = mCommands.NextCommand(); - gl.ViewportIndexedf(0, cmd->x, cmd->y, cmd->width, cmd->height); + if (gl.IsAtLeastGL(4, 1)) { + gl.ViewportIndexedf(0, cmd->x, cmd->y, cmd->width, cmd->height); + } else { + // Floating-point viewport coords are unsupported on OpenGL ES, but + // truncation is ok because other APIs do not guarantee subpixel precision + // either. + gl.Viewport(static_cast(cmd->x), static_cast(cmd->y), + static_cast(cmd->width), static_cast(cmd->height)); + } gl.DepthRangef(cmd->minDepth, cmd->maxDepth); break; } diff --git a/src/tests/end2end/ViewportOrientationTests.cpp b/src/tests/end2end/ViewportOrientationTests.cpp index 7c2a04af08..4f591e9034 100644 --- a/src/tests/end2end/ViewportOrientationTests.cpp +++ b/src/tests/end2end/ViewportOrientationTests.cpp @@ -68,4 +68,5 @@ DAWN_INSTANTIATE_TEST(ViewportOrientationTests, D3D12Backend(), MetalBackend(), OpenGLBackend(), + OpenGLESBackend(), VulkanBackend()); diff --git a/src/tests/end2end/ViewportTests.cpp b/src/tests/end2end/ViewportTests.cpp index 2b35e2849b..528439c653 100644 --- a/src/tests/end2end/ViewportTests.cpp +++ b/src/tests/end2end/ViewportTests.cpp @@ -213,4 +213,5 @@ DAWN_INSTANTIATE_TEST(ViewportTest, D3D12Backend(), MetalBackend(), OpenGLBackend(), + OpenGLESBackend(), VulkanBackend());