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

//
// Copyright 2020 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.
//
// EXT_clip_cull_distance_test.cpp:
//   Test for EXT_clip_cull_distance
//

#include "tests/test_utils/ShaderExtensionTest.h"

namespace
{
const char EXTPragma[] =;

const char ANGLEPragma[] =;

// Shader using gl_ClipDistance and gl_CullDistance
const char VertexShaderCompileSucceeds1[] =;

// Shader redeclares gl_ClipDistance and gl_CullDistance
const char VertexShaderCompileSucceeds2[] =;

#if defined(ANGLE_ENABLE_VULKAN)
// Shader using gl_ClipDistance and gl_CullDistance
// But, the sum of the sizes is greater than gl_MaxCombinedClipAndCullDistances
const char VertexShaderCompileFails1[] =;

// Shader redeclares gl_ClipDistance and gl_CullDistance
// But, the sum of the sizes is greater than gl_MaxCombinedClipAndCullDistances
const char VertexShaderCompileFails2[] =;

// Shader redeclares gl_ClipDistance
// But, the array size is greater than gl_MaxClipDistances
const char VertexShaderCompileFails3[] =;

// Access gl_CullDistance with integral constant index
// But, the index is greater than gl_MaxCullDistances
const char VertexShaderCompileFails4[] =;

// Simple ESSL1 vertex shader that should still fail because of incompatible
// #extension require
const char VertexShaderCompileFails5[] =;
#endif

// Shader using gl_ClipDistance and gl_CullDistance
const char FragmentShaderCompileSucceeds1[] =;

// Shader redeclares gl_ClipDistance and gl_CullDistance
const char FragmentShaderCompileSucceeds2[] =;

#if defined(ANGLE_ENABLE_VULKAN)
// Shader using gl_ClipDistance and gl_CullDistance
// But, the sum of the sizes is greater than gl_MaxCombinedClipAndCullDistances
const char FragmentShaderCompileFails1[] =;

// Shader redeclares gl_ClipDistance and gl_CullDistance
// But, the sum of the sizes is greater than gl_MaxCombinedClipAndCullDistances
const char FragmentShaderCompileFails2[] =;

// In fragment shader, writing to gl_ClipDistance should be denied.
const char FragmentShaderCompileFails3[] =;

// In fragment shader, writing to gl_CullDistance should be denied even if redeclaring it with the
// array size
const char FragmentShaderCompileFails4[] =;

// Accessing to gl_Clip/CullDistance with non-const index should be denied if the size of
// gl_Clip/CullDistance is not decided.
const char FragmentShaderCompileFails5[] =;

// In compute shader, redeclaring gl_ClipDistance should be denied.
const char ComputeShaderCompileFails1[] =;

// In compute shader, writing to gl_ClipDistance should be denied.
const char ComputeShaderCompileFails2[] =;

// In compute shader, reading gl_ClipDistance should be denied.
const char ComputeShaderCompileFails3[] =;

// In compute shader, redeclaring gl_CullDistance should be denied.
const char ComputeShaderCompileFails4[] =;

// In compute shader, writing to gl_CullDistance should be denied.
const char ComputeShaderCompileFails5[] =;

// In compute shader, reading gl_CullDistance should be denied.
const char ComputeShaderCompileFails6[] =;
#endif

class EXTClipCullDistanceTest : public sh::ShaderExtensionTest
{};

class EXTClipCullDistanceForVertexShaderTest : public EXTClipCullDistanceTest
{};

class EXTClipCullDistanceForFragmentShaderTest : public EXTClipCullDistanceTest
{};

class EXTClipCullDistanceForComputeShaderTest : public EXTClipCullDistanceTest
{};

// Extension flag is required to compile properly. Expect failure when it is
// not present.
TEST_P(EXTClipCullDistanceForVertexShaderTest, CompileFailsWithoutExtension)
{}

// Extension directive is required to compile properly. Expect failure when
// it is not present.
TEST_P(EXTClipCullDistanceForVertexShaderTest, CompileFailsWithExtensionWithoutPragma)
{}

#if defined(ANGLE_ENABLE_VULKAN)
// With extension flag and extension directive, compiling using TranslatorVulkan succeeds.
TEST_P(EXTClipCullDistanceForVertexShaderTest, CompileSucceedsVulkan)
{}
#endif

// Extension flag is required to compile properly. Expect failure when it is
// not present.
TEST_P(EXTClipCullDistanceForFragmentShaderTest, CompileFailsWithoutExtension)
{}

// Extension directive is required to compile properly. Expect failure when
// it is not present.
TEST_P(EXTClipCullDistanceForFragmentShaderTest, CompileFailsWithExtensionWithoutPragma)
{}

#if defined(ANGLE_ENABLE_VULKAN)
// With extension flag and extension directive, compiling using TranslatorVulkan succeeds.
TEST_P(EXTClipCullDistanceForFragmentShaderTest, CompileSucceedsVulkan)
{}

class EXTClipCullDistanceForVertexShaderCompileFailureTest
    : public EXTClipCullDistanceForVertexShaderTest
{};

class EXTClipCullDistanceForFragmentShaderCompileFailureTest
    : public EXTClipCullDistanceForFragmentShaderTest
{};

class EXTClipCullDistanceForComputeShaderCompileFailureTest
    : public EXTClipCullDistanceForComputeShaderTest
{};

TEST_P(EXTClipCullDistanceForVertexShaderCompileFailureTest, CompileFails)
{}

TEST_P(EXTClipCullDistanceForFragmentShaderCompileFailureTest, CompileFails)
{}

// Test that the clip and cull distance built-ins are not defined for compute shaders.
TEST_P(EXTClipCullDistanceForComputeShaderCompileFailureTest, CompileFails)
{}
#endif

INSTANTIATE_TEST_SUITE_P();

INSTANTIATE_TEST_SUITE_P();

// The corresponding TEST_Ps are defined only when ANGLE_ENABLE_VULKAN is
// defined.
#if defined(ANGLE_ENABLE_VULKAN)
INSTANTIATE_TEST_SUITE_P();

INSTANTIATE_TEST_SUITE_P();

INSTANTIATE_TEST_SUITE_P();

INSTANTIATE_TEST_SUITE_P();
#endif

}  // anonymous namespace