Commit ffdd58f5 by Artem Bolgar Committed by Commit Bot

Fixing OVR_multiview and OVR_multiview2 issues

Found two issues when native OVR_multiview and OVR_multiview2 extensions are generated. 1. OVR_multiview got replaced by the OVR_multiview2 in the translated shader (ESSL & GLSL) 2. Duplicate #extension OVR_multiview2 (for Fragment & Vertex) and 'layout (num_views=x)' (for Vertex) got generated into the translated shader. Bug: angleproject:4247 Change-Id: I9a550883eeb326d95af4557578f8202a9493f4ec Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1983802Reviewed-by: 's avatarShahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: 's avatarRafael Cintron <rafael.cintron@microsoft.com> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Commit-Queue: Geoff Lang <geofflang@chromium.org>
parent 86f73097
...@@ -33,6 +33,7 @@ AdaptVis GmbH ...@@ -33,6 +33,7 @@ AdaptVis GmbH
Samsung Electronics, Inc. Samsung Electronics, Inc.
Arm Ltd. Arm Ltd.
Broadcom Inc. Broadcom Inc.
Facebook, Inc.
Jacek Caban Jacek Caban
Mark Callow Mark Callow
...@@ -63,3 +64,4 @@ Jaime Bernardo ...@@ -63,3 +64,4 @@ Jaime Bernardo
Le Hoang Quyen Le Hoang Quyen
Ethan Lee Ethan Lee
Renaud Lepage Renaud Lepage
Artem Bolgar
...@@ -171,3 +171,6 @@ Arm Ltd. ...@@ -171,3 +171,6 @@ Arm Ltd.
Broadcom Inc. Broadcom Inc.
Gary Sweet Gary Sweet
Facebook, Inc.
Artem Bolgar
...@@ -1475,6 +1475,7 @@ void EmitWorkGroupSizeGLSL(const TCompiler &compiler, TInfoSinkBase &sink) ...@@ -1475,6 +1475,7 @@ void EmitWorkGroupSizeGLSL(const TCompiler &compiler, TInfoSinkBase &sink)
void EmitMultiviewGLSL(const TCompiler &compiler, void EmitMultiviewGLSL(const TCompiler &compiler,
const ShCompileOptions &compileOptions, const ShCompileOptions &compileOptions,
const TExtension extension,
const TBehavior behavior, const TBehavior behavior,
TInfoSinkBase &sink) TInfoSinkBase &sink)
{ {
...@@ -1499,7 +1500,12 @@ void EmitMultiviewGLSL(const TCompiler &compiler, ...@@ -1499,7 +1500,12 @@ void EmitMultiviewGLSL(const TCompiler &compiler,
} }
else else
{ {
sink << "#extension GL_OVR_multiview2 : " << GetBehaviorString(behavior) << "\n"; sink << "#extension GL_OVR_multiview";
if (extension == TExtension::OVR_multiview2)
{
sink << "2";
}
sink << " : " << GetBehaviorString(behavior) << "\n";
const auto &numViews = compiler.getNumViews(); const auto &numViews = compiler.getNumViews();
if (isVertexShader && numViews != -1) if (isVertexShader && numViews != -1)
......
...@@ -305,7 +305,11 @@ TCompiler *ConstructCompiler(sh::GLenum type, ShShaderSpec spec, ShShaderOutput ...@@ -305,7 +305,11 @@ TCompiler *ConstructCompiler(sh::GLenum type, ShShaderSpec spec, ShShaderOutput
void DeleteCompiler(TCompiler *); void DeleteCompiler(TCompiler *);
void EmitWorkGroupSizeGLSL(const TCompiler &, TInfoSinkBase &sink); void EmitWorkGroupSizeGLSL(const TCompiler &, TInfoSinkBase &sink);
void EmitMultiviewGLSL(const TCompiler &, const ShCompileOptions &, TBehavior, TInfoSinkBase &sink); void EmitMultiviewGLSL(const TCompiler &,
const ShCompileOptions &,
const TExtension,
const TBehavior,
TInfoSinkBase &sink);
} // namespace sh } // namespace sh
......
...@@ -150,7 +150,12 @@ void TranslatorESSL::writeExtensionBehavior(ShCompileOptions compileOptions) ...@@ -150,7 +150,12 @@ void TranslatorESSL::writeExtensionBehavior(ShCompileOptions compileOptions)
} }
else if (isMultiview) else if (isMultiview)
{ {
EmitMultiviewGLSL(*this, compileOptions, iter->second, sink); // Only either OVR_multiview OR OVR_multiview2 should be emitted.
if ((iter->first != TExtension::OVR_multiview) ||
!IsExtensionEnabled(extBehavior, TExtension::OVR_multiview2))
{
EmitMultiviewGLSL(*this, compileOptions, iter->first, iter->second, sink);
}
} }
else if (iter->first == TExtension::EXT_geometry_shader) else if (iter->first == TExtension::EXT_geometry_shader)
{ {
......
...@@ -290,7 +290,12 @@ void TranslatorGLSL::writeExtensionBehavior(TIntermNode *root, ShCompileOptions ...@@ -290,7 +290,12 @@ void TranslatorGLSL::writeExtensionBehavior(TIntermNode *root, ShCompileOptions
(iter.first == TExtension::OVR_multiview) || (iter.first == TExtension::OVR_multiview2); (iter.first == TExtension::OVR_multiview) || (iter.first == TExtension::OVR_multiview2);
if (isMultiview) if (isMultiview)
{ {
EmitMultiviewGLSL(*this, compileOptions, iter.second, sink); // Only either OVR_multiview or OVR_multiview2 should be emitted.
if ((iter.first != TExtension::OVR_multiview) ||
!IsExtensionEnabled(extBehavior, TExtension::OVR_multiview2))
{
EmitMultiviewGLSL(*this, compileOptions, iter.first, iter.second, sink);
}
} }
// Support ANGLE_texture_multisample extension on GLSL300 // Support ANGLE_texture_multisample extension on GLSL300
......
...@@ -643,6 +643,30 @@ TEST_F(OVRMultiview2FragmentShaderOutputCodeTest, ViewportArray2IsNotEmitted) ...@@ -643,6 +643,30 @@ TEST_F(OVRMultiview2FragmentShaderOutputCodeTest, ViewportArray2IsNotEmitted)
EXPECT_FALSE(foundInESSLCode("#extension GL_NV_viewport_array2")); EXPECT_FALSE(foundInESSLCode("#extension GL_NV_viewport_array2"));
} }
// The test checks if OVR_multiview2 is emitted only once and no other
// multiview extensions are emitted.
TEST_F(OVRMultiview2FragmentShaderOutputCodeTest, NativeOvrMultiview2Output)
{
const std::string &shaderString =
"#version 300 es\n"
"#extension GL_OVR_multiview2 : require\n"
"void main()\n"
"{\n"
"}\n";
compile(shaderString);
EXPECT_FALSE(foundInGLSLCode("#extension GL_NV_viewport_array2"));
EXPECT_FALSE(foundInESSLCode("#extension GL_NV_viewport_array2"));
EXPECT_TRUE(foundInESSLCode("#extension GL_OVR_multiview2"));
EXPECT_TRUE(foundInGLSLCode("#extension GL_OVR_multiview2"));
// no double extension
std::vector<const char *> notExpectedStrings1 = {"#extension GL_OVR_multiview",
"#extension GL_OVR_multiview"};
EXPECT_FALSE(foundInCodeInOrder(SH_ESSL_OUTPUT, notExpectedStrings1));
EXPECT_FALSE(foundInCodeInOrder(SH_GLSL_COMPATIBILITY_OUTPUT, notExpectedStrings1));
}
// The test checks that the GL_NV_viewport_array2 extension is not emitted in a compute shader if // The test checks that the GL_NV_viewport_array2 extension is not emitted in a compute shader if
// the SH_SELECT_VIEW_IN_NV_GLSL_VERTEX_SHADER option is set. // the SH_SELECT_VIEW_IN_NV_GLSL_VERTEX_SHADER option is set.
TEST_F(OVRMultiview2ComputeShaderOutputCodeTest, ViewportArray2IsNotEmitted) TEST_F(OVRMultiview2ComputeShaderOutputCodeTest, ViewportArray2IsNotEmitted)
...@@ -700,7 +724,9 @@ TEST_F(OVRMultiview2VertexShaderOutputCodeTest, GlLayerIsSet) ...@@ -700,7 +724,9 @@ TEST_F(OVRMultiview2VertexShaderOutputCodeTest, GlLayerIsSet)
EXPECT_TRUE(foundInCodeInOrder(SH_GLSL_COMPATIBILITY_OUTPUT, expectedStrings)); EXPECT_TRUE(foundInCodeInOrder(SH_GLSL_COMPATIBILITY_OUTPUT, expectedStrings));
} }
// Test that the OVR_multiview2 without emulation is emits OVR_multiview2 output. // Test that the OVR_multiview2 without emulation emits OVR_multiview2 output.
// It also tests that the GL_OVR_multiview2 is emitted only once and no other
// multiview extensions are emitted.
TEST_F(OVRMultiview2VertexShaderOutputCodeTest, NativeOvrMultiview2Output) TEST_F(OVRMultiview2VertexShaderOutputCodeTest, NativeOvrMultiview2Output)
{ {
const std::string &shaderString = const std::string &shaderString =
...@@ -722,6 +748,17 @@ TEST_F(OVRMultiview2VertexShaderOutputCodeTest, NativeOvrMultiview2Output) ...@@ -722,6 +748,17 @@ TEST_F(OVRMultiview2VertexShaderOutputCodeTest, NativeOvrMultiview2Output)
EXPECT_FALSE(foundInGLSLCode("gl_ViewportIndex")); EXPECT_FALSE(foundInGLSLCode("gl_ViewportIndex"));
EXPECT_FALSE(foundInESSLCode("gl_ViewportIndex")); EXPECT_FALSE(foundInESSLCode("gl_ViewportIndex"));
// no double extension
std::vector<const char *> notExpectedStrings1 = {"#extension GL_OVR_multiview",
"#extension GL_OVR_multiview"};
EXPECT_FALSE(foundInCodeInOrder(SH_ESSL_OUTPUT, notExpectedStrings1));
EXPECT_FALSE(foundInCodeInOrder(SH_GLSL_COMPATIBILITY_OUTPUT, notExpectedStrings1));
// no double num_views
std::vector<const char *> notExpectedStrings2 = {"layout(num_views", "layout(num_views"};
EXPECT_FALSE(foundInCodeInOrder(SH_ESSL_OUTPUT, notExpectedStrings2));
EXPECT_FALSE(foundInCodeInOrder(SH_GLSL_COMPATIBILITY_OUTPUT, notExpectedStrings2));
} }
} // namespace } // namespace
...@@ -659,6 +659,33 @@ TEST_F(OVRMultiviewFragmentShaderOutputCodeTest, ViewportArray2IsNotEmitted) ...@@ -659,6 +659,33 @@ TEST_F(OVRMultiviewFragmentShaderOutputCodeTest, ViewportArray2IsNotEmitted)
EXPECT_FALSE(foundInESSLCode("#extension GL_NV_viewport_array2")); EXPECT_FALSE(foundInESSLCode("#extension GL_NV_viewport_array2"));
} }
// The test checks if OVR_multiview is emitted only once and no other
// multiview extensions are emitted.
TEST_F(OVRMultiviewFragmentShaderOutputCodeTest, NativeOvrMultiviewOutput)
{
const std::string &shaderString =
"#version 300 es\n"
"#extension GL_OVR_multiview : require\n"
"void main()\n"
"{\n"
"}\n";
compile(shaderString);
EXPECT_FALSE(foundInGLSLCode("#extension GL_NV_viewport_array2"));
EXPECT_FALSE(foundInESSLCode("#extension GL_NV_viewport_array2"));
EXPECT_TRUE(foundInESSLCode("#extension GL_OVR_multiview"));
EXPECT_TRUE(foundInGLSLCode("#extension GL_OVR_multiview"));
EXPECT_FALSE(foundInESSLCode("#extension GL_OVR_multiview2"));
EXPECT_FALSE(foundInGLSLCode("#extension GL_OVR_multiview2"));
// no double extension
std::vector<const char *> notExpectedStrings1 = {"#extension GL_OVR_multiview",
"#extension GL_OVR_multiview"};
EXPECT_FALSE(foundInCodeInOrder(SH_ESSL_OUTPUT, notExpectedStrings1));
EXPECT_FALSE(foundInCodeInOrder(SH_GLSL_COMPATIBILITY_OUTPUT, notExpectedStrings1));
}
// The test checks that the GL_NV_viewport_array2 extension is not emitted in a compute shader if // The test checks that the GL_NV_viewport_array2 extension is not emitted in a compute shader if
// the SH_SELECT_VIEW_IN_NV_GLSL_VERTEX_SHADER option is set. // the SH_SELECT_VIEW_IN_NV_GLSL_VERTEX_SHADER option is set.
TEST_F(OVRMultiviewComputeShaderOutputCodeTest, ViewportArray2IsNotEmitted) TEST_F(OVRMultiviewComputeShaderOutputCodeTest, ViewportArray2IsNotEmitted)
...@@ -716,4 +743,43 @@ TEST_F(OVRMultiviewVertexShaderOutputCodeTest, GlLayerIsSet) ...@@ -716,4 +743,43 @@ TEST_F(OVRMultiviewVertexShaderOutputCodeTest, GlLayerIsSet)
EXPECT_TRUE(foundInCodeInOrder(SH_GLSL_COMPATIBILITY_OUTPUT, expectedStrings)); EXPECT_TRUE(foundInCodeInOrder(SH_GLSL_COMPATIBILITY_OUTPUT, expectedStrings));
} }
// Test that the OVR_multiview without emulation emits OVR_multiview output.
// It also tests that the GL_OVR_multiview is emitted only once and no other
// multiview extensions are emitted.
TEST_F(OVRMultiviewVertexShaderOutputCodeTest, NativeOvrMultiviewOutput)
{
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";
compile(shaderString);
std::vector<const char *> expectedStrings = {"#extension GL_OVR_multiview", "layout(num_views"};
EXPECT_TRUE(foundInCodeInOrder(SH_ESSL_OUTPUT, expectedStrings));
EXPECT_TRUE(foundInCodeInOrder(SH_GLSL_COMPATIBILITY_OUTPUT, expectedStrings));
EXPECT_FALSE(foundInGLSLCode("#extension GL_NV_viewport_array2"));
EXPECT_FALSE(foundInESSLCode("#extension GL_NV_viewport_array2"));
EXPECT_FALSE(foundInGLSLCode("#extension GL_OVR_multiview2"));
EXPECT_FALSE(foundInESSLCode("#extension GL_OVR_multiview2"));
EXPECT_FALSE(foundInGLSLCode("gl_ViewportIndex"));
EXPECT_FALSE(foundInESSLCode("gl_ViewportIndex"));
// no double extension
std::vector<const char *> notExpectedStrings1 = {"#extension GL_OVR_multiview",
"#extension GL_OVR_multiview"};
EXPECT_FALSE(foundInCodeInOrder(SH_ESSL_OUTPUT, notExpectedStrings1));
EXPECT_FALSE(foundInCodeInOrder(SH_GLSL_COMPATIBILITY_OUTPUT, notExpectedStrings1));
// no double num_views
std::vector<const char *> notExpectedStrings2 = {"layout(num_views", "layout(num_views"};
EXPECT_FALSE(foundInCodeInOrder(SH_ESSL_OUTPUT, notExpectedStrings2));
EXPECT_FALSE(foundInCodeInOrder(SH_GLSL_COMPATIBILITY_OUTPUT, notExpectedStrings2));
}
} // namespace } // namespace
\ No newline at end of file
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