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,
gpu::SharedContextState* context_state,
gpu::MailboxManager* mailbox_manager,
gpu::SharedImageManager* shared_image_manager,
bool use_gl,
scoped_refptr<gpu::SyncPointClientState> sync_point_client_state)
: shared_image_manager_(shared_image_manager),
shared_image_factory_(gpu_preferences,
......@@ -284,8 +283,7 @@ class DirectContextProviderDelegateImpl : public DirectContextProviderDelegate,
shared_image_manager,
nullptr /* image_factory */,
nullptr /* memory_tracker */,
true /* is_using_skia_renderer */,
use_gl),
true /* is_using_skia_renderer */),
sync_point_client_state_(sync_point_client_state) {}
~DirectContextProviderDelegateImpl() override {
......@@ -746,7 +744,7 @@ void SkiaOutputSurfaceImplOnGpu::CopyOutput(
gpu_preferences_, channel_manager->gpu_driver_bug_workarounds(),
channel_manager->gpu_feature_info(), context_state_.get(),
mailbox_manager_, gpu_service_->shared_image_manager(),
!is_using_vulkan(), CreateSyncPointClientState(gpu_service_));
CreateSyncPointClientState(gpu_service_));
context_provider_ = base::MakeRefCounted<DirectContextProvider>(
context_state_->context(), gl_surface_, supports_alpha_,
gpu_preferences_, feature_info_.get(), std::move(client));
......
......@@ -24,6 +24,7 @@
#include "gpu/command_buffer/service/shared_image_representation.h"
#include "gpu/command_buffer/service/wrapped_sk_image.h"
#include "gpu/config/gpu_preferences.h"
#include "ui/gl/gl_implementation.h"
#include "ui/gl/trace_util.h"
#if (defined(USE_X11) || defined(OS_FUCHSIA)) && BUILDFLAG(ENABLE_VULKAN)
......@@ -67,13 +68,13 @@ SharedImageFactory::SharedImageFactory(
SharedImageManager* shared_image_manager,
ImageFactory* image_factory,
MemoryTracker* memory_tracker,
bool is_using_skia_renderer,
bool use_gl)
bool enable_wrapped_sk_image)
: mailbox_manager_(mailbox_manager),
shared_image_manager_(shared_image_manager),
memory_tracker_(std::make_unique<MemoryTypeTracker>(memory_tracker)),
using_vulkan_(context_state && context_state->GrContextIsVulkan()),
using_metal_(context_state && context_state->GrContextIsMetal()) {
bool use_gl = gl::GetGLImplementation() != gl::kGLImplementationNone;
if (use_gl) {
gl_backing_factory_ = std::make_unique<SharedImageBackingFactoryGLTexture>(
gpu_preferences, workarounds, gpu_feature_info, image_factory);
......@@ -98,10 +99,7 @@ SharedImageFactory::SharedImageFactory(
// Others
DCHECK(!using_vulkan_);
#endif
// Certain test suites may enable UseSkiaRenderer feature flag, but never
// create a SkiaRenderer. In this case context_state is nullptr and we should
// not create a WrappedSkImageFactory.
if (is_using_skia_renderer && context_state) {
if (enable_wrapped_sk_image && context_state) {
wrapped_sk_image_factory_ =
std::make_unique<raster::WrappedSkImageFactory>(context_state);
}
......
......@@ -51,8 +51,7 @@ class GPU_GLES2_EXPORT SharedImageFactory {
SharedImageManager* manager,
ImageFactory* image_factory,
MemoryTracker* tracker,
bool is_using_skia_renderer,
bool use_gl_);
bool enable_wrapped_sk_image);
~SharedImageFactory();
bool CreateSharedImage(const Mailbox& mailbox,
......
......@@ -41,7 +41,7 @@ class SharedImageFactoryTest : public testing::Test {
factory_ = std::make_unique<SharedImageFactory>(
preferences, workarounds, GpuFeatureInfo(), nullptr, &mailbox_manager_,
&shared_image_manager_, &image_factory_, nullptr,
/*is_using_skia_renderer=*/false, /*use_gl=*/true);
/*enable_wrapped_sk_image=*/false);
}
void TearDown() override {
......@@ -91,7 +91,7 @@ TEST_F(SharedImageFactoryTest, DuplicateMailbox) {
auto other_factory = std::make_unique<SharedImageFactory>(
preferences, workarounds, GpuFeatureInfo(), nullptr, &mailbox_manager_,
&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,
color_space, usage));
}
......
......@@ -39,7 +39,7 @@ class WebGPUDecoderTest : public ::testing::Test {
GpuPreferences(), GpuDriverBugWorkarounds(), GpuFeatureInfo(),
/*context_state=*/nullptr, /*mailbox_manager=*/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 {
......
......@@ -385,7 +385,7 @@ class CommandBufferSetup {
gpu_preferences_, config_.workarounds, gpu_feature_info,
context_state_.get(), &mailbox_manager_, shared_image_manager_.get(),
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;
usage <= SHARED_IMAGE_USAGE_RGB_EMULATION; usage <<= 1) {
Mailbox::Name name;
......
......@@ -1391,12 +1391,15 @@ void InProcessCommandBuffer::LazyCreateSharedImageFactory() {
if (shared_image_factory_)
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>(
GetGpuPreferences(), context_group_->feature_info()->workarounds(),
GetGpuFeatureInfo(), context_state_.get(),
context_group_->mailbox_manager(), task_executor_->shared_image_manager(),
image_factory_, nullptr, features::IsUsingSkiaRenderer(),
context_ != nullptr);
image_factory_, nullptr, enable_wrapped_sk_image);
}
void InProcessCommandBuffer::CreateSharedImageOnGpuThread(
......
......@@ -373,7 +373,7 @@ ContextResult SharedImageStub::MakeContextCurrentAndCreateFactory() {
channel_manager->mailbox_manager(),
channel_manager->shared_image_manager(),
gmb_factory ? gmb_factory->AsImageFactory() : nullptr, this,
features::IsUsingSkiaRenderer(), /*use_gl=*/true);
features::IsUsingSkiaRenderer());
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