Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/angle
Path: blob/main_old/src/tests/compiler_tests/EXT_frag_depth_test.cpp
1693 views
1
//
2
// Copyright 2018 The ANGLE Project Authors. All rights reserved.
3
// Use of this source code is governed by a BSD-style license that can be
4
// found in the LICENSE file.
5
//
6
// EXT_frag_depth_test.cpp:
7
// Test for EXT_frag_depth
8
//
9
10
#include "tests/test_utils/ShaderExtensionTest.h"
11
12
using EXTFragDepthTest = sh::ShaderExtensionTest;
13
14
namespace
15
{
16
const char EXTPragma[] = "#extension GL_EXT_frag_depth : require\n";
17
18
// Shader setting gl_FragDepthEXT
19
const char ESSL100_FragDepthShader[] =
20
21
R"(
22
precision mediump float;
23
24
void main()
25
{
26
gl_FragDepthEXT = 1.0;
27
})";
28
29
// Extension flag is required to compile properly. Expect failure when it is
30
// not present.
31
TEST_P(EXTFragDepthTest, CompileFailsWithoutExtension)
32
{
33
mResources.EXT_frag_depth = 0;
34
InitializeCompiler();
35
EXPECT_FALSE(TestShaderCompile(EXTPragma));
36
}
37
38
// Extension directive is required to compile properly. Expect failure when
39
// it is not present.
40
TEST_P(EXTFragDepthTest, CompileFailsWithExtensionWithoutPragma)
41
{
42
mResources.EXT_frag_depth = 1;
43
InitializeCompiler();
44
EXPECT_FALSE(TestShaderCompile(""));
45
}
46
47
// With extension flag and extension directive, compiling succeeds.
48
// Also test that the extension directive state is reset correctly.
49
TEST_P(EXTFragDepthTest, CompileSucceedsWithExtensionAndPragma)
50
{
51
mResources.EXT_frag_depth = 1;
52
InitializeCompiler();
53
EXPECT_TRUE(TestShaderCompile(EXTPragma));
54
// Test reset functionality.
55
EXPECT_FALSE(TestShaderCompile(""));
56
EXPECT_TRUE(TestShaderCompile(EXTPragma));
57
}
58
59
// The SL #version 100 shaders that are correct work similarly
60
// in both GL2 and GL3, with and without the version string.
61
INSTANTIATE_TEST_SUITE_P(CorrectESSL100Shaders,
62
EXTFragDepthTest,
63
Combine(Values(SH_GLES2_SPEC),
64
Values(sh::ESSLVersion100),
65
Values(ESSL100_FragDepthShader)));
66
67
} // anonymous namespace
68
69