Hash :
2b15062b
Author :
Date :
2021-02-11T12:52:39
Allow more formats as texture attachments in GLES 1
This change allows all formats in the GLES 1.1 spec, table 3.4
to be used as a texture attachment.
Also normalize values passed into glColorPointer if the format
is of type GL_UNSIGNED_BYTE.
These changes are needed for the android app, Kick the Buddy
to render correctly.
Bug: angleproject:5599
Tests: *DrawTextureTest.ColorArrayDifferentTypes*
*FramebufferObjectTest.TextureObjectDifferentFormats*
Change-Id: Ie9d27fc24d94106651262cf9b2080dd3f05af1c5
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2690920
Commit-Queue: Mohan Maiya <m.maiya@samsung.com>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Geoff Lang <geofflang@chromium.org>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155
//
// Copyright 2020 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// FramebufferObjectTest.cpp: Tests basic usage of OES_framebuffer_object extension.
#include "test_utils/ANGLETest.h"
#include "test_utils/gl_raii.h"
using namespace angle;
class FramebufferObjectTest : public ANGLETest
{
protected:
FramebufferObjectTest()
{
setWindowWidth(32);
setWindowHeight(32);
setConfigRedBits(8);
setConfigGreenBits(8);
setConfigBlueBits(8);
setConfigAlphaBits(8);
setConfigDepthBits(24);
}
void testSetUp() override
{
mTexture.reset(new GLTexture());
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, mTexture->get());
}
void testTearDown() override { mTexture.reset(); }
std::unique_ptr<GLTexture> mTexture;
};
// Checks that framebuffer object can be used without GL errors.
TEST_P(FramebufferObjectTest, FramebufferObject)
{
GLuint fboId;
GLint params;
glGenFramebuffersOES(1, &fboId);
EXPECT_GL_NO_ERROR();
glIsFramebufferOES(fboId);
EXPECT_GL_NO_ERROR();
glBindFramebufferOES(GL_FRAMEBUFFER, fboId);
EXPECT_GL_NO_ERROR();
glCheckFramebufferStatusOES(GL_FRAMEBUFFER);
EXPECT_GL_NO_ERROR();
glGetFramebufferAttachmentParameterivOES(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, ¶ms);
EXPECT_GL_NO_ERROR();
glBindFramebuffer(GL_FRAMEBUFFER, 0);
glDeleteFramebuffersOES(1, &fboId);
EXPECT_GL_NO_ERROR();
}
// Checks that texture object can be bound for framebuffer object.
TEST_P(FramebufferObjectTest, TextureObject)
{
GLuint fboId;
glGenFramebuffers(1, &fboId);
glBindFramebuffer(GL_FRAMEBUFFER, fboId);
glFramebufferTexture2DOES(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, mTexture->get(),
0);
EXPECT_GL_NO_ERROR();
glBindFramebuffer(GL_FRAMEBUFFER, 0);
glDeleteFramebuffers(1, &fboId);
}
// Checks different formats for a texture object bound to a framebuffer object.
TEST_P(FramebufferObjectTest, TextureObjectDifferentFormats)
{
// http://anglebug.com/5642
ANGLE_SKIP_TEST_IF(IsOSX() && IsOpenGL());
GLuint fboId;
glGenFramebuffersOES(1, &fboId);
glBindFramebufferOES(GL_FRAMEBUFFER_OES, fboId);
using FormatInfo = std::array<GLenum, 3>;
constexpr std::array<FormatInfo, 5> kFormatArrays = {
{{GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE},
{GL_RGB, GL_RGB, GL_UNSIGNED_BYTE},
{GL_RGBA, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4},
{GL_RGBA, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1},
{GL_RGB, GL_RGB, GL_UNSIGNED_SHORT_5_6_5}}};
for (const FormatInfo &formatInfo : kFormatArrays)
{
glTexImage2D(GL_TEXTURE_2D, 0, formatInfo[0], 1, 1, 0, formatInfo[1], formatInfo[2],
&GLColor::green);
glFramebufferTexture2DOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES, GL_TEXTURE_2D,
mTexture->get(), 0);
ASSERT_EQ(glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES),
(GLenum)GL_FRAMEBUFFER_COMPLETE_OES);
}
EXPECT_GL_NO_ERROR();
glBindFramebufferOES(GL_FRAMEBUFFER_OES, 0);
glDeleteFramebuffersOES(1, &fboId);
}
// Checks that renderbuffer object can be used and can be bound for framebuffer object.
TEST_P(FramebufferObjectTest, RenderbufferObject)
{
GLuint fboId;
GLuint rboId;
GLint params;
glGenFramebuffers(1, &fboId);
glBindFramebuffer(GL_FRAMEBUFFER, fboId);
glGenRenderbuffersOES(1, &rboId);
EXPECT_GL_NO_ERROR();
glIsRenderbufferOES(rboId);
EXPECT_GL_NO_ERROR();
glBindRenderbufferOES(GL_RENDERBUFFER, rboId);
EXPECT_GL_NO_ERROR();
glRenderbufferStorageOES(GL_RENDERBUFFER, GL_RGBA8, 32, 32);
EXPECT_GL_NO_ERROR();
glFramebufferRenderbufferOES(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, rboId);
EXPECT_GL_NO_ERROR();
glGetRenderbufferParameterivOES(GL_RENDERBUFFER, GL_RENDERBUFFER_WIDTH, ¶ms);
EXPECT_GL_NO_ERROR();
glBindFramebuffer(GL_FRAMEBUFFER, 0);
glDeleteFramebuffers(1, &fboId);
glDeleteRenderbuffersOES(1, &rboId);
EXPECT_GL_NO_ERROR();
}
// Checks that generateMipmap can be called without GL errors.
TEST_P(FramebufferObjectTest, GenerateMipmap)
{
constexpr uint32_t kSize = 32;
std::vector<unsigned char> pixelData(kSize * kSize * 4, 0);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixelData.data());
glGenerateMipmapOES(GL_TEXTURE_2D);
EXPECT_GL_NO_ERROR();
}
ANGLE_INSTANTIATE_TEST_ES1(FramebufferObjectTest);