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());