Skip to content

VERY experimental Nintendo Switch 2 emulator

C++

[ffmpeg] proper drm inclusion (#328)

Caio Oliveiraf07309afd2a3
diff --git a/docs/build/Linux.md b/docs/build/Linux.md
index ab653dad00..be58b451fa 100644
--- a/docs/build/Linux.md
+++ b/docs/build/Linux.md
@@ -37,7 +37,7 @@ Dependencies are listed here as commands that can be copied/pasted. Of course, t
- GCC 11 or later is required.
- Ubuntu / Linux Mint / Debian:
- - `sudo apt-get install autoconf cmake g++ gcc git glslang-tools libasound2 libboost-context-dev libglu1-mesa-dev libhidapi-dev libpulse-dev libtool libudev-dev libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-render-util0 libxcb-xinerama0 libxcb-xkb1 libxext-dev libxkbcommon-x11-0 mesa-common-dev nasm ninja-build qt6-base-private-dev libmbedtls-dev catch2 libfmt-dev liblz4-dev nlohmann-json3-dev libzstd-dev libssl-dev libavfilter-dev libavcodec-dev libswscale-dev pkg-config zlib1g-dev`
+ - `sudo apt-get install autoconf cmake g++ gcc git glslang-tools libasound2 libboost-context-dev libglu1-mesa-dev libhidapi-dev libpulse-dev libtool libudev-dev libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-render-util0 libxcb-xinerama0 libxcb-xkb1 libxext-dev libxkbcommon-x11-0 mesa-common-dev nasm ninja-build qt6-base-private-dev libmbedtls-dev catch2 libfmt-dev liblz4-dev nlohmann-json3-dev libzstd-dev libssl-dev libavfilter-dev libavcodec-dev libswscale-dev pkg-config zlib1g-dev libva-dev libvdpau-dev`
- Ubuntu 22.04, Linux Mint 20, or Debian 12 or later is required.
- Users need to manually specify building with QT Web Engine enabled. This is done using the parameter `-DYUZU_USE_QT_WEB_ENGINE=ON` when running CMake.
- Users need to manually disable building SDL2 from externals if they intend to use the version provided by their system by adding the parameters `-DYUZU_USE_EXTERNAL_SDL2=OFF`
diff --git a/externals/ffmpeg/CMakeLists.txt b/externals/ffmpeg/CMakeLists.txt
index b514ede3be..54c852f831 100644
--- a/externals/ffmpeg/CMakeLists.txt
+++ b/externals/ffmpeg/CMakeLists.txt
@@ -63,32 +63,44 @@ if (NOT WIN32 AND NOT ANDROID)
set(FFmpeg_HWACCEL_INCLUDE_DIRS)
set(FFmpeg_HWACCEL_LDFLAGS)
- if(LIBVA_FOUND)
+ # In Solaris needs explicit linking for ffmpeg which links to /lib/amd64/libX11.so
+ if(PLATFORM_SUN)
+ list(APPEND FFmpeg_HWACCEL_LIBRARIES
+ X11
+ "/usr/lib/xorg/amd64/libdrm.so")
+ else()
pkg_check_modules(LIBDRM libdrm REQUIRED)
+ list(APPEND FFmpeg_HWACCEL_LIBRARIES
+ ${LIBDRM_LIBRARIES})
+ list(APPEND FFmpeg_HWACCEL_INCLUDE_DIRS
+ ${LIBDRM_INCLUDE_DIRS})
+ endif()
+ list(APPEND FFmpeg_HWACCEL_FLAGS
+ --enable-libdrm)
+
+ if(LIBVA_FOUND)
find_package(X11 REQUIRED)
pkg_check_modules(LIBVA-DRM libva-drm REQUIRED)
pkg_check_modules(LIBVA-X11 libva-x11 REQUIRED)
list(APPEND FFmpeg_HWACCEL_LIBRARIES
- ${LIBDRM_LIBRARIES}
${X11_LIBRARIES}
${LIBVA-DRM_LIBRARIES}
${LIBVA-X11_LIBRARIES}
${LIBVA_LIBRARIES})
- set(FFmpeg_HWACCEL_FLAGS
+ list(APPEND FFmpeg_HWACCEL_FLAGS
--enable-hwaccel=h264_vaapi
--enable-hwaccel=vp8_vaapi
- --enable-hwaccel=vp9_vaapi
- --enable-libdrm)
+ --enable-hwaccel=vp9_vaapi)
list(APPEND FFmpeg_HWACCEL_INCLUDE_DIRS
- ${LIBDRM_INCLUDE_DIRS}
${X11_INCLUDE_DIRS}
${LIBVA-DRM_INCLUDE_DIRS}
${LIBVA-X11_INCLUDE_DIRS}
${LIBVA_INCLUDE_DIRS}
)
- message(STATUS "VA-API found")
+ message(STATUS "ffmpeg: va-api libraries version ${LIBVA_VERSION} found")
else()
- set(FFmpeg_HWACCEL_FLAGS --disable-vaapi)
+ list(APPEND FFmpeg_HWACCEL_FLAGS --disable-vaapi)
+ message(WARNING "ffmpeg: libva-dev not found, disabling Video Aceleraion API (VA-API)...")
endif()
if (FFNVCODEC_FOUND)
@@ -103,7 +115,7 @@ if (NOT WIN32 AND NOT ANDROID)
list(APPEND FFmpeg_HWACCEL_LIBRARIES ${FFNVCODEC_LIBRARIES})
list(APPEND FFmpeg_HWACCEL_INCLUDE_DIRS ${FFNVCODEC_INCLUDE_DIRS})
list(APPEND FFmpeg_HWACCEL_LDFLAGS ${FFNVCODEC_LDFLAGS})
- message(STATUS "ffnvcodec libraries version ${FFNVCODEC_VERSION} found")
+ message(STATUS "ffmpeg: ffnvcodec libraries version ${FFNVCODEC_VERSION} found")
# ffnvenc could load CUDA libraries at the runtime using dlopen/dlsym or LoadLibrary/GetProcAddress
# here we handle the hard-linking senario where CUDA is linked during compilation
if (CUDA_FOUND)
@@ -112,7 +124,7 @@ if (NOT WIN32 AND NOT ANDROID)
list(APPEND FFmpeg_HWACCEL_LIBRARIES ${CUDA_LIBRARIES})
list(APPEND FFmpeg_HWACCEL_INCLUDE_DIRS ${CUDA_INCLUDE_DIRS})
list(APPEND FFmpeg_HWACCEL_LDFLAGS ${CUDA_LDFLAGS})
- message(STATUS "CUDA libraries found, hard-linking will be performed")
+ message(STATUS "ffmpeg: CUDA libraries found, hard-linking will be performed")
endif(CUDA_FOUND)
endif()
@@ -125,9 +137,10 @@ if (NOT WIN32 AND NOT ANDROID)
list(APPEND FFmpeg_HWACCEL_LIBRARIES ${VDPAU_LIBRARIES})
list(APPEND FFmpeg_HWACCEL_INCLUDE_DIRS ${VDPAU_INCLUDE_DIRS})
list(APPEND FFmpeg_HWACCEL_LDFLAGS ${VDPAU_LDFLAGS})
- message(STATUS "vdpau libraries version ${VDPAU_VERSION} found")
+ message(STATUS "ffmpeg: vdpau libraries version ${VDPAU_VERSION} found")
else()
list(APPEND FFmpeg_HWACCEL_FLAGS --disable-vdpau)
+ message(WARNING "ffmpeg: libvdpau-dev not found, disabling Video Decode and Presentation API for Unix (VDPAU)...")
endif()
find_program(BASH_PROGRAM bash REQUIRED)
diff --git a/src/yuzu/CMakeLists.txt b/src/yuzu/CMakeLists.txt
index f979a5c181..0ce8f3b898 100644
--- a/src/yuzu/CMakeLists.txt
+++ b/src/yuzu/CMakeLists.txt
@@ -501,11 +501,6 @@ if (YUZU_ROOM)
target_link_libraries(yuzu PRIVATE yuzu-room)
endif()
-# Explicit linking required
-if (PLATFORM_SUN)
- target_link_libraries(yuzu PRIVATE X11 "/usr/lib/xorg/amd64/libdrm.so")
-endif()
-
# Extra deps
add_subdirectory(externals)
target_link_libraries(yuzu PRIVATE QuaZip::QuaZip)
diff --git a/src/yuzu_cmd/CMakeLists.txt b/src/yuzu_cmd/CMakeLists.txt
index afd003a86c..ebd8fd7387 100644
--- a/src/yuzu_cmd/CMakeLists.txt
+++ b/src/yuzu_cmd/CMakeLists.txt
@@ -40,11 +40,6 @@ target_include_directories(yuzu-cmd PRIVATE ${RESOURCES_DIR})
target_link_libraries(yuzu-cmd PRIVATE SDL2::SDL2 Vulkan::Headers)
-# In Solaris needs explicit linking for ffmpeg which links to /lib/amd64/libX11.so
-if (PLATFORM_SUN)
- target_link_libraries(yuzu-cmd PRIVATE X11 "/usr/lib/xorg/amd64/libdrm.so")
-endif()
-
if(UNIX AND NOT APPLE)
install(TARGETS yuzu-cmd)
endif()