From 4ddada76bde13ac37366efa3cbcec0a4cbe64cdf Mon Sep 17 00:00:00 2001 From: X512 <45505339+X547@users.noreply.github.com> Date: Sat, 13 Nov 2021 00:16:11 +0900 Subject: [PATCH] vulkan: add recipe (#6392) --- .../vulkan/patches/vulkan-1.2.198.patchset | 136 ++++++++++++++++++ sys-libs/vulkan/vulkan-1.2.198.recipe | 92 ++++++++++++ 2 files changed, 228 insertions(+) create mode 100644 sys-libs/vulkan/patches/vulkan-1.2.198.patchset create mode 100644 sys-libs/vulkan/vulkan-1.2.198.recipe diff --git a/sys-libs/vulkan/patches/vulkan-1.2.198.patchset b/sys-libs/vulkan/patches/vulkan-1.2.198.patchset new file mode 100644 index 000000000..e93a67442 --- /dev/null +++ b/sys-libs/vulkan/patches/vulkan-1.2.198.patchset @@ -0,0 +1,136 @@ +From cbcbd40e3cae480ed98cf966f818926657813c70 Mon Sep 17 00:00:00 2001 +From: X512 +Date: Mon, 4 Oct 2021 03:12:53 +0900 +Subject: basic fixes for haiku + +--- + CMakeLists.txt | 2 +- + loader/allocation.h | 4 ++-- + loader/get_environment.c | 7 ++++--- + loader/loader.h | 5 +++-- + loader/vk_loader_platform.h | 6 +++--- + 5 files changed, 13 insertions(+), 11 deletions(-) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index eba079c..7eae8d5 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -207,7 +207,7 @@ if(UNIX) + ) + endif() + +-if(UNIX AND NOT APPLE) # i.e.: Linux ++if(UNIX AND NOT APPLE AND NOT HAIKU) # i.e.: Linux + option(BUILD_WSI_XCB_SUPPORT "Build XCB WSI support" ON) + option(BUILD_WSI_XLIB_SUPPORT "Build Xlib WSI support" ON) + option(BUILD_WSI_WAYLAND_SUPPORT "Build Wayland WSI support" ON) +diff --git a/loader/allocation.h b/loader/allocation.h +index 6c84050..2a5ecec 100644 +--- a/loader/allocation.h ++++ b/loader/allocation.h +@@ -39,8 +39,8 @@ void loader_device_heap_free(const struct loader_device *device, void *pMemory); + void *loader_device_heap_realloc(const struct loader_device *device, void *pMemory, size_t orig_size, size_t size, + VkSystemAllocationScope alloc_scope); + +-#if defined(__linux__) || defined(__APPLE__) || defined(__Fuchsia__) || defined(__QNXNTO__) || defined(__FreeBSD__) ++#if defined(__linux__) || defined(__APPLE__) || defined(__Fuchsia__) || defined(__QNXNTO__) || defined(__FreeBSD__) || defined(__HAIKU__) + #define loader_stack_alloc(size) alloca(size) + #elif defined(_WIN32) + #define loader_stack_alloc(size) _alloca(size) +-#endif // defined(_WIN32) +\ No newline at end of file ++#endif // defined(_WIN32) +diff --git a/loader/get_environment.c b/loader/get_environment.c +index bf878da..fcf924d 100644 +--- a/loader/get_environment.c ++++ b/loader/get_environment.c +@@ -37,7 +37,7 @@ + #endif // !defined(VULKAN_NON_CMAKE_BUILD) + + // Environment variables +-#if defined(__linux__) || defined(__APPLE__) || defined(__Fuchsia__) || defined(__QNXNTO__) || defined(__FreeBSD__) ++#if defined(__linux__) || defined(__APPLE__) || defined(__Fuchsia__) || defined(__QNXNTO__) || defined(__FreeBSD__) || defined(__HAIKU__) + + bool is_high_integrity() { return geteuid() != getuid() || getegid() != getgid(); } + +@@ -45,11 +45,12 @@ char *loader_getenv(const char *name, const struct loader_instance *inst) { + // No allocation of memory necessary for Linux, but we should at least touch + // the inst pointer to get rid of compiler warnings. + (void)inst; ++ return NULL; + return getenv(name); + } + + char *loader_secure_getenv(const char *name, const struct loader_instance *inst) { +-#if defined(__APPLE__) || defined(__FreeBSD__) ++#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__HAIKU__) + // Apple does not appear to have a secure getenv implementation. + // The main difference between secure getenv and getenv is that secure getenv + // returns NULL if the process is being run with elevated privileges by a normal user. +@@ -169,4 +170,4 @@ void loader_free_getenv(char *val, const struct loader_instance *inst) { + (void)inst; + } + +-#endif +\ No newline at end of file ++#endif +diff --git a/loader/loader.h b/loader/loader.h +index cfebfba..fe150ae 100644 +--- a/loader/loader.h ++++ b/loader/loader.h +@@ -55,12 +55,13 @@ static inline struct loader_instance_dispatch_table *loader_get_instance_dispatc + } + + static inline void loader_init_dispatch(void *obj, const void *data) { ++/* + #ifdef DEBUG + assert(valid_loader_magic_value(obj) && + "Incompatible ICD, first dword must be initialized to " + "ICD_LOADER_MAGIC. See loader/README.md for details."); + #endif +- ++*/ + loader_set_dispatch(obj, data); + } + +@@ -161,4 +162,4 @@ VkResult setup_loader_term_phys_devs(struct loader_instance *inst); + VkStringErrorFlags vk_string_validate(const int max_length, const char *char_array); + char *loader_get_next_path(char *path); + VkResult add_data_files_in_path(const struct loader_instance *inst, char *search_path, bool is_directory_list, +- struct loader_data_files *out_files, bool use_first_found_manifest); +\ No newline at end of file ++ struct loader_data_files *out_files, bool use_first_found_manifest); +diff --git a/loader/vk_loader_platform.h b/loader/vk_loader_platform.h +index 507a901..40c84d7 100644 +--- a/loader/vk_loader_platform.h ++++ b/loader/vk_loader_platform.h +@@ -42,7 +42,7 @@ + #include "dlopen_fuchsia.h" + #endif // defined(__Fuchsia__) + +-#if defined(__linux__) || defined(__APPLE__) || defined(__Fuchsia__) || defined(__QNXNTO__) || defined(__FreeBSD__) ++#if defined(__linux__) || defined(__APPLE__) || defined(__Fuchsia__) || defined(__QNXNTO__) || defined(__FreeBSD__) || defined(__HAIKU__) + #include + // Note: The following file is for dynamic loading: + #include +@@ -102,7 +102,7 @@ + // Override layer information + #define VK_OVERRIDE_LAYER_NAME "VK_LAYER_LUNARG_override" + +-#if defined(__linux__) || defined(__APPLE__) || defined(__Fuchsia__) || defined(__QNXNTO__) || defined(__FreeBSD__) ++#if defined(__linux__) || defined(__APPLE__) || defined(__Fuchsia__) || defined(__QNXNTO__) || defined(__FreeBSD__) || defined(__HAIKU__) + /* Linux-specific common code: */ + + // VK Library Filenames, Paths, etc.: +@@ -195,7 +195,7 @@ static inline char *loader_platform_executable_path(char *buffer, size_t size) { + + return buffer; + } +-#elif defined(__Fuchsia__) ++#elif defined(__Fuchsia__) || defined(__HAIKU__) + static inline char *loader_platform_executable_path(char *buffer, size_t size) { return NULL; } + #elif defined(__QNXNTO__) + +-- +2.30.2 + diff --git a/sys-libs/vulkan/vulkan-1.2.198.recipe b/sys-libs/vulkan/vulkan-1.2.198.recipe new file mode 100644 index 000000000..b1fa589d3 --- /dev/null +++ b/sys-libs/vulkan/vulkan-1.2.198.recipe @@ -0,0 +1,92 @@ +SUMMARY="Installable Client Driver (ICD) Loader for Vulkan" +DESCRIPTION="Vulkan is an explicit API, enabling direct control over how GPUs \ +actually work. As such, Vulkan supports systems that have multiple GPUs, each \ +running with a different driver, or ICD (Installable Client Driver). Vulkan \ +also supports multiple global contexts (instances, in Vulkan terminology). The \ +ICD loader is a library that is placed between a Vulkan application and any \ +number of Vulkan drivers, in order to support multiple drivers and the \ +instance-level functionality that works across these drivers. Additionally, \ +the loader manages inserting Vulkan layer libraries, such as validation \ +layers, between an application and the drivers." +HOMEPAGE="https://www.vulkan.org/" +COPYRIGHT="2014-2021 The Khronos Group Inc." +LICENSE="Apache v2" +REVISION="1" +SOURCE_URI="https://github.com/KhronosGroup/Vulkan-Loader/archive/refs/tags/v${portVersion}.tar.gz" +SOURCE_FILENAME="Vulkan-Loader-${portVersion}.tar.gz" +CHECKSUM_SHA256="b4a0ec6ce8921f50ab291f1c3a16802cfbe2c3dbd86820eb699bfb98890ad126" +SOURCE_DIR="Vulkan-Loader-${portVersion}" +SOURCE_URI_2="https://github.com/KhronosGroup/Vulkan-Headers/archive/refs/tags/v${portVersion}.tar.gz" +SOURCE_FILENAME_2="Vulkan-Headers-${portVersion}.tar.gz" +CHECKSUM_SHA256_2="0b2c69bc392a0022652f65efe5c51ec39ae90ec427065a914ba74ac6c728db30" +SOURCE_DIR_2="Vulkan-Headers-${portVersion}" +PATCHES="vulkan-$portVersion.patchset" + +ARCHITECTURES="all !x86_gcc2" +SECONDARY_ARCHITECTURES="all" + +PROVIDES=" + vulkan$secondaryArchSuffix = $portVersion compat >= 1 + lib:libvulkan$secondaryArchSuffix = $portVersion compat >= 1 + " +REQUIRES=" + haiku$secondaryArchSuffix + " + +PROVIDES_devel=" + vulkan${secondaryArchSuffix}_devel = $portVersion compat >= 1 + devel:libvulkan$secondaryArchSuffix = $portVersion compat >= 1 + " +REQUIRES_devel=" + vulkan$secondaryArchSuffix == $portVersion base + " + +BUILD_REQUIRES=" + haiku${secondaryArchSuffix}_devel + " +BUILD_PREREQUIRES=" + cmd:cmake + cmd:gcc$secondaryArchSuffix + cmd:ld$secondaryArchSuffix + cmd:ninja + cmd:pkg_config$secondaryArchSuffix + " + +defineDebugInfoPackage vulkan$secondaryArchSuffix \ + "$libDir"/libvulkan.so.$portVersion + +BUILD() +{ + rm -rf build + mkdir build + cd build + + cmake .. \ + -DCMAKE_BUILD_TYPE=RelWithDebInfo \ + -DCMAKE_INSTALL_PREFIX:PATH=$prefix \ + -DVULKAN_HEADERS_INSTALL_DIR=$sourceDir2 \ + -DVulkanRegistry_DIR=$sourceDir2/registry \ + -DFALLBACK_CONFIG_DIRS="/boot/home/config/non-packaged/add-ons:/boot/home/config/add-ons:/boot/system/non-packaged/add-ons:/boot/system/add-ons" \ + -G Ninja + + ninja +} + +INSTALL() +{ + cd build + ninja install + + mkdir -p $dataDir/vulkan/registry + cp $sourceDir2/registry/vk.xml $dataDir/vulkan/registry/vk.xml + + mkdir -p $includeDir + cp -r $sourceDir2/include/* $includeDir + + prepareInstalledDevelLib libvulkan + fixPkgconfig + + # devel package + packageEntries devel \ + $developDir +}