Commit 87c182e1 by Bryan Bernhart Committed by Commit Bot

Enable shader validation with WebGL compatibility extension.

The change configures shaders to be of a compatible spec upon creation. BUG=angleproject:1523 Change-Id: Id345d0b8f0abad8ed3c4fb3117d0fdfeab9fea53 Reviewed-on: https://chromium-review.googlesource.com/405778 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org>
parent 02bd82cd
...@@ -68,6 +68,7 @@ Intel Corporation ...@@ -68,6 +68,7 @@ Intel Corporation
Jiawei Shao Jiawei Shao
Jie Chen Jie Chen
Qiankun Miao Qiankun Miao
Bryan Bernhart
Klarälvdalens Datakonsult AB Klarälvdalens Datakonsult AB
Milian Wolff Milian Wolff
......
...@@ -23,27 +23,29 @@ namespace ...@@ -23,27 +23,29 @@ namespace
// ShFinalize. // ShFinalize.
size_t activeCompilerHandles = 0; size_t activeCompilerHandles = 0;
ShShaderSpec SelectShaderSpec(GLint majorVersion, GLint minorVersion) ShShaderSpec SelectShaderSpec(GLint majorVersion, GLint minorVersion, bool isWebGL)
{ {
if (majorVersion >= 3) if (majorVersion >= 3)
{ {
if (minorVersion == 1) if (minorVersion == 1)
{ {
return SH_GLES3_1_SPEC; return isWebGL ? SH_WEBGL3_SPEC : SH_GLES3_1_SPEC;
} }
else else
{ {
return SH_GLES3_SPEC; return isWebGL ? SH_WEBGL2_SPEC : SH_GLES3_SPEC;
} }
} }
return SH_GLES2_SPEC; return isWebGL ? SH_WEBGL_SPEC : SH_GLES2_SPEC;
} }
} // anonymous namespace } // anonymous namespace
Compiler::Compiler(rx::GLImplFactory *implFactory, const ContextState &state) Compiler::Compiler(rx::GLImplFactory *implFactory, const ContextState &state)
: mImplementation(implFactory->createCompiler()), : mImplementation(implFactory->createCompiler()),
mSpec(SelectShaderSpec(state.getClientMajorVersion(), state.getClientMinorVersion())), mSpec(SelectShaderSpec(state.getClientMajorVersion(),
state.getClientMinorVersion(),
state.getExtensions().webglCompatibility)),
mOutputType(mImplementation->getTranslatorOutputType()), mOutputType(mImplementation->getTranslatorOutputType()),
mResources(), mResources(),
mFragmentCompiler(nullptr), mFragmentCompiler(nullptr),
......
...@@ -112,6 +112,33 @@ TEST_P(WebGLCompatibilityTest, EnableExtensionUintIndices) ...@@ -112,6 +112,33 @@ TEST_P(WebGLCompatibilityTest, EnableExtensionUintIndices)
} }
} }
// Verify that shaders are of a compatible spec when the extension is enabled.
TEST_P(WebGLCompatibilityTest, ExtensionCompilerSpec)
{
EXPECT_TRUE(extensionEnabled("GL_ANGLE_webgl_compatibility"));
// Use of reserved _webgl prefix should fail when the shader specification is for WebGL.
const std::string &vert =
"struct Foo {\n"
" int _webgl_bar;\n"
"};\n"
"void main()\n"
"{\n"
" Foo foo = Foo(1);\n"
"}";
// Default fragement shader.
const std::string &frag =
"void main()\n"
"{\n"
" gl_FragColor = vec4(1.0,0.0,0.0,1.0);\n"
"}";
GLuint program = CompileProgram(vert, frag);
EXPECT_EQ(0u, program);
glDeleteProgram(program);
}
// Use this to select which configurations (e.g. which renderer, which GLES major version) these // Use this to select which configurations (e.g. which renderer, which GLES major version) these
// tests should be run against. // tests should be run against.
ANGLE_INSTANTIATE_TEST(WebGLCompatibilityTest, ANGLE_INSTANTIATE_TEST(WebGLCompatibilityTest,
......
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