Commit 43d76b65 authored by Peng Huang's avatar Peng Huang Committed by Commit Bot

Revert "Add VulkanContextProvider to RasterDecoderContextState."

This reverts commit 4df3f6e1.

Reason for revert: This CL causes crash in RasterCommandBufferStub.
The raster decoder still uses GL context and GL APIs even with vulkan.
Before removing the GL contect for vulkan, we need remove all
unnecessary GL context usage and GL calls for raster decoder.

#0 0x55d1ec37f6ef base::debug::StackTrace::StackTrace()
#1 0x55d1ec37f261 base::debug::(anonymous namespace)::StackDumpSignalHandler()
#2 0x7fe55e62d0c0 <unknown>
#3 0x55d1ed30103e gpu::RasterCommandBufferStub::Initialize()
#4 0x55d1ed25f35c gpu::GpuChannel::OnCreateCommandBuffer()
#5 0x55d1ed25ed0a bool IPC::MessageT<GpuChannelMsg_CreateCommandBuffer_Meta, std::__1::tuple<GPUCreateCommandBufferConfig, int, base::UnsafeSharedMemoryRegion>, std::__1::tuple<gpu::ContextResult, gpu::Capabilities> >::Dispatch<gpu::GpuChannel, gpu::GpuChannel, void, void (gpu::GpuChannel::*)(GPUCreateCommandBufferConfig const&, int, base::UnsafeSharedMemoryRegion, gpu::ContextResult*, gpu::Capabilities*)>(IPC::Message const*, gpu::GpuChannel*, gpu::GpuChannel*, void*, void (gpu::GpuChannel::*)(GPUCreateCommandBufferConfig const&, int, base::UnsafeSharedMemoryRegion, gpu::ContextResult*, gpu::Capabilities*))
#6 0x55d1ed25fcc4 gpu::GpuChannel::HandleMessageHelper()
#7 0x55d1ec3058f1 base::debug::TaskAnnotator::RunTask()
#8 0x55d1ec3050af base::MessageLoop::RunTask()
#9 0x55d1ec305432 base::MessageLoop::DoWork()
#10 0x55d1ec30743f base::(anonymous namespace)::WorkSourceDispatch()
#11 0x7fe55def6fc7 g_main_context_dispatch
#12 0x7fe55def7200 <unknown>
#13 0x7fe55def728c g_main_context_iteration
#14 0x55d1ec3072f2 base::MessagePumpGlib::Run()
#15 0x55d1ec31fba5 base::RunLoop::Run()
#16 0x55d1eeaedd3c content::GpuMain()
#17 0x55d1ebb80562 content::ContentMainRunnerImpl::Run()
#18 0x55d1ed68984c service_manager::Main()
#19 0x55d1eb1d6081 content::ContentMain()
#20 0x55d1ea8e316b main
#21 0x7fe559a992b1 __libc_start_main
#22 0x55d1ea8e302a _start

Original change's description:
> Add VulkanContextProvider to RasterDecoderContextState.
> 
> Add VulkanContextProvider to RasterDecoderContextState which is needed
> to get VkDevice in shareable image. Refactor RasterDecoderContextState
> class to have seperate constructors for Vulkan and GL.
> 
> Bug: 891060
> Change-Id: I0ca7e657d33fdcfa62ab6465f7023a914610b7ce
> Reviewed-on: https://chromium-review.googlesource.com/c/1312194
> Commit-Queue: vikas soni <vikassoni@chromium.org>
> Reviewed-by: Eric Karl <ericrk@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#605146}

TBR=ericrk@chromium.org,vikassoni@chromium.org

# Not skipping CQ checks because original CL landed > 1 day ago.

