Merge pull request #862 from brooksytech/dev

Update vulkan, mesa, yuzu, dolphin
This commit is contained in:
Brooksytech 2022-12-30 13:41:33 -08:00 committed by GitHub
commit fd14d04d9b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 829 additions and 397 deletions

View file

@ -10,7 +10,7 @@ case ${DEVICE} in
handheld)
PKG_SITE="https://github.com/dolphin-emu/dolphin"
PKG_URL="${PKG_SITE}.git"
PKG_VERSION="e0fba20f1f353a2373b929f739773cd10132e311"
PKG_VERSION="f6fbeaf3554b3af06d9e1584189bcf2274838063"
PKG_PATCH_DIRS+=" wayland"
;;
*)

View file

@ -2,7 +2,7 @@
# Copyright (C) 2022-present BrooksyTech (https://github.com/brooksytech)
PKG_NAME="yuzusa"
PKG_VERSION="9fdacb5e3a03928a5671670d0db1e0058daf344e"
PKG_VERSION="88f5d38b9349afefd9257a779323531b21001500"
PKG_ARCH="x86_64"
PKG_LICENSE="GPLv3"
PKG_SITE="https://github.com/yuzu-emu/yuzu"
@ -30,7 +30,7 @@ then
PKG_DEPENDS_TARGET+=" vulkan-loader vulkan-headers"
fi
PKG_CMAKE_OPTS_TARGET+=" -DENABLE_QT=OFF \
PKG_CMAKE_OPTS_TARGET+=" -DENABLE_QT=ON \
-DCMAKE_BUILD_TYPE=Release \
-DYUZU_USE_BUNDLED_SDL2=OFF \
-DYUZU_TESTS=OFF \
@ -42,7 +42,7 @@ PKG_CMAKE_OPTS_TARGET+=" -DENABLE_QT=OFF \
makeinstall_target() {
mkdir -p ${INSTALL}/usr/bin
cp -rf ${PKG_BUILD}/.${TARGET_NAME}/bin/yuzu-cmd ${INSTALL}/usr/bin
cp -rf ${PKG_BUILD}/.${TARGET_NAME}/bin/yuzu* ${INSTALL}/usr/bin
cp -rf ${PKG_DIR}/scripts/* ${INSTALL}/usr/bin
chmod +x ${INSTALL}/usr/bin/start_yuzu.sh

View file

@ -11,6 +11,18 @@ if [ ! -d "/storage/.config/yuzu" ]; then
cp -r "/usr/config/yuzu" "/storage/.config/"
fi
#Check if sdl2-config.ini exists in .config/yuzu
if [ ! -f "/storage/.config/yuzu/sdl2-config.ini" ]; then
cp -r "/usr/config/yuzu/sdl2-config.ini" "/storage/.config/yuzu/sdl2-config.ini"
fi
#Move Nand / Saves to switch roms folder
if [ ! -d "/storage/roms/switch/yuzu/nand" ]; then
mkdir -p "/storage/switch/yuzu/nand"
fi
rm -rf /storage/.config/yuzu/nand
ln -sf /storage/roms/switch/yuzu/nand /storage/.config/yuzu/nand
#Link yuzu keys to bios folder
if [ ! -d "/storage/roms/bios/yuzu" ]; then
mkdir -p "/storage/.config/yuzu"
@ -18,6 +30,147 @@ fi
rm -rf /storage/.config/yuzu/keys
ln -sf /storage/roms/bios/yuzu /storage/.config/yuzu/keys
#Emulation Station Features
GAME=$(echo "${1}"| sed "s#^/.*/##")
AF=$(get_setting anisotropic_filtering switch "${GAME}")
AA=$(get_setting anti_aliasing switch "${GAME}")
ASPECT=$(get_setting aspect_ratio switch "${GAME}")
GRENDERER=$(get_setting graphics_backend switch "${GAME}")
IRES=$(get_setting internal_resolution switch "${GAME}")
PFILTER=$(get_setting pixel_filter switch "${GAME}")
SDOCK=$(get_setting switch_mode switch "${GAME}")
VSYNC=$(get_setting vsync switch "${GAME}")
#Anisotropic Filtering
if [ "$AF" = "0" ]
then
sed -i '/max_anisotropy =/c\max_anisotropy = 0' /storage/.config/yuzu/sdl2-config.ini
fi
if [ "$AF" = "1" ]
then
sed -i '/max_anisotropy =/c\max_anisotropy = 1' /storage/.config/yuzu/sdl2-config.ini
fi
if [ "$AF" = "2" ]
then
sed -i '/max_anisotropy =/c\max_anisotropy = 2' /storage/.config/yuzu/sdl2-config.ini
fi
if [ "$AF" = "3" ]
then
sed -i '/max_anisotropy =/c\max_anisotropy = 3' /storage/.config/yuzu/sdl2-config.ini
fi
if [ "$AF" = "4" ]
then
sed -i '/max_anisotropy =/c\max_anisotropy = 4' /storage/.config/yuzu/sdl2-config.ini
fi
#Anti-Aliasing
if [ "$AA" = "0" ]
then
sed -i '/anti_aliasing =/c\anti_aliasing = 0' /storage/.config/yuzu/sdl2-config.ini
fi
if [ "$AA" = "1" ]
then
sed -i '/anti_aliasing =/c\anti_aliasing = 1' /storage/.config/yuzu/sdl2-config.ini
fi
#Aspect Ratio
if [ "$ASPECT" = "0" ]
then
sed -i '/aspect_ratio =/c\aspect_ratio = 0' /storage/.config/yuzu/sdl2-config.ini
fi
if [ "$ASPECT" = "1" ]
then
sed -i '/aspect_ratio =/c\aspect_ratio = 1' /storage/.config/yuzu/sdl2-config.ini
fi
if [ "$ASPECT" = "2" ]
then
sed -i '/aspect_ratio =/c\aspect_ratio = 2' /storage/.config/yuzu/sdl2-config.ini
fi
if [ "$ASPECT" = "3" ]
then
sed -i '/aspect_ratio =/c\aspect_ratio = 3' /storage/.config/yuzu/sdl2-config.ini
fi
#Graphics Backend
if [ "$GRENDERER" = "0" ]
then
sed -i '/backend =/c\backend = 0' /storage/.config/yuzu/sdl2-config.ini
fi
if [ "$GRENDERER" = "1" ]
then
sed -i '/backend =/c\backend = 1' /storage/.config/yuzu/sdl2-config.ini
fi
#Internal Resolution
if [ "$IRES" = "0" ]
then
sed -i '/resolution_setup =/c\resolution_setup = 0' /storage/.config/yuzu/sdl2-config.ini
fi
if [ "$IRES" = "1" ]
then
sed -i '/resolution_setup =/c\resolution_setup = 1' /storage/.config/yuzu/sdl2-config.ini
fi
if [ "$IRES" = "2" ]
then
sed -i '/resolution_setup =/c\resolution_setup = 2' /storage/.config/yuzu/sdl2-config.ini
fi
#Pixel Filter
if [ "$PFILTER" = "0" ]
then
sed -i '/scaling_filter =/c\scaling_filter = 0' /storage/.config/yuzu/sdl2-config.ini
fi
if [ "$PFILTER" = "1" ]
then
sed -i '/scaling_filter =/c\scaling_filter = 1' /storage/.config/yuzu/sdl2-config.ini
fi
if [ "$PFILTER" = "2" ]
then
sed -i '/scaling_filter =/c\scaling_filter = 2' /storage/.config/yuzu/sdl2-config.ini
fi
if [ "$PFILTER" = "3" ]
then
sed -i '/scaling_filter =/c\scaling_filter = 3' /storage/.config/yuzu/sdl2-config.ini
fi
if [ "$PFILTER" = "4" ]
then
sed -i '/scaling_filter =/c\scaling_filter = 4' /storage/.config/yuzu/sdl2-config.ini
fi
if [ "$PFILTER" = "5" ]
then
sed -i '/scaling_filter =/c\scaling_filter = 5' /storage/.config/yuzu/sdl2-config.ini
fi
#Switch Mode
if [ "$SDOCK" = "0" ]
then
sed -i '/use_docked_mode =/c\use_docked_mode = 0' /storage/.config/yuzu/sdl2-config.ini
fi
if [ "$SDOCK" = "1" ]
then
sed -i '/use_docked_mode =/c\use_docked_mode = 1' /storage/.config/yuzu/sdl2-config.ini
fi
#Vysnc
if [ "$VSYNC" = "0" ]
then
sed -i '/use_vsync =/c\use_vsync = 0' /storage/.config/yuzu/sdl2-config.ini
fi
if [ "$VSYNC" = "1" ]
then
sed -i '/use_vsync =/c\use_vsync = 1' /storage/.config/yuzu/sdl2-config.ini
fi
#Link .config/yuzu to .local
rm -rf /storage/.local/share/yuzu
ln -sf /storage/.config/yuzu /storage/.local/share/yuzu

View file

@ -3,14 +3,14 @@
# Copyright (C) 2018-present Team LibreELEC (https://libreelec.tv)
PKG_NAME="mesa"
PKG_VERSION="d5394296becfc97bc992c82d6f5d013b35b5275a"
PKG_VERSION="22.3.2"
PKG_SHA256="c15df758a8795f53e57f2a228eb4593c22b16dffd9b38f83901f76cd9533140b"
PKG_LICENSE="OSS"
PKG_SITE="https://gitlab.freedesktop.org/mesa/mesa"
PKG_URL="${PKG_SITE}.git"
PKG_SITE="http://www.mesa3d.org/"
PKG_URL="https://mesa.freedesktop.org/archive/mesa-${PKG_VERSION}.tar.xz"
PKG_DEPENDS_TARGET="toolchain expat libdrm Mako:host"
PKG_LONGDESC="Mesa is a 3-D graphics library with an API."
PKG_TOOLCHAIN="meson"
get_graphicdrivers
PKG_MESON_OPTS_TARGET="-Ddri-drivers= \

32
packages/graphics/vulkan/glslang/package.mk Normal file → Executable file
View file

@ -3,20 +3,20 @@
# Copyright (C) 2021-present Team LibreELEC (https://libreelec.tv)
PKG_NAME="glslang"
# The SPIRV-Tools & SPIRV-Headers have to be specific versions matching the pkg version
# The SPIRV-Tools & SPIRV-Headers pkg_version/s need to match the compatible (known_good) glslang pkg_version.
# https://raw.githubusercontent.com/KhronosGroup/glslang/${PKG_VERSION}/known_good.json
# if you update glslang make sure spirv-tools & spirv-headers versions a known good
PKG_VERSION="11.12.0"
PKG_SHA256="7795a97450fecd9779f3d821858fbc2d1a3bf1dd602617d95b685ccbcabc302f"
# When updating glslang pkg_version please update to the known_good spirv-tools & spirv-headers pkg_version/s.
PKG_VERSION="11.13.0"
PKG_SHA256="592c98aeb03b3e81597ddaf83633c4e63068d14b18a766fd11033bad73127162"
PKG_LICENSE="Apache-2.0"
PKG_SITE="https://github.com/KhronosGroup/glslang"
PKG_URL="https://github.com/KhronosGroup/glslang/archive/${PKG_VERSION}.tar.gz"
PKG_DEPENDS_HOST="toolchain:host Python3:host spirv-tools:host spirv-headers:host"
PKG_DEPENDS_HOST="toolchain:host Python3:host"
PKG_DEPENDS_TARGET="toolchain Python3"
PKG_LONGDESC="Khronos-reference front end for GLSL/ESSL, partial front end for HLSL, and a SPIR-V generator."
PKG_DEPENDS_UNPACK="spirv-headers spirv-tools"
pre_configure_host() {
PKG_CMAKE_OPTS_HOST="-DBUILD_SHARED_LIBS=OFF \
-DBUILD_EXTERNAL=ON \
PKG_CMAKE_OPTS_COMMON="-DBUILD_EXTERNAL=ON \
-DENABLE_SPVREMAPPER=OFF \
-DENABLE_GLSLANG_JS=OFF \
-DENABLE_RTTI=OFF \
@ -24,10 +24,24 @@ pre_configure_host() {
-DENABLE_OPT=ON \
-DENABLE_PCH=ON \
-DENABLE_CTEST=OFF \
-DENABLE_RTTI=OFF \
-DUSE_CCACHE=ON \
-Wno-dev"
post_unpack() {
# Enables SPIR-V optimzer capability needed for ENABLE_OPT CMake build option
mkdir -p ${PKG_BUILD}/External/spirv-tools/external/spirv-headers
cp -R $(get_build_dir spirv-tools)/* ${PKG_BUILD}/External/spirv-tools
cp -R $(get_build_dir spirv-headers)/* ${PKG_BUILD}/External/spirv-tools/external/spirv-headers
}
pre_configure_host() {
PKG_CMAKE_OPTS_HOST+="${PKG_CMAKE_OPTS_COMMON} \
-DBUILD_SHARED_LIBS=OFF"
}
pre_configure_target() {
PKG_CMAKE_OPTS_TARGET+="${PKG_CMAKE_OPTS_COMMON} \
-DBUILD_SHARED_LIBS=ON \
-DENABLE_GLSLANG_BINARIES=OFF"
}

View file

@ -0,0 +1,34 @@
--- a/External/CMakeLists.txt
+++ b/External/CMakeLists.txt
@@ -71,7 +71,8 @@ endif()
if(ENABLE_OPT AND NOT TARGET SPIRV-Tools-opt)
if(IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/spirv-tools)
set(SPIRV_SKIP_TESTS ON CACHE BOOL "Skip building SPIRV-Tools tests")
- add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/spirv-tools spirv-tools)
+ set(BUILD_SHARED_LIBS OFF CACHE BOOL "Disable build shared libs" FORCE)
+ add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/spirv-tools EXCLUDE_FROM_ALL)
endif()
endif()
--- a/SPIRV/CMakeLists.txt
+++ b/SPIRV/CMakeLists.txt
@@ -100,7 +100,7 @@ if(ENABLE_OPT)
target_link_libraries(SPIRV PRIVATE MachineIndependent SPIRV-Tools-opt)
target_include_directories(SPIRV PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../External>
- $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/External>)
+ $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
else()
target_link_libraries(SPIRV PRIVATE MachineIndependent)
endif()
--- a/StandAlone/CMakeLists.txt
+++ b/StandAlone/CMakeLists.txt
@@ -83,7 +83,7 @@ endif()
target_link_libraries(glslangValidator ${LIBRARIES})
target_include_directories(glslangValidator PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../External>
- $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/External>)
+ $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
if(ENABLE_OPT)
target_include_directories(glslangValidator

10
packages/graphics/vulkan/spirv-headers/package.mk Normal file → Executable file
View file

@ -3,11 +3,11 @@
# Copyright (C) 2021-present Team LibreELEC (https://libreelec.tv)
PKG_NAME="spirv-headers"
# The SPIRV-Headers have to be specific versions matching the glslang pkg version
# https://github.com/KhronosGroup/glslang/blob/11.12.0/known_good.json
# if you update glslang make sure spirv-tools & spirv-headers versions a known good
PKG_VERSION="85a1ed200d50660786c1a88d9166e871123cce39"
PKG_SHA256="9729304d0915e758c5ea2a1c60b55a123d976f172c0a8dae3162ad23c77ef33b"
# The SPIRV-Headers pkg_version needs to match the compatible (known_good) glslang pkg_version.
# https://raw.githubusercontent.com/KhronosGroup/glslang/${PKG_VERSION}/known_good.json
# When updating glslang pkg_version please update to the known_good spirv-headers pkg_version.
PKG_VERSION="1d31a100405cf8783ca7a31e31cdd727c9fc54c3"
PKG_SHA256="ec09b682c93bffc6e3d58459840a0306b6b9360e56e797c4243d2d7b785dea74"
PKG_LICENSE="Apache-2.0"
PKG_SITE="https://github.com/KhronosGroup/SPIRV-headers"
PKG_URL="https://github.com/KhronosGroup/SPIRV-headers/archive/${PKG_VERSION}.tar.gz"

10
packages/graphics/vulkan/spirv-tools/package.mk Normal file → Executable file
View file

@ -3,11 +3,11 @@
# Copyright (C) 2021-present Team LibreELEC (https://libreelec.tv)
PKG_NAME="spirv-tools"
# The SPIRV-Tools have to be specific versions matching the glslang pkg version
# https://github.com/KhronosGroup/glslang/blob/11.12.0/known_good.json
# if you update glslang make sure spirv-tools & spirv-headers versions a known good
PKG_VERSION="eb0a36633d2acf4de82588504f951ad0f2cecacb"
PKG_SHA256="9f7c423c9dad6c9e664e0600226646232a328051f73f30d6795360370aa06a2f"
# The SPIRV-Tools pkg_version needs to match the compatible (known_good) glslang pkg_version.
# https://raw.githubusercontent.com/KhronosGroup/glslang/${PKG_VERSION}/known_good.json
# When updating glslang pkg_version please update to the known_good spirv-tools pkg_version.
PKG_VERSION="40f5bf59c6acb4754a0bffd3c53a715732883a12"
PKG_SHA256="b99c91307a4b466754ffeaaaa6086bda55780ccf1557592004a1736fb9aa7ce7"
PKG_LICENSE="Apache-2.0"
PKG_SITE="https://github.com/KhronosGroup/SPIRV-Tools"
PKG_URL="https://github.com/KhronosGroup/SPIRV-Tools/archive/${PKG_VERSION}.tar.gz"

4
packages/graphics/vulkan/vkmark/package.mk Normal file → Executable file
View file

@ -2,8 +2,8 @@
# Copyright (C) 2022-present Team LibreELEC (https://libreelec.tv)
PKG_NAME="vkmark"
PKG_VERSION="d872846e2e7c47010c11227eb713d00ccfdd35c6"
PKG_SHA256="3b03785c9952d5f1ebad6c08349d8697814ad6724f81c05891afabb59f54bf22"
PKG_VERSION="30d2cd37f0566589d90914501fc7c51a4e51f559"
PKG_SHA256="6a2ab6a9c58b4bd11eb0235a8e31b10b3d0cbcd5c64b799d342572936a717745"
PKG_LICENSE="LGPL-2.1-or-later"
PKG_SITE="https://github.com/vkmark/vkmark"
PKG_URL="https://github.com/vkmark/vkmark/archive/${PKG_VERSION}.tar.gz"

View file

@ -0,0 +1,542 @@
From 51c7eb0c8c1cd4872eec176775276cca3565a0a6 Mon Sep 17 00:00:00 2001
From: Alexandros Frantzis <alexandros.frantzis@collabora.com>
Date: Fri, 9 Sep 2022 18:32:03 +0300
Subject: [PATCH 1/4] github: Build with both ubuntu-20.04 and ubuntu-22.04 in
CI
---
.github/workflows/build.yml | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index fbb5682..b60ad80 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -10,7 +10,10 @@ on:
jobs:
build:
- runs-on: ubuntu-latest
+ strategy:
+ matrix:
+ os: [ubuntu-20.04, ubuntu-22.04]
+ runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v1
- name: Install dependencies
From 7bbe275e49045237f2cdbc2f441a394b562b0aa5 Mon Sep 17 00:00:00 2001
From: Alexandros Frantzis <alexandros.frantzis@collabora.com>
Date: Fri, 9 Sep 2022 18:08:12 +0300
Subject: [PATCH 2/4] core: Improve log message consistency
---
src/vulkan_state.cpp | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/src/vulkan_state.cpp b/src/vulkan_state.cpp
index 6f50673..fbd789c 100644
--- a/src/vulkan_state.cpp
+++ b/src/vulkan_state.cpp
@@ -44,7 +44,7 @@ std::vector<vk::PhysicalDevice> VulkanState::available_devices(VulkanWSI& vulkan
{
if (!vulkan_wsi.is_physical_device_supported(*it_device))
{
- Log::debug("device with uuid %s is not supported by window system integration layer",
+ Log::debug("Device with uuid %s is not supported by window system integration layer\n",
static_cast<DeviceUUID>(it_device->getProperties().pipelineCacheUUID).representation().data());
it_device = available_devices.erase(it_device);
}
@@ -193,17 +193,17 @@ void VulkanState::create_command_pool()
vk::PhysicalDevice ChooseFirstSupportedStrategy::operator()(const std::vector<vk::PhysicalDevice>& available_devices)
{
- Log::debug("Trying to use first supported device.\n");
+ Log::debug("Trying to use first supported device\n");
for (auto const& physical_device : available_devices)
{
if (find_queue_family_index(physical_device, vk::QueueFlagBits::eGraphics).second)
{
- Log::debug("First supported device choosen!\n");
+ Log::debug("First supported device chosen\n");
return physical_device;
}
- Log::debug("device with uuid %s skipped!\n",
+ Log::debug("Device with uuid %s skipped\n",
static_cast<DeviceUUID>(physical_device.getProperties().pipelineCacheUUID).representation().data()
);
}
@@ -213,7 +213,7 @@ vk::PhysicalDevice ChooseFirstSupportedStrategy::operator()(const std::vector<vk
vk::PhysicalDevice ChooseByUUIDStrategy::operator()(const std::vector<vk::PhysicalDevice>& available_devices)
{
- Log::debug("Trying to use device with specified UUID %s.\n",
+ Log::debug("Trying to use device with specified UUID %s\n",
m_selected_device_uuid.representation().data());
for (auto const& physical_device: available_devices)
@@ -227,5 +227,5 @@ vk::PhysicalDevice ChooseByUUIDStrategy::operator()(const std::vector<vk::Physic
}
// if device is not supported by wsi it would appear in list_all_devices but is not available here
- throw std::runtime_error(std::string("Device specified by uuid is not available!"));
+ throw std::runtime_error(std::string("Device specified by uuid is not available"));
}
From 6395c5621fb8d83d649a174f53cfdb1626959f0e Mon Sep 17 00:00:00 2001
From: Alexandros Frantzis <alexandros.frantzis@collabora.com>
Date: Fri, 9 Sep 2022 17:48:44 +0300
Subject: [PATCH 3/4] core,ws: Allow WSI backends to request device extensions
The backends were able to request instance extensions, support
requesting device extensions, too.
---
src/vulkan_state.cpp | 5 ++---
src/vulkan_wsi.h | 8 +++++++-
src/ws/kms_window_system.cpp | 2 +-
src/ws/kms_window_system.h | 2 +-
src/ws/native_system.h | 2 +-
src/ws/swapchain_window_system.cpp | 4 ++--
src/ws/swapchain_window_system.h | 2 +-
src/ws/wayland_native_system.cpp | 2 +-
src/ws/wayland_native_system.h | 2 +-
src/ws/xcb_native_system.cpp | 2 +-
src/ws/xcb_native_system.h | 2 +-
tests/null_window_system.h | 2 +-
tests/test_window_system_plugin.cpp | 2 +-
tests/window_system_loader_test.cpp | 2 +-
14 files changed, 22 insertions(+), 17 deletions(-)
diff --git a/src/vulkan_state.cpp b/src/vulkan_state.cpp
index fbd789c..b1973ed 100644
--- a/src/vulkan_state.cpp
+++ b/src/vulkan_state.cpp
@@ -87,7 +87,7 @@ void VulkanState::create_instance(VulkanWSI& vulkan_wsi)
auto const app_info = vk::ApplicationInfo{}
.setPApplicationName("vkmark");
- std::vector<char const*> enabled_extensions{vulkan_wsi.vulkan_extensions()};
+ std::vector<char const*> enabled_extensions{vulkan_wsi.required_extensions().instance};
enabled_extensions.push_back(VK_KHR_SURFACE_EXTENSION_NAME);
auto const create_info = vk::InstanceCreateInfo{}
@@ -159,8 +159,7 @@ void VulkanState::create_logical_device(VulkanWSI& vulkan_wsi)
Log::debug("VulkanState: Using queue family index %d for rendering\n",
graphics_queue_family_index());
- std::array<char const*,1> enabled_extensions{
- {VK_KHR_SWAPCHAIN_EXTENSION_NAME}};
+ std::vector<char const*> enabled_extensions{vulkan_wsi.required_extensions().device};
auto const device_features = vk::PhysicalDeviceFeatures{}
.setSamplerAnisotropy(true);
diff --git a/src/vulkan_wsi.h b/src/vulkan_wsi.h
index f8c50eb..22e87f1 100644
--- a/src/vulkan_wsi.h
+++ b/src/vulkan_wsi.h
@@ -32,7 +32,13 @@ class VulkanWSI
public:
virtual ~VulkanWSI() = default;
- virtual std::vector<char const*> vulkan_extensions() = 0;
+ struct Extensions
+ {
+ std::vector<char const*> instance;
+ std::vector<char const*> device;
+ };
+
+ virtual Extensions required_extensions() = 0;
virtual bool is_physical_device_supported(vk::PhysicalDevice const& pd) = 0;
virtual std::vector<uint32_t> physical_device_queue_family_indices(
vk::PhysicalDevice const& pd) = 0;
diff --git a/src/ws/kms_window_system.cpp b/src/ws/kms_window_system.cpp
index ca8220f..6132e64 100644
--- a/src/ws/kms_window_system.cpp
+++ b/src/ws/kms_window_system.cpp
@@ -533,7 +533,7 @@ void KMSWindowSystem::wait_for_drm_page_flip_event()
}
}
-std::vector<char const*> KMSWindowSystem::vulkan_extensions()
+VulkanWSI::Extensions KMSWindowSystem::required_extensions()
{
return {};
}
diff --git a/src/ws/kms_window_system.h b/src/ws/kms_window_system.h
index 4389ef7..20a067f 100644
--- a/src/ws/kms_window_system.h
+++ b/src/ws/kms_window_system.h
@@ -61,7 +61,7 @@ class KMSWindowSystem : public WindowSystem, public VulkanWSI
bool should_quit() override;
// VulkanWSI
- std::vector<char const*> vulkan_extensions() override;
+ Extensions required_extensions() override;
bool is_physical_device_supported(vk::PhysicalDevice const& pd) override;
std::vector<uint32_t> physical_device_queue_family_indices(
vk::PhysicalDevice const& pd) override;
diff --git a/src/ws/native_system.h b/src/ws/native_system.h
index 076948e..cbe073a 100644
--- a/src/ws/native_system.h
+++ b/src/ws/native_system.h
@@ -34,7 +34,7 @@ class NativeSystem
public:
virtual ~NativeSystem() = default;
- virtual std::vector<char const*> vulkan_extensions() = 0;
+ virtual std::vector<char const*> instance_extensions() = 0;
virtual uint32_t get_presentation_queue_family_index(vk::PhysicalDevice const& pd) = 0;
virtual bool should_quit() = 0;
virtual vk::Extent2D get_vk_extent() = 0;
diff --git a/src/ws/swapchain_window_system.cpp b/src/ws/swapchain_window_system.cpp
index d38fa6b..9f9fba3 100644
--- a/src/ws/swapchain_window_system.cpp
+++ b/src/ws/swapchain_window_system.cpp
@@ -251,9 +251,9 @@ ManagedResource<vk::SwapchainKHR> SwapchainWindowSystem::create_vk_swapchain()
[this] (auto& s) { vulkan->device().destroySwapchainKHR(s); }};
}
-std::vector<char const*> SwapchainWindowSystem::vulkan_extensions()
+VulkanWSI::Extensions SwapchainWindowSystem::required_extensions()
{
- return native->vulkan_extensions();
+ return {native->instance_extensions(), {VK_KHR_SWAPCHAIN_EXTENSION_NAME}};
}
bool SwapchainWindowSystem::is_physical_device_supported(vk::PhysicalDevice const& pd)
diff --git a/src/ws/swapchain_window_system.h b/src/ws/swapchain_window_system.h
index c3b2780..412b924 100644
--- a/src/ws/swapchain_window_system.h
+++ b/src/ws/swapchain_window_system.h
@@ -51,7 +51,7 @@ class SwapchainWindowSystem : public WindowSystem, public VulkanWSI
bool should_quit() override;
// VulkanWSI
- std::vector<char const*> vulkan_extensions() override;
+ Extensions required_extensions() override;
bool is_physical_device_supported(vk::PhysicalDevice const& pd) override;
std::vector<uint32_t> physical_device_queue_family_indices(
vk::PhysicalDevice const& pd) override;
diff --git a/src/ws/wayland_native_system.cpp b/src/ws/wayland_native_system.cpp
index 642d8fe..816a7b9 100644
--- a/src/ws/wayland_native_system.cpp
+++ b/src/ws/wayland_native_system.cpp
@@ -145,7 +145,7 @@ WaylandNativeSystem::WaylandNativeSystem(int width, int height)
create_native_window();
}
-std::vector<char const*> WaylandNativeSystem::vulkan_extensions()
+std::vector<char const*> WaylandNativeSystem::instance_extensions()
{
return {VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME};
}
diff --git a/src/ws/wayland_native_system.h b/src/ws/wayland_native_system.h
index 400c358..01cdbaa 100644
--- a/src/ws/wayland_native_system.h
+++ b/src/ws/wayland_native_system.h
@@ -35,7 +35,7 @@ class WaylandNativeSystem : public NativeSystem
public:
WaylandNativeSystem(int width, int height);
- std::vector<char const*> vulkan_extensions() override;
+ std::vector<char const*> instance_extensions() override;
uint32_t get_presentation_queue_family_index(vk::PhysicalDevice const& pd) override;
bool should_quit() override;
vk::Extent2D get_vk_extent() override;
diff --git a/src/ws/xcb_native_system.cpp b/src/ws/xcb_native_system.cpp
index 59c84f0..b683772 100644
--- a/src/ws/xcb_native_system.cpp
+++ b/src/ws/xcb_native_system.cpp
@@ -47,7 +47,7 @@ XcbNativeSystem::~XcbNativeSystem()
xcb_disconnect(connection);
}
-std::vector<char const*> XcbNativeSystem::vulkan_extensions()
+std::vector<char const*> XcbNativeSystem::instance_extensions()
{
return {VK_KHR_XCB_SURFACE_EXTENSION_NAME};
}
diff --git a/src/ws/xcb_native_system.h b/src/ws/xcb_native_system.h
index 7fcc44a..dadc32f 100644
--- a/src/ws/xcb_native_system.h
+++ b/src/ws/xcb_native_system.h
@@ -35,7 +35,7 @@ class XcbNativeSystem : public NativeSystem
XcbNativeSystem(int width, int height, xcb_visualid_t visual_id);
~XcbNativeSystem();
- std::vector<char const*> vulkan_extensions() override;
+ std::vector<char const*> instance_extensions() override;
uint32_t get_presentation_queue_family_index(vk::PhysicalDevice const& pd) override;
bool should_quit() override;
vk::Extent2D get_vk_extent() override;
diff --git a/tests/null_window_system.h b/tests/null_window_system.h
index bc01276..b7cc9ba 100644
--- a/tests/null_window_system.h
+++ b/tests/null_window_system.h
@@ -39,7 +39,7 @@ class NullWindowSystem : public WindowSystem, public VulkanWSI
bool should_quit() override { return false; }
- std::vector<char const*> vulkan_extensions() override { return {}; }
+ Extensions required_extensions() override { return {}; }
bool is_physical_device_supported(vk::PhysicalDevice const&) override { return true; }
std::vector<uint32_t> physical_device_queue_family_indices(
vk::PhysicalDevice const&) override
diff --git a/tests/test_window_system_plugin.cpp b/tests/test_window_system_plugin.cpp
index 7877c8e..a562958 100644
--- a/tests/test_window_system_plugin.cpp
+++ b/tests/test_window_system_plugin.cpp
@@ -32,7 +32,7 @@ class TestWindowSystem : public NullWindowSystem
{
public:
TestWindowSystem(std::string const& id) : id{id} {}
- std::vector<char const*> vulkan_extensions() override { return {id.c_str()}; }
+ Extensions required_extensions() override { return {{id.c_str()}, {}}; }
private:
std::string const id;
diff --git a/tests/window_system_loader_test.cpp b/tests/window_system_loader_test.cpp
index 8aed335..c458e61 100644
--- a/tests/window_system_loader_test.cpp
+++ b/tests/window_system_loader_test.cpp
@@ -84,7 +84,7 @@ class TestWindowSystems
int window_system_id(WindowSystem& ws)
{
- return std::stoi(ws.vulkan_wsi().vulkan_extensions()[0]);
+ return std::stoi(ws.vulkan_wsi().required_extensions().instance[0]);
}
}
From dd75130a7ddf747eb7fd755946e84baf98a6e05f Mon Sep 17 00:00:00 2001
From: Alexandros Frantzis <alexandros.frantzis@collabora.com>
Date: Fri, 9 Sep 2022 16:23:40 +0300
Subject: [PATCH 4/4] kms: Use VK_EXT_external_memory_dmabuf to create
dmabuf-backed Vulkan images
Drop the vkCreateDmaBufImageINTEL extension function and use the
functionality provided by the official VK_EXT_external_memory_dmabuf
extension to create dmabuf-backed Vulkan images.
Fixes #33
Co-authored-by: Jeffy Chen <jeffy.chen@rock-chips.com>
---
meson.build | 7 +-
src/ws/kms_window_system.cpp | 132 +++++++++++++++++++++++------------
2 files changed, 89 insertions(+), 50 deletions(-)
diff --git a/meson.build b/meson.build
index 7d305dc..0d83918 100644
--- a/meson.build
+++ b/meson.build
@@ -32,16 +32,11 @@ wayland_protocols_dep = dependency('wayland-protocols', version : '>= 1.12',
wayland_scanner_dep = dependency('wayland-scanner', required : get_option('wayland') == 'true')
libdrm_dep = dependency('libdrm', required : get_option('kms') == 'true')
gbm_dep = dependency('gbm', required : get_option('kms') == 'true')
-has_vulkan_intel_header = cpp.has_header('vulkan/vulkan_intel.h', dependencies: vulkan_dep)
-
-if get_option('kms') == 'true' and not has_vulkan_intel_header
- error('KMS plugin needs the vulkan_intel.h header, but it couldn\'t be found')
-endif
build_xcb_ws = xcb_dep.found() and xcb_icccm_dep.found() and get_option('xcb') != 'false'
build_wayland_ws = (wayland_client_dep.found() and wayland_protocols_dep.found() and
wayland_scanner_dep.found() and get_option('wayland') != 'false')
-build_kms_ws = libdrm_dep.found() and gbm_dep.found() and has_vulkan_intel_header and get_option('kms') != 'false'
+build_kms_ws = libdrm_dep.found() and gbm_dep.found() and get_option('kms') != 'false'
if not build_xcb_ws and not build_wayland_ws and not build_kms_ws
error('vkmark needs at least one winsys to work - xcb, wayland or kms')
diff --git a/src/ws/kms_window_system.cpp b/src/ws/kms_window_system.cpp
index 6132e64..fc02eae 100644
--- a/src/ws/kms_window_system.cpp
+++ b/src/ws/kms_window_system.cpp
@@ -29,8 +29,8 @@
#include <xf86drm.h>
#include <drm_fourcc.h>
-#include <vulkan/vulkan_intel.h>
+#include <algorithm>
#include <system_error>
#include <fcntl.h>
#include <unistd.h>
@@ -270,6 +270,24 @@ void restore_vt(int)
global_vt_state->restore();
}
+uint32_t find_memory_type_index(vk::PhysicalDevice const& physical_device,
+ vk::MemoryRequirements const& requirements,
+ vk::MemoryPropertyFlags flags)
+{
+ auto const properties = physical_device.getMemoryProperties();
+
+ for (uint32_t i = 0; i < properties.memoryTypeCount; i++)
+ {
+ if ((requirements.memoryTypeBits & (1 << i)) &&
+ (properties.memoryTypes[i].propertyFlags & flags) == flags)
+ {
+ return i;
+ }
+ }
+
+ throw std::runtime_error{"Coudn't find matching memory type"};
+}
+
}
VTState::VTState()
@@ -433,14 +451,20 @@ void KMSWindowSystem::create_drm_fbs()
for (auto const& gbm_bo : gbm_bos)
{
uint32_t fb = 0;
+ uint32_t handles[4] = {0};
+ uint32_t strides[4] = {0};
+ uint32_t offsets[4] = {0};
- uint32_t handles[4] = {gbm_bo_get_handle(gbm_bo).u32, 0, 0, 0};
- uint32_t strides[4] = {gbm_bo_get_stride(gbm_bo), 0, 0, 0};
- uint32_t offsets[4] = {0, 0, 0, 0};
+ for (auto i = 0; i < gbm_bo_get_plane_count(gbm_bo); i++)
+ {
+ handles[i] = gbm_bo_get_handle_for_plane(gbm_bo, i).u32;
+ offsets[i] = gbm_bo_get_offset(gbm_bo, i);
+ strides[i] = gbm_bo_get_stride_for_plane(gbm_bo, i);
+ }
auto const ret = drmModeAddFB2(
drm_fd, vk_extent.width, vk_extent.height,
- DRM_FORMAT_XRGB8888,
+ gbm_bo_get_format(gbm_bo),
handles, strides, offsets, &fb, 0);
if (ret < 0)
@@ -453,52 +477,65 @@ void KMSWindowSystem::create_drm_fbs()
}
}
-// TODO: Use an official extension to create the VkImages when it becomes
-// available (e.g. VK_MESAX_external_image_dma_buf)
void KMSWindowSystem::create_vk_images()
{
- auto const create_dma_buf_image =
- reinterpret_cast<PFN_vkCreateDmaBufImageINTEL>(
- vulkan->device().getProcAddr("vkCreateDmaBufImageINTEL"));
-
- if (!create_dma_buf_image)
- throw std::runtime_error{"Failed to get vkCreateDmaBufImageINTEL function pointer"};
-
for (auto const& gbm_bo : gbm_bos)
{
auto const fd = ManagedResource<int>{gbm_bo_get_fd(gbm_bo), close};
- auto const stride = gbm_bo_get_stride(gbm_bo);
-
- VkDmaBufImageCreateInfo create_info{};
- create_info.sType = static_cast<VkStructureType>(VK_STRUCTURE_TYPE_DMA_BUF_IMAGE_CREATE_INFO_INTEL);
- create_info.fd = fd;
- create_info.format = static_cast<VkFormat>(vk_image_format);
- create_info.extent = {vk_extent.width, vk_extent.height, 1};
- create_info.strideInBytes = stride;
-
- VkImage image;
- VkDeviceMemory device_memory;
-
- VkResult result = create_dma_buf_image(
- vulkan->device(),
- &create_info,
- nullptr,
- &device_memory,
- &image);
-
- if (result != VK_SUCCESS)
- {
- vk::throwResultException(static_cast<vk::Result>(result),
- "vkCreateDmbBufImageINTEL");
- }
+ uint64_t modifier = gbm_bo_get_modifier(gbm_bo);
+
+ auto const modifier_info = vk::ImageDrmFormatModifierListCreateInfoEXT{}
+ .setDrmFormatModifierCount(1)
+ .setPDrmFormatModifiers(&modifier);
+ auto const external_memory_create_info = vk::ExternalMemoryImageCreateInfoKHR{}
+ .setHandleTypes(vk::ExternalMemoryHandleTypeFlagBitsKHR::eDmaBufEXT)
+ .setPNext(&modifier_info);
+ auto const image_create_info = vk::ImageCreateInfo{}
+ .setPNext(&external_memory_create_info)
+ .setImageType(vk::ImageType::e2D)
+ .setFormat(vk_image_format)
+ .setExtent({vk_extent.width, vk_extent.height, 1})
+ .setMipLevels(1)
+ .setArrayLayers(1)
+ .setSamples(vk::SampleCountFlagBits::e1)
+ .setTiling(vk::ImageTiling::eDrmFormatModifierEXT)
+ .setUsage(vk::ImageUsageFlagBits::eColorAttachment)
+ .setSharingMode(vk::SharingMode::eExclusive)
+ .setInitialLayout(vk::ImageLayout::eUndefined);
+
+ auto vk_image = ManagedResource<vk::Image>{
+ vulkan->device().createImage(image_create_info),
+ [vptr=vulkan] (auto const& i) { vptr->device().destroyImage(i); }};
+
+ auto const requirements = vulkan->device().getImageMemoryRequirements(vk_image);
+ uint32_t index = find_memory_type_index(vulkan->physical_device(),
+ requirements,
+ vk::MemoryPropertyFlagBits::eDeviceLocal);
+
+ auto const import_memory_fd_info = vk::ImportMemoryFdInfoKHR{}
+ .setHandleType(vk::ExternalMemoryHandleTypeFlagBitsKHR::eDmaBufEXT)
+ .setFd(fd);
+ auto const dedicated_allocate_info = vk::MemoryDedicatedAllocateInfoKHR{}
+ .setPNext(&import_memory_fd_info)
+ .setImage(vk_image);
+ auto const memory_allocate_info = vk::MemoryAllocateInfo{}
+ .setPNext(&dedicated_allocate_info)
+ .setAllocationSize(requirements.size)
+ .setMemoryTypeIndex((uint32_t)index);
+
+ auto device_memory = ManagedResource<vk::DeviceMemory>{
+ vulkan->device().allocateMemory(memory_allocate_info),
+ [vptr=vulkan] (auto const& m) { vptr->device().freeMemory(m); }};
+
+ vulkan->device().bindImageMemory(vk_image, device_memory, 0);
vk_images.push_back(
ManagedResource<vk::Image>{
- vk::Image{image},
- [vptr=vulkan, device_memory] (auto& image)
+ vk_image.steal(),
+ [vptr=vulkan, mem=device_memory.steal()] (auto const& image)
{
vptr->device().destroyImage(image);
- vptr->device().freeMemory(device_memory);
+ vptr->device().freeMemory(mem);
}});
}
}
@@ -535,12 +572,19 @@ void KMSWindowSystem::wait_for_drm_page_flip_event()
VulkanWSI::Extensions KMSWindowSystem::required_extensions()
{
- return {};
+ return {{}, {VK_EXT_EXTERNAL_MEMORY_DMA_BUF_EXTENSION_NAME}};
}
-bool KMSWindowSystem::is_physical_device_supported(vk::PhysicalDevice const&)
+bool KMSWindowSystem::is_physical_device_supported(vk::PhysicalDevice const& physdev)
{
- return true;
+ auto const props = physdev.enumerateDeviceExtensionProperties();
+ auto const iter = std::find_if(
+ props.begin(), props.end(),
+ [](vk::ExtensionProperties prop)
+ {
+ return std::string{VK_EXT_EXTERNAL_MEMORY_DMA_BUF_EXTENSION_NAME} == prop.extensionName;
+ });
+ return iter != props.end();
}
std::vector<uint32_t> KMSWindowSystem::physical_device_queue_family_indices(

View file

@ -1,273 +0,0 @@
From 0dd62e9adff82d51ed67c625a4f456a8e5f1a2e2 Mon Sep 17 00:00:00 2001
From: Jeffy Chen <jeffy.chen@rock-chips.com>
Date: Mon, 23 May 2022 10:57:27 +0800
Subject: [PATCH] kms: Drop dependency on vkCreateDmaBufImageINTEL
Based on chromium's gpu/vulkan/vulkan_image{_linux,}.cc
Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
---
meson.build | 7 +-
src/ws/kms_window_system.cpp | 172 ++++++++++++++++++++++++++---------
src/ws/kms_window_system.h | 1 -
3 files changed, 130 insertions(+), 50 deletions(-)
diff --git a/meson.build b/meson.build
index 7d305dc..0d83918 100644
--- a/meson.build
+++ b/meson.build
@@ -32,16 +32,11 @@ wayland_protocols_dep = dependency('wayland-protocols', version : '>= 1.12',
wayland_scanner_dep = dependency('wayland-scanner', required : get_option('wayland') == 'true')
libdrm_dep = dependency('libdrm', required : get_option('kms') == 'true')
gbm_dep = dependency('gbm', required : get_option('kms') == 'true')
-has_vulkan_intel_header = cpp.has_header('vulkan/vulkan_intel.h', dependencies: vulkan_dep)
-
-if get_option('kms') == 'true' and not has_vulkan_intel_header
- error('KMS plugin needs the vulkan_intel.h header, but it couldn\'t be found')
-endif
build_xcb_ws = xcb_dep.found() and xcb_icccm_dep.found() and get_option('xcb') != 'false'
build_wayland_ws = (wayland_client_dep.found() and wayland_protocols_dep.found() and
wayland_scanner_dep.found() and get_option('wayland') != 'false')
-build_kms_ws = libdrm_dep.found() and gbm_dep.found() and has_vulkan_intel_header and get_option('kms') != 'false'
+build_kms_ws = libdrm_dep.found() and gbm_dep.found() and get_option('kms') != 'false'
if not build_xcb_ws and not build_wayland_ws and not build_kms_ws
error('vkmark needs at least one winsys to work - xcb, wayland or kms')
diff --git a/src/ws/kms_window_system.cpp b/src/ws/kms_window_system.cpp
index ca8220f..18c5384 100644
--- a/src/ws/kms_window_system.cpp
+++ b/src/ws/kms_window_system.cpp
@@ -29,7 +29,6 @@
#include <xf86drm.h>
#include <drm_fourcc.h>
-#include <vulkan/vulkan_intel.h>
#include <system_error>
#include <fcntl.h>
@@ -352,7 +351,6 @@ void KMSWindowSystem::init_vulkan(VulkanState& vulkan_)
vk_image_format = vk::Format::eB8G8R8A8Srgb;
create_gbm_bos();
- create_drm_fbs();
create_vk_images();
}
@@ -428,68 +426,122 @@ void KMSWindowSystem::create_gbm_bos()
}
}
-void KMSWindowSystem::create_drm_fbs()
-{
- for (auto const& gbm_bo : gbm_bos)
- {
- uint32_t fb = 0;
-
- uint32_t handles[4] = {gbm_bo_get_handle(gbm_bo).u32, 0, 0, 0};
- uint32_t strides[4] = {gbm_bo_get_stride(gbm_bo), 0, 0, 0};
- uint32_t offsets[4] = {0, 0, 0, 0};
-
- auto const ret = drmModeAddFB2(
- drm_fd, vk_extent.width, vk_extent.height,
- DRM_FORMAT_XRGB8888,
- handles, strides, offsets, &fb, 0);
-
- if (ret < 0)
- throw std::system_error{-ret, std::system_category(), "Failed to add drm fb"};
+// TODO: Use an official extension to create the VkImages when it becomes
+// available (e.g. VK_MESAX_external_image_dma_buf)
- drm_fbs.push_back(
- ManagedResource<uint32_t>{
- std::move(fb),
- [this] (auto& fb) { drmModeRmFB(drm_fd, fb); }});
+static int find_memory_type_index(VkPhysicalDevice physical_device,
+ const VkMemoryRequirements* requirements,
+ VkMemoryPropertyFlags flags) {
+ VkPhysicalDeviceMemoryProperties properties;
+ vkGetPhysicalDeviceMemoryProperties(physical_device, &properties);
+ for (int i = 0; i <= 31; i++) {
+ if (((1u << i) & requirements->memoryTypeBits) == 0)
+ continue;
+ if ((properties.memoryTypes[i].propertyFlags & flags) != flags)
+ continue;
+ return i;
}
+ return -1;
}
-// TODO: Use an official extension to create the VkImages when it becomes
-// available (e.g. VK_MESAX_external_image_dma_buf)
void KMSWindowSystem::create_vk_images()
{
- auto const create_dma_buf_image =
- reinterpret_cast<PFN_vkCreateDmaBufImageINTEL>(
- vulkan->device().getProcAddr("vkCreateDmaBufImageINTEL"));
-
- if (!create_dma_buf_image)
- throw std::runtime_error{"Failed to get vkCreateDmaBufImageINTEL function pointer"};
-
for (auto const& gbm_bo : gbm_bos)
{
auto const fd = ManagedResource<int>{gbm_bo_get_fd(gbm_bo), close};
- auto const stride = gbm_bo_get_stride(gbm_bo);
- VkDmaBufImageCreateInfo create_info{};
- create_info.sType = static_cast<VkStructureType>(VK_STRUCTURE_TYPE_DMA_BUF_IMAGE_CREATE_INFO_INTEL);
- create_info.fd = fd;
- create_info.format = static_cast<VkFormat>(vk_image_format);
- create_info.extent = {vk_extent.width, vk_extent.height, 1};
- create_info.strideInBytes = stride;
+ VkExternalMemoryImageCreateInfoKHR external_image_create_info = {
+ .sType = VK_STRUCTURE_TYPE_EXTERNAL_MEMORY_IMAGE_CREATE_INFO_KHR,
+ .handleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_DMA_BUF_BIT_EXT,
+ };
+
+ uint64_t modifier = DRM_FORMAT_MOD_LINEAR;
+ VkImageDrmFormatModifierListCreateInfoEXT modifier_info = {
+ .sType = VK_STRUCTURE_TYPE_IMAGE_DRM_FORMAT_MODIFIER_LIST_CREATE_INFO_EXT,
+ .drmFormatModifierCount = 1,
+ .pDrmFormatModifiers = &modifier,
+ };
+ external_image_create_info.pNext = &modifier_info;
+
+ VkImportMemoryFdInfoKHR import_memory_fd_info = {
+ .sType = VK_STRUCTURE_TYPE_IMPORT_MEMORY_FD_INFO_KHR,
+ .handleType = VK_EXTERNAL_MEMORY_HANDLE_TYPE_DMA_BUF_BIT_EXT,
+ .fd = fd,
+ };
+
+ VkImageCreateInfo create_info{};
+ create_info = {
+ .sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO,
+ .pNext = &external_image_create_info,
+ .flags = 0,
+ .imageType = VK_IMAGE_TYPE_2D,
+ .format = static_cast<VkFormat>(vk_image_format),
+ .extent = {vk_extent.width, vk_extent.height, 1},
+ .mipLevels = 1,
+ .arrayLayers = 1,
+ .samples = VK_SAMPLE_COUNT_1_BIT,
+ .tiling = VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT,
+ .usage = 0,
+ .sharingMode = VK_SHARING_MODE_EXCLUSIVE,
+ .queueFamilyIndexCount = 0,
+ .pQueueFamilyIndices = nullptr,
+ .initialLayout = VK_IMAGE_LAYOUT_UNDEFINED,
+ };
VkImage image;
- VkDeviceMemory device_memory;
- VkResult result = create_dma_buf_image(
+ VkResult result = vkCreateImage(
vulkan->device(),
&create_info,
nullptr,
- &device_memory,
&image);
+ if (result != VK_SUCCESS)
+ {
+ vk::throwResultException(static_cast<vk::Result>(result),
+ "vkCreateImage");
+ }
+
+ VkMemoryDedicatedAllocateInfoKHR dedicated_memory_info = {
+ .sType = VK_STRUCTURE_TYPE_MEMORY_DEDICATED_ALLOCATE_INFO_KHR,
+ .pNext = &import_memory_fd_info,
+ .image = image,
+ };
+
+ VkMemoryRequirements requirements;
+ vkGetImageMemoryRequirements(vulkan->device(), image, &requirements);
+ if (!requirements.memoryTypeBits) {
+ throw std::runtime_error{"Failed in vkGetImageMemoryRequirements"};
+ }
+
+ int index = find_memory_type_index(vulkan->physical_device(),
+ &requirements,
+ VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT);
+ if (index < 0) {
+ throw std::runtime_error{"Failed to get memoryTypeIndex"};
+ }
+
+ VkMemoryAllocateInfo memory_allocate_info = {
+ .sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO,
+ .pNext = &dedicated_memory_info,
+ .allocationSize = requirements.size,
+ .memoryTypeIndex = (uint32_t)index,
+ };
+
+ VkDeviceMemory device_memory = VK_NULL_HANDLE;
+ result = vkAllocateMemory(vulkan->device(), &memory_allocate_info,
+ nullptr /* pAllocator */, &device_memory);
if (result != VK_SUCCESS)
{
vk::throwResultException(static_cast<vk::Result>(result),
- "vkCreateDmbBufImageINTEL");
+ "vkAllocateMemory");
+ }
+
+ result = vkBindImageMemory(vulkan->device(), image, device_memory,
+ 0 /* memoryOffset */);
+ if (result != VK_SUCCESS) {
+ vk::throwResultException(static_cast<vk::Result>(result),
+ "vkBindImageMemory");
}
vk_images.push_back(
@@ -500,6 +552,40 @@ void KMSWindowSystem::create_vk_images()
vptr->device().destroyImage(image);
vptr->device().freeMemory(device_memory);
}});
+
+ std::array<VkSubresourceLayout, 4> layouts = {};
+ const VkImageSubresource image_subresource = {
+ .aspectMask = VK_IMAGE_ASPECT_COLOR_BIT,
+ .mipLevel = 0,
+ .arrayLayer = 0,
+ };
+ vkGetImageSubresourceLayout(vulkan->device(), image,
+ &image_subresource, &layouts[0]);
+
+ uint32_t fb = 0;
+
+ uint32_t handles[4] = {0,};
+ uint32_t strides[4] = {0,};
+ uint32_t offsets[4] = {0,};
+
+ for (auto i = 0; i < gbm_bo_get_plane_count(gbm_bo); i++) {
+ handles[i] = gbm_bo_get_handle(gbm_bo).u32;
+ offsets[i] = layouts[i].offset;
+ strides[i] = layouts[i].rowPitch;
+ }
+
+ auto const ret = drmModeAddFB2(
+ drm_fd, vk_extent.width, vk_extent.height,
+ DRM_FORMAT_XRGB8888,
+ handles, strides, offsets, &fb, 0);
+
+ if (ret < 0)
+ throw std::system_error{-ret, std::system_category(), "Failed to add drm fb"};
+
+ drm_fbs.push_back(
+ ManagedResource<uint32_t>{
+ std::move(fb),
+ [this] (auto& fb) { drmModeRmFB(drm_fd, fb); }});
}
}
diff --git a/src/ws/kms_window_system.h b/src/ws/kms_window_system.h
index 4389ef7..ca304c0 100644
--- a/src/ws/kms_window_system.h
+++ b/src/ws/kms_window_system.h
@@ -68,7 +68,6 @@ class KMSWindowSystem : public WindowSystem, public VulkanWSI
protected:
void create_gbm_bos();
- void create_drm_fbs();
void create_vk_images();
void wait_for_drm_page_flip_event();

4
packages/graphics/vulkan/vulkan-headers/package.mk Normal file → Executable file
View file

@ -3,8 +3,8 @@
# Copyright (C) 2021-present Team LibreELEC (https://libreelec.tv)
PKG_NAME="vulkan-headers"
PKG_VERSION="1.3.217"
PKG_SHA256="004b4f7841bd912d1cc3f5ac5694d5dea2f944f10053451233b533874368df87"
PKG_VERSION="1.3.237"
PKG_SHA256="3f0d9a01a7859efbf312f34140259fc90aa0ba04f635e98f8f36321de4bd509b"
PKG_LICENSE="Apache-2.0"
PKG_SITE="https://github.com/KhronosGroup/Vulkan-Headers"
PKG_URL="https://github.com/KhronosGroup/Vulkan-Headers/archive/v${PKG_VERSION}.tar.gz"

32
packages/graphics/vulkan/vulkan-loader/package.mk Normal file → Executable file
View file

@ -3,44 +3,23 @@
# Copyright (C) 2021-present Team LibreELEC (https://libreelec.tv)
PKG_NAME="vulkan-loader"
PKG_VERSION="1.3.217"
PKG_SHA256="59c0e4934fca328366bbb50b3a8d2dfc3daeab7589fdadd7a29b8a79fe242a7f"
PKG_VERSION="1.3.237"
PKG_SHA256="03cfe1cb3dc5623304f64a2d0e8714dd8b51702da71365dacb9fbdc1f9ac138e"
PKG_LICENSE="Apache-2.0"
PKG_SITE="https://github.com/KhronosGroup/Vulkan-Loader"
PKG_URL="https://github.com/KhronosGroup/Vulkan-Loader/archive/v${PKG_VERSION}.tar.gz"
PKG_DEPENDS_HOST="toolchain:host vulkan-headers:host"
PKG_DEPENDS_TARGET="toolchain vulkan-headers"
PKG_DEPENDS_TARGET="toolchain Python3:host vulkan-headers"
PKG_LONGDESC="Vulkan Installable Client Driver (ICD) Loader."
configure_package() {
# Builds asm_offset binary for GAS / GNU Assembler
if [ "${ARCH}" != "arm" ]; then
PKG_DEPENDS_TARGET+=" vulkan-loader:host"
fi
# Displayserver Support
if [ "${DISPLAYSERVER}" = "x11" ]; then
PKG_DEPENDS_TARGET+=" libxcb libX11"
PKG_DEPENDS_TARGET+=" libxcb libX11 libXrandr"
elif [ "${DISPLAYSERVER}" = "wl" ]; then
PKG_DEPENDS_TARGET+=" wayland"
fi
}
pre_configure_host() {
PKG_CMAKE_OPTS_HOST="-DBUILD_WSI_XCB_SUPPORT=OFF \
-DBUILD_WSI_XLIB_SUPPORT=OFF \
-DBUILD_WSI_WAYLAND_SUPPORT=OFF \
-DBUILD_TESTS=OFF"
# Hack to workaround missing options to build a standalone asm_offset binary,
# if the glibc version of the host & target system differs build will fail otherwise.
sed -e 's|COMMAND asm_offset GAS|COMMAND ./asm_offset GAS|g' -i ${PKG_BUILD}/loader/CMakeLists.txt
}
makeinstall_host() {
cp ${PKG_BUILD}/.${HOST_NAME}/loader/asm_offset ${TOOLCHAIN}/bin/
}
pre_configure_target() {
PKG_CMAKE_OPTS_TARGET="-DBUILD_TESTS=OFF"
@ -62,7 +41,4 @@ pre_configure_target() {
-DBUILD_WSI_XLIB_SUPPORT=OFF \
-DBUILD_WSI_WAYLAND_SUPPORT=OFF"
fi
# Hack to run asm_offset located at toolchain path
sed -e 's|COMMAND ./asm_offset GAS|COMMAND asm_offset GAS|g' -i ${PKG_BUILD}/loader/CMakeLists.txt
}

7
packages/graphics/vulkan/vulkan-tools/package.mk Normal file → Executable file
View file

@ -3,8 +3,8 @@
# Copyright (C) 2021-present Team LibreELEC (https://libreelec.tv)
PKG_NAME="vulkan-tools"
PKG_VERSION="1.3.217"
PKG_SHA256="09e1ae38c4546ca709dae788562f25f2bdd9ed7f401bd9e03abc29233a552a0f"
PKG_VERSION="1.3.237"
PKG_SHA256="af35d59e601d20a83b9c2b555994cc8e9b5994b23d1b9702c2a1c354e223d593"
PKG_LICENSE="Apache-2.0"
PKG_SITE="https://github.com/KhronosGroup/Vulkan-Tools"
PKG_URL="https://github.com/KhronosGroup/Vulkan-tools/archive/v${PKG_VERSION}.tar.gz"
@ -21,7 +21,8 @@ configure_package() {
}
pre_configure_target() {
PKG_CMAKE_OPTS_TARGET="-DBUILD_VULKANINFO=ON \
PKG_CMAKE_OPTS_TARGET="-DVULKAN_HEADERS_INSTALL_DIR=${SYSROOT_PREFIX}/usr \
-DBUILD_VULKANINFO=ON \
-DBUILD_ICD=OFF \
-DINSTALL_ICD=OFF \
-DBUILD_WSI_DIRECTFB_SUPPORT=OFF \

View file

@ -1,61 +0,0 @@
From 8770458f74f4df71bb8450d0adcdd31f3eac7168 Mon Sep 17 00:00:00 2001
From: SupervisedThinking <supervisedthinking@gmail.com>
Date: Wed, 9 Mar 2022 20:58:53 +0100
Subject: [PATCH] cube: allow cross compile
---
cube/CMakeLists.txt | 6 ------
1 file changed, 6 deletions(-)
diff --git a/cube/CMakeLists.txt b/cube/CMakeLists.txt
index 616fbc96a..fa6f8d4fa 100644
--- a/cube/CMakeLists.txt
+++ b/cube/CMakeLists.txt
@@ -228,7 +228,6 @@ include_directories(${CUBE_INCLUDE_DIRS})
if(APPLE)
include(macOS/cube/cube.cmake)
elseif(NOT WIN32)
- if(${CMAKE_SYSTEM_PROCESSOR} STREQUAL ${CMAKE_HOST_SYSTEM_PROCESSOR})
add_executable(vkcube
cube.c
${PROJECT_SOURCE_DIR}/cube/cube.vert
@@ -243,7 +242,6 @@ elseif(NOT WIN32)
if (NEED_RT)
target_link_libraries(vkcube rt)
endif()
- endif()
else()
if(CMAKE_CL_64)
set(LIB_DIR "Win64")
@@ -280,7 +278,6 @@ endif()
if(APPLE)
include(macOS/cubepp/cubepp.cmake)
elseif(NOT WIN32)
- if(${CMAKE_SYSTEM_PROCESSOR} STREQUAL ${CMAKE_HOST_SYSTEM_PROCESSOR})
add_executable(vkcubepp
cube.cpp
${PROJECT_SOURCE_DIR}/cube/cube.vert
@@ -290,7 +287,6 @@ elseif(NOT WIN32)
${OPTIONAL_WAYLAND_DATA_FILES})
target_link_libraries(vkcubepp Vulkan::Vulkan)
target_compile_definitions(vkcubepp PUBLIC ${CUBE_PLATFORM})
- endif()
else()
if(CMAKE_CL_64)
set(LIB_DIR "Win64")
@@ -334,7 +330,6 @@ if(UNIX AND NOT APPLE) # i.e. Linux
${CMAKE_CURRENT_BINARY_DIR}/xdg-decoration-code.c
${CMAKE_CURRENT_BINARY_DIR}/xdg-decoration-client-header.h)
include_directories(${CMAKE_CURRENT_BINARY_DIR})
- if(${CMAKE_SYSTEM_PROCESSOR} STREQUAL ${CMAKE_HOST_SYSTEM_PROCESSOR})
add_executable(vkcube-wayland
cube.c
${PROJECT_SOURCE_DIR}/cube/cube.vert
@@ -349,7 +344,6 @@ if(UNIX AND NOT APPLE) # i.e. Linux
if (NEED_RT)
target_link_libraries(vkcube-wayland rt)
endif()
- endif()
install(TARGETS vkcube-wayland RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
endif()
endif()

View file

@ -154,6 +154,52 @@
</feature>
</features>
</emulator>
<emulator name="yuzu">
<features>
<feature name="anisotropic filtering">
<choice name="off" value="0"/>
<choice name="2x" value="1"/>
<choice name="4x" value="2"/>
<choice name="8x" value="3"/>
<choice name="16x" value="4"/>
</feature>
<feature name="anti aliasing">
<choice name="off" value="0"/>
<choice name="fxaa" value="1"/>
</feature>
<feature name="aspect ratio">
<choice name="16/9" value="0"/>
<choice name="4/3" value="1"/>
<choice name="21:9" value="2"/>
<choice name="stretch" value="3"/>
</feature>
<feature name="graphics backend">
<choice name="opengl" value="0"/>
<choice name="vulkan" value="1"/>
</feature>
<feature name="internal resolution">
<choice name="0.5x (360p/540p)" value="0"/>
<choice name="0.75x (540p/810p)" value="1"/>
<choice name="1x (720p/1080p)" value="2"/>
</feature>
<feature name="pixel filter">
<choice name="nearest neighbor" value="0"/>
<choice name="bilinear" value="1"/>
<choice name="bicubic" value="2"/>
<choice name="gaussian" value="3"/>
<choice name="scaleforce" value="4"/>
<choice name="amd fidelityfx" value="5"/>
</feature>
<feature name="switch mode">
<choice name="handheld" value="0"/>
<choice name="docked" value="1"/>
</feature>
<feature name="vysnc">
<choice name="off" value="0"/>
<choice name="on" value="1"/>
</feature>
</features>
</emulator>
<emulator name="retroarch" features="ratio, smooth, shaders, pixel_perfect, latency_reduction, game_translation">
<cores>
<core name="2048" features="netplay, rewind, autosave" />

View file

@ -59,7 +59,7 @@ fi
# Clean OS specific packages.
PKG_CLEAN="${PKG_CLEAN} system-utils plymouth-lite initramfs busybox linux grub u-boot SDL2 modules \
emulationstation retroarch lib32 autostart splash jelos"
emulationstation retroarch lib32 autostart splash jelos mesa"
if [ ! -n "${DIRTY}" ]
then