Commit dc0cdba8 by Jamie Madill Committed by Commit Bot

Vulkan: Fix Texture attachment state changes.

This implements a notification to the Framebuffer that an attachment had a state change that might require recreating the VkFramebuffer. This implementation is much simpler than the prior method with signal notifications. Only currently implemented for TextureVk but will also be implemented for RenderbufferVk. Bug: angleproject:2347 Change-Id: I05f7da4132f6ed2bda02671e8ba5ee9805252928 Reviewed-on: https://chromium-review.googlesource.com/930024Reviewed-by: 's avatarLuc Ferron <lucferron@google.com> Reviewed-by: 's avatarYuly Novikov <ynovikov@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent 78e39b3f
......@@ -31,6 +31,8 @@ gl::Error TextureVk::onDestroy(const gl::Context *context)
ContextVk *contextVk = vk::GetImpl(context);
RendererVk *renderer = contextVk->getRenderer();
onStateChange(context, angle::SubjectMessage::DEPENDENT_DIRTY_BITS);
renderer->releaseResource(*this, &mImage);
renderer->releaseResource(*this, &mDeviceMemory);
renderer->releaseResource(*this, &mImageView);
......@@ -64,6 +66,8 @@ gl::Error TextureVk::setImage(const gl::Context *context,
if (desc.size != size ||
!gl::Format::SameSized(desc.format, gl::Format(internalFormat, type)))
{
onStateChange(context, angle::SubjectMessage::DEPENDENT_DIRTY_BITS);
renderer->releaseResource(*this, &mImage);
renderer->releaseResource(*this, &mDeviceMemory);
renderer->releaseResource(*this, &mImageView);
......
......@@ -1052,6 +1052,31 @@ TEST_P(SimpleStateChangeTest, RedefineFramebufferInUse)
ASSERT_GL_NO_ERROR();
}
// Tests that redefining a Framebuffer Texture Attachment works as expected.
TEST_P(SimpleStateChangeTest, RedefineFramebufferTexture)
{
GLFramebuffer framebuffer;
glBindFramebuffer(GL_FRAMEBUFFER, framebuffer);
// Bind a simple 8x8 texture to the framebuffer, draw red.
GLTexture texture;
glBindTexture(GL_TEXTURE_2D, texture);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 8, 8, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
glViewport(0, 0, 8, 8);
simpleDrawWithColor(GLColor::red);
ASSERT_GL_NO_ERROR();
EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::red) << "first draw should be red";
// Redefine the texture to 32x32, draw green. Verify we get what we expect.
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
glViewport(0, 0, 32, 32);
simpleDrawWithColor(GLColor::green);
ASSERT_GL_NO_ERROR();
EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::green) << "second draw should be green";
}
// Validates disabling cull face really disables it.
TEST_P(SimpleStateChangeTest, EnableAndDisableCullFace)
{
......
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