Commit daab0014 by Olli Etuaho Committed by Commit Bot

Test and fix robust resource init for multisampled textures

New test coverage for robust initialization of multisampled textures is added in angle_end2end_tests. Some missing functionality that was affecting the initialization of multisampled 2D array textures is now fixed. BUG=angleproject:2775 TEST=angle_end2end_tests Change-Id: I1d9d3cd154ca2910159941fe8b1bef4ae6320bdd Reviewed-on: https://chromium-review.googlesource.com/1224530Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
parent 44286dc8
...@@ -379,6 +379,11 @@ Error FramebufferAttachmentObject::initializeContents(const Context *context, ...@@ -379,6 +379,11 @@ Error FramebufferAttachmentObject::initializeContents(const Context *context,
ImageIndex::Make2DArray(imageIndex.getLevelIndex(), ImageIndex::kEntireLevel); ImageIndex::Make2DArray(imageIndex.getLevelIndex(), ImageIndex::kEntireLevel);
return getAttachmentImpl()->initializeContents(context, fullMipIndex); return getAttachmentImpl()->initializeContents(context, fullMipIndex);
} }
else if (imageIndex.getType() == TextureType::_2DMultisampleArray && imageIndex.hasLayer())
{
ImageIndex fullMipIndex = ImageIndex::Make2DMultisampleArray(ImageIndex::kEntireLevel);
return getAttachmentImpl()->initializeContents(context, fullMipIndex);
}
else else
{ {
return getAttachmentImpl()->initializeContents(context, imageIndex); return getAttachmentImpl()->initializeContents(context, imageIndex);
......
...@@ -256,14 +256,14 @@ ImageIndexIterator ImageIndexIterator::Make2DArray(GLint minMip, GLint maxMip, ...@@ -256,14 +256,14 @@ ImageIndexIterator ImageIndexIterator::Make2DArray(GLint minMip, GLint maxMip,
ImageIndexIterator ImageIndexIterator::Make2DMultisample() ImageIndexIterator ImageIndexIterator::Make2DMultisample()
{ {
return ImageIndexIterator(TextureType::_2DMultisample, Range<GLint>(0, 0), return ImageIndexIterator(TextureType::_2DMultisample, Range<GLint>(0, 1),
Range<GLint>(ImageIndex::kEntireLevel, ImageIndex::kEntireLevel), Range<GLint>(ImageIndex::kEntireLevel, ImageIndex::kEntireLevel),
nullptr); nullptr);
} }
ImageIndexIterator ImageIndexIterator::Make2DMultisampleArray(const GLsizei *layerCounts) ImageIndexIterator ImageIndexIterator::Make2DMultisampleArray(const GLsizei *layerCounts)
{ {
return ImageIndexIterator(TextureType::_2DMultisampleArray, Range<GLint>(0, 0), return ImageIndexIterator(TextureType::_2DMultisampleArray, Range<GLint>(0, 1),
Range<GLint>(0, IMPLEMENTATION_MAX_2D_ARRAY_TEXTURE_LAYERS), Range<GLint>(0, IMPLEMENTATION_MAX_2D_ARRAY_TEXTURE_LAYERS),
layerCounts); layerCounts);
} }
......
...@@ -574,8 +574,12 @@ angle::Result TextureD3D::ensureRenderTarget(const gl::Context *context) ...@@ -574,8 +574,12 @@ angle::Result TextureD3D::ensureRenderTarget(const gl::Context *context)
bool TextureD3D::canCreateRenderTargetForImage(const gl::ImageIndex &index) const bool TextureD3D::canCreateRenderTargetForImage(const gl::ImageIndex &index) const
{ {
if (index.getType() == gl::TextureType::_2DMultisample) if (index.getType() == gl::TextureType::_2DMultisample ||
index.getType() == gl::TextureType::_2DMultisampleArray)
{
ASSERT(index.getType() != gl::TextureType::_2DMultisampleArray || index.hasLayer());
return true; return true;
}
ImageD3D *image = getImage(index); ImageD3D *image = getImage(index);
ASSERT(image); ASSERT(image);
...@@ -686,6 +690,21 @@ gl::Error TextureD3D::initializeContents(const gl::Context *context, ...@@ -686,6 +690,21 @@ gl::Error TextureD3D::initializeContents(const gl::Context *context,
} }
return gl::NoError(); return gl::NoError();
} }
else if (imageIndexIn.getType() == gl::TextureType::_2DMultisampleArray &&
!imageIndexIn.hasLayer())
{
std::array<GLint, gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS> tempLayerCounts;
ASSERT(imageIndexIn.getLevelIndex() == 0);
tempLayerCounts[0] = getLayerCount(0);
gl::ImageIndexIterator iterator =
gl::ImageIndexIterator::Make2DMultisampleArray(tempLayerCounts.data());
while (iterator.hasNext())
{
ANGLE_TRY(initializeContents(context, iterator.next()));
}
return gl::NoError();
}
// Force image clean. // Force image clean.
ImageD3D *image = getImage(imageIndex); ImageD3D *image = getImage(imageIndex);
......
...@@ -1727,6 +1727,88 @@ TEST_P(RobustResourceInitTest, SurfaceInitializedAfterSwap) ...@@ -1727,6 +1727,88 @@ TEST_P(RobustResourceInitTest, SurfaceInitializedAfterSwap)
} }
} }
// Test that multisampled 2D textures are initialized.
TEST_P(RobustResourceInitTestES31, Multisample2DTexture)
{
ANGLE_SKIP_TEST_IF(!hasGLExtension());
const GLsizei kWidth = 128;
const GLsizei kHeight = 128;
GLTexture texture;
glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, texture);
glTexStorage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, 2, GL_RGBA8, kWidth, kHeight, false);
GLFramebuffer framebuffer;
glBindFramebuffer(GL_READ_FRAMEBUFFER, framebuffer);
glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D_MULTISAMPLE,
texture, 0);
GLTexture resolveTexture;
glBindTexture(GL_TEXTURE_2D, resolveTexture);
glTexStorage2D(GL_TEXTURE_2D, 1, GL_RGBA8, kWidth, kHeight);
GLFramebuffer resolveFramebuffer;
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, resolveFramebuffer);
glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, resolveTexture,
0);
ASSERT_GL_NO_ERROR();
glBlitFramebuffer(0, 0, kWidth, kHeight, 0, 0, kWidth, kHeight, GL_COLOR_BUFFER_BIT,
GL_NEAREST);
ASSERT_GL_NO_ERROR();
glBindFramebuffer(GL_READ_FRAMEBUFFER, resolveFramebuffer);
EXPECT_PIXEL_RECT_EQ(0, 0, kWidth, kHeight, GLColor::transparentBlack);
}
// Test that multisampled 2D texture arrays from OES_texture_storage_multisample_2d_array are
// initialized.
TEST_P(RobustResourceInitTestES31, Multisample2DTextureArray)
{
ANGLE_SKIP_TEST_IF(!hasGLExtension());
if (extensionRequestable("GL_OES_texture_storage_multisample_2d_array"))
{
glRequestExtensionANGLE("GL_OES_texture_storage_multisample_2d_array");
}
ANGLE_SKIP_TEST_IF(!extensionEnabled("GL_OES_texture_storage_multisample_2d_array"));
const GLsizei kWidth = 128;
const GLsizei kHeight = 128;
const GLsizei kLayers = 4;
GLTexture texture;
glBindTexture(GL_TEXTURE_2D_MULTISAMPLE_ARRAY_OES, texture);
glTexStorage3DMultisampleOES(GL_TEXTURE_2D_MULTISAMPLE_ARRAY_OES, 2, GL_RGBA8, kWidth, kHeight,
kLayers, false);
GLTexture resolveTexture;
glBindTexture(GL_TEXTURE_2D, resolveTexture);
glTexStorage2D(GL_TEXTURE_2D, 1, GL_RGBA8, kWidth, kHeight);
GLFramebuffer resolveFramebuffer;
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, resolveFramebuffer);
glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, resolveTexture,
0);
ASSERT_GL_NO_ERROR();
for (GLsizei layerIndex = 0; layerIndex < kLayers; ++layerIndex)
{
GLFramebuffer framebuffer;
glBindFramebuffer(GL_READ_FRAMEBUFFER, framebuffer);
glFramebufferTextureLayer(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, texture, 0,
layerIndex);
glBlitFramebuffer(0, 0, kWidth, kHeight, 0, 0, kWidth, kHeight, GL_COLOR_BUFFER_BIT,
GL_NEAREST);
ASSERT_GL_NO_ERROR();
glBindFramebuffer(GL_READ_FRAMEBUFFER, resolveFramebuffer);
EXPECT_PIXEL_RECT_EQ(0, 0, kWidth, kHeight, GLColor::transparentBlack);
}
}
ANGLE_INSTANTIATE_TEST(RobustResourceInitTest, ANGLE_INSTANTIATE_TEST(RobustResourceInitTest,
ES2_D3D9(), ES2_D3D9(),
ES2_D3D11(), ES2_D3D11(),
......
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