diff options
author | Peter Varga <pvarga@inf.u-szeged.hu> | 2023-01-10 15:12:39 +0100 |
---|---|---|
committer | Peter Varga <pvarga@inf.u-szeged.hu> | 2023-01-12 09:44:55 +0000 |
commit | d7abc8b24375a9093d2daae39b292be7c7ce84b7 (patch) | |
tree | 488f27752285390f00d2f9281749326d119e7b54 | |
parent | 4e5c881f1596ba27f43db1adeeb08e39a0f27544 (diff) | |
download | qtwebengine-chromium-d7abc8b24375a9093d2daae39b292be7c7ce84b7.tar.gz |
[Backport] Fix up guarding SharedImage factories using Vulkan
Bug: none
Change-Id: Ifafe188054714b1166e15680a61ec16923dc4b21
Review-URL: https://chromium-review.googlesource.com/c/chromium/src/+/4004619
Cr-Commit-Position: refs/heads/main@{#1070301}
Reviewed-on: https://codereview.qt-project.org/c/qt/qtwebengine-chromium/+/453117
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
4 files changed, 44 insertions, 27 deletions
diff --git a/chromium/gpu/command_buffer/service/BUILD.gn b/chromium/gpu/command_buffer/service/BUILD.gn index 6548a939cfb..49d6f750b79 100644 --- a/chromium/gpu/command_buffer/service/BUILD.gn +++ b/chromium/gpu/command_buffer/service/BUILD.gn @@ -372,6 +372,14 @@ target(link_target_type, "gles2_sources") { } if (use_ozone) { + sources += [ + "shared_image/gl_ozone_image_representation.cc", + "shared_image/gl_ozone_image_representation.h", + "shared_image/ozone_image_backing.cc", + "shared_image/ozone_image_backing.h", + "shared_image/ozone_image_backing_factory.cc", + "shared_image/ozone_image_backing_factory.h", + ] deps += [ "//ui/base:features", "//ui/ozone", @@ -413,12 +421,6 @@ target(link_target_type, "gles2_sources") { if (use_ozone) { sources += [ - "shared_image/gl_ozone_image_representation.cc", - "shared_image/gl_ozone_image_representation.h", - "shared_image/ozone_image_backing.cc", - "shared_image/ozone_image_backing.h", - "shared_image/ozone_image_backing_factory.cc", - "shared_image/ozone_image_backing_factory.h", "shared_image/skia_vk_ozone_image_representation.cc", "shared_image/skia_vk_ozone_image_representation.h", ] @@ -430,13 +432,6 @@ target(link_target_type, "gles2_sources") { "shared_image/external_vk_image_dawn_representation.h", ] } - - if (use_ozone && use_dawn) { - sources += [ - "shared_image/dawn_ozone_image_representation.cc", - "shared_image/dawn_ozone_image_representation.h", - ] - } } if (use_dawn) { @@ -452,6 +447,12 @@ target(link_target_type, "gles2_sources") { "shared_image/dawn_egl_image_representation.h", ] } + if (use_ozone) { + sources += [ + "shared_image/dawn_ozone_image_representation.cc", + "shared_image/dawn_ozone_image_representation.h", + ] + } } if (is_mac) { diff --git a/chromium/gpu/command_buffer/service/shared_image/ozone_image_backing.cc b/chromium/gpu/command_buffer/service/shared_image/ozone_image_backing.cc index 902081da5d4..d83cf1a8cbb 100644 --- a/chromium/gpu/command_buffer/service/shared_image/ozone_image_backing.cc +++ b/chromium/gpu/command_buffer/service/shared_image/ozone_image_backing.cc @@ -23,11 +23,8 @@ #include "gpu/command_buffer/service/shared_image/shared_image_manager.h" #include "gpu/command_buffer/service/shared_image/shared_image_representation.h" #include "gpu/command_buffer/service/shared_image/skia_gl_image_representation.h" -#include "gpu/command_buffer/service/shared_image/skia_vk_ozone_image_representation.h" #include "gpu/command_buffer/service/shared_memory_region_wrapper.h" #include "gpu/command_buffer/service/skia_utils.h" -#include "gpu/vulkan/vulkan_image.h" -#include "gpu/vulkan/vulkan_implementation.h" #include "third_party/skia/include/core/SkPromiseImageTexture.h" #include "third_party/skia/include/gpu/GrBackendSemaphore.h" #include "ui/gfx/buffer_format_util.h" @@ -42,6 +39,12 @@ #include "ui/gl/buildflags.h" #include "ui/gl/gl_image_native_pixmap.h" +#if BUILDFLAG(ENABLE_VULKAN) +#include "gpu/command_buffer/service/shared_image/skia_vk_ozone_image_representation.h" +#include "gpu/vulkan/vulkan_image.h" +#include "gpu/vulkan/vulkan_implementation.h" +#endif // BUILDFLAG(ENABLE_VULKAN) + #if BUILDFLAG(USE_DAWN) #include "gpu/command_buffer/service/shared_image/dawn_ozone_image_representation.h" #endif // BUILDFLAG(USE_DAWN) @@ -210,6 +213,7 @@ std::unique_ptr<SkiaImageRepresentation> OzoneImageBacking::ProduceSkia( return skia_representation; } if (context_state->GrContextIsVulkan()) { +#if BUILDFLAG(ENABLE_VULKAN) auto* device_queue = context_state->vk_context_provider()->GetDeviceQueue(); gfx::GpuMemoryBufferHandle gmb_handle; gmb_handle.type = gfx::GpuMemoryBufferType::NATIVE_PIXMAP; @@ -226,6 +230,10 @@ std::unique_ptr<SkiaImageRepresentation> OzoneImageBacking::ProduceSkia( return std::make_unique<SkiaVkOzoneImageRepresentation>( manager, this, std::move(context_state), std::move(vulkan_image), tracker); +#else + NOTREACHED() << "Vulkan is disabled."; + return nullptr; +#endif } NOTIMPLEMENTED_LOG_ONCE(); return nullptr; diff --git a/chromium/gpu/command_buffer/service/shared_image/ozone_image_backing_factory.cc b/chromium/gpu/command_buffer/service/shared_image/ozone_image_backing_factory.cc index 45bd32c8402..ba785a88c5e 100644 --- a/chromium/gpu/command_buffer/service/shared_image/ozone_image_backing_factory.cc +++ b/chromium/gpu/command_buffer/service/shared_image/ozone_image_backing_factory.cc @@ -12,14 +12,12 @@ #include "build/build_config.h" #include "build/chromecast_buildflags.h" #include "build/chromeos_buildflags.h" -#include "components/viz/common/gpu/vulkan_context_provider.h" #include "components/viz/common/resources/resource_format_utils.h" #include "gpu/command_buffer/common/gpu_memory_buffer_support.h" #include "gpu/command_buffer/common/shared_image_usage.h" #include "gpu/command_buffer/service/service_utils.h" #include "gpu/command_buffer/service/shared_image/ozone_image_backing.h" #include "gpu/command_buffer/service/shared_memory_region_wrapper.h" -#include "gpu/vulkan/vulkan_device_queue.h" #include "ui/gfx/gpu_memory_buffer.h" #include "ui/gfx/native_pixmap.h" #include "ui/gl/buildflags.h" @@ -28,6 +26,11 @@ #include "ui/ozone/public/ozone_platform.h" #include "ui/ozone/public/surface_factory_ozone.h" +#if BUILDFLAG(ENABLE_VULKAN) +#include "components/viz/common/gpu/vulkan_context_provider.h" +#include "gpu/vulkan/vulkan_device_queue.h" +#endif // BUILDFLAG(ENABLE_VULKAN) + namespace gpu { namespace { @@ -72,11 +75,13 @@ OzoneImageBackingFactory::CreateSharedImageInternal( uint32_t usage) { gfx::BufferFormat buffer_format = viz::BufferFormat(format); VulkanDeviceQueue* device_queue = nullptr; +#if BUILDFLAG(ENABLE_VULKAN) DCHECK(shared_context_state_); if (shared_context_state_->vk_context_provider()) { device_queue = shared_context_state_->vk_context_provider()->GetDeviceQueue(); } +#endif // BUILDFLAG(ENABLE_VULKAN) ui::SurfaceFactoryOzone* surface_factory = ui::OzonePlatform::GetInstance()->GetSurfaceFactoryOzone(); scoped_refptr<gfx::NativePixmap> pixmap = surface_factory->CreateNativePixmap( @@ -233,6 +238,7 @@ bool OzoneImageBackingFactory::IsSupported( } bool OzoneImageBackingFactory::CanImportNativePixmapToVulkan() { +#if BUILDFLAG(ENABLE_VULKAN) if (!shared_context_state_->vk_context_provider()) { return false; } @@ -241,6 +247,9 @@ bool OzoneImageBackingFactory::CanImportNativePixmapToVulkan() { return shared_context_state_->vk_context_provider() ->GetVulkanImplementation() ->CanImportGpuMemoryBuffer(vk_device, gfx::NATIVE_PIXMAP); +#else + return false; +#endif // BUILDFLAG(ENABLE_VULKAN) } bool OzoneImageBackingFactory::CanImportNativePixmapToWebGPU() { diff --git a/chromium/gpu/command_buffer/service/shared_image/shared_image_factory.cc b/chromium/gpu/command_buffer/service/shared_image/shared_image_factory.cc index 17fa2bd464f..876861acd42 100644 --- a/chromium/gpu/command_buffer/service/shared_image/shared_image_factory.cc +++ b/chromium/gpu/command_buffer/service/shared_image/shared_image_factory.cc @@ -41,7 +41,7 @@ #include "gpu/command_buffer/service/shared_image/angle_vulkan_image_backing_factory.h" #include "gpu/command_buffer/service/shared_image/external_vk_image_backing_factory.h" #include "gpu/vulkan/vulkan_device_queue.h" -#endif +#endif // BUILDFLAG(ENABLE_VULKAN) #if defined(USE_OZONE) #include "gpu/command_buffer/service/shared_image/ozone_image_backing_factory.h" @@ -50,9 +50,7 @@ #include "ui/ozone/public/surface_factory_ozone.h" #endif -#if BUILDFLAG(IS_ANDROID) && BUILDFLAG(ENABLE_VULKAN) -#include "gpu/command_buffer/service/shared_image/ahardwarebuffer_image_backing_factory.h" -#elif BUILDFLAG(IS_MAC) +#if BUILDFLAG(IS_MAC) #include "gpu/command_buffer/service/shared_image/iosurface_image_backing_factory.h" #endif @@ -70,6 +68,7 @@ #if BUILDFLAG(IS_ANDROID) #include "base/android/android_hardware_buffer_compat.h" +#include "gpu/command_buffer/service/shared_image/ahardwarebuffer_image_backing_factory.h" #include "gpu/command_buffer/service/shared_image/egl_image_backing_factory.h" #endif @@ -208,15 +207,17 @@ SharedImageFactory::SharedImageFactory( gpu_preferences, workarounds, context_state); factories_.push_back(std::move(factory)); } -#endif -#if BUILDFLAG(IS_WIN) && BUILDFLAG(ENABLE_VULKAN) +#if BUILDFLAG(IS_WIN) if (gr_context_type_ == GrContextType::kVulkan) { auto external_vk_image_factory = std::make_unique<ExternalVkImageBackingFactory>(context_state); factories_.push_back(std::move(external_vk_image_factory)); } -#elif BUILDFLAG(IS_ANDROID) +#endif // BUILDFLAG(IS_WIN) +#endif // BUILDFLAG(ENABLE_VULKAN) + +#if BUILDFLAG(IS_ANDROID) if (use_gl) { auto egl_backing_factory = std::make_unique<EGLImageBackingFactory>( gpu_preferences, workarounds, feature_info.get()); @@ -239,14 +240,12 @@ SharedImageFactory::SharedImageFactory( feature_info.get()); factories_.push_back(std::move(ahb_factory)); } -#if BUILDFLAG(ENABLE_VULKAN) if (gr_context_type_ == GrContextType::kVulkan && !base::FeatureList::IsEnabled(features::kVulkanFromANGLE)) { auto external_vk_image_factory = std::make_unique<ExternalVkImageBackingFactory>(context_state); factories_.push_back(std::move(external_vk_image_factory)); } -#endif // BUILDFLAG(ENABLE_VULKAN) #elif defined(USE_OZONE) // For all Ozone platforms - Desktop Linux, ChromeOS, Fuchsia, CastOS. if (ui::OzonePlatform::GetInstance() |