Allow 24-bit depth as a valid Renderbuffer format.

Bug: angleproject:3229
Test: angle_end2end_tests --gtest_filter=DepthStencilFormatsTest.DepthBuffer/*
Change-Id: I166639ec0e000595dc55848e4b8b7bef627b6471
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1661050
Commit-Queue: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
This commit is contained in:
Mohan Maiya 2019-06-17 17:56:59 -07:00 коммит произвёл Commit Bot
Родитель a4c639c416
Коммит 141a23f64f
6 изменённых файлов: 102 добавлений и 5 удалений

Просмотреть файл

@ -148,4 +148,6 @@ AdaptVis GmbH
Sascha Kolodzey Sascha Kolodzey
Samsung Electronics, Inc. Samsung Electronics, Inc.
Brandon Schade
Minkyu Jeong Minkyu Jeong
Mohan Maiya

Просмотреть файл

@ -176,6 +176,7 @@ Extensions::Extensions()
sRGB(false), sRGB(false),
depthTextureANGLE(false), depthTextureANGLE(false),
depthTextureOES(false), depthTextureOES(false),
depth24OES(false),
depth32(false), depth32(false),
textureStorage(false), textureStorage(false),
textureNPOT(false), textureNPOT(false),
@ -678,6 +679,16 @@ static bool DetermineDepthTextureOESSupport(const TextureCapsMap &textureCaps)
return GetFormatSupport(textureCaps, requiredFormats, true, true, true, true); return GetFormatSupport(textureCaps, requiredFormats, true, true, true, true);
} }
// Check for GL_OES_depth24
static bool DetermineDepth24OESSupport(const TextureCapsMap &textureCaps)
{
constexpr GLenum requiredFormats[] = {
GL_DEPTH_COMPONENT24_OES,
};
return GetFormatSupport(textureCaps, requiredFormats, false, false, false, true);
}
// Check for GL_OES_depth32 // Check for GL_OES_depth32
static bool DetermineDepth32Support(const TextureCapsMap &textureCaps) static bool DetermineDepth32Support(const TextureCapsMap &textureCaps)
{ {
@ -799,6 +810,7 @@ void Extensions::setTextureExtensionSupport(const TextureCapsMap &textureCaps)
sRGB = DetermineSRGBTextureSupport(textureCaps); sRGB = DetermineSRGBTextureSupport(textureCaps);
depthTextureANGLE = DetermineDepthTextureANGLESupport(textureCaps); depthTextureANGLE = DetermineDepthTextureANGLESupport(textureCaps);
depthTextureOES = DetermineDepthTextureOESSupport(textureCaps); depthTextureOES = DetermineDepthTextureOESSupport(textureCaps);
depth24OES = DetermineDepth24OESSupport(textureCaps);
depth32 = DetermineDepth32Support(textureCaps); depth32 = DetermineDepth32Support(textureCaps);
colorBufferFloatRGB = DetermineColorBufferFloatRGBSupport(textureCaps); colorBufferFloatRGB = DetermineColorBufferFloatRGBSupport(textureCaps);
colorBufferFloatRGBA = DetermineColorBufferFloatRGBASupport(textureCaps); colorBufferFloatRGBA = DetermineColorBufferFloatRGBASupport(textureCaps);
@ -862,6 +874,7 @@ const ExtensionInfoMap &GetExtensionInfoMap()
map["GL_EXT_sRGB"] = enableableExtension(&Extensions::sRGB); map["GL_EXT_sRGB"] = enableableExtension(&Extensions::sRGB);
map["GL_ANGLE_depth_texture"] = esOnlyExtension(&Extensions::depthTextureANGLE); map["GL_ANGLE_depth_texture"] = esOnlyExtension(&Extensions::depthTextureANGLE);
map["GL_OES_depth_texture"] = esOnlyExtension(&Extensions::depthTextureOES); map["GL_OES_depth_texture"] = esOnlyExtension(&Extensions::depthTextureOES);
map["GL_OES_depth24"] = esOnlyExtension(&Extensions::depth24OES);
map["GL_OES_depth32"] = esOnlyExtension(&Extensions::depth32); map["GL_OES_depth32"] = esOnlyExtension(&Extensions::depth32);
map["GL_EXT_texture_storage"] = enableableExtension(&Extensions::textureStorage); map["GL_EXT_texture_storage"] = enableableExtension(&Extensions::textureStorage);
map["GL_OES_texture_npot"] = enableableExtension(&Extensions::textureNPOT); map["GL_OES_texture_npot"] = enableableExtension(&Extensions::textureNPOT);

Просмотреть файл

@ -244,6 +244,10 @@ struct Extensions
// OES_depth_texture // OES_depth_texture
bool depthTextureOES; bool depthTextureOES;
// GL_OES_depth24
// Allows DEPTH_COMPONENT24_OES as a valid Renderbuffer format.
bool depth24OES;
// GL_OES_depth32 // GL_OES_depth32
// Allows DEPTH_COMPONENT32_OES as a valid Renderbuffer format. // Allows DEPTH_COMPONENT32_OES as a valid Renderbuffer format.
bool depth32; bool depth32;

Просмотреть файл

@ -795,7 +795,7 @@ static InternalFormatInfoMap BuildInternalFormatInfoMap()
// ANGLE Depth stencil formats // ANGLE Depth stencil formats
// | Internal format |sized| D |S | X | Format | Type | Component type | Texture supported | Filterable | Texture attachment | Renderbuffer | // | Internal format |sized| D |S | X | Format | Type | Component type | Texture supported | Filterable | Texture attachment | Renderbuffer |
AddDepthStencilFormat(&map, GL_DEPTH_COMPONENT16, true, 16, 0, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT, GL_UNSIGNED_NORMALIZED, RequireES<1, 0>, RequireESOrExtOrExt<3, 0, &Extensions::depthTextureANGLE, &Extensions::depthTextureOES>, RequireES<1, 0>, RequireES<1, 0> ); AddDepthStencilFormat(&map, GL_DEPTH_COMPONENT16, true, 16, 0, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT, GL_UNSIGNED_NORMALIZED, RequireES<1, 0>, RequireESOrExtOrExt<3, 0, &Extensions::depthTextureANGLE, &Extensions::depthTextureOES>, RequireES<1, 0>, RequireES<1, 0> );
AddDepthStencilFormat(&map, GL_DEPTH_COMPONENT24, true, 24, 0, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, GL_UNSIGNED_NORMALIZED, RequireES<3, 0>, RequireESOrExt<3, 0, &Extensions::depthTextureANGLE>, RequireES<3, 0>, RequireES<3, 0> ); AddDepthStencilFormat(&map, GL_DEPTH_COMPONENT24, true, 24, 0, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, GL_UNSIGNED_NORMALIZED, RequireES<3, 0>, RequireESOrExt<3, 0, &Extensions::depthTextureANGLE>, RequireES<3, 0>, RequireESOrExt<3, 0, &Extensions::depth24OES> );
AddDepthStencilFormat(&map, GL_DEPTH_COMPONENT32F, true, 32, 0, 0, GL_DEPTH_COMPONENT, GL_FLOAT, GL_FLOAT, RequireES<3, 0>, RequireESOrExt<3, 0, &Extensions::depthTextureANGLE>, RequireES<3, 0>, RequireES<3, 0> ); AddDepthStencilFormat(&map, GL_DEPTH_COMPONENT32F, true, 32, 0, 0, GL_DEPTH_COMPONENT, GL_FLOAT, GL_FLOAT, RequireES<3, 0>, RequireESOrExt<3, 0, &Extensions::depthTextureANGLE>, RequireES<3, 0>, RequireES<3, 0> );
AddDepthStencilFormat(&map, GL_DEPTH_COMPONENT32_OES, true, 32, 0, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, GL_UNSIGNED_NORMALIZED, RequireExtOrExtOrExt<&Extensions::depthTextureANGLE, &Extensions::depthTextureOES, &Extensions::depth32>, AlwaysSupported, RequireExtOrExtOrExt<&Extensions::depthTextureANGLE, &Extensions::depthTextureOES, &Extensions::depth32>, RequireExtOrExtOrExt<&Extensions::depthTextureANGLE, &Extensions::depthTextureOES, &Extensions::depth32>); AddDepthStencilFormat(&map, GL_DEPTH_COMPONENT32_OES, true, 32, 0, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, GL_UNSIGNED_NORMALIZED, RequireExtOrExtOrExt<&Extensions::depthTextureANGLE, &Extensions::depthTextureOES, &Extensions::depth32>, AlwaysSupported, RequireExtOrExtOrExt<&Extensions::depthTextureANGLE, &Extensions::depthTextureOES, &Extensions::depth32>, RequireExtOrExtOrExt<&Extensions::depthTextureANGLE, &Extensions::depthTextureOES, &Extensions::depth32>);
AddDepthStencilFormat(&map, GL_DEPTH24_STENCIL8, true, 24, 8, 0, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, GL_UNSIGNED_NORMALIZED, RequireESOrExt<3, 0, &Extensions::depthTextureANGLE>, AlwaysSupported, RequireESOrExtOrExt<3, 0, &Extensions::depthTextureANGLE, &Extensions::packedDepthStencil>, RequireESOrExtOrExt<3, 0, &Extensions::depthTextureANGLE, &Extensions::packedDepthStencil>); AddDepthStencilFormat(&map, GL_DEPTH24_STENCIL8, true, 24, 8, 0, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, GL_UNSIGNED_NORMALIZED, RequireESOrExt<3, 0, &Extensions::depthTextureANGLE>, AlwaysSupported, RequireESOrExtOrExt<3, 0, &Extensions::depthTextureANGLE, &Extensions::packedDepthStencil>, RequireESOrExtOrExt<3, 0, &Extensions::depthTextureANGLE, &Extensions::packedDepthStencil>);

Просмотреть файл

@ -64,6 +64,62 @@ class DepthStencilFormatsTestBase : public ANGLETest
return (glGetError() == GL_NO_ERROR); return (glGetError() == GL_NO_ERROR);
} }
void verifyDepthRenderBuffer(GLenum internalFormat)
{
GLTexture tex;
glBindTexture(GL_TEXTURE_2D, tex);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
ASSERT_GL_NO_ERROR();
GLRenderbuffer rbDepth;
glBindRenderbuffer(GL_RENDERBUFFER, rbDepth);
glRenderbufferStorage(GL_RENDERBUFFER, internalFormat, 1, 1);
ASSERT_GL_NO_ERROR();
GLFramebuffer fbo;
glBindFramebuffer(GL_FRAMEBUFFER, fbo);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tex, 0);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, rbDepth);
EXPECT_GL_FRAMEBUFFER_COMPLETE(GL_FRAMEBUFFER);
ASSERT_GL_NO_ERROR();
ANGLE_GL_PROGRAM(programRed, essl1_shaders::vs::Simple(), essl1_shaders::fs::Red());
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_GEQUAL);
glClearDepthf(0.99f);
glClearColor(0, 0, 0, 1);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// Pass Depth Test and draw red
float depthValue = 1.0f;
drawQuad(programRed.get(), essl1_shaders::PositionAttrib(), depthValue * 2 - 1);
EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::red);
ASSERT_GL_NO_ERROR();
ANGLE_GL_PROGRAM(programGreen, essl1_shaders::vs::Simple(), essl1_shaders::fs::Green());
// Fail Depth Test and color buffer is unchanged
depthValue = 0.98f;
drawQuad(programGreen.get(), essl1_shaders::PositionAttrib(), depthValue * 2 - 1);
EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::red);
ASSERT_GL_NO_ERROR();
ANGLE_GL_PROGRAM(programBlue, essl1_shaders::vs::Simple(), essl1_shaders::fs::Blue());
glClearDepthf(0.0f);
glClear(GL_DEPTH_BUFFER_BIT);
// Pass Depth Test and draw blue
depthValue = 0.01f;
drawQuad(programBlue.get(), essl1_shaders::PositionAttrib(), depthValue * 2 - 1);
EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::blue);
glDisable(GL_DEPTH_TEST);
ASSERT_GL_NO_ERROR();
}
void testSetUp() override void testSetUp() override
{ {
constexpr char kVS[] = R"(precision highp float; constexpr char kVS[] = R"(precision highp float;
@ -470,6 +526,27 @@ void main()
} }
} }
// This test will initialize a frame buffer, attaching a color and 16-bit depth buffer,
// render to it with depth testing, and verify pixel correctness.
TEST_P(DepthStencilFormatsTest, DepthBuffer16)
{
verifyDepthRenderBuffer(GL_DEPTH_COMPONENT16);
}
// This test will initialize a frame buffer, attaching a color and 24-bit depth buffer,
// render to it with depth testing, and verify pixel correctness.
TEST_P(DepthStencilFormatsTest, DepthBuffer24)
{
bool shouldHaveRenderbufferSupport = IsGLExtensionEnabled("GL_OES_depth24");
EXPECT_EQ(shouldHaveRenderbufferSupport,
checkRenderbufferFormatSupport(GL_DEPTH_COMPONENT24_OES));
if (shouldHaveRenderbufferSupport)
{
verifyDepthRenderBuffer(GL_DEPTH_COMPONENT24_OES);
}
}
TEST_P(DepthStencilFormatsTestES3, DrawWithDepthStencil) TEST_P(DepthStencilFormatsTestES3, DrawWithDepthStencil)
{ {
GLushort data[16]; GLushort data[16];

Просмотреть файл

@ -52,8 +52,8 @@ class DepthStencilTest : public ANGLETest
ASSERT_GL_NO_ERROR(); ASSERT_GL_NO_ERROR();
// Note: GL_DEPTH_COMPONENT24 is not allowed in GLES2. // Note: GL_DEPTH_COMPONENT24 is allowed in GLES2 with GL_OES_depth24 extension.
if (getClientMajorVersion() >= 3) if (getClientMajorVersion() >= 3 || IsGLExtensionEnabled("GL_OES_depth24"))
{ {
// Setup Color/Depth FBO with a depth format that's emulated with packed depth/stencil. // Setup Color/Depth FBO with a depth format that's emulated with packed depth/stencil.
glBindFramebuffer(GL_FRAMEBUFFER, mColorDepthFBO); glBindFramebuffer(GL_FRAMEBUFFER, mColorDepthFBO);
@ -234,7 +234,7 @@ void DepthStencilTest::prepareSingleEmulatedWithPacked()
// Tests that clearing or rendering into a depth-only format doesn't affect stencil. // Tests that clearing or rendering into a depth-only format doesn't affect stencil.
TEST_P(DepthStencilTest, DepthOnlyEmulatedWithPacked) TEST_P(DepthStencilTest, DepthOnlyEmulatedWithPacked)
{ {
ANGLE_SKIP_TEST_IF(getClientMajorVersion() < 3); ANGLE_SKIP_TEST_IF(getClientMajorVersion() < 3 && !IsGLExtensionEnabled("GL_OES_depth24"));
bindColorDepthFBO(); bindColorDepthFBO();
prepareSingleEmulatedWithPacked(); prepareSingleEmulatedWithPacked();
@ -256,6 +256,7 @@ ANGLE_INSTANTIATE_TEST(DepthStencilTest,
ES3_OPENGL(), ES3_OPENGL(),
ES2_OPENGLES(), ES2_OPENGLES(),
ES3_OPENGLES(), ES3_OPENGLES(),
ES2_VULKAN()); ES2_VULKAN(),
ES3_VULKAN());
} // anonymous namespace } // anonymous namespace