Commit 0cdf3683 by Martin Radev Committed by Commit Bot

Do not propagate OVR_multiview extension directive

The patch fixes the bug of having the OVR_multiview extension directive being outputted by the ESSL translator whenever the SH_INITIALIZE_BUILTINS_FOR_INSTANCED_MULTIVIEW option is enabled. The directive should not be outputted because the extension is emulated through that option. BUG=angleproject:2062 TEST=angle_unittests Change-Id: I95d0a651ace6db42d496de08e774ec7ceca4c197 Reviewed-on: https://chromium-review.googlesource.com/558981 Commit-Queue: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org>
parent 83f0fb4d
......@@ -120,6 +120,10 @@ void TranslatorESSL::writeExtensionBehavior(ShCompileOptions compileOptions)
{
TInfoSinkBase &sink = getInfoSink().obj;
const TExtensionBehavior &extBehavior = getExtensionBehavior();
const bool isMultiviewExtEmulated =
(compileOptions & (SH_TRANSLATE_VIEWID_OVR_TO_UNIFORM |
SH_INITIALIZE_BUILTINS_FOR_INSTANCED_MULTIVIEW)) != 0u;
for (TExtensionBehavior::const_iterator iter = extBehavior.begin(); iter != extBehavior.end();
++iter)
{
......@@ -136,7 +140,7 @@ void TranslatorESSL::writeExtensionBehavior(ShCompileOptions compileOptions)
sink << "#extension GL_NV_draw_buffers : " << getBehaviorString(iter->second)
<< "\n";
}
else if (compileOptions & SH_TRANSLATE_VIEWID_OVR_TO_UNIFORM &&
else if (isMultiviewExtEmulated &&
(iter->first == "GL_OVR_multiview" || iter->first == "GL_OVR_multiview2"))
{
// No output
......
......@@ -690,4 +690,30 @@ TEST_F(WEBGLMultiviewVertexShaderOutputCodeTest, ViewIDAndInstanceIDHaveCorrectV
EXPECT_TRUE(foundInHLSLCode("ViewID_OVR = (uvec1(gl_InstanceID) % 3)"));
EXPECT_TRUE(foundInHLSLCode("InstanceID = (gl_InstanceID / 3)"));
}
\ No newline at end of file
}
// The test checks that the directive enabling GL_OVR_multiview is not outputted if the extension is
// emulated.
TEST_F(WEBGLMultiviewVertexShaderOutputCodeTest, StrippedOVRMultiviewDirective)
{
const std::string &shaderString =
"#version 300 es\n"
"#extension GL_OVR_multiview : require\n"
"layout(num_views = 3) in;\n"
"void main()\n"
"{\n"
"}\n";
// The directive must not be present if any of the multiview emulation options are set.
compile(shaderString, SH_INITIALIZE_BUILTINS_FOR_INSTANCED_MULTIVIEW);
EXPECT_FALSE(foundInESSLCode("GL_OVR_multiview"));
EXPECT_FALSE(foundInGLSLCode("GL_OVR_multiview"));
compile(shaderString, SH_TRANSLATE_VIEWID_OVR_TO_UNIFORM);
EXPECT_FALSE(foundInESSLCode("GL_OVR_multiview"));
EXPECT_FALSE(foundInGLSLCode("GL_OVR_multiview"));
// The directive should be outputted from the ESSL translator with none of the options being
// set.
compile(shaderString);
EXPECT_TRUE(foundInESSLCode("GL_OVR_multiview"));
}
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