chromium/third_party/angle/src/tests/compiler_tests/OVR_multiview_test.cpp

//
// Copyright 2019 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_multiview_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 OVRMultiviewVertexShaderTest : public ShaderCompileTreeTest
{};

class OVRMultiviewFragmentShaderTest : public ShaderCompileTreeTest
{};

class OVRMultiviewOutputCodeTest : public MatchOutputCodeTest
{};

class OVRMultiviewVertexShaderOutputCodeTest : public OVRMultiviewOutputCodeTest
{};

class OVRMultiviewFragmentShaderOutputCodeTest : public OVRMultiviewOutputCodeTest
{};

class OVRMultiviewComputeShaderOutputCodeTest : public OVRMultiviewOutputCodeTest
{};

void VariableOccursNTimes(TIntermBlock *root,
                          const ImmutableString &varName,
                          const TQualifier varQualifier,
                          unsigned n)
{}

// Unsupported GL_OVR_multiview extension directive (GL_OVR_multiview spec only exposes
// GL_OVR_multiview).
TEST_F(OVRMultiviewVertexShaderTest, InvalidMultiview)
{}

// Invalid combination of non-matching num_views declarations.
TEST_F(OVRMultiviewVertexShaderTest, InvalidNumViewsMismatch)
{}

// Invalid value zero for num_views.
TEST_F(OVRMultiviewVertexShaderTest, InvalidNumViewsZero)
{}

// Too large value for num_views.
TEST_F(OVRMultiviewVertexShaderTest, InvalidNumViewsGreaterThanMax)
{}

// Test that GL_OVR_multiview cannot be used in an ESSL 1.00 vertex shader.
TEST_F(OVRMultiviewVertexShaderTest, InvalidShaderVersion)
{}

// Valid use of gl_ViewID_OVR.
TEST_F(OVRMultiviewVertexShaderTest, ViewIDUsed)
{}

// Read gl_FragCoord in a OVR_multiview2 fragment shader.
TEST_F(OVRMultiviewFragmentShaderTest, ReadOfFragCoord)
{}

// Read gl_ViewID_OVR in an OVR_multiview2 fragment shader.
TEST_F(OVRMultiviewFragmentShaderTest, ReadOfViewID)
{}

// Correct use of GL_OVR_multiview macro.
TEST_F(OVRMultiviewVertexShaderTest, UseOfExtensionMacro)
{}

// Test that gl_ViewID_OVR can't be used as an l-value.
TEST_F(OVRMultiviewVertexShaderTest, ViewIdAsLValue)
{}

// Test that compiling an ESSL 1.00 shader with multiview support fails.
TEST_F(OVRMultiviewVertexShaderTest, ESSL1Shader)
{}

// Test that compiling an ESSL 1.00 shader with an unsupported global layout qualifier fails.
TEST_F(OVRMultiviewVertexShaderTest, ESSL1ShaderUnsupportedGlobalLayoutQualifier)
{}

// Test that compiling an ESSL 1.00 vertex shader with an unsupported input storage qualifier fails.
TEST_F(OVRMultiviewVertexShaderTest, ESSL1ShaderUnsupportedInputStorageQualifier)
{}

// Test that compiling an ESSL 1.00 fragment shader with an unsupported input storage qualifier
// fails.
TEST_F(OVRMultiviewFragmentShaderTest, 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(OVRMultiviewVertexShaderTest, 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(OVRMultiviewVertexShaderTest, GLViewIDIsRenamed)
{}

// The test checks that ViewID_OVR and InstanceID have the correct initializers based on the
// number of views.
TEST_F(OVRMultiviewVertexShaderOutputCodeTest, ViewIDAndInstanceIDHaveCorrectValues)
{}

// The test checks that the directive enabling GL_OVR_multiview is not outputted if the extension
// is emulated.
TEST_F(OVRMultiviewVertexShaderOutputCodeTest, StrippedOVRMultiviewDirective)
{}

// Test that ViewID_OVR has a proper qualifier in an ESSL 3.00 fragment shader.
TEST_F(OVRMultiviewFragmentShaderTest, ViewIDDeclaredAsViewID)
{}

// The test checks that the GL_NV_viewport_array2 extension is emitted in a vertex shader if the
// selectViewInNvGLSLVertexShader option is set.
TEST_F(OVRMultiviewVertexShaderOutputCodeTest, 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(OVRMultiviewVertexShaderOutputCodeTest, 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(OVRMultiviewFragmentShaderOutputCodeTest, ViewportArray2IsNotEmitted)
{}

// The test checks if OVR_multiview is emitted only once and no other
// multiview extensions are emitted.
TEST_F(OVRMultiviewFragmentShaderOutputCodeTest, NativeOvrMultiviewOutput)
{}

// 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(OVRMultiviewComputeShaderOutputCodeTest, ViewportArray2IsNotEmitted)
{}

// The test checks that the layer is selected after the initialization of ViewID_OVR for
// GLSL and ESSL ouputs.
TEST_F(OVRMultiviewVertexShaderOutputCodeTest, GlLayerIsSet)
{}

// 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)
{}

}  // namespace