Path: blob/main_old/src/tests/gl_tests/BlendPackedTest.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//56#include "test_utils/ANGLETest.h"7#include "test_utils/gl_raii.h"89using namespace angle;1011class BlendPackedTest : public ANGLETest12{13protected:14BlendPackedTest()15{16setWindowWidth(128);17setWindowHeight(128);18setConfigRedBits(8);19setConfigGreenBits(8);20setConfigBlueBits(8);21setConfigAlphaBits(8);22}2324template <GLenum internalformat, GLuint components>25void runTest()26{27constexpr char kFs[] =28"#version 100\n"29"void main(void)\n"30"{\n"31" gl_FragColor = vec4(0.0, 0.0, 1.0, 1.0);\n"32"}\n";3334ANGLE_GL_PROGRAM(program, essl1_shaders::vs::Simple(), kFs);35glUseProgram(program);3637GLFramebuffer framebuffer;38glBindFramebuffer(GL_FRAMEBUFFER, framebuffer);3940GLRenderbuffer colorRenderbuffer;41glBindRenderbuffer(GL_RENDERBUFFER, colorRenderbuffer);42glRenderbufferStorage(GL_RENDERBUFFER, internalformat, getWindowWidth(), getWindowHeight());43glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER,44colorRenderbuffer);4546glClearColor(1.0, 1.0, 0.0, 0.0);47glClear(GL_COLOR_BUFFER_BIT);48ASSERT_GL_NO_ERROR();4950if (components == 3)51{52EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::yellow);53}54else55{56EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor(255u, 255u, 0, 0));57}5859glEnable(GL_BLEND);60glBlendEquation(GL_FUNC_ADD);61glBlendFunc(GL_ONE, GL_ONE);6263drawQuad(program, essl1_shaders::PositionAttrib(), 0.5f);64ASSERT_GL_NO_ERROR();6566EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::white);67}68};6970// Test that blending is applied to attachments with packed formats.71TEST_P(BlendPackedTest, RGB565)72{73runTest<GL_RGB565, 3>();74}7576TEST_P(BlendPackedTest, RGBA4)77{78runTest<GL_RGBA4, 4>();79}8081TEST_P(BlendPackedTest, RGB5_A1)82{83// RGB5_A1 is not color-renderable on NVIDIA Mac, see https://crbug.com/676209.84ANGLE_SKIP_TEST_IF(IsNVIDIA() && IsOSX() && IsOpenGL());85runTest<GL_RGB5_A1, 4>();86}8788TEST_P(BlendPackedTest, RGB10_A2)89{90ANGLE_SKIP_TEST_IF(getClientMajorVersion() < 3);91runTest<GL_RGB10_A2, 4>();92}9394// Use this to select which configurations (e.g. which renderer, which GLES major version) these95// tests should be run against.96ANGLE_INSTANTIATE_TEST_ES2_AND_ES3(BlendPackedTest);979899