Commit 882f8cf0 authored by Jonathan Backer's avatar Jonathan Backer Committed by Commit Bot

enable_wrapped_sk_image for VK viz_unittests

Currently there are only a couple of ways to create a SharedImage from
pixel data:

(a) using and SharedImageBackingFactoryGLTexture or
(b) using WrappedSkImageFactory

We prefer WrappedSkImageFactory when using SkiaRenderer for potential
performance benefit. This CL changes the logic inside
InProcessCommandBuffer to enable_wrapped_sk_image if (a) is not
possible. This supports running viz_unittests with --enable-vulkan.

Bug: 966016
Change-Id: I84a77802653b689da92f8697cf2394b429e59d54
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1627938
Commit-Queue: Jonathan Backer <backer@chromium.org>
Auto-Submit: Jonathan Backer <backer@chromium.org>
Reviewed-by: default avatarSaman Sami <samans@chromium.org>
Cr-Commit-Position: refs/heads/master@{#663146}
parent 3b14d3be
...@@ -273,7 +273,6 @@ class DirectContextProviderDelegateImpl : public DirectContextProviderDelegate, ...@@ -273,7 +273,6 @@ class DirectContextProviderDelegateImpl : public DirectContextProviderDelegate,
gpu::SharedContextState* context_state, gpu::SharedContextState* context_state,
gpu::MailboxManager* mailbox_manager, gpu::MailboxManager* mailbox_manager,
gpu::SharedImageManager* shared_image_manager, gpu::SharedImageManager* shared_image_manager,
bool use_gl,
scoped_refptr<gpu::SyncPointClientState> sync_point_client_state) scoped_refptr<gpu::SyncPointClientState> sync_point_client_state)
: shared_image_manager_(shared_image_manager), : shared_image_manager_(shared_image_manager),
shared_image_factory_(gpu_preferences, shared_image_factory_(gpu_preferences,
...@@ -284,8 +283,7 @@ class DirectContextProviderDelegateImpl : public DirectContextProviderDelegate, ...@@ -284,8 +283,7 @@ class DirectContextProviderDelegateImpl : public DirectContextProviderDelegate,
shared_image_manager, shared_image_manager,
nullptr /* image_factory */, nullptr /* image_factory */,
nullptr /* memory_tracker */, nullptr /* memory_tracker */,
true /* is_using_skia_renderer */, true /* is_using_skia_renderer */),
use_gl),
sync_point_client_state_(sync_point_client_state) {} sync_point_client_state_(sync_point_client_state) {}
~DirectContextProviderDelegateImpl() override { ~DirectContextProviderDelegateImpl() override {
...@@ -746,7 +744,7 @@ void SkiaOutputSurfaceImplOnGpu::CopyOutput( ...@@ -746,7 +744,7 @@ void SkiaOutputSurfaceImplOnGpu::CopyOutput(
gpu_preferences_, channel_manager->gpu_driver_bug_workarounds(), gpu_preferences_, channel_manager->gpu_driver_bug_workarounds(),
channel_manager->gpu_feature_info(), context_state_.get(), channel_manager->gpu_feature_info(), context_state_.get(),
mailbox_manager_, gpu_service_->shared_image_manager(), mailbox_manager_, gpu_service_->shared_image_manager(),
!is_using_vulkan(), CreateSyncPointClientState(gpu_service_)); CreateSyncPointClientState(gpu_service_));
context_provider_ = base::MakeRefCounted<DirectContextProvider>( context_provider_ = base::MakeRefCounted<DirectContextProvider>(
context_state_->context(), gl_surface_, supports_alpha_, context_state_->context(), gl_surface_, supports_alpha_,
gpu_preferences_, feature_info_.get(), std::move(client)); gpu_preferences_, feature_info_.get(), std::move(client));
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include "gpu/command_buffer/service/shared_image_representation.h" #include "gpu/command_buffer/service/shared_image_representation.h"
#include "gpu/command_buffer/service/wrapped_sk_image.h" #include "gpu/command_buffer/service/wrapped_sk_image.h"
#include "gpu/config/gpu_preferences.h" #include "gpu/config/gpu_preferences.h"
#include "ui/gl/gl_implementation.h"
#include "ui/gl/trace_util.h" #include "ui/gl/trace_util.h"
#if (defined(USE_X11) || defined(OS_FUCHSIA)) && BUILDFLAG(ENABLE_VULKAN) #if (defined(USE_X11) || defined(OS_FUCHSIA)) && BUILDFLAG(ENABLE_VULKAN)
...@@ -67,13 +68,13 @@ SharedImageFactory::SharedImageFactory( ...@@ -67,13 +68,13 @@ SharedImageFactory::SharedImageFactory(
SharedImageManager* shared_image_manager, SharedImageManager* shared_image_manager,
ImageFactory* image_factory, ImageFactory* image_factory,
MemoryTracker* memory_tracker, MemoryTracker* memory_tracker,
bool is_using_skia_renderer, bool enable_wrapped_sk_image)
bool use_gl)
: mailbox_manager_(mailbox_manager), : mailbox_manager_(mailbox_manager),
shared_image_manager_(shared_image_manager), shared_image_manager_(shared_image_manager),
memory_tracker_(std::make_unique<MemoryTypeTracker>(memory_tracker)), memory_tracker_(std::make_unique<MemoryTypeTracker>(memory_tracker)),
using_vulkan_(context_state && context_state->GrContextIsVulkan()), using_vulkan_(context_state && context_state->GrContextIsVulkan()),
using_metal_(context_state && context_state->GrContextIsMetal()) { using_metal_(context_state && context_state->GrContextIsMetal()) {
bool use_gl = gl::GetGLImplementation() != gl::kGLImplementationNone;
if (use_gl) { if (use_gl) {
gl_backing_factory_ = std::make_unique<SharedImageBackingFactoryGLTexture>( gl_backing_factory_ = std::make_unique<SharedImageBackingFactoryGLTexture>(
gpu_preferences, workarounds, gpu_feature_info, image_factory); gpu_preferences, workarounds, gpu_feature_info, image_factory);
...@@ -98,10 +99,7 @@ SharedImageFactory::SharedImageFactory( ...@@ -98,10 +99,7 @@ SharedImageFactory::SharedImageFactory(
// Others // Others
DCHECK(!using_vulkan_); DCHECK(!using_vulkan_);
#endif #endif
// Certain test suites may enable UseSkiaRenderer feature flag, but never if (enable_wrapped_sk_image && context_state) {
// create a SkiaRenderer. In this case context_state is nullptr and we should
// not create a WrappedSkImageFactory.
if (is_using_skia_renderer && context_state) {
wrapped_sk_image_factory_ = wrapped_sk_image_factory_ =
std::make_unique<raster::WrappedSkImageFactory>(context_state); std::make_unique<raster::WrappedSkImageFactory>(context_state);
} }
......
...@@ -51,8 +51,7 @@ class GPU_GLES2_EXPORT SharedImageFactory { ...@@ -51,8 +51,7 @@ class GPU_GLES2_EXPORT SharedImageFactory {
SharedImageManager* manager, SharedImageManager* manager,
ImageFactory* image_factory, ImageFactory* image_factory,
MemoryTracker* tracker, MemoryTracker* tracker,
bool is_using_skia_renderer, bool enable_wrapped_sk_image);
bool use_gl_);
~SharedImageFactory(); ~SharedImageFactory();
bool CreateSharedImage(const Mailbox& mailbox, bool CreateSharedImage(const Mailbox& mailbox,
......
...@@ -41,7 +41,7 @@ class SharedImageFactoryTest : public testing::Test { ...@@ -41,7 +41,7 @@ class SharedImageFactoryTest : public testing::Test {
factory_ = std::make_unique<SharedImageFactory>( factory_ = std::make_unique<SharedImageFactory>(
preferences, workarounds, GpuFeatureInfo(), nullptr, &mailbox_manager_, preferences, workarounds, GpuFeatureInfo(), nullptr, &mailbox_manager_,
&shared_image_manager_, &image_factory_, nullptr, &shared_image_manager_, &image_factory_, nullptr,
/*is_using_skia_renderer=*/false, /*use_gl=*/true); /*enable_wrapped_sk_image=*/false);
} }
void TearDown() override { void TearDown() override {
...@@ -91,7 +91,7 @@ TEST_F(SharedImageFactoryTest, DuplicateMailbox) { ...@@ -91,7 +91,7 @@ TEST_F(SharedImageFactoryTest, DuplicateMailbox) {
auto other_factory = std::make_unique<SharedImageFactory>( auto other_factory = std::make_unique<SharedImageFactory>(
preferences, workarounds, GpuFeatureInfo(), nullptr, &mailbox_manager_, preferences, workarounds, GpuFeatureInfo(), nullptr, &mailbox_manager_,
&shared_image_manager_, &image_factory_, nullptr, &shared_image_manager_, &image_factory_, nullptr,
/*is_using_skia_renderer=*/false, /*use_gl=*/true); /*enable_wrapped_sk_image=*/false);
EXPECT_FALSE(other_factory->CreateSharedImage(mailbox, format, size, EXPECT_FALSE(other_factory->CreateSharedImage(mailbox, format, size,
color_space, usage)); color_space, usage));
} }
......
...@@ -39,7 +39,7 @@ class WebGPUDecoderTest : public ::testing::Test { ...@@ -39,7 +39,7 @@ class WebGPUDecoderTest : public ::testing::Test {
GpuPreferences(), GpuDriverBugWorkarounds(), GpuFeatureInfo(), GpuPreferences(), GpuDriverBugWorkarounds(), GpuFeatureInfo(),
/*context_state=*/nullptr, /*mailbox_manager=*/nullptr, /*context_state=*/nullptr, /*mailbox_manager=*/nullptr,
&shared_image_manager_, /*image_factory=*/nullptr, /*tracker=*/nullptr, &shared_image_manager_, /*image_factory=*/nullptr, /*tracker=*/nullptr,
/*is_using_skia_renderer=*/false, /*use_gl=*/false); /*enable_wrapped_sk_image=*/false);
} }
void TearDown() override { void TearDown() override {
......
...@@ -385,7 +385,7 @@ class CommandBufferSetup { ...@@ -385,7 +385,7 @@ class CommandBufferSetup {
gpu_preferences_, config_.workarounds, gpu_feature_info, gpu_preferences_, config_.workarounds, gpu_feature_info,
context_state_.get(), &mailbox_manager_, shared_image_manager_.get(), context_state_.get(), &mailbox_manager_, shared_image_manager_.get(),
nullptr /* image_factory */, nullptr /* memory_tracker */, nullptr /* image_factory */, nullptr /* memory_tracker */,
false /* is_using_skia_renderer */, /* use_gl */ true); false /* enable_wrapped_sk_image */);
for (uint32_t usage = SHARED_IMAGE_USAGE_GLES2; for (uint32_t usage = SHARED_IMAGE_USAGE_GLES2;
usage <= SHARED_IMAGE_USAGE_RGB_EMULATION; usage <<= 1) { usage <= SHARED_IMAGE_USAGE_RGB_EMULATION; usage <<= 1) {
Mailbox::Name name; Mailbox::Name name;
......
...@@ -1391,12 +1391,15 @@ void InProcessCommandBuffer::LazyCreateSharedImageFactory() { ...@@ -1391,12 +1391,15 @@ void InProcessCommandBuffer::LazyCreateSharedImageFactory() {
if (shared_image_factory_) if (shared_image_factory_)
return; return;
// We need WrappedSkImage to support creating a SharedImage with pixel data
// when GL is unavailable. This is used in various unit tests.
const bool enable_wrapped_sk_image =
context_state_ && !context_state_->GrContextIsGL();
shared_image_factory_ = std::make_unique<SharedImageFactory>( shared_image_factory_ = std::make_unique<SharedImageFactory>(
GetGpuPreferences(), context_group_->feature_info()->workarounds(), GetGpuPreferences(), context_group_->feature_info()->workarounds(),
GetGpuFeatureInfo(), context_state_.get(), GetGpuFeatureInfo(), context_state_.get(),
context_group_->mailbox_manager(), task_executor_->shared_image_manager(), context_group_->mailbox_manager(), task_executor_->shared_image_manager(),
image_factory_, nullptr, features::IsUsingSkiaRenderer(), image_factory_, nullptr, enable_wrapped_sk_image);
context_ != nullptr);
} }
void InProcessCommandBuffer::CreateSharedImageOnGpuThread( void InProcessCommandBuffer::CreateSharedImageOnGpuThread(
......
...@@ -373,7 +373,7 @@ ContextResult SharedImageStub::MakeContextCurrentAndCreateFactory() { ...@@ -373,7 +373,7 @@ ContextResult SharedImageStub::MakeContextCurrentAndCreateFactory() {
channel_manager->mailbox_manager(), channel_manager->mailbox_manager(),
channel_manager->shared_image_manager(), channel_manager->shared_image_manager(),
gmb_factory ? gmb_factory->AsImageFactory() : nullptr, this, gmb_factory ? gmb_factory->AsImageFactory() : nullptr, this,
features::IsUsingSkiaRenderer(), /*use_gl=*/true); features::IsUsingSkiaRenderer());
return ContextResult::kSuccess; return ContextResult::kSuccess;
} }
......
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