Path: blob/main_old/src/tests/compiler_tests/OES_standard_derivatives_test.cpp
1693 views
//1// Copyright 2018 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// OES_standard_derivatives_test.cpp:6// Test for OES_standard_derivatives7//89#include "tests/test_utils/ShaderExtensionTest.h"1011using OESStandardDerivativesTest = sh::ShaderExtensionTest;1213namespace14{15const char OESPragma[] = "#extension GL_OES_standard_derivatives : require\n";1617// Shader calling dFdx()18const char ESSL100_DfdxShader[] =19R"(20precision mediump float;21varying float x;2223void main()24{25gl_FragColor = vec4(dFdx(x));26})";2728// Shader calling dFdy()29const char ESSL100_DfdyShader[] =30R"(31precision mediump float;32varying float x;3334void main()35{36gl_FragColor = vec4(dFdy(x));37})";3839// Shader calling fwidth()40const char ESSL100_FwidthShader[] =41R"(42precision mediump float;43varying float x;4445void main()46{47gl_FragColor = vec4(fwidth(x));48})";4950// Extension flag is required to compile properly. Expect failure when it is51// not present.52TEST_P(OESStandardDerivativesTest, CompileFailsWithoutExtension)53{54mResources.OES_standard_derivatives = 0;55InitializeCompiler();56EXPECT_FALSE(TestShaderCompile(OESPragma));57}5859// Extension directive is required to compile properly. Expect failure when60// it is not present.61TEST_P(OESStandardDerivativesTest, CompileFailsWithExtensionWithoutPragma)62{63mResources.OES_standard_derivatives = 1;64InitializeCompiler();65EXPECT_FALSE(TestShaderCompile(""));66}6768// With extension flag and extension directive, compiling succeeds.69// Also test that the extension directive state is reset correctly.70TEST_P(OESStandardDerivativesTest, CompileSucceedsWithExtensionAndPragma)71{72mResources.OES_standard_derivatives = 1;73InitializeCompiler();74EXPECT_TRUE(TestShaderCompile(OESPragma));75// Test reset functionality.76EXPECT_FALSE(TestShaderCompile(""));77EXPECT_TRUE(TestShaderCompile(OESPragma));78}7980// The SL #version 100 shaders that are correct work similarly81// in both GL2 and GL3, with and without the version string.82INSTANTIATE_TEST_SUITE_P(83CorrectESSL100Shaders,84OESStandardDerivativesTest,85Combine(Values(SH_GLES2_SPEC),86Values(sh::ESSLVersion100),87Values(ESSL100_DfdxShader, ESSL100_DfdyShader, ESSL100_FwidthShader)));8889} // anonymous namespace909192