Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/angle
Path: blob/main_old/src/tests/gl_tests/BlendPackedTest.cpp
1693 views
1
//
2
// Copyright 2020 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
7
#include "test_utils/ANGLETest.h"
8
#include "test_utils/gl_raii.h"
9
10
using namespace angle;
11
12
class BlendPackedTest : public ANGLETest
13
{
14
protected:
15
BlendPackedTest()
16
{
17
setWindowWidth(128);
18
setWindowHeight(128);
19
setConfigRedBits(8);
20
setConfigGreenBits(8);
21
setConfigBlueBits(8);
22
setConfigAlphaBits(8);
23
}
24
25
template <GLenum internalformat, GLuint components>
26
void runTest()
27
{
28
constexpr char kFs[] =
29
"#version 100\n"
30
"void main(void)\n"
31
"{\n"
32
" gl_FragColor = vec4(0.0, 0.0, 1.0, 1.0);\n"
33
"}\n";
34
35
ANGLE_GL_PROGRAM(program, essl1_shaders::vs::Simple(), kFs);
36
glUseProgram(program);
37
38
GLFramebuffer framebuffer;
39
glBindFramebuffer(GL_FRAMEBUFFER, framebuffer);
40
41
GLRenderbuffer colorRenderbuffer;
42
glBindRenderbuffer(GL_RENDERBUFFER, colorRenderbuffer);
43
glRenderbufferStorage(GL_RENDERBUFFER, internalformat, getWindowWidth(), getWindowHeight());
44
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER,
45
colorRenderbuffer);
46
47
glClearColor(1.0, 1.0, 0.0, 0.0);
48
glClear(GL_COLOR_BUFFER_BIT);
49
ASSERT_GL_NO_ERROR();
50
51
if (components == 3)
52
{
53
EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::yellow);
54
}
55
else
56
{
57
EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor(255u, 255u, 0, 0));
58
}
59
60
glEnable(GL_BLEND);
61
glBlendEquation(GL_FUNC_ADD);
62
glBlendFunc(GL_ONE, GL_ONE);
63
64
drawQuad(program, essl1_shaders::PositionAttrib(), 0.5f);
65
ASSERT_GL_NO_ERROR();
66
67
EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::white);
68
}
69
};
70
71
// Test that blending is applied to attachments with packed formats.
72
TEST_P(BlendPackedTest, RGB565)
73
{
74
runTest<GL_RGB565, 3>();
75
}
76
77
TEST_P(BlendPackedTest, RGBA4)
78
{
79
runTest<GL_RGBA4, 4>();
80
}
81
82
TEST_P(BlendPackedTest, RGB5_A1)
83
{
84
// RGB5_A1 is not color-renderable on NVIDIA Mac, see https://crbug.com/676209.
85
ANGLE_SKIP_TEST_IF(IsNVIDIA() && IsOSX() && IsOpenGL());
86
runTest<GL_RGB5_A1, 4>();
87
}
88
89
TEST_P(BlendPackedTest, RGB10_A2)
90
{
91
ANGLE_SKIP_TEST_IF(getClientMajorVersion() < 3);
92
runTest<GL_RGB10_A2, 4>();
93
}
94
95
// Use this to select which configurations (e.g. which renderer, which GLES major version) these
96
// tests should be run against.
97
ANGLE_INSTANTIATE_TEST_ES2_AND_ES3(BlendPackedTest);
98
99