Commit ccd0b7e1 by Mohan Maiya Committed by Commit Bot

Add support for OES_framebuffer_object extension

Expose OES_framebuffer_object extension for GLES1 contexts. Bug: angleproject:5401 Test: FramebufferObjectTest* Change-Id: I63b504f580cdab4655b4bfbd3438bcd807b422ea Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2561795 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: 's avatarShahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org>
parent ff38106d
...@@ -1052,6 +1052,7 @@ const ExtensionInfoMap &GetExtensionInfoMap() ...@@ -1052,6 +1052,7 @@ const ExtensionInfoMap &GetExtensionInfoMap()
map["GL_OES_texture_cube_map"] = enableableExtension(&Extensions::textureCubeMapOES); map["GL_OES_texture_cube_map"] = enableableExtension(&Extensions::textureCubeMapOES);
map["GL_OES_point_sprite"] = enableableExtension(&Extensions::pointSpriteOES); map["GL_OES_point_sprite"] = enableableExtension(&Extensions::pointSpriteOES);
map["GL_OES_draw_texture"] = enableableExtension(&Extensions::drawTextureOES); map["GL_OES_draw_texture"] = enableableExtension(&Extensions::drawTextureOES);
map["GL_OES_framebuffer_object"] = enableableExtension(&Extensions::framebufferObjectOES);
map["GL_ANGLE_memory_size"] = enableableExtension(&Extensions::memorySize); map["GL_ANGLE_memory_size"] = enableableExtension(&Extensions::memorySize);
map["GL_EXT_shader_non_constant_global_initializers"] = enableableExtension(&Extensions::shaderNonConstGlobalInitializersEXT); map["GL_EXT_shader_non_constant_global_initializers"] = enableableExtension(&Extensions::shaderNonConstGlobalInitializersEXT);
map["GL_WEBGL_video_texture"] = enableableExtension(&Extensions::webglVideoTexture); map["GL_WEBGL_video_texture"] = enableableExtension(&Extensions::webglVideoTexture);
......
...@@ -562,6 +562,9 @@ struct Extensions ...@@ -562,6 +562,9 @@ struct Extensions
// GL_OES_draw_texture // GL_OES_draw_texture
bool drawTextureOES = false; bool drawTextureOES = false;
// GL_OES_framebuffer_object
bool framebufferObjectOES = false;
// EGL_ANGLE_explicit_context GL subextensions // EGL_ANGLE_explicit_context GL subextensions
// GL_ANGLE_explicit_context_gles1 // GL_ANGLE_explicit_context_gles1
bool explicitContextGles1 = false; bool explicitContextGles1 = false;
......
...@@ -3179,6 +3179,7 @@ Extensions Context::generateSupportedExtensions() const ...@@ -3179,6 +3179,7 @@ Extensions Context::generateSupportedExtensions() const
supportedExtensions.textureCubeMapOES = true; supportedExtensions.textureCubeMapOES = true;
supportedExtensions.pointSpriteOES = true; supportedExtensions.pointSpriteOES = true;
supportedExtensions.drawTextureOES = true; supportedExtensions.drawTextureOES = true;
supportedExtensions.framebufferObjectOES = true;
supportedExtensions.parallelShaderCompile = false; supportedExtensions.parallelShaderCompile = false;
supportedExtensions.texture3DOES = false; supportedExtensions.texture3DOES = false;
} }
......
...@@ -101,17 +101,6 @@ Program *GetValidProgram(const Context *context, ShaderProgramID id); ...@@ -101,17 +101,6 @@ Program *GetValidProgram(const Context *context, ShaderProgramID id);
Shader *GetValidShader(const Context *context, ShaderProgramID id); Shader *GetValidShader(const Context *context, ShaderProgramID id);
bool ValidateAttachmentTarget(const Context *context, GLenum attachment); bool ValidateAttachmentTarget(const Context *context, GLenum attachment);
bool ValidateRenderbufferStorageParametersBase(const Context *context,
GLenum target,
GLsizei samples,
GLenum internalformat,
GLsizei width,
GLsizei height);
bool ValidateFramebufferRenderbufferParameters(const Context *context,
GLenum target,
GLenum attachment,
GLenum renderbuffertarget,
RenderbufferID renderbuffer);
bool ValidateBlitFramebufferParameters(const Context *context, bool ValidateBlitFramebufferParameters(const Context *context,
GLint srcX0, GLint srcX0,
...@@ -125,6 +114,29 @@ bool ValidateBlitFramebufferParameters(const Context *context, ...@@ -125,6 +114,29 @@ bool ValidateBlitFramebufferParameters(const Context *context,
GLbitfield mask, GLbitfield mask,
GLenum filter); GLenum filter);
bool ValidateBindFramebufferBase(const Context *context, GLenum target, FramebufferID framebuffer);
bool ValidateBindRenderbufferBase(const Context *context,
GLenum target,
RenderbufferID renderbuffer);
bool ValidateFramebufferRenderbufferBase(const Context *context,
GLenum target,
GLenum attachment,
GLenum renderbuffertarget,
RenderbufferID renderbuffer);
bool ValidateFramebufferTextureBase(const Context *context,
GLenum target,
GLenum attachment,
TextureID texture,
GLint level);
bool ValidateGenerateMipmapBase(const Context *context, TextureType target);
bool ValidateRenderbufferStorageParametersBase(const Context *context,
GLenum target,
GLsizei samples,
GLenum internalformat,
GLsizei width,
GLsizei height);
bool ValidatePixelPack(const Context *context, bool ValidatePixelPack(const Context *context,
GLenum format, GLenum format,
GLenum type, GLenum type,
...@@ -408,12 +420,6 @@ bool ValidateDrawElementsInstancedEXT(const Context *context, ...@@ -408,12 +420,6 @@ bool ValidateDrawElementsInstancedEXT(const Context *context,
bool ValidateDrawInstancedANGLE(const Context *context); bool ValidateDrawInstancedANGLE(const Context *context);
bool ValidateFramebufferTextureBase(const Context *context,
GLenum target,
GLenum attachment,
TextureID texture,
GLint level);
bool ValidateGetUniformBase(const Context *context, bool ValidateGetUniformBase(const Context *context,
ShaderProgramID program, ShaderProgramID program,
UniformLocation location); UniformLocation location);
......
...@@ -1551,49 +1551,90 @@ bool ValidateGenFramebuffersOES(const Context *context, ...@@ -1551,49 +1551,90 @@ bool ValidateGenFramebuffersOES(const Context *context,
GLsizei n, GLsizei n,
const FramebufferID *framebuffers) const FramebufferID *framebuffers)
{ {
UNIMPLEMENTED(); if (!context->getExtensions().framebufferObjectOES)
return true; {
context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
return false;
}
return ValidateGenOrDelete(context, n);
} }
bool ValidateDeleteFramebuffersOES(const Context *context, bool ValidateDeleteFramebuffersOES(const Context *context,
GLsizei n, GLsizei n,
const FramebufferID *framebuffers) const FramebufferID *framebuffers)
{ {
UNIMPLEMENTED(); if (!context->getExtensions().framebufferObjectOES)
return true; {
context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
return false;
}
return ValidateGenOrDelete(context, n);
} }
bool ValidateGenRenderbuffersOES(const Context *context, bool ValidateGenRenderbuffersOES(const Context *context,
GLsizei n, GLsizei n,
const RenderbufferID *renderbuffers) const RenderbufferID *renderbuffers)
{ {
UNIMPLEMENTED(); if (!context->getExtensions().framebufferObjectOES)
return true; {
context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
return false;
}
return ValidateGenOrDelete(context, n);
} }
bool ValidateDeleteRenderbuffersOES(const Context *context, bool ValidateDeleteRenderbuffersOES(const Context *context,
GLsizei n, GLsizei n,
const RenderbufferID *renderbuffers) const RenderbufferID *renderbuffers)
{ {
UNIMPLEMENTED(); if (!context->getExtensions().framebufferObjectOES)
return true; {
context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
return false;
}
return ValidateGenOrDelete(context, n);
} }
bool ValidateBindFramebufferOES(const Context *context, GLenum target, FramebufferID framebuffer) bool ValidateBindFramebufferOES(const Context *context, GLenum target, FramebufferID framebuffer)
{ {
UNIMPLEMENTED(); if (!context->getExtensions().framebufferObjectOES)
return true; {
context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
return false;
}
return ValidateBindFramebufferBase(context, target, framebuffer);
} }
bool ValidateBindRenderbufferOES(const Context *context, GLenum target, RenderbufferID renderbuffer) bool ValidateBindRenderbufferOES(const Context *context, GLenum target, RenderbufferID renderbuffer)
{ {
UNIMPLEMENTED(); if (!context->getExtensions().framebufferObjectOES)
return true; {
context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
return false;
}
return ValidateBindRenderbufferBase(context, target, renderbuffer);
} }
bool ValidateCheckFramebufferStatusOES(const Context *context, GLenum target) bool ValidateCheckFramebufferStatusOES(const Context *context, GLenum target)
{ {
UNIMPLEMENTED(); if (!context->getExtensions().framebufferObjectOES)
{
context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
return false;
}
if (!ValidFramebufferTarget(context, target))
{
context->validationError(GL_INVALID_ENUM, kInvalidFramebufferTarget);
return false;
}
return true; return true;
} }
...@@ -1603,8 +1644,13 @@ bool ValidateFramebufferRenderbufferOES(const Context *context, ...@@ -1603,8 +1644,13 @@ bool ValidateFramebufferRenderbufferOES(const Context *context,
GLenum rbtarget, GLenum rbtarget,
RenderbufferID renderbuffer) RenderbufferID renderbuffer)
{ {
UNIMPLEMENTED(); if (!context->getExtensions().framebufferObjectOES)
return true; {
context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
return false;
}
return ValidateFramebufferRenderbufferBase(context, target, attachment, rbtarget, renderbuffer);
} }
bool ValidateFramebufferTexture2DOES(const Context *context, bool ValidateFramebufferTexture2DOES(const Context *context,
...@@ -1614,14 +1660,91 @@ bool ValidateFramebufferTexture2DOES(const Context *context, ...@@ -1614,14 +1660,91 @@ bool ValidateFramebufferTexture2DOES(const Context *context,
TextureID texture, TextureID texture,
GLint level) GLint level)
{ {
UNIMPLEMENTED(); if (!context->getExtensions().framebufferObjectOES)
{
context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
return false;
}
if (level != 0)
{
context->validationError(GL_INVALID_VALUE, kInvalidFramebufferTextureLevel);
return false;
}
if (!ValidateFramebufferTextureBase(context, target, attachment, texture, level))
{
return false;
}
if (texture.value != 0)
{
Texture *tex = context->getTexture(texture);
ASSERT(tex);
const Caps &caps = context->getCaps();
switch (textarget)
{
case TextureTarget::_2D:
{
if (level > log2(caps.max2DTextureSize))
{
context->validationError(GL_INVALID_VALUE, kInvalidMipLevel);
return false;
}
if (tex->getType() != TextureType::_2D)
{
context->validationError(GL_INVALID_OPERATION, kInvalidTextureTarget);
return false;
}
}
break;
case TextureTarget::CubeMapNegativeX:
case TextureTarget::CubeMapNegativeY:
case TextureTarget::CubeMapNegativeZ:
case TextureTarget::CubeMapPositiveX:
case TextureTarget::CubeMapPositiveY:
case TextureTarget::CubeMapPositiveZ:
{
if (!context->getExtensions().textureCubeMapOES)
{
context->validationError(GL_INVALID_ENUM, kInvalidTextureTarget);
return false;
}
if (level > log2(caps.maxCubeMapTextureSize))
{
context->validationError(GL_INVALID_VALUE, kInvalidMipLevel);
return false;
}
if (tex->getType() != TextureType::CubeMap)
{
context->validationError(GL_INVALID_OPERATION, kTextureTargetMismatch);
return false;
}
}
break;
default:
context->validationError(GL_INVALID_ENUM, kInvalidTextureTarget);
return false;
}
}
return true; return true;
} }
bool ValidateGenerateMipmapOES(const Context *context, TextureType target) bool ValidateGenerateMipmapOES(const Context *context, TextureType target)
{ {
UNIMPLEMENTED(); if (!context->getExtensions().framebufferObjectOES)
return true; {
context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
return false;
}
return ValidateGenerateMipmapBase(context, target);
} }
bool ValidateGetFramebufferAttachmentParameterivOES(const Context *context, bool ValidateGetFramebufferAttachmentParameterivOES(const Context *context,
...@@ -1630,8 +1753,14 @@ bool ValidateGetFramebufferAttachmentParameterivOES(const Context *context, ...@@ -1630,8 +1753,14 @@ bool ValidateGetFramebufferAttachmentParameterivOES(const Context *context,
GLenum pname, GLenum pname,
const GLint *params) const GLint *params)
{ {
UNIMPLEMENTED(); if (!context->getExtensions().framebufferObjectOES)
return true; {
context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
return false;
}
return ValidateGetFramebufferAttachmentParameterivBase(context, target, attachment, pname,
nullptr);
} }
bool ValidateGetRenderbufferParameterivOES(const Context *context, bool ValidateGetRenderbufferParameterivOES(const Context *context,
...@@ -1639,19 +1768,34 @@ bool ValidateGetRenderbufferParameterivOES(const Context *context, ...@@ -1639,19 +1768,34 @@ bool ValidateGetRenderbufferParameterivOES(const Context *context,
GLenum pname, GLenum pname,
const GLint *params) const GLint *params)
{ {
UNIMPLEMENTED(); if (!context->getExtensions().framebufferObjectOES)
return true; {
context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
return false;
}
return ValidateGetRenderbufferParameterivBase(context, target, pname, nullptr);
} }
bool ValidateIsFramebufferOES(const Context *context, FramebufferID framebuffer) bool ValidateIsFramebufferOES(const Context *context, FramebufferID framebuffer)
{ {
UNIMPLEMENTED(); if (!context->getExtensions().framebufferObjectOES)
{
context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
return false;
}
return true; return true;
} }
bool ValidateIsRenderbufferOES(const Context *context, RenderbufferID renderbuffer) bool ValidateIsRenderbufferOES(const Context *context, RenderbufferID renderbuffer)
{ {
UNIMPLEMENTED(); if (!context->getExtensions().framebufferObjectOES)
{
context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
return false;
}
return true; return true;
} }
...@@ -1661,8 +1805,14 @@ bool ValidateRenderbufferStorageOES(const Context *context, ...@@ -1661,8 +1805,14 @@ bool ValidateRenderbufferStorageOES(const Context *context,
GLsizei width, GLsizei width,
GLsizei height) GLsizei height)
{ {
UNIMPLEMENTED(); if (!context->getExtensions().framebufferObjectOES)
return true; {
context->validationError(GL_INVALID_OPERATION, kExtensionNotEnabled);
return false;
}
return ValidateRenderbufferStorageParametersBase(context, target, 0, internalformat, width,
height);
} }
// GL_OES_texture_cube_map // GL_OES_texture_cube_map
......
...@@ -3994,38 +3994,12 @@ bool ValidateBindAttribLocation(const Context *context, ...@@ -3994,38 +3994,12 @@ bool ValidateBindAttribLocation(const Context *context,
bool ValidateBindFramebuffer(const Context *context, GLenum target, FramebufferID framebuffer) bool ValidateBindFramebuffer(const Context *context, GLenum target, FramebufferID framebuffer)
{ {
if (!ValidFramebufferTarget(context, target)) return ValidateBindFramebufferBase(context, target, framebuffer);
{
context->validationError(GL_INVALID_ENUM, kInvalidFramebufferTarget);
return false;
}
if (!context->getState().isBindGeneratesResourceEnabled() &&
!context->isFramebufferGenerated(framebuffer))
{
context->validationError(GL_INVALID_OPERATION, kObjectNotGenerated);
return false;
}
return true;
} }
bool ValidateBindRenderbuffer(const Context *context, GLenum target, RenderbufferID renderbuffer) bool ValidateBindRenderbuffer(const Context *context, GLenum target, RenderbufferID renderbuffer)
{ {
if (target != GL_RENDERBUFFER) return ValidateBindRenderbufferBase(context, target, renderbuffer);
{
context->validationError(GL_INVALID_ENUM, kInvalidRenderbufferTarget);
return false;
}
if (!context->getState().isBindGeneratesResourceEnabled() &&
!context->isRenderbufferGenerated(renderbuffer))
{
context->validationError(GL_INVALID_OPERATION, kObjectNotGenerated);
return false;
}
return true;
} }
static bool ValidBlendEquationMode(const Context *context, GLenum mode) static bool ValidBlendEquationMode(const Context *context, GLenum mode)
...@@ -5397,20 +5371,8 @@ bool ValidateFramebufferRenderbuffer(const Context *context, ...@@ -5397,20 +5371,8 @@ bool ValidateFramebufferRenderbuffer(const Context *context,
GLenum renderbuffertarget, GLenum renderbuffertarget,
RenderbufferID renderbuffer) RenderbufferID renderbuffer)
{ {
if (!ValidFramebufferTarget(context, target)) return ValidateFramebufferRenderbufferBase(context, target, attachment, renderbuffertarget,
{ renderbuffer);
context->validationError(GL_INVALID_ENUM, kInvalidFramebufferTarget);
return false;
}
if (renderbuffertarget != GL_RENDERBUFFER && renderbuffer.value != 0)
{
context->validationError(GL_INVALID_ENUM, kInvalidRenderbufferTarget);
return false;
}
return ValidateFramebufferRenderbufferParameters(context, target, attachment,
renderbuffertarget, renderbuffer);
} }
bool ValidateFramebufferTexture2D(const Context *context, bool ValidateFramebufferTexture2D(const Context *context,
...@@ -5638,95 +5600,7 @@ bool ValidateGenTextures(const Context *context, GLint n, const TextureID *textu ...@@ -5638,95 +5600,7 @@ bool ValidateGenTextures(const Context *context, GLint n, const TextureID *textu
bool ValidateGenerateMipmap(const Context *context, TextureType target) bool ValidateGenerateMipmap(const Context *context, TextureType target)
{ {
if (!ValidTextureTarget(context, target)) return ValidateGenerateMipmapBase(context, target);
{
context->validationError(GL_INVALID_ENUM, kInvalidTextureTarget);
return false;
}
Texture *texture = context->getTextureByType(target);
if (texture == nullptr)
{
context->validationError(GL_INVALID_OPERATION, kTextureNotBound);
return false;
}
const GLuint effectiveBaseLevel = texture->getTextureState().getEffectiveBaseLevel();
// This error isn't spelled out in the spec in a very explicit way, but we interpret the spec so
// that out-of-range base level has a non-color-renderable / non-texture-filterable format.
if (effectiveBaseLevel >= IMPLEMENTATION_MAX_TEXTURE_LEVELS)
{
context->validationError(GL_INVALID_OPERATION, kBaseLevelOutOfRange);
return false;
}
TextureTarget baseTarget = (target == TextureType::CubeMap)
? TextureTarget::CubeMapPositiveX
: NonCubeTextureTypeToTarget(target);
const auto &format = *(texture->getFormat(baseTarget, effectiveBaseLevel).info);
if (format.sizedInternalFormat == GL_NONE || format.compressed || format.depthBits > 0 ||
format.stencilBits > 0)
{
context->validationError(GL_INVALID_OPERATION, kGenerateMipmapNotAllowed);
return false;
}
// GenerateMipmap accepts formats that are unsized or both color renderable and filterable.
bool formatUnsized = !format.sized;
bool formatColorRenderableAndFilterable =
format.filterSupport(context->getClientVersion(), context->getExtensions()) &&
format.textureAttachmentSupport(context->getClientVersion(), context->getExtensions());
if (!formatUnsized && !formatColorRenderableAndFilterable)
{
context->validationError(GL_INVALID_OPERATION, kGenerateMipmapNotAllowed);
return false;
}
// GL_EXT_sRGB adds an unsized SRGB (no alpha) format which has explicitly disabled mipmap
// generation
if (format.colorEncoding == GL_SRGB && format.format == GL_RGB)
{
context->validationError(GL_INVALID_OPERATION, kGenerateMipmapNotAllowed);
return false;
}
// According to the OpenGL extension spec EXT_sRGB.txt, EXT_SRGB is based on ES 2.0 and
// generateMipmap is not allowed if texture format is SRGB_EXT or SRGB_ALPHA_EXT.
if (context->getClientVersion() < Version(3, 0) && format.colorEncoding == GL_SRGB)
{
context->validationError(GL_INVALID_OPERATION, kGenerateMipmapNotAllowed);
return false;
}
// Non-power of 2 ES2 check
if (context->getClientVersion() < Version(3, 0) && !context->getExtensions().textureNPOTOES &&
(!isPow2(static_cast<int>(texture->getWidth(baseTarget, 0))) ||
!isPow2(static_cast<int>(texture->getHeight(baseTarget, 0)))))
{
ASSERT(target == TextureType::_2D || target == TextureType::Rectangle ||
target == TextureType::CubeMap);
context->validationError(GL_INVALID_OPERATION, kTextureNotPow2);
return false;
}
// Cube completeness check
if (target == TextureType::CubeMap && !texture->getTextureState().isCubeComplete())
{
context->validationError(GL_INVALID_OPERATION, kCubemapIncomplete);
return false;
}
if (context->getExtensions().webglCompatibility &&
(texture->getWidth(baseTarget, effectiveBaseLevel) == 0 ||
texture->getHeight(baseTarget, effectiveBaseLevel) == 0))
{
context->validationError(GL_INVALID_OPERATION, kGenerateMipmapZeroSize);
return false;
}
return true;
} }
bool ValidateGetBufferParameteriv(const Context *context, bool ValidateGetBufferParameteriv(const Context *context,
......
...@@ -155,6 +155,7 @@ angle_end2end_tests_sources = [ ...@@ -155,6 +155,7 @@ angle_end2end_tests_sources = [
"gl_tests/gles1/CurrentTextureCoordsTest.cpp", "gl_tests/gles1/CurrentTextureCoordsTest.cpp",
"gl_tests/gles1/DrawTextureTest.cpp", "gl_tests/gles1/DrawTextureTest.cpp",
"gl_tests/gles1/FogTest.cpp", "gl_tests/gles1/FogTest.cpp",
"gl_tests/gles1/FramebufferObjectTest.cpp",
"gl_tests/gles1/LightsTest.cpp", "gl_tests/gles1/LightsTest.cpp",
"gl_tests/gles1/MaterialsTest.cpp", "gl_tests/gles1/MaterialsTest.cpp",
"gl_tests/gles1/MatrixBuiltinsTest.cpp", "gl_tests/gles1/MatrixBuiltinsTest.cpp",
......
//
// 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, &params);
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 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, &params);
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);
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment