Path: blob/main_old/src/tests/compiler_tests/EXT_shadow_samplers_test.cpp
1693 views
//1// Copyright 2020 The ANGLE Project Authors. All rights reserved.2// Use of this source code is governed by a BSD-style license that can be3// found in the LICENSE file.4//5// EXT_shadow_samplers_test.cpp:6// Test for EXT_shadow_samplers7//89#include "tests/test_utils/ShaderExtensionTest.h"1011using EXTShadowSamplersTest = sh::ShaderExtensionTest;1213namespace14{15const char EXTPragma[] = "#extension GL_EXT_shadow_samplers : require\n";1617// Shader calling shadow2DEXT()18const char ESSL100_ShadowSamplersShader[] =19R"(20precision mediump float;21varying vec3 texCoord0v;22uniform sampler2DShadow tex;23void main()24{25float color = shadow2DEXT(tex, texCoord0v);26})";2728// Extension flag is required to compile properly. Expect failure when it is29// not present.30TEST_P(EXTShadowSamplersTest, CompileFailsWithoutExtension)31{32mResources.EXT_shadow_samplers = 0;33InitializeCompiler();34EXPECT_FALSE(TestShaderCompile(EXTPragma));35}3637// Extension directive is required to compile properly. Expect failure when38// it is not present.39TEST_P(EXTShadowSamplersTest, CompileFailsWithExtensionWithoutPragma)40{41mResources.EXT_shadow_samplers = 1;42InitializeCompiler();43EXPECT_FALSE(TestShaderCompile(""));44}4546// With extension flag and extension directive, compiling succeeds.47// Also test that the extension directive state is reset correctly.48TEST_P(EXTShadowSamplersTest, CompileSucceedsWithExtensionAndPragma)49{50mResources.EXT_shadow_samplers = 1;51InitializeCompiler();52EXPECT_TRUE(TestShaderCompile(EXTPragma));53// Test reset functionality.54EXPECT_FALSE(TestShaderCompile(""));55EXPECT_TRUE(TestShaderCompile(EXTPragma));56}5758// The SL #version 100 shaders that are correct work similarly59// in both GL2 and GL3, with and without the version string.60INSTANTIATE_TEST_SUITE_P(CorrectESSL100Shaders,61EXTShadowSamplersTest,62Combine(Values(SH_GLES2_SPEC),63Values(sh::ESSLVersion100),64Values(ESSL100_ShadowSamplersShader)));6566} // anonymous namespace6768