Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/angle
Path: blob/main_old/src/tests/compiler_tests/GlFragDataNotModified_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
// GlFragDataNotModified_test.cpp:
7
// Test that the properties of built-in gl_FragData are not modified when a shader is compiled
8
// multiple times.
9
//
10
11
#include "tests/test_utils/ShaderCompileTreeTest.h"
12
13
namespace
14
{
15
16
class GlFragDataNotModifiedTest : public sh::ShaderCompileTreeTest
17
{
18
public:
19
GlFragDataNotModifiedTest() {}
20
21
protected:
22
void initResources(ShBuiltInResources *resources) override
23
{
24
resources->MaxDrawBuffers = 4;
25
resources->EXT_draw_buffers = 1;
26
}
27
28
::GLenum getShaderType() const override { return GL_FRAGMENT_SHADER; }
29
ShShaderSpec getShaderSpec() const override { return SH_GLES2_SPEC; }
30
};
31
32
// Test a bug where we could modify the value of a builtin variable.
33
TEST_F(GlFragDataNotModifiedTest, BuiltinRewritingBug)
34
{
35
const std::string &shaderString =
36
"#extension GL_EXT_draw_buffers : require\n"
37
"precision mediump float;\n"
38
"void main() {\n"
39
" gl_FragData[gl_MaxDrawBuffers] = vec4(0.0);\n"
40
"}";
41
42
if (compile(shaderString))
43
{
44
FAIL() << "Shader compilation succeeded, expecting failure\n";
45
}
46
if (compile(shaderString))
47
{
48
FAIL() << "Shader compilation succeeded, expecting failure\n";
49
}
50
}
51
52
} // anonymous namespace
53
54