Bug: 891060
Change-Id: I4ceebc7033b4bd74e643a5f89bbbd6791b3eb6c0
Reviewed-on: https://chromium-review.googlesource.com/c/1318073Reviewed-by: default avatarPeng Huang <penghuang@chromium.org>
Commit-Queue: Peng Huang <penghuang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#605376}
parent 65ff9677
......@@ -257,6 +257,8 @@ void GpuServiceImpl::InitializeWithHost(
skia_output_surface_sequence_id_ =
scheduler_->CreateSequence(gpu::SchedulingPriority::kHigh);
GrContext* vulkan_gr_context =
is_using_vulkan() ? vulkan_context_provider()->GetGrContext() : nullptr;
// Defer creation of the render thread. This is to prevent it from handling
// IPC messages before the sandbox has been enabled and all other necessary
// initialization has succeeded.
......@@ -264,7 +266,7 @@ void GpuServiceImpl::InitializeWithHost(
gpu_preferences_, this, watchdog_thread_.get(), main_runner_, io_runner_,
scheduler_.get(), sync_point_manager_, gpu_memory_buffer_factory_.get(),
gpu_feature_info_, std::move(activity_flags),
std::move(default_offscreen_surface), vulkan_context_provider());
std::move(default_offscreen_surface), vulkan_gr_context);
media_gpu_channel_manager_.reset(
new media::MediaGpuChannelManager(gpu_channel_manager_.get()));
......
......@@ -5,7 +5,6 @@
import("//build/config/jumbo.gni")
import("//build/config/ui.gni")
import("//third_party/protobuf/proto_library.gni")
import("//gpu/vulkan/features.gni")
group("service") {
if (is_component_build) {
......@@ -294,7 +293,6 @@ target(link_target_type, "gles2_sources") {
"//gpu/command_buffer/common:gles2_utils",
"//gpu/config",
"//gpu/ipc/common:surface_handle_type",
"//gpu/vulkan:buildflags",
"//third_party/angle:angle_image_util",
"//third_party/angle:commit_id",
"//third_party/angle:translator",
......@@ -309,10 +307,6 @@ target(link_target_type, "gles2_sources") {
"//ui/gl/init",
]
if (enable_vulkan) {
deps += [ "//components/viz/common:vulkan_context_provider" ]
}
if (is_mac) {
# Required by gles2_cmd_decoder.cc on Mac.
libs = [
......
include_rules = [
"+cc/paint",
"+third_party/skia",
"+components/viz/common/gpu/vulkan_context_provider.h",
"+components/viz/common/resources/resource_format.h",
"+components/viz/common/resources/resource_format_utils.h",
"+components/viz/common/resources/resource_sizes.h",
......
......@@ -9,17 +9,12 @@
#include "gpu/command_buffer/common/activity_flags.h"
#include "gpu/command_buffer/service/service_transfer_cache.h"
#include "gpu/config/gpu_driver_bug_workarounds.h"
#include "gpu/vulkan/buildflags.h"
#include "ui/gl/gl_bindings.h"
#include "ui/gl/gl_context.h"
#include "ui/gl/gl_share_group.h"
#include "ui/gl/gl_surface.h"
#include "ui/gl/init/create_gr_gl_interface.h"
#if BUILDFLAG(ENABLE_VULKAN)
#include "components/viz/common/gpu/vulkan_context_provider.h"
#endif
namespace gpu {
namespace raster {
......@@ -27,10 +22,13 @@ RasterDecoderContextState::RasterDecoderContextState(
scoped_refptr<gl::GLShareGroup> share_group,
scoped_refptr<gl::GLSurface> surface,
scoped_refptr<gl::GLContext> context,
bool use_virtualized_gl_contexts)
bool use_virtualized_gl_contexts,
GrContext* vulkan_gr_context)
: share_group(std::move(share_group)),
surface(std::move(surface)),
context(std::move(context)),
gr_context(vulkan_gr_context),
use_vulkan_gr_context(!!gr_context),
use_virtualized_gl_contexts(use_virtualized_gl_contexts) {
if (base::ThreadTaskRunnerHandle::IsSet()) {
base::trace_event::MemoryDumpManager::GetInstance()->RegisterDumpProvider(
......@@ -38,27 +36,6 @@ RasterDecoderContextState::RasterDecoderContextState(
}
}
RasterDecoderContextState::RasterDecoderContextState(
viz::VulkanContextProvider* vulkan_context_provider)
#if BUILDFLAG(ENABLE_VULKAN)
: vk_context_provider(vulkan_context_provider),
gr_context(vk_context_provider->GetGrContext()),
use_vulkan_gr_context(true)
#endif
{
// This constructor should not be called if Vulkan is not enabled.
#if !BUILDFLAG(ENABLE_VULKAN)
DCHECK(false);
#endif
// gr_context should not be null.
DCHECK(gr_context);
if (base::ThreadTaskRunnerHandle::IsSet()) {
base::trace_event::MemoryDumpManager::GetInstance()->RegisterDumpProvider(
this, "RasterDecoderContextState", base::ThreadTaskRunnerHandle::Get());
}
}
RasterDecoderContextState::~RasterDecoderContextState() {
if (gr_context)
gr_context->abandonContext();
......
......@@ -19,10 +19,6 @@ class GLShareGroup;
class GLSurface;
} // namespace gl
namespace viz {
class VulkanContextProvider;
} // namespace viz
namespace gpu {
class GpuDriverBugWorkarounds;
class GpuProcessActivityFlags;
......@@ -34,16 +30,11 @@ struct GPU_GLES2_EXPORT RasterDecoderContextState
: public base::RefCounted<RasterDecoderContextState>,
public base::trace_event::MemoryDumpProvider {
public:
// Used for GL.
RasterDecoderContextState(scoped_refptr<gl::GLShareGroup> share_group,
scoped_refptr<gl::GLSurface> surface,
scoped_refptr<gl::GLContext> context,
bool use_virtualized_gl_contexts);
// Used for Vulkan.
RasterDecoderContextState(
viz::VulkanContextProvider* vulkan_context_provider);
bool use_virtualized_gl_contexts,
GrContext* vulkan_gr_context = nullptr);
void InitializeGrContext(const GpuDriverBugWorkarounds& workarounds,
GrContextOptions::PersistentCache* cache,
GpuProcessActivityFlags* activity_flags = nullptr,
......@@ -51,14 +42,10 @@ struct GPU_GLES2_EXPORT RasterDecoderContextState
void PurgeMemory(
base::MemoryPressureListener::MemoryPressureLevel memory_pressure_level);
// These should be null for Vulkan mode.
scoped_refptr<gl::GLShareGroup> share_group;
scoped_refptr<gl::GLSurface> surface;
scoped_refptr<gl::GLContext> context;
// Should be null for GL mode.
viz::VulkanContextProvider* vk_context_provider = nullptr;
GrContext* gr_context = nullptr;
GrContext* gr_context;
sk_sp<GrContext> owned_gr_context;
std::unique_ptr<ServiceTransferCache> transfer_cache;
const bool use_vulkan_gr_context = false;
......
......@@ -63,7 +63,7 @@ GpuChannelManager::GpuChannelManager(
const GpuFeatureInfo& gpu_feature_info,
GpuProcessActivityFlags activity_flags,
scoped_refptr<gl::GLSurface> default_offscreen_surface,
viz::VulkanContextProvider* vulkan_context_provider)
GrContext* vulkan_gr_context)
: task_runner_(task_runner),
io_task_runner_(io_task_runner),
gpu_preferences_(gpu_preferences),
......@@ -84,7 +84,7 @@ GpuChannelManager::GpuChannelManager(
memory_pressure_listener_(
base::Bind(&GpuChannelManager::HandleMemoryPressure,
base::Unretained(this))),
vulkan_context_provider_(vulkan_context_provider),
vulkan_gr_context_(vulkan_gr_context),
weak_factory_(this) {
DCHECK(task_runner->BelongsToCurrentThread());
DCHECK(io_task_runner);
......@@ -432,15 +432,9 @@ GpuChannelManager::GetRasterDecoderContextState(ContextResult* result) {
}
// TODO(penghuang): https://crbug.com/899735 Handle device lost for Vulkan.
if (vulkan_context_provider_) {
raster_decoder_context_state_ =
new raster::RasterDecoderContextState(vulkan_context_provider_);
} else {
raster_decoder_context_state_ = new raster::RasterDecoderContextState(
std::move(share_group), std::move(surface), std::move(context),
use_virtualized_gl_contexts);
}
raster_decoder_context_state_ = new raster::RasterDecoderContextState(
std::move(share_group), std::move(surface), std::move(context),
use_virtualized_gl_contexts, vulkan_gr_context_);
const bool enable_raster_transport =
gpu_feature_info_.status_values[GPU_FEATURE_TYPE_OOP_RASTERIZATION] ==
gpu::kGpuFeatureStatusEnabled;
......
......@@ -37,6 +37,8 @@
#include "ui/gl/gl_surface.h"
#include "url/gurl.h"
class GrContext;
namespace gl {
class GLShareGroup;
}
......@@ -66,19 +68,18 @@ class ProgramCache;
class GPU_IPC_SERVICE_EXPORT GpuChannelManager
: public raster::GrShaderCache::Client {
public:
GpuChannelManager(
const GpuPreferences& gpu_preferences,
GpuChannelManagerDelegate* delegate,
GpuWatchdogThread* watchdog,
scoped_refptr<base::SingleThreadTaskRunner> task_runner,
scoped_refptr<base::SingleThreadTaskRunner> io_task_runner,
Scheduler* scheduler,
SyncPointManager* sync_point_manager,
GpuMemoryBufferFactory* gpu_memory_buffer_factory,
const GpuFeatureInfo& gpu_feature_info,
GpuProcessActivityFlags activity_flags,
scoped_refptr<gl::GLSurface> default_offscreen_surface,
viz::VulkanContextProvider* vulkan_context_provider = nullptr);
GpuChannelManager(const GpuPreferences& gpu_preferences,
GpuChannelManagerDelegate* delegate,
GpuWatchdogThread* watchdog,
scoped_refptr<base::SingleThreadTaskRunner> task_runner,
scoped_refptr<base::SingleThreadTaskRunner> io_task_runner,
Scheduler* scheduler,
SyncPointManager* sync_point_manager,
GpuMemoryBufferFactory* gpu_memory_buffer_factory,
const GpuFeatureInfo& gpu_feature_info,
GpuProcessActivityFlags activity_flags,
scoped_refptr<gl::GLSurface> default_offscreen_surface,
GrContext* vulkan_gr_context = nullptr);
~GpuChannelManager() override;
GpuChannelManagerDelegate* delegate() const { return delegate_; }
......@@ -240,9 +241,9 @@ class GPU_IPC_SERVICE_EXPORT GpuChannelManager
scoped_refptr<raster::RasterDecoderContextState>
raster_decoder_context_state_;
// With --enable-vulkan, the vulkan_context_provider_ will be set from
// With --enable-vulkan, the vulkan_gr_context_ will be set from
// viz::GpuServiceImpl. The raster decoders will use it for rasterization.
viz::VulkanContextProvider* vulkan_context_provider_;
GrContext* vulkan_gr_context_;
// Member variables should appear before the WeakPtrFactory, to ensure
// that any WeakPtrs to Controller are invalidated before its members
......
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