Commit 1f3dd677 authored by Vasiliy Telezhnikov's avatar Vasiliy Telezhnikov Committed by Commit Bot

Revert "Use GrShaderCache with Vulkan"

This reverts commit db7626d6.

Reason for revert: Causes crash on windows

Original change's description:
> Use GrShaderCache with Vulkan
>
> VulkanContextProvider is created before GrShaderCache and so cache
> wasn't pass to Skia via GrContextOptions.
>
> This CL defers init of GrContext in VulkanInProcessContextProvider to
> SharedContextState::InitializeGrContext to mitigate this.
>
> Use of cache itself is under feature flag for metrics comparison and
> a kill switch purpose.
>
> Bug: 1151031
> Change-Id: Idc410b9b557f7ca67164eb80d6a37a27ceb0f6d2
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2551245
> Reviewed-by: Peng Huang <penghuang@chromium.org>
> Commit-Queue: Vasiliy Telezhnikov <vasilyt@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#829651}

TBR=penghuang@chromium.org,vasilyt@chromium.org

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

Bug: 1151031, 1151645
Change-Id: Ic6712d111d234f72fd799a4c48a90a4426aa1a1e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2553698Reviewed-by: default avatarVasiliy Telezhnikov <vasilyt@chromium.org>
Commit-Queue: Vasiliy Telezhnikov <vasilyt@chromium.org>
Cr-Commit-Position: refs/heads/master@{#830229}
parent 8545b384
...@@ -215,13 +215,6 @@ bool AwVulkanContextProvider::Initialize(AwDrawFn_InitVkParams* params) { ...@@ -215,13 +215,6 @@ bool AwVulkanContextProvider::Initialize(AwDrawFn_InitVkParams* params) {
return !!globals_; return !!globals_;
} }
bool AwVulkanContextProvider::InitializeGrContext(
const GrContextOptions& context_options) {
// GrContext is created in Globals, so nothing to do here besides DCHECK.
DCHECK(globals_);
return globals_->gr_context.get() != nullptr;
}
void AwVulkanContextProvider::SecondaryCBDrawBegin( void AwVulkanContextProvider::SecondaryCBDrawBegin(
sk_sp<GrVkSecondaryCBDrawContext> draw_context) { sk_sp<GrVkSecondaryCBDrawContext> draw_context) {
DCHECK(draw_context); DCHECK(draw_context);
......
...@@ -48,7 +48,6 @@ class AwVulkanContextProvider final : public viz::VulkanContextProvider { ...@@ -48,7 +48,6 @@ class AwVulkanContextProvider final : public viz::VulkanContextProvider {
AwDrawFn_InitVkParams* params); AwDrawFn_InitVkParams* params);
// viz::VulkanContextProvider implementation: // viz::VulkanContextProvider implementation:
bool InitializeGrContext(const GrContextOptions& context_options) override;
gpu::VulkanImplementation* GetVulkanImplementation() override; gpu::VulkanImplementation* GetVulkanImplementation() override;
gpu::VulkanDeviceQueue* GetDeviceQueue() override; gpu::VulkanDeviceQueue* GetDeviceQueue() override;
GrDirectContext* GetGrContext() override; GrDirectContext* GetGrContext() override;
......
...@@ -12,7 +12,6 @@ ...@@ -12,7 +12,6 @@
#include "components/viz/common/viz_vulkan_context_provider_export.h" #include "components/viz/common/viz_vulkan_context_provider_export.h"
#include "third_party/vulkan_headers/include/vulkan/vulkan.h" #include "third_party/vulkan_headers/include/vulkan/vulkan.h"
struct GrContextOptions;
class GrDirectContext; class GrDirectContext;
class GrVkSecondaryCBDrawContext; class GrVkSecondaryCBDrawContext;
...@@ -27,7 +26,6 @@ namespace viz { ...@@ -27,7 +26,6 @@ namespace viz {
class VIZ_VULKAN_CONTEXT_PROVIDER_EXPORT VulkanContextProvider class VIZ_VULKAN_CONTEXT_PROVIDER_EXPORT VulkanContextProvider
: public base::RefCountedThreadSafe<VulkanContextProvider> { : public base::RefCountedThreadSafe<VulkanContextProvider> {
public: public:
virtual bool InitializeGrContext(const GrContextOptions& context_options) = 0;
virtual gpu::VulkanImplementation* GetVulkanImplementation() = 0; virtual gpu::VulkanImplementation* GetVulkanImplementation() = 0;
virtual gpu::VulkanDeviceQueue* GetDeviceQueue() = 0; virtual gpu::VulkanDeviceQueue* GetDeviceQueue() = 0;
virtual GrDirectContext* GetGrContext() = 0; virtual GrDirectContext* GetGrContext() = 0;
......
...@@ -23,10 +23,11 @@ namespace viz { ...@@ -23,10 +23,11 @@ namespace viz {
scoped_refptr<VulkanInProcessContextProvider> scoped_refptr<VulkanInProcessContextProvider>
VulkanInProcessContextProvider::Create( VulkanInProcessContextProvider::Create(
gpu::VulkanImplementation* vulkan_implementation, gpu::VulkanImplementation* vulkan_implementation,
const GrContextOptions& options,
const gpu::GPUInfo* gpu_info) { const gpu::GPUInfo* gpu_info) {
scoped_refptr<VulkanInProcessContextProvider> context_provider( scoped_refptr<VulkanInProcessContextProvider> context_provider(
new VulkanInProcessContextProvider(vulkan_implementation)); new VulkanInProcessContextProvider(vulkan_implementation));
if (!context_provider->Initialize(gpu_info)) if (!context_provider->Initialize(options, gpu_info))
return nullptr; return nullptr;
return context_provider; return context_provider;
} }
...@@ -40,6 +41,7 @@ VulkanInProcessContextProvider::~VulkanInProcessContextProvider() { ...@@ -40,6 +41,7 @@ VulkanInProcessContextProvider::~VulkanInProcessContextProvider() {
} }
bool VulkanInProcessContextProvider::Initialize( bool VulkanInProcessContextProvider::Initialize(
const GrContextOptions& context_options,
const gpu::GPUInfo* gpu_info) { const gpu::GPUInfo* gpu_info) {
DCHECK(!device_queue_); DCHECK(!device_queue_);
...@@ -62,11 +64,6 @@ bool VulkanInProcessContextProvider::Initialize( ...@@ -62,11 +64,6 @@ bool VulkanInProcessContextProvider::Initialize(
if (!device_queue_) if (!device_queue_)
return false; return false;
return true;
}
bool VulkanInProcessContextProvider::InitializeGrContext(
const GrContextOptions& context_options) {
GrVkBackendContext backend_context; GrVkBackendContext backend_context;
backend_context.fInstance = device_queue_->GetVulkanInstance(); backend_context.fInstance = device_queue_->GetVulkanInstance();
backend_context.fPhysicalDevice = device_queue_->GetVulkanPhysicalDevice(); backend_context.fPhysicalDevice = device_queue_->GetVulkanPhysicalDevice();
...@@ -89,10 +86,6 @@ bool VulkanInProcessContextProvider::InitializeGrContext( ...@@ -89,10 +86,6 @@ bool VulkanInProcessContextProvider::InitializeGrContext(
return vkGetInstanceProcAddr(instance, proc_name); return vkGetInstanceProcAddr(instance, proc_name);
}; };
const auto& instance_extensions = vulkan_implementation_->GetVulkanInstance()
->vulkan_info()
.enabled_instance_extensions;
std::vector<const char*> device_extensions; std::vector<const char*> device_extensions;
device_extensions.reserve(device_queue_->enabled_extensions().size()); device_extensions.reserve(device_queue_->enabled_extensions().size());
for (const auto& extension : device_queue_->enabled_extensions()) for (const auto& extension : device_queue_->enabled_extensions())
......
...@@ -30,12 +30,12 @@ class VIZ_VULKAN_CONTEXT_PROVIDER_EXPORT VulkanInProcessContextProvider ...@@ -30,12 +30,12 @@ class VIZ_VULKAN_CONTEXT_PROVIDER_EXPORT VulkanInProcessContextProvider
public: public:
static scoped_refptr<VulkanInProcessContextProvider> Create( static scoped_refptr<VulkanInProcessContextProvider> Create(
gpu::VulkanImplementation* vulkan_implementation, gpu::VulkanImplementation* vulkan_implementation,
const GrContextOptions& context_options = GrContextOptions(),
const gpu::GPUInfo* gpu_info = nullptr); const gpu::GPUInfo* gpu_info = nullptr);
void Destroy(); void Destroy();
// VulkanContextProvider implementation // VulkanContextProvider implementation
bool InitializeGrContext(const GrContextOptions& context_options) override;
gpu::VulkanImplementation* GetVulkanImplementation() override; gpu::VulkanImplementation* GetVulkanImplementation() override;
gpu::VulkanDeviceQueue* GetDeviceQueue() override; gpu::VulkanDeviceQueue* GetDeviceQueue() override;
GrDirectContext* GetGrContext() override; GrDirectContext* GetGrContext() override;
...@@ -49,7 +49,8 @@ class VIZ_VULKAN_CONTEXT_PROVIDER_EXPORT VulkanInProcessContextProvider ...@@ -49,7 +49,8 @@ class VIZ_VULKAN_CONTEXT_PROVIDER_EXPORT VulkanInProcessContextProvider
gpu::VulkanImplementation* vulkan_implementation); gpu::VulkanImplementation* vulkan_implementation);
~VulkanInProcessContextProvider() override; ~VulkanInProcessContextProvider() override;
bool Initialize(const gpu::GPUInfo* gpu_info); bool Initialize(const GrContextOptions& context_options,
const gpu::GPUInfo* gpu_info);
#if BUILDFLAG(ENABLE_VULKAN) #if BUILDFLAG(ENABLE_VULKAN)
sk_sp<GrDirectContext> gr_context_; sk_sp<GrDirectContext> gr_context_;
......
...@@ -369,7 +369,7 @@ GpuServiceImpl::GpuServiceImpl( ...@@ -369,7 +369,7 @@ GpuServiceImpl::GpuServiceImpl(
// If GL is using a real GPU, the gpu_info will be passed in and vulkan will // If GL is using a real GPU, the gpu_info will be passed in and vulkan will
// use the same GPU. // use the same GPU.
vulkan_context_provider_ = VulkanInProcessContextProvider::Create( vulkan_context_provider_ = VulkanInProcessContextProvider::Create(
vulkan_implementation_, vulkan_implementation_, context_options,
(is_native_vulkan && is_native_gl) ? &gpu_info : nullptr); (is_native_vulkan && is_native_gl) ? &gpu_info : nullptr);
if (vulkan_context_provider_) { if (vulkan_context_provider_) {
// If Vulkan is supported, then OOP-R is supported. // If Vulkan is supported, then OOP-R is supported.
......
...@@ -17,7 +17,6 @@ ...@@ -17,7 +17,6 @@
#include "gpu/command_buffer/service/service_utils.h" #include "gpu/command_buffer/service/service_utils.h"
#include "gpu/command_buffer/service/skia_utils.h" #include "gpu/command_buffer/service/skia_utils.h"
#include "gpu/config/gpu_driver_bug_workarounds.h" #include "gpu/config/gpu_driver_bug_workarounds.h"
#include "gpu/config/gpu_finch_features.h"
#include "gpu/config/skia_limits.h" #include "gpu/config/skia_limits.h"
#include "gpu/vulkan/buildflags.h" #include "gpu/vulkan/buildflags.h"
#include "skia/buildflags.h" #include "skia/buildflags.h"
...@@ -34,6 +33,10 @@ ...@@ -34,6 +33,10 @@
#include "gpu/vulkan/vulkan_device_queue.h" #include "gpu/vulkan/vulkan_device_queue.h"
#endif #endif
#if defined(OS_ANDROID)
#include "gpu/config/gpu_finch_features.h"
#endif
#if defined(OS_FUCHSIA) #if defined(OS_FUCHSIA)
#include "gpu/vulkan/fuchsia/vulkan_fuchsia_ext.h" #include "gpu/vulkan/fuchsia/vulkan_fuchsia_ext.h"
#endif #endif
...@@ -175,10 +178,12 @@ SharedContextState::SharedContextState( ...@@ -175,10 +178,12 @@ SharedContextState::SharedContextState(
case GrContextType::kVulkan: case GrContextType::kVulkan:
if (vk_context_provider_) { if (vk_context_provider_) {
#if BUILDFLAG(ENABLE_VULKAN) #if BUILDFLAG(ENABLE_VULKAN)
gr_context_ = vk_context_provider_->GetGrContext();
external_semaphore_pool_ = external_semaphore_pool_ =
std::make_unique<ExternalSemaphorePool>(this); std::make_unique<ExternalSemaphorePool>(this);
#endif #endif
use_virtualized_gl_contexts_ = false; use_virtualized_gl_contexts_ = false;
DCHECK(gr_context_);
} }
break; break;
case GrContextType::kMetal: case GrContextType::kMetal:
...@@ -266,16 +271,6 @@ bool SharedContextState::InitializeGrContext( ...@@ -266,16 +271,6 @@ bool SharedContextState::InitializeGrContext(
DetermineGrCacheLimitsFromAvailableMemory(&max_resource_cache_bytes, DetermineGrCacheLimitsFromAvailableMemory(&max_resource_cache_bytes,
&glyph_cache_max_texture_bytes); &glyph_cache_max_texture_bytes);
// If you make any changes to the GrContext::Options here that could
// affect text rendering, make sure to match the capabilities initialized
// in GetCapabilities and ensuring these are also used by the
// PaintOpBufferSerializer.
GrContextOptions options = GetDefaultGrContextOptions(gr_context_type_);
options.fPersistentCache = cache;
options.fShaderErrorHandler = this;
if (gpu_preferences.force_max_texture_size)
options.fMaxTextureSizeOverride = gpu_preferences.force_max_texture_size;
if (gr_context_type_ == GrContextType::kGL) { if (gr_context_type_ == GrContextType::kGL) {
DCHECK(context_->IsCurrent(nullptr)); DCHECK(context_->IsCurrent(nullptr));
bool use_version_es2 = false; bool use_version_es2 = false;
...@@ -301,31 +296,25 @@ bool SharedContextState::InitializeGrContext( ...@@ -301,31 +296,25 @@ bool SharedContextState::InitializeGrContext(
glProgramBinary(program, binaryFormat, binary, length); glProgramBinary(program, binaryFormat, binary, length);
}; };
} }
// If you make any changes to the GrContext::Options here that could
// affect text rendering, make sure to match the capabilities initialized
// in GetCapabilities and ensuring these are also used by the
// PaintOpBufferSerializer.
GrContextOptions options = GetDefaultGrContextOptions(GrContextType::kGL);
options.fDriverBugWorkarounds = options.fDriverBugWorkarounds =
GrDriverBugWorkarounds(workarounds.ToIntSet()); GrDriverBugWorkarounds(workarounds.ToIntSet());
options.fPersistentCache = cache;
options.fAvoidStencilBuffers = workarounds.avoid_stencil_buffers; options.fAvoidStencilBuffers = workarounds.avoid_stencil_buffers;
if (workarounds.disable_program_disk_cache) { if (workarounds.disable_program_disk_cache) {
options.fShaderCacheStrategy = options.fShaderCacheStrategy =
GrContextOptions::ShaderCacheStrategy::kBackendSource; GrContextOptions::ShaderCacheStrategy::kBackendSource;
} }
options.fShaderErrorHandler = this;
if (gpu_preferences.force_max_texture_size)
options.fMaxTextureSizeOverride = gpu_preferences.force_max_texture_size;
options.fPreferExternalImagesOverES3 = true; options.fPreferExternalImagesOverES3 = true;
owned_gr_context_ = GrDirectContext::MakeGL(std::move(interface), options); owned_gr_context_ = GrDirectContext::MakeGL(std::move(interface), options);
gr_context_ = owned_gr_context_.get(); gr_context_ = owned_gr_context_.get();
} else if (gr_context_type_ == GrContextType::kVulkan) {
#if BUILDFLAG(ENABLE_VULKAN)
DCHECK(vk_context_provider_);
// TODO(vasilyt): Remove this if there is no problem with caching.
if (!base::FeatureList::IsEnabled(features::kEnableGrShaderCacheForVulkan))
options.fPersistentCache = nullptr;
if (!vk_context_provider_->InitializeGrContext(options)) {
LOG(ERROR) << "OOP raster support disabled: GrContext creation failed.";
return false;
}
gr_context_ = vk_context_provider_->GetGrContext();
DCHECK(gr_context_);
#endif
} }
if (!gr_context_) { if (!gr_context_) {
......
...@@ -123,10 +123,6 @@ const base::Feature kSkiaDawn{"SkiaDawn", base::FEATURE_DISABLED_BY_DEFAULT}; ...@@ -123,10 +123,6 @@ const base::Feature kSkiaDawn{"SkiaDawn", base::FEATURE_DISABLED_BY_DEFAULT};
const base::Feature kEnableSharedImageForWebview{ const base::Feature kEnableSharedImageForWebview{
"EnableSharedImageForWebview", base::FEATURE_ENABLED_BY_DEFAULT}; "EnableSharedImageForWebview", base::FEATURE_ENABLED_BY_DEFAULT};
// Enable GrShaderCache to use with Vulkan backend.
const base::Feature kEnableGrShaderCacheForVulkan{
"EnableGrShaderCacheForVulkan", base::FEATURE_ENABLED_BY_DEFAULT};
bool IsUsingVulkan() { bool IsUsingVulkan() {
bool enable = base::FeatureList::IsEnabled(kVulkan); bool enable = base::FeatureList::IsEnabled(kVulkan);
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
......
...@@ -53,8 +53,6 @@ GPU_EXPORT extern const base::Feature kSkiaDawn; ...@@ -53,8 +53,6 @@ GPU_EXPORT extern const base::Feature kSkiaDawn;
GPU_EXPORT extern const base::Feature kEnableSharedImageForWebview; GPU_EXPORT extern const base::Feature kEnableSharedImageForWebview;
GPU_EXPORT extern const base::Feature kEnableGrShaderCacheForVulkan;
GPU_EXPORT bool IsUsingVulkan(); GPU_EXPORT bool IsUsingVulkan();
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
GPU_EXPORT bool IsAImageReaderEnabled(); GPU_EXPORT bool IsAImageReaderEnabled();
......
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