Commit 3adb34ca authored by Maksim Sisov's avatar Maksim Sisov Committed by Commit Bot

X11 and Ozone: //gpu: choose code path with IsUsingOzonePlatform

This patch adds for usage of ozone platform in //gpu.
And changes the following patterns:

#ifdef(USE_X11)
DoXxx();
#endif

to

#ifdef(USE_X11)
if (!IsUsingOzonePlatform())
  DoXxx();
#endif

and

#ifdef(USE_OZONE)
DoXxx();
#endif

to

#ifdef(USE_OZONE)
if (IsUsingOzonePlatform())
  DoXxx();
#endif

-----

Please note that this ugliness is added temporarily and
will be removed as soon as use_x11 is removed (hopefully
by Q1 2021 depending on how the finch trial goes).

Please also note that it's impossible to build use_x11 && use_ozone
without some hacks in PlatformCursor code. The changes to that are
on their way to upstream.

----

Bug: 1085700
Change-Id: Ic947aae6d6f78d9ae037ee610ab9c0605a28ff8d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2250204Reviewed-by: default avatarScott Violet <sky@chromium.org>
Reviewed-by: default avatarZhenyao Mo <zmo@chromium.org>
Reviewed-by: default avatarPeng Huang <penghuang@chromium.org>
Reviewed-by: default avatarTom Sepez <tsepez@chromium.org>
Reviewed-by: default avatarDaniele Castagna <dcastagna@chromium.org>
Commit-Queue: Maksim Sisov <msisov@igalia.com>
Cr-Commit-Position: refs/heads/master@{#783028}
parent dfb8f495
......@@ -160,6 +160,10 @@ if (!use_static_angle) {
if (is_linux && !is_component_build) {
configs += [ "//build/config/gcc:rpath_for_built_shared_libraries" ]
}
if (use_ozone) {
deps += [ "//ui/base:features" ]
}
}
} # if (!use_static_angle)
......@@ -698,7 +702,10 @@ test("gpu_perftests") {
]
if (use_ozone) {
deps += [ "//ui/ozone" ]
deps += [
"//ui/base:features",
"//ui/ozone",
]
}
data_deps = [
......@@ -732,7 +739,10 @@ test("command_buffer_perftests") {
]
if (use_ozone) {
deps += [ "//ui/ozone" ]
deps += [
"//ui/base:features",
"//ui/ozone",
]
}
data_deps = [
......
......@@ -12,4 +12,5 @@ include_rules = [
"+ui/gl",
"+ui/surface",
"+ui/ozone/public",
"+ui/base/ui_base_features.h",
]
......@@ -370,6 +370,9 @@ target(link_target_type, "gles2_sources") {
"shared_image_representation_dawn_ozone.h",
]
}
if (use_x11) {
deps += [ "//ui/base:features" ]
}
}
if (use_dawn) {
......
......@@ -27,6 +27,10 @@
#include "ui/gl/gl_implementation.h"
#include "ui/gl/trace_util.h"
#if defined(USE_X11) && BUILDFLAG(ENABLE_VULKAN)
#include "ui/base/ui_base_features.h" // nogncheck
#endif
#if (defined(USE_X11) || defined(OS_FUCHSIA) || defined(OS_WIN)) && \
BUILDFLAG(ENABLE_VULKAN)
#include "gpu/command_buffer/service/external_vk_image_factory.h"
......@@ -95,8 +99,17 @@ SharedImageFactory::SharedImageFactory(
}
// For X11
#if (defined(USE_X11) || defined(OS_FUCHSIA) || defined(OS_WIN)) && \
BUILDFLAG(ENABLE_VULKAN)
#if defined(USE_X11) && BUILDFLAG(ENABLE_VULKAN)
if (!features::IsUsingOzonePlatform()) {
if (using_vulkan_) {
interop_backing_factory_ =
std::make_unique<ExternalVkImageFactory>(context_state);
}
} else if (using_vulkan_) {
LOG(ERROR) << "ERROR: using_vulkan_ = true and interop_backing_factory_ is "
"not set";
}
#elif (defined(OS_FUCHSIA) || defined(OS_WIN)) && BUILDFLAG(ENABLE_VULKAN)
if (using_vulkan_) {
interop_backing_factory_ =
std::make_unique<ExternalVkImageFactory>(context_state);
......
......@@ -13,17 +13,22 @@
#include "testing/gmock/include/gmock/gmock.h"
#include "gpu/gles2_conform_support/egl/test_support.h" // NOLINT
#if defined(USE_OZONE)
#include "ui/base/ui_base_features.h" // nogncheck
#endif
// This file implements the main entry point for tests for command_buffer_gles2,
// the mode of command buffer where the code is compiled as a standalone dynamic
// library and exposed through EGL API.
namespace {
int RunHelper(base::TestSuite* testSuite) {
base::MessagePumpType pump_type = base::MessagePumpType::IO;
#if defined(USE_OZONE)
base::SingleThreadTaskExecutor executor(base::MessagePumpType::UI);
#else
base::SingleThreadTaskExecutor executor(base::MessagePumpType::IO);
if (features::IsUsingOzonePlatform())
pump_type = base::MessagePumpType::UI;
#endif
base::SingleThreadTaskExecutor executor(pump_type);
return testSuite->Run();
}
......
......@@ -21,6 +21,7 @@
#endif
#if defined(USE_OZONE)
#include "ui/base/ui_base_features.h"
#include "ui/ozone/public/ozone_platform.h"
#endif
......@@ -37,14 +38,16 @@ class GlTestsSuite : public base::TestSuite {
task_environment_ = std::make_unique<base::test::TaskEnvironment>(
base::test::TaskEnvironment::MainThreadType::UI);
#if defined(USE_OZONE)
// Make Ozone run in single-process mode.
ui::OzonePlatform::InitParams params;
params.single_process = true;
if (features::IsUsingOzonePlatform()) {
// Make Ozone run in single-process mode.
ui::OzonePlatform::InitParams params;
params.single_process = true;
// This initialization must be done after TaskEnvironment has
// initialized the UI thread.
ui::OzonePlatform::InitializeForUI(params);
ui::OzonePlatform::InitializeForGPU(params);
// This initialization must be done after TaskEnvironment has
// initialized the UI thread.
ui::OzonePlatform::InitializeForUI(params);
ui::OzonePlatform::InitializeForGPU(params);
}
#endif
gpu::GLTestHelper::InitializeGLDefault();
......
......@@ -220,6 +220,9 @@ jumbo_source_set("config_sources") {
deps += [ "//third_party/angle:angle_gpu_info_util" ]
}
if (use_x11) {
deps += [ "//ui/gfx/linux:gpu_memory_buffer_support_x11" ]
deps += [
"//ui/base:features",
"//ui/gfx/linux:gpu_memory_buffer_support_x11",
]
}
}
......@@ -35,6 +35,7 @@
#include "ui/gl/init/gl_factory.h"
#if defined(USE_X11)
#include "ui/base/ui_base_features.h" // nogncheck
#include "ui/gfx/linux/gpu_memory_buffer_support_x11.h"
#include "ui/gfx/switches.h"
#include "ui/gl/gl_visual_picker_glx.h"
......@@ -497,6 +498,8 @@ bool CollectGpuExtraInfo(GpuExtraInfo* gpu_extra_info,
}
#if defined(USE_X11)
if (features::IsUsingOzonePlatform())
return true;
// Create the GLVisualPickerGLX singleton now while the GbmSupportX11
// singleton is busy being created on another thread.
gl::GLVisualPickerGLX* visual_picker;
......
......@@ -16,6 +16,7 @@
#include "ui/gfx/native_pixmap.h"
#if defined(USE_OZONE)
#include "ui/base/ui_base_features.h"
#include "ui/ozone/public/ozone_platform.h"
#include "ui/ozone/public/surface_factory_ozone.h"
#endif
......@@ -70,18 +71,20 @@ base::OnceClosure GpuMemoryBufferImplNativePixmap::AllocateForTesting(
gfx::BufferFormat format,
gfx::BufferUsage usage,
gfx::GpuMemoryBufferHandle* handle) {
#if defined(USE_OZONE)
scoped_refptr<gfx::NativePixmap> pixmap =
ui::OzonePlatform::GetInstance()
->GetSurfaceFactoryOzone()
->CreateNativePixmap(gfx::kNullAcceleratedWidget, VK_NULL_HANDLE,
size, format, usage);
handle->native_pixmap_handle = pixmap->ExportHandle();
#else
// TODO(j.isorce): use gbm_bo_create / gbm_bo_get_fd from system libgbm.
scoped_refptr<gfx::NativePixmap> pixmap;
NOTIMPLEMENTED();
#if defined(USE_OZONE)
if (features::IsUsingOzonePlatform()) {
pixmap = ui::OzonePlatform::GetInstance()
->GetSurfaceFactoryOzone()
->CreateNativePixmap(gfx::kNullAcceleratedWidget,
VK_NULL_HANDLE, size, format, usage);
handle->native_pixmap_handle = pixmap->ExportHandle();
} else
#endif
{
// TODO(j.isorce): use gbm_bo_create / gbm_bo_get_fd from system libgbm.
NOTIMPLEMENTED();
}
handle->type = gfx::NATIVE_PIXMAP;
return base::BindOnce(&FreeNativePixmapForTesting, pixmap);
}
......
......@@ -38,6 +38,10 @@
#include "gpu/ipc/common/gpu_memory_buffer_impl_android_hardware_buffer.h"
#endif
#if defined(USE_X11)
#include "ui/base/ui_base_features.h"
#endif
namespace gpu {
GpuMemoryBufferSupport::GpuMemoryBufferSupport() {
......@@ -151,10 +155,10 @@ bool GpuMemoryBufferSupport::IsConfigurationSupportedForTest(
if (type == GetNativeGpuMemoryBufferType()) {
#if defined(USE_X11)
// On X11, we require GPUInfo to determine configuration support.
return false;
#else
return IsNativeGpuMemoryBufferConfigurationSupported(format, usage);
if (!features::IsUsingOzonePlatform())
return false;
#endif
return IsNativeGpuMemoryBufferConfigurationSupported(format, usage);
}
if (type == gfx::SHARED_MEMORY_BUFFER) {
......
......@@ -14,6 +14,7 @@
#if defined(USE_OZONE)
#include "base/message_loop/message_pump_type.h"
#include "mojo/public/cpp/base/message_pump_type_mojom_traits.h"
#include "ui/base/ui_base_features.h"
#endif
namespace mojo {
......
......@@ -17,6 +17,7 @@ source_set("host") {
"//gpu/config",
"//gpu/ipc/common",
"//net",
"//ui/base:features",
"//ui/gfx",
"//ui/gl",
]
......
......@@ -7,6 +7,7 @@
#include "build/build_config.h"
#include "gpu/command_buffer/common/gpu_memory_buffer_support.h"
#include "gpu/ipc/common/gpu_memory_buffer_support.h"
#include "ui/base/ui_base_features.h"
#include "ui/gl/gl_bindings.h"
namespace gpu {
......@@ -17,6 +18,10 @@ GpuMemoryBufferConfigurationSet GetNativeGpuMemoryBufferConfigurations(
#if defined(USE_OZONE) || defined(OS_MACOSX) || defined(OS_WIN) || \
defined(OS_ANDROID)
#if defined(USE_OZONE)
if (!features::IsUsingOzonePlatform())
return configurations;
#endif
const gfx::BufferFormat kBufferFormats[] = {
gfx::BufferFormat::R_8, gfx::BufferFormat::R_16,
gfx::BufferFormat::RG_88, gfx::BufferFormat::BGR_565,
......
......@@ -87,6 +87,7 @@
#endif
#if defined(USE_OZONE)
#include "ui/base/ui_base_features.h"
#include "ui/ozone/public/ozone_platform.h"
#include "ui/ozone/public/platform_window_surface.h"
#include "ui/ozone/public/surface_factory_ozone.h"
......@@ -450,7 +451,8 @@ gpu::ContextResult InProcessCommandBuffer::InitializeOnGpuThread(
break;
}
#if defined(USE_OZONE)
if (params.surface_handle != gpu::kNullSurfaceHandle) {
if (features::IsUsingOzonePlatform() &&
params.surface_handle != gpu::kNullSurfaceHandle) {
window_surface_ =
ui::OzonePlatform::GetInstance()
->GetSurfaceFactoryOzone()
......
......@@ -40,6 +40,7 @@
#endif
#if defined(USE_OZONE)
#include "ui/base/ui_base_features.h"
#include "ui/ozone/public/ozone_platform.h"
#include "ui/ozone/public/surface_factory_ozone.h"
#endif
......@@ -291,13 +292,11 @@ bool GpuInit::InitializeAndStartSandbox(base::CommandLine* command_line,
#if defined(USE_OZONE)
// Initialize Ozone GPU after the watchdog in case it hangs. The sandbox
// may also have started at this point.
ui::OzonePlatform::InitParams params;
params.single_process = false;
ui::OzonePlatform::InitializeForGPU(params);
const std::vector<gfx::BufferFormat> supported_buffer_formats_for_texturing =
ui::OzonePlatform::GetInstance()
->GetSurfaceFactoryOzone()
->GetSupportedFormatsForTexturing();
if (features::IsUsingOzonePlatform()) {
ui::OzonePlatform::InitParams params;
params.single_process = false;
ui::OzonePlatform::InitializeForGPU(params);
}
#endif
if (!gl_use_swiftshader_) {
......@@ -558,12 +557,16 @@ bool GpuInit::InitializeAndStartSandbox(base::CommandLine* command_line,
init_successful_ = true;
#if defined(USE_OZONE)
ui::OzonePlatform::GetInstance()->AfterSandboxEntry();
#endif
#if defined(USE_OZONE)
gpu_feature_info_.supported_buffer_formats_for_allocation_and_texturing =
std::move(supported_buffer_formats_for_texturing);
if (features::IsUsingOzonePlatform()) {
ui::OzonePlatform::GetInstance()->AfterSandboxEntry();
const std::vector<gfx::BufferFormat>
supported_buffer_formats_for_texturing =
ui::OzonePlatform::GetInstance()
->GetSurfaceFactoryOzone()
->GetSupportedFormatsForTexturing();
gpu_feature_info_.supported_buffer_formats_for_allocation_and_texturing =
std::move(supported_buffer_formats_for_texturing);
}
#endif
if (!watchdog_thread_)
......@@ -595,13 +598,11 @@ void GpuInit::InitializeInProcess(base::CommandLine* command_line,
gpu_preferences_ = gpu_preferences;
init_successful_ = true;
#if defined(USE_OZONE)
ui::OzonePlatform::InitParams params;
params.single_process = true;
ui::OzonePlatform::InitializeForGPU(params);
const std::vector<gfx::BufferFormat> supported_buffer_formats_for_texturing =
ui::OzonePlatform::GetInstance()
->GetSurfaceFactoryOzone()
->GetSupportedFormatsForTexturing();
if (features::IsUsingOzonePlatform()) {
ui::OzonePlatform::InitParams params;
params.single_process = true;
ui::OzonePlatform::InitializeForGPU(params);
}
#endif
bool needs_more_info = true;
#if !BUILDFLAG(IS_CHROMECAST)
......@@ -694,8 +695,15 @@ void GpuInit::InitializeInProcess(base::CommandLine* command_line,
}
#if defined(USE_OZONE)
gpu_feature_info_.supported_buffer_formats_for_allocation_and_texturing =
std::move(supported_buffer_formats_for_texturing);
if (features::IsUsingOzonePlatform()) {
const std::vector<gfx::BufferFormat>
supported_buffer_formats_for_texturing =
ui::OzonePlatform::GetInstance()
->GetSurfaceFactoryOzone()
->GetSupportedFormatsForTexturing();
gpu_feature_info_.supported_buffer_formats_for_allocation_and_texturing =
std::move(supported_buffer_formats_for_texturing);
}
#endif
DisableInProcessGpuVulkan(&gpu_feature_info_, &gpu_preferences_);
......
......@@ -4,6 +4,7 @@
#include "gpu/ipc/service/gpu_memory_buffer_factory_native_pixmap.h"
#include "build/build_config.h"
#include "components/viz/common/gpu/vulkan_context_provider.h"
#include "gpu/command_buffer/common/gpu_memory_buffer_support.h"
#include "gpu/vulkan/vulkan_device_queue.h"
......@@ -17,6 +18,10 @@
#include "ui/gl/gl_image_native_pixmap.h"
#include "ui/gl/gl_implementation.h"
#if defined(USE_X11) || defined(USE_OZONE)
#include "ui/base/ui_base_features.h"
#endif
#if defined(USE_OZONE)
#include "ui/ozone/public/ozone_platform.h"
#include "ui/ozone/public/surface_factory_ozone.h"
......@@ -68,14 +73,19 @@ GpuMemoryBufferFactoryNativePixmap::CreateGpuMemoryBuffer(
int client_id,
SurfaceHandle surface_handle) {
#if defined(USE_OZONE)
scoped_refptr<gfx::NativePixmap> pixmap =
ui::OzonePlatform::GetInstance()
->GetSurfaceFactoryOzone()
->CreateNativePixmap(surface_handle, GetVulkanDevice(), size, format,
usage);
return CreateGpuMemoryBufferFromNativePixmap(id, size, format, usage,
client_id, std::move(pixmap));
#elif defined(USE_X11)
if (features::IsUsingOzonePlatform()) {
scoped_refptr<gfx::NativePixmap> pixmap =
ui::OzonePlatform::GetInstance()
->GetSurfaceFactoryOzone()
->CreateNativePixmap(surface_handle, GetVulkanDevice(), size,
format, usage);
return CreateGpuMemoryBufferFromNativePixmap(id, size, format, usage,
client_id, std::move(pixmap));
}
#endif
#if defined(USE_X11)
DCHECK(!features::IsUsingOzonePlatform());
std::unique_ptr<ui::GbmBuffer> buffer =
ui::GpuMemoryBufferSupportX11::GetInstance()->CreateBuffer(format, size,
usage);
......@@ -102,15 +112,20 @@ void GpuMemoryBufferFactoryNativePixmap::CreateGpuMemoryBufferAsync(
SurfaceHandle surface_handle,
CreateGpuMemoryBufferAsyncCallback callback) {
#if defined(USE_OZONE)
ui::OzonePlatform::GetInstance()
->GetSurfaceFactoryOzone()
->CreateNativePixmapAsync(
surface_handle, GetVulkanDevice(), size, format, usage,
base::BindOnce(
&GpuMemoryBufferFactoryNativePixmap::OnNativePixmapCreated, id,
size, format, usage, client_id, std::move(callback),
weak_factory_.GetWeakPtr()));
#elif defined(USE_X11)
if (features::IsUsingOzonePlatform()) {
ui::OzonePlatform::GetInstance()
->GetSurfaceFactoryOzone()
->CreateNativePixmapAsync(
surface_handle, GetVulkanDevice(), size, format, usage,
base::BindOnce(
&GpuMemoryBufferFactoryNativePixmap::OnNativePixmapCreated, id,
size, format, usage, client_id, std::move(callback),
weak_factory_.GetWeakPtr()));
return;
}
#endif
#if defined(USE_X11)
std::move(callback).Run(CreateGpuMemoryBuffer(id, size, format, usage,
client_id, surface_handle));
#else
......@@ -156,17 +171,23 @@ GpuMemoryBufferFactoryNativePixmap::CreateImageForGpuMemoryBuffer(
// Create new pixmap from handle if one doesn't already exist.
if (!pixmap) {
#if defined(USE_OZONE)
pixmap = ui::OzonePlatform::GetInstance()
->GetSurfaceFactoryOzone()
->CreateNativePixmapFromHandle(
surface_handle, size, format,
std::move(handle.native_pixmap_handle));
#else
DCHECK_EQ(surface_handle, gpu::kNullSurfaceHandle);
pixmap = base::WrapRefCounted(new gfx::NativePixmapDmaBuf(
size, format, std::move(handle.native_pixmap_handle)));
if (features::IsUsingOzonePlatform()) {
pixmap = ui::OzonePlatform::GetInstance()
->GetSurfaceFactoryOzone()
->CreateNativePixmapFromHandle(
surface_handle, size, format,
std::move(handle.native_pixmap_handle));
}
#endif
#if !defined(OS_FUCHSIA)
if (!pixmap) {
DCHECK_EQ(surface_handle, gpu::kNullSurfaceHandle);
pixmap = base::WrapRefCounted(new gfx::NativePixmapDmaBuf(
size, format, std::move(handle.native_pixmap_handle)));
}
#endif
if (!pixmap.get()) {
if (!pixmap) {
DLOG(ERROR) << "Failed to create pixmap from handle";
return nullptr;
}
......@@ -180,6 +201,12 @@ GpuMemoryBufferFactoryNativePixmap::CreateImageForGpuMemoryBuffer(
pixmap);
#if defined(USE_X11)
case gl::kGLImplementationDesktopGL:
#if defined(USE_OZONE)
if (features::IsUsingOzonePlatform()) {
NOTREACHED();
return nullptr;
}
#endif
// GLX
return CreateImageFromPixmap<gl::GLImageGLXNativePixmap>(size, format,
pixmap);
......@@ -192,10 +219,10 @@ GpuMemoryBufferFactoryNativePixmap::CreateImageForGpuMemoryBuffer(
bool GpuMemoryBufferFactoryNativePixmap::SupportsCreateAnonymousImage() const {
#if defined(USE_OZONE)
return true;
#else
return false;
if (features::IsUsingOzonePlatform())
return true;
#endif
return false;
}
scoped_refptr<gl::GLImage>
......@@ -207,10 +234,12 @@ GpuMemoryBufferFactoryNativePixmap::CreateAnonymousImage(
bool* is_cleared) {
scoped_refptr<gfx::NativePixmap> pixmap;
#if defined(USE_OZONE)
pixmap = ui::OzonePlatform::GetInstance()
->GetSurfaceFactoryOzone()
->CreateNativePixmap(surface_handle, GetVulkanDevice(), size,
format, usage);
if (features::IsUsingOzonePlatform()) {
pixmap = ui::OzonePlatform::GetInstance()
->GetSurfaceFactoryOzone()
->CreateNativePixmap(surface_handle, GetVulkanDevice(), size,
format, usage);
}
#else
NOTIMPLEMENTED();
#endif
......
......@@ -22,6 +22,10 @@
#include "ui/gl/test/gl_surface_test_support.h"
#endif
#if defined(USE_X11)
#include "ui/base/ui_base_features.h"
#endif
namespace gpu {
template <typename GpuMemoryBufferFactoryType>
......@@ -70,11 +74,11 @@ TYPED_TEST_P(GpuMemoryBufferFactoryTest, CreateGpuMemoryBuffer) {
for (auto usage : usages) {
#if defined(USE_X11)
// On X11, we require GPUInfo to determine configuration support.
continue;
#else
if (!support.IsNativeGpuMemoryBufferConfigurationSupported(format, usage))
if (!features::IsUsingOzonePlatform())
continue;
#endif
if (!support.IsNativeGpuMemoryBufferConfigurationSupported(format, usage))
continue;
gfx::GpuMemoryBufferHandle handle =
TestFixture::factory_.CreateGpuMemoryBuffer(kBufferId, buffer_size,
......
......@@ -13,19 +13,27 @@
#include "ui/gl/init/gl_factory.h"
#if defined(USE_OZONE)
#include "ui/base/ui_base_features.h" // nogncheck
#include "ui/ozone/public/ozone_platform.h"
#endif
static int RunHelper(base::TestSuite* test_suite) {
base::FeatureList::InitializeInstance(std::string(), std::string());
std::unique_ptr<base::SingleThreadTaskExecutor> executor;
#if defined(USE_OZONE)
base::SingleThreadTaskExecutor executor(base::MessagePumpType::UI);
ui::OzonePlatform::InitParams params;
params.single_process = true;
ui::OzonePlatform::InitializeForGPU(params);
#else
base::SingleThreadTaskExecutor executor(base::MessagePumpType::IO);
if (features::IsUsingOzonePlatform()) {
executor = std::make_unique<base::SingleThreadTaskExecutor>(
base::MessagePumpType::UI);
ui::OzonePlatform::InitParams params;
params.single_process = true;
ui::OzonePlatform::InitializeForGPU(params);
} else
#endif
{
executor = std::make_unique<base::SingleThreadTaskExecutor>(
base::MessagePumpType::IO);
}
CHECK(gl::init::InitializeGLOneOff());
return test_suite->Run();
}
......
......@@ -155,6 +155,9 @@ if (enable_vulkan) {
data_deps += [ "//third_party/fuchsia-sdk:vulkan_validation" ]
}
}
if (use_x11) {
deps += [ "//ui/base:features" ]
}
}
static_library("test_support") {
......
......@@ -30,7 +30,10 @@ component("init") {
deps += [ "//gpu/vulkan/android" ]
}
if (use_ozone) {
deps += [ "//ui/ozone" ]
deps += [
"//ui/base:features",
"//ui/ozone",
]
}
if (is_win) {
deps += [ "//gpu/vulkan/win32" ]
......
......@@ -20,6 +20,7 @@
#endif
#if defined(USE_OZONE)
#include "ui/base/ui_base_features.h" // nogncheck
#include "ui/ozone/public/ozone_platform.h"
#include "ui/ozone/public/surface_factory_ozone.h"
#endif
......@@ -41,6 +42,14 @@ std::unique_ptr<VulkanImplementation> CreateVulkanImplementation(
<< "Protected memory is not supported on this platform.";
#endif // !defined(OS_FUCHSIA)
#if defined(USE_X11)
#if defined(USE_OZONE)
if (features::IsUsingOzonePlatform()) {
return ui::OzonePlatform::GetInstance()
->GetSurfaceFactoryOzone()
->CreateVulkanImplementation(allow_protected_memory,
enforce_protected_memory);
}
#endif
return std::make_unique<VulkanImplementationX11>(use_swiftshader);
#elif defined(OS_ANDROID)
return std::make_unique<VulkanImplementationAndroid>();
......
......@@ -12,6 +12,7 @@
#include "ui/gfx/geometry/rect.h"
#if defined(USE_OZONE)
#include "ui/base/ui_base_features.h"
#include "ui/ozone/public/ozone_platform.h"
#endif
......@@ -24,9 +25,11 @@ BasicVulkanTest::~BasicVulkanTest() {}
void BasicVulkanTest::SetUp() {
bool supports_swapchain = true;
#if defined(USE_OZONE)
supports_swapchain = ui::OzonePlatform::GetInstance()
->GetPlatformProperties()
.supports_vulkan_swap_chain;
if (features::IsUsingOzonePlatform()) {
supports_swapchain = ui::OzonePlatform::GetInstance()
->GetPlatformProperties()
.supports_vulkan_swap_chain;
}
#endif
bool use_swiftshader =
......
......@@ -16,6 +16,10 @@
#include "gpu/vulkan/vulkan_device_queue.h"
#include "gpu/vulkan/vulkan_function_pointers.h"
#if defined(USE_X11)
#include "ui/base/ui_base_features.h" // nogncheck
#endif
namespace gpu {
namespace {
......@@ -457,6 +461,7 @@ bool VulkanSwapChain::AcquireNextImage() {
VkSemaphore vk_semaphore = CreateSemaphore(device);
DCHECK(vk_semaphore != VK_NULL_HANDLE);
uint64_t kTimeout = UINT64_MAX;
#if defined(USE_X11)
// The xserver should still composite windows with a 1Hz fake vblank when
// screen is off or the window is offscreen. However there is an xserver
......@@ -466,9 +471,10 @@ bool VulkanSwapChain::AcquireNextImage() {
// vkAcquireNextImageKHR(). When timeout happens, we consider the swapchain
// hang happened, and then make the surface lost, so a new swapchain will
// be recreated.
constexpr uint64_t kTimeout = base::Time::kNanosecondsPerSecond * 2;
#else
constexpr uint64_t kTimeout = UINT64_MAX;
//
// TODO(https://crbug.com/1098237): set correct timeout for ozone/x11.
if (!features::IsUsingOzonePlatform())
kTimeout = base::Time::kNanosecondsPerSecond * 2;
#endif
// Acquire the next image.
uint32_t next_image;
......
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