LibCore+LibGfx+LibWeb: Move VulkanContext into LibGfx

Since the Vulkan context is currently only used by LibGfx, it could be
moved there to avoid having Vulkan as a dependency for everything that
uses LibCore.
This commit is contained in:
Aliaksandr Kalenik 2024-09-26 17:27:58 +02:00 committed by Alexander Kalenik
parent c4bc4fc5f6
commit ab9ecbd79d
Notes: github-actions[bot] 2024-11-07 12:49:19 +00:00
8 changed files with 22 additions and 24 deletions

View file

@ -1,5 +1,3 @@
include(vulkan)
# These are the minimal set of sources needed to build the code generators. We separate them to allow
# LibCore to depend on generated sources.
set(SOURCES
@ -81,10 +79,6 @@ else()
)
endif()
if (HAS_VULKAN)
list(APPEND SOURCES VulkanContext.cpp)
endif()
if (APPLE OR CMAKE_SYSTEM_NAME STREQUAL "GNU")
list(APPEND SOURCES MachPort.cpp)
endif()
@ -107,7 +101,3 @@ endif()
if (ANDROID)
target_link_libraries(LibCore PRIVATE log)
endif()
if (HAS_VULKAN)
target_link_libraries(LibCore PUBLIC Vulkan::Vulkan Vulkan::Headers)
endif()

View file

@ -74,6 +74,10 @@ if (APPLE)
list(APPEND SOURCES MetalContext.mm)
endif()
if (HAS_VULKAN)
list(APPEND SOURCES VulkanContext.cpp)
endif()
serenity_lib(LibGfx gfx)
target_link_libraries(LibGfx PRIVATE LibCompress LibCore LibCrypto LibFileSystem LibRIFF LibTextCodec LibIPC LibUnicode LibURL)
@ -137,3 +141,7 @@ endif()
if (APPLE)
target_link_libraries(LibCore PUBLIC "-framework Metal")
endif()
if (HAS_VULKAN)
target_link_libraries(LibCore PUBLIC Vulkan::Vulkan Vulkan::Headers)
endif()

View file

@ -58,7 +58,7 @@ private:
NonnullOwnPtr<skgpu::VulkanExtensions> m_extensions;
};
RefPtr<SkiaBackendContext> SkiaBackendContext::create_vulkan_context(Core::VulkanContext& vulkan_context)
RefPtr<SkiaBackendContext> SkiaBackendContext::create_vulkan_context(Gfx::VulkanContext& vulkan_context)
{
skgpu::VulkanBackendContext backend_context;

View file

@ -14,7 +14,7 @@
#endif
#ifdef USE_VULKAN
# include <LibCore/VulkanContext.h>
# include <LibGfx/VulkanContext.h>
#endif
class GrDirectContext;
@ -28,7 +28,7 @@ class SkiaBackendContext : public RefCounted<SkiaBackendContext> {
public:
#ifdef USE_VULKAN
static RefPtr<SkiaBackendContext> create_vulkan_context(Core::VulkanContext&);
static RefPtr<SkiaBackendContext> create_vulkan_context(Gfx::VulkanContext&);
#endif
#ifdef AK_OS_MACOS

View file

@ -6,9 +6,9 @@
#include <AK/Format.h>
#include <AK/Vector.h>
#include <LibCore/VulkanContext.h>
#include <LibGfx/VulkanContext.h>
namespace Core {
namespace Gfx {
static ErrorOr<VkInstance> create_instance(uint32_t api_version)
{

View file

@ -6,15 +6,13 @@
#pragma once
#if !defined(USE_VULKAN)
static_assert(false, "This file must only be used when Vulkan is available");
#endif
#ifdef USE_VULKAN
#include <AK/Forward.h>
#include <AK/Function.h>
#include <vulkan/vulkan.h>
# include <AK/Forward.h>
# include <AK/Function.h>
# include <vulkan/vulkan.h>
namespace Core {
namespace Gfx {
struct VulkanContext {
uint32_t api_version { VK_API_VERSION_1_0 };
@ -27,3 +25,5 @@ struct VulkanContext {
ErrorOr<VulkanContext> create_vulkan_context();
}
#endif

View file

@ -39,7 +39,7 @@ TraversableNavigable::TraversableNavigable(JS::NonnullGCPtr<Page> page)
#ifdef USE_VULKAN
auto display_list_player_type = page->client().display_list_player_type();
if (display_list_player_type == DisplayListPlayerType::SkiaGPUIfAvailable) {
auto maybe_vulkan_context = Core::create_vulkan_context();
auto maybe_vulkan_context = Gfx::create_vulkan_context();
if (!maybe_vulkan_context.is_error()) {
auto vulkan_context = maybe_vulkan_context.release_value();
m_skia_backend_context = Gfx::SkiaBackendContext::create_vulkan_context(vulkan_context);

View file

@ -20,7 +20,7 @@
#endif
#ifdef USE_VULKAN
# include <LibCore/VulkanContext.h>
# include <LibGfx/VulkanContext.h>
#endif
namespace Web::HTML {