// // Copyright 2016 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // // OVR_multiview2_test.cpp: // Test that shaders with gl_ViewID_OVR are validated correctly. // #include "GLSLANG/ShaderLang.h" #include "compiler/translator/tree_util/IntermTraverse.h" #include "tests/test_utils/ShaderCompileTreeTest.h" #include "tests/test_utils/compiler_test.h" usingnamespacesh; namespace { class SymbolOccurrenceCounter : public TIntermTraverser { … }; class SymbolOccurrenceCounterByQualifier : public SymbolOccurrenceCounter { … }; class SymbolOccurrenceCounterByName : public SymbolOccurrenceCounter { … }; class SymbolOccurrenceCounterByNameAndQualifier : public SymbolOccurrenceCounter { … }; class OVRMultiview2VertexShaderTest : public ShaderCompileTreeTest { … }; class OVRMultiview2FragmentShaderTest : public ShaderCompileTreeTest { … }; class OVRMultiview2OutputCodeTest : public MatchOutputCodeTest { … }; class OVRMultiview2VertexShaderOutputCodeTest : public OVRMultiview2OutputCodeTest { … }; class OVRMultiview2FragmentShaderOutputCodeTest : public OVRMultiview2OutputCodeTest { … }; class OVRMultiview2ComputeShaderOutputCodeTest : public OVRMultiview2OutputCodeTest { … }; void VariableOccursNTimes(TIntermBlock *root, const ImmutableString &varName, const TQualifier varQualifier, unsigned n) { … } // Invalid combination of non-matching num_views declarations. TEST_F(OVRMultiview2VertexShaderTest, InvalidNumViewsMismatch) { … } // Invalid value zero for num_views. TEST_F(OVRMultiview2VertexShaderTest, InvalidNumViewsZero) { … } // Too large value for num_views. TEST_F(OVRMultiview2VertexShaderTest, InvalidNumViewsGreaterThanMax) { … } // Test that GL_OVR_multiview2 cannot be used in an ESSL 1.00 vertex shader. TEST_F(OVRMultiview2VertexShaderTest, InvalidShaderVersion) { … } // Valid use of gl_ViewID_OVR. TEST_F(OVRMultiview2VertexShaderTest, ViewIDUsed) { … } // Read gl_FragCoord in a OVR_multiview2 fragment shader. TEST_F(OVRMultiview2FragmentShaderTest, ReadOfFragCoord) { … } // Read gl_ViewID_OVR in an OVR_multiview2 fragment shader. TEST_F(OVRMultiview2FragmentShaderTest, ReadOfViewID) { … } // Correct use of GL_OVR_multiview2 macro. TEST_F(OVRMultiview2VertexShaderTest, UseOfExtensionMacro) { … } // Test that gl_ViewID_OVR can't be used as an l-value. TEST_F(OVRMultiview2VertexShaderTest, ViewIdAsLValue) { … } // Test that compiling an ESSL 1.00 shader with multiview support fails. TEST_F(OVRMultiview2VertexShaderTest, ESSL1Shader) { … } // Test that compiling an ESSL 1.00 shader with an unsupported global layout qualifier fails. TEST_F(OVRMultiview2VertexShaderTest, ESSL1ShaderUnsupportedGlobalLayoutQualifier) { … } // Test that compiling an ESSL 1.00 vertex shader with an unsupported input storage qualifier fails. TEST_F(OVRMultiview2VertexShaderTest, ESSL1ShaderUnsupportedInputStorageQualifier) { … } // Test that compiling an ESSL 1.00 fragment shader with an unsupported input storage qualifier // fails. TEST_F(OVRMultiview2FragmentShaderTest, ESSL1ShaderUnsupportedInStorageQualifier) { … } // Test that gl_InstanceID gets correctly replaced by InstanceID. gl_InstanceID should only be used // twice: once to initialize ViewID_OVR and once for InstanceID. The number of occurrences of // InstanceID in the AST should be the sum of two and the number of occurrences of gl_InstanceID // before any renaming. TEST_F(OVRMultiview2VertexShaderTest, GLInstanceIDIsRenamed) { … } // Test that gl_ViewID_OVR gets correctly replaced by ViewID_OVR. gl_ViewID_OVR should not be found // by the name. The number of occurrences of ViewID_OVR in the AST should be the sum // of two and the number of occurrences of gl_ViewID_OVR before any renaming. TEST_F(OVRMultiview2VertexShaderTest, GLViewIDIsRenamed) { … } // The test checks that ViewID_OVR and InstanceID have the correct initializers based on the // number of views. TEST_F(OVRMultiview2VertexShaderOutputCodeTest, ViewIDAndInstanceIDHaveCorrectValues) { … } // The test checks that the directive enabling GL_OVR_multiview2 is not outputted if the extension // is emulated. TEST_F(OVRMultiview2VertexShaderOutputCodeTest, StrippedOVRMultiviewDirective) { … } // Test that ViewID_OVR has a proper qualifier in an ESSL 3.00 fragment shader. TEST_F(OVRMultiview2FragmentShaderTest, ViewIDDeclaredAsViewID) { … } // Test that GL_OVR_multiview is not defined by the preprocessor for WebGL spec shader; // Test that GL_OVR_multiview2 is defined by the preprocessor for WebGL spec shader. TEST_F(OVRMultiview2FragmentShaderTest, PreprocessorOutput) { … } // Test that GL_OVR_multiview is not defined by the preprocessor for WebGL spec shader; // Test that GL_OVR_multiview2 is defined by the preprocessor for WebGL spec shader. TEST_F(OVRMultiview2VertexShaderTest, PreprocessorOutput) { … } // The test checks that the GL_NV_viewport_array2 extension is emitted in a vertex shader if the // selectViewInNvGLSLVertexShader option is set. TEST_F(OVRMultiview2VertexShaderOutputCodeTest, ViewportArray2IsEmitted) { … } // The test checks that the GL_NV_viewport_array2 extension is not emitted in a vertex shader if the // OVR_multiview2 extension is not requested in the shader source even if the // selectViewInNvGLSLVertexShader option is set. TEST_F(OVRMultiview2VertexShaderOutputCodeTest, ViewportArray2IsNotEmitted) { … } // The test checks that the GL_NV_viewport_array2 extension is not emitted in a fragment shader if // the selectViewInNvGLSLVertexShader option is set. TEST_F(OVRMultiview2FragmentShaderOutputCodeTest, ViewportArray2IsNotEmitted) { … } // The test checks if OVR_multiview2 is emitted only once and no other // multiview extensions are emitted. TEST_F(OVRMultiview2FragmentShaderOutputCodeTest, NativeOvrMultiview2Output) { … } // The test checks that the GL_NV_viewport_array2 extension is not emitted in a compute shader if // the selectViewInNvGLSLVertexShader option is set. TEST_F(OVRMultiview2ComputeShaderOutputCodeTest, ViewportArray2IsNotEmitted) { … } // The test checks that the layer is selected after the initialization of ViewID_OVR for // GLSL and ESSL ouputs. TEST_F(OVRMultiview2VertexShaderOutputCodeTest, GlLayerIsSet) { … } // 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) { … } } // namespace