Commit 321a5026 authored by Sunny Sachanandani's avatar Sunny Sachanandani Committed by Commit Bot

gpu: Mark swap chain and DXGI handle shared image backings as cleared

Swap chain and DXGI handle shared image backings are not marked as
cleared which causes SkiaOutputDeviceGL to fail importing using shared
image representations and fallback to importing from MailboxManager even
though the mailboxes are associated with the shared image backings.

Bug: 1136194
Change-Id: I5951574875420cafe2dc48b9bed6164a7b360d9e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2469897Reviewed-by: default avatarkylechar <kylechar@chromium.org>
Commit-Queue: Sunny Sachanandani <sunnyps@chromium.org>
Cr-Commit-Position: refs/heads/master@{#817079}
parent 1a8ded3e
......@@ -269,6 +269,7 @@ SharedImageBackingFactoryD3D::CreateSwapChain(
nullptr /* d3d11_texture */, base::win::ScopedHandle());
if (!back_buffer_backing)
return {nullptr, nullptr};
back_buffer_backing->SetCleared();
auto front_buffer_backing = MakeBacking(
front_buffer_mailbox, format, size, color_space, surface_origin,
......@@ -276,6 +277,7 @@ SharedImageBackingFactoryD3D::CreateSwapChain(
nullptr /* d3d11_texture */, base::win::ScopedHandle());
if (!front_buffer_backing)
return {nullptr, nullptr};
front_buffer_backing->SetCleared();
return {std::move(front_buffer_backing), std::move(back_buffer_backing)};
}
......@@ -420,10 +422,14 @@ SharedImageBackingFactoryD3D::CreateSharedImage(
return nullptr;
}
return MakeBacking(mailbox, viz::GetResourceFormat(format), size, color_space,
surface_origin, alpha_type, usage, /*swap_chain=*/nullptr,
/*buffer_index=*/0, std::move(d3d11_texture),
std::move(handle.dxgi_handle));
auto backing =
MakeBacking(mailbox, viz::GetResourceFormat(format), size, color_space,
surface_origin, alpha_type, usage, /*swap_chain=*/nullptr,
/*buffer_index=*/0, std::move(d3d11_texture),
std::move(handle.dxgi_handle));
if (backing)
backing->SetCleared();
return backing;
}
// Returns true if the specified GpuMemoryBufferType can be imported using
......
......@@ -102,8 +102,9 @@ class GPU_GLES2_EXPORT SharedImageBackingFactoryD3D
private:
// Wraps the optional swap chain buffer (front buffer/back buffer) and texture
// into GLimage and creates a GL texture and stores it as gles2::Texture or as
// gles2::TexturePassthrough in the backing that is created.
// into GLimage and gles2::TexturePassthrough in the backing that is created.
// The backing isn't assumed to be cleared so it's the caller's responsibility
// to mark the backing as cleared using SetCleared()/SetClearedRect().
std::unique_ptr<SharedImageBacking> MakeBacking(
const Mailbox& mailbox,
viz::ResourceFormat format,
......
......@@ -178,8 +178,11 @@ TEST_F(SharedImageBackingFactoryD3DTestSwapChain, CreateAndPresentSwapChain) {
auto backings = shared_image_factory_->CreateSwapChain(
front_buffer_mailbox, back_buffer_mailbox, format, size, color_space,
surface_origin, alpha_type, usage);
EXPECT_TRUE(backings.front_buffer);
EXPECT_TRUE(backings.back_buffer);
ASSERT_TRUE(backings.front_buffer);
EXPECT_TRUE(backings.front_buffer->IsCleared());
ASSERT_TRUE(backings.back_buffer);
EXPECT_TRUE(backings.back_buffer->IsCleared());
std::unique_ptr<SharedImageRepresentationFactoryRef> back_factory_ref =
shared_image_manager_.Register(std::move(backings.back_buffer),
......@@ -188,19 +191,16 @@ TEST_F(SharedImageBackingFactoryD3DTestSwapChain, CreateAndPresentSwapChain) {
shared_image_manager_.Register(std::move(backings.front_buffer),
memory_type_tracker_.get());
GLuint back_texture_id, front_texture_id = 0u;
gl::GLImageD3D *back_image, *front_image = 0u;
auto back_texture = shared_image_representation_factory_
->ProduceGLTexturePassthrough(back_buffer_mailbox)
->GetTexturePassthrough();
ASSERT_TRUE(back_texture);
EXPECT_EQ(back_texture->target(), static_cast<unsigned>(GL_TEXTURE_2D));
back_texture_id = back_texture->service_id();
GLuint back_texture_id = back_texture->service_id();
EXPECT_NE(back_texture_id, 0u);
back_image = gl::GLImageD3D::FromGLImage(
auto* back_image = gl::GLImageD3D::FromGLImage(
back_texture->GetLevelImage(GL_TEXTURE_2D, 0));
auto front_texture = shared_image_representation_factory_
......@@ -209,10 +209,10 @@ TEST_F(SharedImageBackingFactoryD3DTestSwapChain, CreateAndPresentSwapChain) {
ASSERT_TRUE(front_texture);
EXPECT_EQ(front_texture->target(), static_cast<unsigned>(GL_TEXTURE_2D));
front_texture_id = front_texture->service_id();
GLuint front_texture_id = front_texture->service_id();
EXPECT_NE(front_texture_id, 0u);
front_image = gl::GLImageD3D::FromGLImage(
auto* front_image = gl::GLImageD3D::FromGLImage(
front_texture->GetLevelImage(GL_TEXTURE_2D, 0));
ASSERT_TRUE(back_image);
......@@ -906,6 +906,7 @@ TEST_F(SharedImageBackingFactoryD3DTest, CreateSharedImageFromHandle) {
EXPECT_EQ(backing->surface_origin(), surface_origin);
EXPECT_EQ(backing->alpha_type(), alpha_type);
EXPECT_EQ(backing->mailbox(), mailbox);
EXPECT_TRUE(backing->IsCleared());
SharedImageBackingD3D* backing_d3d =
static_cast<SharedImageBackingD3D*>(backing.get());
......
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