diff options
| author | 2021-09-11 23:11:32 +0200 | |
|---|---|---|
| committer | 2021-09-11 23:11:32 +0200 | |
| commit | be4e1929033aff005472163164ab0ccc80d81c19 (patch) | |
| tree | b3b3f62a3b3e8e3c329ee35411d8d18e20a835ab /CMakeLists.txt | |
| parent | Merge pull request #6901 from ameerj/vk-clear-bits (diff) | |
| parent | h264: Lower max_num_ref_frames (diff) | |
| download | yuzu-be4e1929033aff005472163164ab0ccc80d81c19.tar.gz yuzu-be4e1929033aff005472163164ab0ccc80d81c19.tar.xz yuzu-be4e1929033aff005472163164ab0ccc80d81c19.zip | |
Merge pull request #6846 from ameerj/nvdec-gpu-decode
nvdec: Add GPU video decoding for all capable drivers and platforms
Diffstat (limited to 'CMakeLists.txt')
| -rw-r--r-- | CMakeLists.txt | 90 |
1 files changed, 78 insertions, 12 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 0e064ab44..5df2ff3fa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt | |||
| @@ -518,6 +518,10 @@ set(FFmpeg_COMPONENTS | |||
| 518 | avutil | 518 | avutil |
| 519 | swscale) | 519 | swscale) |
| 520 | 520 | ||
| 521 | if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux") | ||
| 522 | Include(FindPkgConfig REQUIRED) | ||
| 523 | pkg_check_modules(LIBVA libva) | ||
| 524 | endif() | ||
| 521 | if (NOT YUZU_USE_BUNDLED_FFMPEG) | 525 | if (NOT YUZU_USE_BUNDLED_FFMPEG) |
| 522 | # Use system installed FFmpeg | 526 | # Use system installed FFmpeg |
| 523 | find_package(FFmpeg QUIET COMPONENTS ${FFmpeg_COMPONENTS}) | 527 | find_package(FFmpeg QUIET COMPONENTS ${FFmpeg_COMPONENTS}) |
| @@ -540,6 +544,9 @@ endif() | |||
| 540 | 544 | ||
| 541 | if (YUZU_USE_BUNDLED_FFMPEG) | 545 | if (YUZU_USE_BUNDLED_FFMPEG) |
| 542 | if (NOT WIN32) | 546 | if (NOT WIN32) |
| 547 | # TODO(lat9nq): Move this to externals/ffmpeg/CMakeLists.txt (and move externals/ffmpeg to | ||
| 548 | # externals/ffmpeg/ffmpeg) | ||
| 549 | |||
| 543 | # Build FFmpeg from externals | 550 | # Build FFmpeg from externals |
| 544 | message(STATUS "Using FFmpeg from externals") | 551 | message(STATUS "Using FFmpeg from externals") |
| 545 | 552 | ||
| @@ -579,20 +586,23 @@ if (YUZU_USE_BUNDLED_FFMPEG) | |||
| 579 | CACHE PATH "Paths to FFmpeg libraries" FORCE) | 586 | CACHE PATH "Paths to FFmpeg libraries" FORCE) |
| 580 | endforeach() | 587 | endforeach() |
| 581 | 588 | ||
| 582 | set(FFmpeg_INCLUDE_DIR | 589 | Include(FindPkgConfig REQUIRED) |
| 583 | "${FFmpeg_PREFIX};${FFmpeg_BUILD_DIR}" | 590 | pkg_check_modules(LIBVA libva) |
| 584 | CACHE PATH "Path to FFmpeg headers" FORCE) | 591 | pkg_check_modules(CUDA cuda) |
| 592 | pkg_check_modules(FFNVCODEC ffnvcodec) | ||
| 593 | pkg_check_modules(VDPAU vdpau) | ||
| 594 | |||
| 595 | set(FFmpeg_HWACCEL_LIBRARIES) | ||
| 596 | set(FFmpeg_HWACCEL_FLAGS) | ||
| 597 | set(FFmpeg_HWACCEL_INCLUDE_DIRS) | ||
| 598 | set(FFmpeg_HWACCEL_LDFLAGS) | ||
| 585 | 599 | ||
| 586 | if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux") | ||
| 587 | Include(FindPkgConfig REQUIRED) | ||
| 588 | pkg_check_modules(LIBVA libva) | ||
| 589 | endif() | ||
| 590 | if(LIBVA_FOUND) | 600 | if(LIBVA_FOUND) |
| 591 | pkg_check_modules(LIBDRM libdrm REQUIRED) | 601 | pkg_check_modules(LIBDRM libdrm REQUIRED) |
| 592 | find_package(X11 REQUIRED) | 602 | find_package(X11 REQUIRED) |
| 593 | pkg_check_modules(LIBVA-DRM libva-drm REQUIRED) | 603 | pkg_check_modules(LIBVA-DRM libva-drm REQUIRED) |
| 594 | pkg_check_modules(LIBVA-X11 libva-x11 REQUIRED) | 604 | pkg_check_modules(LIBVA-X11 libva-x11 REQUIRED) |
| 595 | set(FFmpeg_LIBVA_LIBRARIES | 605 | list(APPEND FFmpeg_HWACCEL_LIBRARIES |
| 596 | ${LIBDRM_LIBRARIES} | 606 | ${LIBDRM_LIBRARIES} |
| 597 | ${X11_LIBRARIES} | 607 | ${X11_LIBRARIES} |
| 598 | ${LIBVA-DRM_LIBRARIES} | 608 | ${LIBVA-DRM_LIBRARIES} |
| @@ -602,11 +612,56 @@ if (YUZU_USE_BUNDLED_FFMPEG) | |||
| 602 | --enable-hwaccel=h264_vaapi | 612 | --enable-hwaccel=h264_vaapi |
| 603 | --enable-hwaccel=vp9_vaapi | 613 | --enable-hwaccel=vp9_vaapi |
| 604 | --enable-libdrm) | 614 | --enable-libdrm) |
| 615 | list(APPEND FFmpeg_HWACCEL_INCLUDE_DIRS | ||
| 616 | ${LIBDRM_INCLUDE_DIRS} | ||
| 617 | ${X11_INCLUDE_DIRS} | ||
| 618 | ${LIBVA-DRM_INCLUDE_DIRS} | ||
| 619 | ${LIBVA-X11_INCLUDE_DIRS} | ||
| 620 | ${LIBVA_INCLUDE_DIRS} | ||
| 621 | ) | ||
| 605 | message(STATUS "VA-API found") | 622 | message(STATUS "VA-API found") |
| 606 | else() | 623 | else() |
| 607 | set(FFmpeg_HWACCEL_FLAGS --disable-vaapi) | 624 | set(FFmpeg_HWACCEL_FLAGS --disable-vaapi) |
| 608 | endif() | 625 | endif() |
| 609 | 626 | ||
| 627 | if (FFNVCODEC_FOUND AND CUDA_FOUND) | ||
| 628 | list(APPEND FFmpeg_HWACCEL_FLAGS | ||
| 629 | --enable-cuvid | ||
| 630 | --enable-ffnvcodec | ||
| 631 | --enable-nvdec | ||
| 632 | --enable-hwaccel=h264_nvdec | ||
| 633 | --enable-hwaccel=vp9_nvdec | ||
| 634 | --extra-cflags=-I${CUDA_INCLUDE_DIRS} | ||
| 635 | ) | ||
| 636 | list(APPEND FFmpeg_HWACCEL_LIBRARIES | ||
| 637 | ${FFNVCODEC_LIBRARIES} | ||
| 638 | ${CUDA_LIBRARIES} | ||
| 639 | ) | ||
| 640 | list(APPEND FFmpeg_HWACCEL_INCLUDE_DIRS | ||
| 641 | ${FFNVCODEC_INCLUDE_DIRS} | ||
| 642 | ${CUDA_INCLUDE_DIRS} | ||
| 643 | ) | ||
| 644 | list(APPEND FFmpeg_HWACCEL_LDFLAGS | ||
| 645 | ${FFNVCODEC_LDFLAGS} | ||
| 646 | ${CUDA_LDFLAGS} | ||
| 647 | ) | ||
| 648 | message(STATUS "ffnvcodec libraries version ${FFNVCODEC_VERSION} found") | ||
| 649 | endif() | ||
| 650 | |||
| 651 | if (VDPAU_FOUND) | ||
| 652 | list(APPEND FFmpeg_HWACCEL_FLAGS | ||
| 653 | --enable-vdpau | ||
| 654 | --enable-hwaccel=h264_vdpau | ||
| 655 | --enable-hwaccel=vp9_vdpau | ||
| 656 | ) | ||
| 657 | list(APPEND FFmpeg_HWACCEL_LIBRARIES ${VDPAU_LIBRARIES}) | ||
| 658 | list(APPEND FFmpeg_HWACCEL_INCLUDE_DIRS ${VDPAU_INCLUDE_DIRS}) | ||
| 659 | list(APPEND FFmpeg_HWACCEL_LDFLAGS ${VDPAU_LDFLAGS}) | ||
| 660 | message(STATUS "vdpau libraries version ${VDPAU_VERSION} found") | ||
| 661 | else() | ||
| 662 | list(APPEND FFmpeg_HWACCEL_FLAGS --disable-vdpau) | ||
| 663 | endif() | ||
| 664 | |||
| 610 | # `configure` parameters builds only exactly what yuzu needs from FFmpeg | 665 | # `configure` parameters builds only exactly what yuzu needs from FFmpeg |
| 611 | # `--disable-vdpau` is needed to avoid linking issues | 666 | # `--disable-vdpau` is needed to avoid linking issues |
| 612 | add_custom_command( | 667 | add_custom_command( |
| @@ -624,7 +679,6 @@ if (YUZU_USE_BUNDLED_FFMPEG) | |||
| 624 | --disable-network | 679 | --disable-network |
| 625 | --disable-postproc | 680 | --disable-postproc |
| 626 | --disable-swresample | 681 | --disable-swresample |
| 627 | --disable-vdpau | ||
| 628 | --enable-decoder=h264 | 682 | --enable-decoder=h264 |
| 629 | --enable-decoder=vp9 | 683 | --enable-decoder=vp9 |
| 630 | --cc="${CMAKE_C_COMPILER}" | 684 | --cc="${CMAKE_C_COMPILER}" |
| @@ -653,15 +707,26 @@ if (YUZU_USE_BUNDLED_FFMPEG) | |||
| 653 | ${FFmpeg_BUILD_DIR} | 707 | ${FFmpeg_BUILD_DIR} |
| 654 | ) | 708 | ) |
| 655 | 709 | ||
| 710 | set(FFmpeg_INCLUDE_DIR | ||
| 711 | "${FFmpeg_PREFIX};${FFmpeg_BUILD_DIR};${FFmpeg_HWACCEL_INCLUDE_DIRS}" | ||
| 712 | CACHE PATH "Path to FFmpeg headers" FORCE) | ||
| 713 | |||
| 714 | set(FFmpeg_LDFLAGS | ||
| 715 | "${FFmpeg_HWACCEL_LDFLAGS}" | ||
| 716 | CACHE STRING "FFmpeg linker flags" FORCE) | ||
| 717 | |||
| 656 | # ALL makes this custom target build every time | 718 | # ALL makes this custom target build every time |
| 657 | # but it won't actually build if the DEPENDS parameter is up to date | 719 | # but it won't actually build if the DEPENDS parameter is up to date |
| 658 | add_custom_target(ffmpeg-configure ALL DEPENDS ${FFmpeg_MAKEFILE}) | 720 | add_custom_target(ffmpeg-configure ALL DEPENDS ${FFmpeg_MAKEFILE}) |
| 659 | add_custom_target(ffmpeg-build ALL DEPENDS ${FFmpeg_BUILD_LIBRARIES} ffmpeg-configure) | 721 | add_custom_target(ffmpeg-build ALL DEPENDS ${FFmpeg_BUILD_LIBRARIES} ffmpeg-configure) |
| 660 | link_libraries(${FFmpeg_LIBVA_LIBRARIES}) | 722 | link_libraries(${FFmpeg_LIBVA_LIBRARIES}) |
| 661 | set(FFmpeg_LIBRARIES ${FFmpeg_LIBVA_LIBRARIES} ${FFmpeg_BUILD_LIBRARIES} | 723 | set(FFmpeg_LIBRARIES ${FFmpeg_BUILD_LIBRARIES} ${FFmpeg_HWACCEL_LIBRARIES} |
| 662 | CACHE PATH "Paths to FFmpeg libraries" FORCE) | 724 | CACHE PATH "Paths to FFmpeg libraries" FORCE) |
| 663 | unset(FFmpeg_BUILD_LIBRARIES) | 725 | unset(FFmpeg_BUILD_LIBRARIES) |
| 664 | unset(FFmpeg_LIBVA_LIBRARIES) | 726 | unset(FFmpeg_HWACCEL_FLAGS) |
| 727 | unset(FFmpeg_HWACCEL_INCLUDE_DIRS) | ||
| 728 | unset(FFmpeg_HWACCEL_LDFLAGS) | ||
| 729 | unset(FFmpeg_HWACCEL_LIBRARIES) | ||
| 665 | 730 | ||
| 666 | if (FFmpeg_FOUND) | 731 | if (FFmpeg_FOUND) |
| 667 | message(STATUS "Found FFmpeg version ${FFmpeg_VERSION}") | 732 | message(STATUS "Found FFmpeg version ${FFmpeg_VERSION}") |
| @@ -670,12 +735,13 @@ if (YUZU_USE_BUNDLED_FFMPEG) | |||
| 670 | endif() | 735 | endif() |
| 671 | else() # WIN32 | 736 | else() # WIN32 |
| 672 | # Use yuzu FFmpeg binaries | 737 | # Use yuzu FFmpeg binaries |
| 673 | set(FFmpeg_EXT_NAME "ffmpeg-4.3.1") | 738 | set(FFmpeg_EXT_NAME "ffmpeg-4.4") |
| 674 | set(FFmpeg_PATH "${CMAKE_BINARY_DIR}/externals/${FFmpeg_EXT_NAME}") | 739 | set(FFmpeg_PATH "${CMAKE_BINARY_DIR}/externals/${FFmpeg_EXT_NAME}") |
| 675 | download_bundled_external("ffmpeg/" ${FFmpeg_EXT_NAME} "") | 740 | download_bundled_external("ffmpeg/" ${FFmpeg_EXT_NAME} "") |
| 676 | set(FFmpeg_FOUND YES) | 741 | set(FFmpeg_FOUND YES) |
| 677 | set(FFmpeg_INCLUDE_DIR "${FFmpeg_PATH}/include" CACHE PATH "Path to FFmpeg headers" FORCE) | 742 | set(FFmpeg_INCLUDE_DIR "${FFmpeg_PATH}/include" CACHE PATH "Path to FFmpeg headers" FORCE) |
| 678 | set(FFmpeg_LIBRARY_DIR "${FFmpeg_PATH}/bin" CACHE PATH "Path to FFmpeg library directory" FORCE) | 743 | set(FFmpeg_LIBRARY_DIR "${FFmpeg_PATH}/bin" CACHE PATH "Path to FFmpeg library directory" FORCE) |
| 744 | set(FFmpeg_LDFLAGS "" CACHE STRING "FFmpeg linker flags" FORCE) | ||
| 679 | set(FFmpeg_DLL_DIR "${FFmpeg_PATH}/bin" CACHE PATH "Path to FFmpeg dll's" FORCE) | 745 | set(FFmpeg_DLL_DIR "${FFmpeg_PATH}/bin" CACHE PATH "Path to FFmpeg dll's" FORCE) |
| 680 | set(FFmpeg_LIBRARIES | 746 | set(FFmpeg_LIBRARIES |
| 681 | ${FFmpeg_LIBRARY_DIR}/swscale.lib | 747 | ${FFmpeg_LIBRARY_DIR}/swscale.lib |