Commit 875bbba0 by Frank Henigman Committed by Commit Bot

Zero gl_Position in WebGL mode.

Set the SH_INIT_GL_POSITION bit in WebGL compatibility mode so gl_Position gets zeroed out. Add corresponding test. BUG=angleproject:1825 Change-Id: I47107804abaa83d6aee5cd46e6b69b532c08e6e8 Reviewed-on: https://chromium-review.googlesource.com/439784Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Commit-Queue: Frank Henigman <fjhenigman@chromium.org>
parent ce02f086
...@@ -252,6 +252,7 @@ void Shader::compile(const Context *context) ...@@ -252,6 +252,7 @@ void Shader::compile(const Context *context)
// Add default options to WebGL shaders to prevent unexpected behavior during compilation. // Add default options to WebGL shaders to prevent unexpected behavior during compilation.
if (context->getExtensions().webglCompatibility) if (context->getExtensions().webglCompatibility)
{ {
compileOptions |= SH_INIT_GL_POSITION;
compileOptions |= SH_LIMIT_CALL_STACK_DEPTH; compileOptions |= SH_LIMIT_CALL_STACK_DEPTH;
compileOptions |= SH_LIMIT_EXPRESSION_COMPLEXITY; compileOptions |= SH_LIMIT_EXPRESSION_COMPLEXITY;
compileOptions |= SH_ENFORCE_PACKING_RESTRICTIONS; compileOptions |= SH_ENFORCE_PACKING_RESTRICTIONS;
......
...@@ -535,6 +535,39 @@ void FillTexture2D(GLuint texture, ...@@ -535,6 +535,39 @@ void FillTexture2D(GLuint texture,
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
} }
// Test that unset gl_Position defaults to (0,0,0,0).
TEST_P(WebGLCompatibilityTest, DefaultPosition)
{
// Draw a quad where each vertex is red if gl_Position is (0,0,0,0) before it is set,
// and green otherwise. The center of each quadrant will be red if and only if all
// four corners are red.
const std::string vertexShader =
"attribute vec3 pos;\n"
"varying vec4 color;\n"
"void main() {\n"
" if (gl_Position == vec4(0,0,0,0)) {\n"
" color = vec4(1,0,0,1);\n"
" } else {\n"
" color = vec4(0,1,0,1);\n"
" }\n"
" gl_Position = vec4(pos,1);\n"
"}\n";
const std::string fragmentShader =
"precision mediump float;\n"
"varying vec4 color;\n"
"void main() {\n"
" gl_FragColor = color;\n"
"}\n";
ANGLE_GL_PROGRAM(program, vertexShader, fragmentShader);
drawQuad(program.get(), "pos", 0.0f, 1.0f, true);
EXPECT_PIXEL_COLOR_EQ(getWindowWidth() * 1 / 4, getWindowHeight() * 1 / 4, GLColor::red);
EXPECT_PIXEL_COLOR_EQ(getWindowWidth() * 1 / 4, getWindowHeight() * 3 / 4, GLColor::red);
EXPECT_PIXEL_COLOR_EQ(getWindowWidth() * 3 / 4, getWindowHeight() * 1 / 4, GLColor::red);
EXPECT_PIXEL_COLOR_EQ(getWindowWidth() * 3 / 4, getWindowHeight() * 3 / 4, GLColor::red);
}
// Tests that a rendering feedback loop triggers a GL error under WebGL. // Tests that a rendering feedback loop triggers a GL error under WebGL.
// Based on WebGL test conformance/renderbuffers/feedback-loop.html. // Based on WebGL test conformance/renderbuffers/feedback-loop.html.
TEST_P(WebGLCompatibilityTest, RenderingFeedbackLoop) TEST_P(WebGLCompatibilityTest, RenderingFeedbackLoop)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment