diff options
Diffstat (limited to 'chromium/gpu/command_buffer/service/shared_context_state.cc')
-rw-r--r-- | chromium/gpu/command_buffer/service/shared_context_state.cc | 51 |
1 files changed, 48 insertions, 3 deletions
diff --git a/chromium/gpu/command_buffer/service/shared_context_state.cc b/chromium/gpu/command_buffer/service/shared_context_state.cc index 37897dcf917..295242470fd 100644 --- a/chromium/gpu/command_buffer/service/shared_context_state.cc +++ b/chromium/gpu/command_buffer/service/shared_context_state.cc @@ -13,6 +13,7 @@ #include "gpu/command_buffer/service/service_utils.h" #include "gpu/config/gpu_driver_bug_workarounds.h" #include "gpu/vulkan/buildflags.h" +#include "skia/buildflags.h" #include "ui/gl/gl_bindings.h" #include "ui/gl/gl_context.h" #include "ui/gl/gl_share_group.h" @@ -28,6 +29,10 @@ #include "components/viz/common/gpu/metal_context_provider.h" #endif +#if BUILDFLAG(SKIA_USE_DAWN) +#include "components/viz/common/gpu/dawn_context_provider.h" +#endif + namespace { static constexpr size_t kInitialScratchDeserializationBufferSize = 1024; } @@ -43,18 +48,47 @@ void SharedContextState::compileError(const char* shader, const char* errors) { } } +SharedContextState::MemoryTracker::MemoryTracker( + gpu::MemoryTracker::Observer* peak_memory_monitor) + : peak_memory_monitor_(peak_memory_monitor) {} + +SharedContextState::MemoryTracker::~MemoryTracker() { + DCHECK(!size_); +} + +void SharedContextState::MemoryTracker::OnMemoryAllocatedChange( + CommandBufferId id, + uint64_t old_size, + uint64_t new_size) { + uint64_t delta = new_size - old_size; + old_size = size_; + size_ += delta; + if (peak_memory_monitor_) + peak_memory_monitor_->OnMemoryAllocatedChange(id, old_size, size_); +} + +uint64_t SharedContextState::MemoryTracker::GetMemoryUsage() const { + return size_; +} + SharedContextState::SharedContextState( scoped_refptr<gl::GLShareGroup> share_group, scoped_refptr<gl::GLSurface> surface, scoped_refptr<gl::GLContext> context, bool use_virtualized_gl_contexts, base::OnceClosure context_lost_callback, + GrContextType gr_context_type, viz::VulkanContextProvider* vulkan_context_provider, - viz::MetalContextProvider* metal_context_provider) + viz::MetalContextProvider* metal_context_provider, + viz::DawnContextProvider* dawn_context_provider, + gpu::MemoryTracker::Observer* peak_memory_monitor) : use_virtualized_gl_contexts_(use_virtualized_gl_contexts), context_lost_callback_(std::move(context_lost_callback)), + gr_context_type_(gr_context_type), + memory_tracker_(peak_memory_monitor), vk_context_provider_(vulkan_context_provider), metal_context_provider_(metal_context_provider), + dawn_context_provider_(dawn_context_provider), share_group_(std::move(share_group)), context_(context), real_context_(std::move(context)), @@ -75,6 +109,13 @@ SharedContextState::SharedContextState( use_virtualized_gl_contexts_ = false; DCHECK(gr_context_); } + if (GrContextIsDawn()) { +#if BUILDFLAG(SKIA_USE_DAWN) + gr_context_ = dawn_context_provider_->GetGrContext(); +#endif + use_virtualized_gl_contexts_ = false; + DCHECK(gr_context_); + } if (base::ThreadTaskRunnerHandle::IsSet()) { base::trace_event::MemoryDumpManager::GetInstance()->RegisterDumpProvider( @@ -252,11 +293,15 @@ bool SharedContextState::InitializeGL( MakeCurrent(nullptr); } + bool is_native_vulkan = + gpu_preferences.use_vulkan == gpu::VulkanImplementationName::kNative || + gpu_preferences.use_vulkan == + gpu::VulkanImplementationName::kForcedNative; + // Swiftshader GL and Vulkan report supporting external objects extensions, // but they don't. support_vulkan_external_object_ = - !gl::g_current_gl_version->is_swiftshader && - gpu_preferences.use_vulkan == gpu::VulkanImplementationName::kNative && + !gl::g_current_gl_version->is_swiftshader && is_native_vulkan && gl::g_current_gl_driver->ext.b_GL_EXT_memory_object_fd && gl::g_current_gl_driver->ext.b_GL_EXT_semaphore_fd; |