OSDN Git Service

Fix clamping viewport dimensions on specification.
authorNicolas Capens <capn@google.com>
Thu, 5 Jan 2017 19:37:22 +0000 (14:37 -0500)
committerNicolas Capens <capn@google.com>
Thu, 5 Jan 2017 20:14:25 +0000 (20:14 +0000)
The spec states that glViewport() silently clamps the viewport
width and height to GL_MAX_VIEWPORT_DIMS[0] and
GL_MAX_VIEWPORT_DIMS[1], respectively.

Bug b/34078120

Change-Id: Ifeec0d6b601ce8a3825796fa551eea1f46150002
Reviewed-on: https://swiftshader-review.googlesource.com/8371
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
Tested-by: Nicolas Capens <capn@google.com>
src/OpenGL/libGLESv2/Context.cpp
src/OpenGL/libGLESv2/Program.cpp
src/OpenGL/libGLESv2/Shader.cpp

index 4ff6a35..f880bb4 100644 (file)
@@ -40,6 +40,8 @@
 
 #include <EGL/eglext.h>
 
+#include <algorithm>
+
 namespace es2
 {
 Context::Context(egl::Display *display, const Context *shareContext, EGLint clientVersion)
@@ -667,8 +669,8 @@ void Context::setViewportParams(GLint x, GLint y, GLsizei width, GLsizei height)
 {
        mState.viewportX = x;
        mState.viewportY = y;
-       mState.viewportWidth = width;
-       mState.viewportHeight = height;
+       mState.viewportWidth = std::min<GLsizei>(width, IMPLEMENTATION_MAX_RENDERBUFFER_SIZE);     // GL_MAX_VIEWPORT_DIMS[0]
+       mState.viewportHeight = std::min<GLsizei>(height, IMPLEMENTATION_MAX_RENDERBUFFER_SIZE);   // GL_MAX_VIEWPORT_DIMS[1]
 }
 
 void Context::setScissorParams(GLint x, GLint y, GLsizei width, GLsizei height)
index 1d403a4..67006fe 100644 (file)
@@ -26,6 +26,7 @@
 #include "Shader/PixelShader.hpp"
 #include "Shader/VertexShader.hpp"
 
+#include <algorithm>
 #include <string>
 #include <stdlib.h>
 
index 5a4c578..df25d29 100644 (file)
@@ -22,6 +22,7 @@
 #include "utilities.h"
 
 #include <string>
+#include <algorithm>
 
 namespace es2
 {