Reland "WrappedSkImage - Unify support check between GL/Vulkan"
Changes from Original CL: exo/buffer.cc creates a texture which is used by RasterImplementationGLES. Accordingly, it should create GLTextureRepresentation which is created if there is GLES2 usage which was not set by the exo client and as a result it was trying to ProduceGLTexture through WrappedSkImage. Here, we set the GLES2 usage to make sure GLTexture backing is used for creating GLTextureRepresentation. Original CL Description: WrappedSkImage earlier checked for usage support based on whether SkiaRenderer was used with GL or Vulkan. Now, we don't have a special path for GL anymore and that has been removed as part of CopySubTexture for GL removal in RasterDecoder. As a result, GL and Vulkan work the same and so we unify it here in the IsSupported check. Also, fix the RasterDecoder unit tests which earlier tested with SharedImageGLRepresentation instead of SharedImageSkiaRepresentation. ash-chrome on Linux (go/lacros-build) on gLinux cloudtop Test: Tested following instructions building lacros-chrome plus Bug: 1332891, 1334092, 1332529 Change-Id: I52d830b1a983aab648ec47c6e1fa04b31a376598 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3694395 Commit-Queue: Saifuddin Hitawala <hitawala@chromium.org> Reviewed-by: Vasiliy Telezhnikov <vasilyt@chromium.org> Reviewed-by: Kramer Ge <fangzhoug@chromium.org> Cr-Commit-Position: refs/heads/main@{#1012568}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
8c832ff51d
commit
149335fea2
@ -138,8 +138,11 @@ Buffer::Texture::Texture(
|
||||
texture_target_(GL_TEXTURE_2D),
|
||||
query_type_(GL_COMMANDS_COMPLETED_CHROMIUM) {
|
||||
gpu::SharedImageInterface* sii = context_provider_->SharedImageInterface();
|
||||
const uint32_t usage =
|
||||
gpu::SHARED_IMAGE_USAGE_RASTER | gpu::SHARED_IMAGE_USAGE_DISPLAY;
|
||||
|
||||
// Add GLES2 usage as it is used by RasterImplementationGLES.
|
||||
const uint32_t usage = gpu::SHARED_IMAGE_USAGE_RASTER |
|
||||
gpu::SHARED_IMAGE_USAGE_DISPLAY |
|
||||
gpu::SHARED_IMAGE_USAGE_GLES2;
|
||||
|
||||
mailbox_ = sii->CreateSharedImage(
|
||||
viz::ResourceFormat::RGBA_8888, size, gfx::ColorSpace::CreateSRGB(),
|
||||
@ -168,8 +171,11 @@ Buffer::Texture::Texture(
|
||||
query_type_(query_type),
|
||||
wait_for_release_delay_(wait_for_release_delay) {
|
||||
gpu::SharedImageInterface* sii = context_provider_->SharedImageInterface();
|
||||
uint32_t usage =
|
||||
gpu::SHARED_IMAGE_USAGE_RASTER | gpu::SHARED_IMAGE_USAGE_DISPLAY;
|
||||
|
||||
// Add GLES2 usage as it is used by RasterImplementationGLES.
|
||||
uint32_t usage = gpu::SHARED_IMAGE_USAGE_RASTER |
|
||||
gpu::SHARED_IMAGE_USAGE_DISPLAY |
|
||||
gpu::SHARED_IMAGE_USAGE_GLES2;
|
||||
if (is_overlay_candidate) {
|
||||
usage |= gpu::SHARED_IMAGE_USAGE_SCANOUT;
|
||||
}
|
||||
|
@ -239,6 +239,11 @@ class RasterDecoderOOPTest : public testing::Test, DecoderClient {
|
||||
client_texture_mailbox_ =
|
||||
CreateMailbox(viz::ResourceFormat::RGBA_8888, /*width=*/2,
|
||||
/*height=*/2, /*cleared=*/false);
|
||||
|
||||
// When creating the mailbox, we create a WrappedSkImage shared image which
|
||||
// sets this flag to true. Some tests expect this flag to be false when
|
||||
// testing so we reset it back here to false.
|
||||
context_state_->set_need_context_state_reset(/*reset=*/false);
|
||||
}
|
||||
void TearDown() override {
|
||||
context_state_->MakeCurrent(nullptr);
|
||||
@ -301,7 +306,8 @@ class RasterDecoderOOPTest : public testing::Test, DecoderClient {
|
||||
if (cleared) {
|
||||
SharedImageRepresentationFactory repr_factory(shared_image_manager(),
|
||||
nullptr);
|
||||
auto representation = repr_factory.ProduceGLTexture(mailbox);
|
||||
auto representation =
|
||||
repr_factory.ProduceSkia(mailbox, context_state_.get());
|
||||
representation->SetCleared();
|
||||
}
|
||||
|
||||
@ -383,8 +389,8 @@ TEST_F(RasterDecoderOOPTest, CopyTexSubImage2DSizeMismatch) {
|
||||
|
||||
SharedImageRepresentationFactory repr_factory(shared_image_manager(),
|
||||
nullptr);
|
||||
auto representation = repr_factory.ProduceGLTexture(client_texture_mailbox_);
|
||||
gles2::Texture* dest_texture = representation->GetTexture();
|
||||
auto representation =
|
||||
repr_factory.ProduceSkia(client_texture_mailbox_, context_state_.get());
|
||||
|
||||
{
|
||||
// This will initialize the bottom right corner of destination.
|
||||
@ -392,8 +398,7 @@ TEST_F(RasterDecoderOOPTest, CopyTexSubImage2DSizeMismatch) {
|
||||
cmd.Init(1, 1, 0, 0, 1, 1, false, mailboxes);
|
||||
EXPECT_EQ(error::kNoError, ExecuteImmediateCmd(cmd, sizeof(mailboxes)));
|
||||
EXPECT_EQ(GL_NO_ERROR, GetGLError());
|
||||
EXPECT_EQ(dest_texture->GetLevelClearedRect(GL_TEXTURE_2D, 0),
|
||||
gfx::Rect(1, 1, 1, 1));
|
||||
EXPECT_EQ(representation->ClearedRect(), gfx::Rect(1, 1, 1, 1));
|
||||
}
|
||||
|
||||
{
|
||||
@ -402,8 +407,7 @@ TEST_F(RasterDecoderOOPTest, CopyTexSubImage2DSizeMismatch) {
|
||||
cmd.Init(2, 2, 0, 0, 1, 1, false, mailboxes);
|
||||
EXPECT_EQ(error::kNoError, ExecuteImmediateCmd(cmd, sizeof(mailboxes)));
|
||||
EXPECT_EQ(GL_INVALID_VALUE, GetGLError());
|
||||
EXPECT_EQ(dest_texture->GetLevelClearedRect(GL_TEXTURE_2D, 0),
|
||||
gfx::Rect(1, 1, 1, 1));
|
||||
EXPECT_EQ(representation->ClearedRect(), gfx::Rect(1, 1, 1, 1));
|
||||
}
|
||||
|
||||
{
|
||||
@ -412,8 +416,7 @@ TEST_F(RasterDecoderOOPTest, CopyTexSubImage2DSizeMismatch) {
|
||||
cmd.Init(0, 0, 0, 0, 2, 2, false, mailboxes);
|
||||
EXPECT_EQ(error::kNoError, ExecuteImmediateCmd(cmd, sizeof(mailboxes)));
|
||||
EXPECT_EQ(GL_INVALID_VALUE, GetGLError());
|
||||
EXPECT_EQ(dest_texture->GetLevelClearedRect(GL_TEXTURE_2D, 0),
|
||||
gfx::Rect(1, 1, 1, 1));
|
||||
EXPECT_EQ(representation->ClearedRect(), gfx::Rect(1, 1, 1, 1));
|
||||
}
|
||||
}
|
||||
|
||||
@ -429,7 +432,8 @@ TEST_F(RasterDecoderOOPTest, CopyTexSubImage2DTwiceClearsUnclearedTexture) {
|
||||
|
||||
SharedImageRepresentationFactory repr_factory(shared_image_manager(),
|
||||
nullptr);
|
||||
auto representation = repr_factory.ProduceGLTexture(client_texture_mailbox_);
|
||||
auto representation =
|
||||
repr_factory.ProduceSkia(client_texture_mailbox_, context_state_.get());
|
||||
EXPECT_FALSE(representation->IsCleared());
|
||||
|
||||
// This will initialize the top half of destination.
|
||||
@ -465,7 +469,8 @@ TEST_F(RasterDecoderOOPTest, CopyTexSubImage2DPartialFailsWithUnalignedRect) {
|
||||
|
||||
SharedImageRepresentationFactory repr_factory(shared_image_manager(),
|
||||
nullptr);
|
||||
auto representation = repr_factory.ProduceGLTexture(client_texture_mailbox_);
|
||||
auto representation =
|
||||
repr_factory.ProduceSkia(client_texture_mailbox_, context_state_.get());
|
||||
EXPECT_FALSE(representation->IsCleared());
|
||||
|
||||
// This will initialize the top half of destination.
|
||||
|
@ -597,17 +597,7 @@ bool WrappedSkImageFactory::CanUseWrappedSkImage(
|
||||
auto kWrappedSkImageUsage = SHARED_IMAGE_USAGE_DISPLAY |
|
||||
SHARED_IMAGE_USAGE_RASTER |
|
||||
SHARED_IMAGE_USAGE_OOP_RASTERIZATION;
|
||||
|
||||
if (gr_context_type != GrContextType::kGL) {
|
||||
// For SkiaRenderer/Vulkan+Dawn use WrappedSkImage if the usage is only
|
||||
// raster and/or display.
|
||||
return (usage & kWrappedSkImageUsage) && !(usage & ~kWrappedSkImageUsage);
|
||||
} else {
|
||||
// For SkiaRenderer/GL only use WrappedSkImages for OOP-R because
|
||||
// CopySubTexture() doesn't use Skia. https://crbug.com/984045
|
||||
return (usage == kWrappedSkImageUsage) ||
|
||||
(usage == SHARED_IMAGE_USAGE_DISPLAY);
|
||||
}
|
||||
return (usage & kWrappedSkImageUsage) && !(usage & ~kWrappedSkImageUsage);
|
||||
}
|
||||
|
||||
bool WrappedSkImageFactory::IsSupported(uint32_t usage,
|
||||
@ -630,6 +620,13 @@ bool WrappedSkImageFactory::IsSupported(uint32_t usage,
|
||||
return false;
|
||||
}
|
||||
|
||||
// Currently, WrappedSkImage does not support LUMINANCE_8 format and this
|
||||
// format is used for single channel planes. See https://crbug.com/1252502 for
|
||||
// more details.
|
||||
if (format == viz::LUMINANCE_8) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!CanUseWrappedSkImage(usage, gr_context_type)) {
|
||||
return false;
|
||||
}
|
||||
|
Reference in New Issue
Block a user