Merge branch 'dolphin-emu:master' into ToastMessage_begone

This commit is contained in:
Mateus B. Cassiano 2024-06-25 00:21:22 -04:00 committed by GitHub
commit 04a1b79da9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2081 changed files with 233683 additions and 524954 deletions

2
.gitignore vendored
View File

@ -6,6 +6,8 @@ Thumbs.db
Externals/mGBA/version.c
Source/Core/Common/scmrev.h
# Ignore files output by build
/cmake-build-debug
/cmake-build-release
/[Bb]uild*/
/[Bb]inary*/
/obj/

30
.gitmodules vendored
View File

@ -54,3 +54,33 @@
[submodule "Externals/rcheevos/rcheevos"]
path = Externals/rcheevos/rcheevos
url = https://github.com/RetroAchievements/rcheevos.git
[submodule "Externals/libadrenotools"]
path = Externals/libadrenotools
url = https://github.com/bylaws/libadrenotools.git
[submodule "Externals/curl/curl"]
path = Externals/curl/curl
url = https://github.com/curl/curl.git
[submodule "Externals/fmt/fmt"]
path = Externals/fmt/fmt
url = https://github.com/fmtlib/fmt.git
[submodule "Externals/lz4/lz4"]
path = Externals/lz4/lz4
url = https://github.com/lz4/lz4
[submodule "Externals/xxhash/xxHash"]
path = Externals/xxhash/xxHash
url = https://github.com/Cyan4973/xxHash.git
[submodule "Externals/enet/enet"]
path = Externals/enet/enet
url = https://github.com/lsalzman/enet.git
[submodule "hidapi-src"]
path = Externals/hidapi/hidapi-src
url = https://github.com/libusb/hidapi
[submodule "Externals/tinygltf/tinygltf"]
path = Externals/tinygltf/tinygltf
url = https://github.com/syoyo/tinygltf.git
[submodule "Externals/minizip-ng/minizip-ng"]
path = Externals/minizip-ng/minizip-ng
url = https://github.com/zlib-ng/minizip-ng
[submodule "Externals/Vulkan-Headers"]
path = Externals/Vulkan-Headers
url = https://github.com/KhronosGroup/Vulkan-Headers.git

View File

@ -1,10 +1,17 @@
find_program(CCACHE_BIN NAMES ccache sccache)
if(CCACHE_BIN)
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ${CCACHE_BIN})
# Official ccache recommendation is to set CMAKE_C(XX)_COMPILER_LAUNCHER
if (NOT CMAKE_C_COMPILER_LAUNCHER MATCHES "ccache")
list(INSERT CMAKE_C_COMPILER_LAUNCHER 0 "${CCACHE_BIN}")
endif()
if (NOT CMAKE_CXX_COMPILER_LAUNCHER MATCHES "ccache")
list(INSERT CMAKE_CXX_COMPILER_LAUNCHER 0 "${CCACHE_BIN}")
endif()
# ccache uses -I when compiling without preprocessor, which makes clang complain.
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Qunused-arguments -fcolor-diagnostics")
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Qunused-arguments -fcolor-diagnostics")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Qunused-arguments -fcolor-diagnostics")
endif()
endif()

View File

@ -21,6 +21,8 @@ function(check_and_add_flag var flag)
set(genexp_config_test "1")
if(ARGV2 STREQUAL "DEBUG_ONLY")
set(genexp_config_test "$<CONFIG:Debug>")
elseif(ARGV2 STREQUAL "NO_DEBINFO_ONLY")
set(genexp_config_test "$<NOT:$<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>>")
elseif(ARGV2 STREQUAL "RELEASE_ONLY")
set(genexp_config_test "$<NOT:$<CONFIG:Debug>>")
elseif(ARGV2)

View File

@ -1,29 +0,0 @@
# When packaging Dolphin for an OS distribution, distro vendors usually prefer
# to limit vendored ("Externals") dependencies as much as possible, in favor of
# using system provided libraries. This modules provides an option to allow
# only specific vendored dependencies and error-out at configuration time for
# non-approved ones.
#
# Usage:
# $ cmake -D APPROVED_VENDORED_DEPENDENCIES="a;b;c;..."
#
# Unless the option is explicitly used, vendored dependencies control is
# disabled.
#
# If you want to disallow all vendored dependencies, put "none" in the approved
# dependencies list.
set(APPROVED_VENDORED_DEPENDENCIES "" CACHE STRING "\
Semicolon separated list of approved vendored dependencies. See docstring in \
CMake/CheckVendoringApproved.cmake.")
function(check_vendoring_approved dep)
if(APPROVED_VENDORED_DEPENDENCIES)
if(NOT dep IN_LIST APPROVED_VENDORED_DEPENDENCIES)
message(SEND_ERROR "\
Library ${dep} was not found systemwide and was not approved for vendoring. \
Vendored dependencies control is enabled. Add \"${dep}\" to the \
APPROVED_VENDORED_DEPENDENCIES list to bypass this error.")
endif()
endif()
endfunction()

View File

@ -1,7 +1,6 @@
include(RemoveCompileFlag)
macro(dolphin_disable_warnings_msvc _target)
if (MSVC)
macro(dolphin_disable_warnings _target)
get_target_property(_target_cxx_flags ${_target} COMPILE_OPTIONS)
if (_target_cxx_flags)
set(new_flags "")
@ -13,6 +12,9 @@ macro(dolphin_disable_warnings_msvc _target)
endforeach()
set_target_properties(${_target} PROPERTIES COMPILE_OPTIONS "${new_flags}")
endif()
if (MSVC)
target_compile_options(${_target} PRIVATE "/W0")
elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU")
target_compile_options(${_target} PRIVATE "-w")
endif()
endmacro()

View File

@ -18,3 +18,78 @@ function(dolphin_make_imported_target_if_missing target lib)
add_library(${target} ALIAS _${lib})
endif()
endfunction()
function(dolphin_optional_system_library library)
string(TOUPPER ${library} upperlib)
set(USE_SYSTEM_${upperlib} "" CACHE STRING "Use system ${library} instead of bundled. ON - Always use system and fail if unavailable, OFF - Always use bundled, AUTO - Use system if available, otherwise use bundled, blank - Delegate to USE_SYSTEM_LIBS. Default is blank.")
if("${USE_SYSTEM_${upperlib}}" STREQUAL "")
if(APPROVED_VENDORED_DEPENDENCIES)
string(TOLOWER ${library} lowerlib)
if(lowerlib IN_LIST APPROVED_VENDORED_DEPENDENCIES)
set(RESOLVED_USE_SYSTEM_${upperlib} AUTO PARENT_SCOPE)
else()
set(RESOLVED_USE_SYSTEM_${upperlib} ON PARENT_SCOPE)
endif()
else()
set(RESOLVED_USE_SYSTEM_${upperlib} ${USE_SYSTEM_LIBS} PARENT_SCOPE)
endif()
else()
set(RESOLVED_USE_SYSTEM_${upperlib} ${USE_SYSTEM_${upperlib}} PARENT_SCOPE)
endif()
endfunction()
function(dolphin_add_bundled_library library bundled_path)
string(TOUPPER ${library} upperlib)
if (${RESOLVED_USE_SYSTEM_${upperlib}} STREQUAL "AUTO")
message(STATUS "No system ${library} was found. Using static ${library} from Externals.")
else()
message(STATUS "Using static ${library} from Externals")
endif()
if (NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${bundled_path}/CMakeLists.txt")
message(FATAL_ERROR "No bundled ${library} was found. Did you forget to checkout submodules?")
endif()
add_subdirectory(${bundled_path} EXCLUDE_FROM_ALL)
endfunction()
function(dolphin_find_optional_system_library library bundled_path)
dolphin_optional_system_library(${library})
string(TOUPPER ${library} upperlib)
if(RESOLVED_USE_SYSTEM_${upperlib})
find_package(${library} ${ARGN})
# Yay for cmake packages being inconsistent
if(DEFINED ${library}_FOUND)
set(prefix ${library})
else()
set(prefix ${upperlib})
endif()
if((NOT ${found}) AND (NOT ${RESOLVED_USE_SYSTEM_${upperlib}} STREQUAL "AUTO"))
message(FATAL_ERROR "No system ${library} was found. Please install it or set USE_SYSTEM_${upperlib} to AUTO or OFF.")
endif()
endif()
if(${prefix}_FOUND)
message(STATUS "Using system ${library}")
set(${prefix}_TYPE "System" PARENT_SCOPE)
else()
dolphin_add_bundled_library(${library} ${bundled_path})
set(${prefix}_TYPE "Bundled" PARENT_SCOPE)
endif()
endfunction()
function(dolphin_find_optional_system_library_pkgconfig library search alias bundled_path)
dolphin_optional_system_library(${library})
string(TOUPPER ${library} upperlib)
if(RESOLVED_USE_SYSTEM_${upperlib})
pkg_search_module(${library} ${search} ${ARGN} IMPORTED_TARGET)
if((NOT ${library}_FOUND) AND (NOT ${RESOLVED_USE_SYSTEM_${upperlib}} STREQUAL "AUTO"))
message(FATAL_ERROR "No system ${library} was found. Please install it or set USE_SYSTEM_${upperlib} to AUTO or OFF.")
endif()
endif()
if(${library}_FOUND)
message(STATUS "Using system ${library}")
dolphin_alias_library(${alias} PkgConfig::${library})
set(${library}_TYPE "System" PARENT_SCOPE)
else()
dolphin_add_bundled_library(${library} ${bundled_path})
set(${library}_TYPE "Bundled" PARENT_SCOPE)
endif()
endfunction()

View File

@ -6,7 +6,7 @@ include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(CUBEB DEFAULT_MSG
CUBEB_INCLUDE_DIR CUBEB_LIBRARY)
if(CUBEB_FOUND AND NOT TARGET CUBEB)
if(CUBEB_FOUND AND NOT TARGET cubeb::cubeb)
add_library(cubeb::cubeb UNKNOWN IMPORTED)
set_target_properties(cubeb::cubeb PROPERTIES
IMPORTED_LOCATION "${CUBEB_LIBRARY}"

15
CMake/FindLZO.cmake Normal file
View File

@ -0,0 +1,15 @@
find_path(LZO_INCLUDE_DIR lzo/lzo1x.h)
find_library(LZO_LIBRARY lzo2)
mark_as_advanced(LZO_INCLUDE_DIR LZO_LIBRARY)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(LZO DEFAULT_MSG
LZO_INCLUDE_DIR LZO_LIBRARY)
if(LZO_FOUND AND NOT TARGET LZO::LZO)
add_library(LZO::LZO UNKNOWN IMPORTED)
set_target_properties(LZO::LZO PROPERTIES
IMPORTED_LOCATION "${LZO_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${LZO_INCLUDE_DIR}"
)
endif()

View File

@ -40,4 +40,11 @@ elseif (NOT LIBUSB_FOUND)
mark_as_advanced(LIBUSB_INCLUDE_DIR LIBUSB_LIBRARIES)
endif ()
if(LIBUSB_FOUND AND NOT TARGET LibUSB::LibUSB)
add_library(LibUSB::LibUSB UNKNOWN IMPORTED)
set_target_properties(LibUSB::LibUSB PROPERTIES
IMPORTED_LOCATION "${LIBUSB_LIBRARIES}"
INTERFACE_INCLUDE_DIRECTORIES "${LIBUSB_INCLUDE_DIR}"
)
endif()

View File

@ -7,17 +7,53 @@ find_library(MBEDCRYPTO_LIBRARY mbedcrypto PATH_SUFFIXES mbedtls2)
set(MBEDTLS_INCLUDE_DIRS ${MBEDTLS_INCLUDE_DIR})
set(MBEDTLS_LIBRARIES ${MBEDTLS_LIBRARY} ${MBEDX509_LIBRARY} ${MBEDCRYPTO_LIBRARY})
set(CMAKE_REQUIRED_INCLUDES ${MBEDTLS_INCLUDE_DIRS})
check_cxx_source_compiles("
#include <mbedtls/version.h>
#if MBEDTLS_VERSION_NUMBER < 0x021C0000
#error \"Your mbed TLS version is too old.\"
#endif
int main() {}"
MBEDTLS_VERSION_OK)
if(NOT MBEDTLS_INCLUDE_DIR STREQUAL "MBEDTLS_INCLUDE_DIR-NOTFOUND")
if(EXISTS ${MBEDTLS_INCLUDE_DIR}/mbedtls/build_info.h)
file(STRINGS ${MBEDTLS_INCLUDE_DIR}/mbedtls/build_info.h MBEDTLS_VERSION_STR REGEX "^#define[ \t]+MBEDTLS_VERSION_STRING[\t ].*")
else()
file(STRINGS ${MBEDTLS_INCLUDE_DIR}/mbedtls/version.h MBEDTLS_VERSION_STR REGEX "^#define[ \t]+MBEDTLS_VERSION_STRING[\t ].*")
endif()
string(REGEX REPLACE "^#define[\t ]+MBEDTLS_VERSION_STRING[\t ]+\"([.0-9]+)\".*" "\\1" MBEDTLS_VERSION ${MBEDTLS_VERSION_STR})
endif()
if(NOT MBEDTLS_INCLUDE_DIR STREQUAL "MBEDTLS_INCLUDE_DIR-NOTFOUND" AND MBEDTLS_VERSION VERSION_GREATER_EQUAL 3)
# Once CMake 3.19 is required, we can enable HANDLE_VERSION_RANGE and use that
if(MBEDTLS_FIND_REQUIRED)
set(type FATAL_ERROR)
else()
set(type STATUS)
endif()
if(MBEDTLS_FIND_REQUIRED OR NOT MBEDTLS_FIND_QUIETLY)
message(${type} "Could NOT find MBEDTLS: Found unsuitable version \"${MBEDTLS_VERSION}\", but a 2.x version is required (found ${MBEDTLS_INCLUDE_DIR})")
endif()
set(MBEDTLS_FOUND FALSE)
else()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(MBEDTLS DEFAULT_MSG
MBEDTLS_INCLUDE_DIR MBEDTLS_LIBRARY MBEDX509_LIBRARY MBEDCRYPTO_LIBRARY MBEDTLS_VERSION_OK)
find_package_handle_standard_args(MBEDTLS
REQUIRED_VARS MBEDTLS_INCLUDE_DIR MBEDTLS_LIBRARY MBEDX509_LIBRARY MBEDCRYPTO_LIBRARY
VERSION_VAR MBEDTLS_VERSION)
endif()
mark_as_advanced(MBEDTLS_INCLUDE_DIR MBEDTLS_LIBRARY MBEDX509_LIBRARY MBEDCRYPTO_LIBRARY)
if(MBEDTLS_FOUND)
add_library(MbedTLS::mbedcrypto UNKNOWN IMPORTED)
set_target_properties(MbedTLS::mbedcrypto PROPERTIES
IMPORTED_LOCATION "${MBEDCRYPTO_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${MBEDTLS_INCLUDE_DIR}"
)
add_library(MbedTLS::mbedx509 UNKNOWN IMPORTED)
set_target_properties(MbedTLS::mbedx509 PROPERTIES
IMPORTED_LOCATION "${MBEDX509_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${MBEDTLS_INCLUDE_DIR}"
INTERFACE_LINK_LIBRARIES MbedTLS::mbedcrypto
)
add_library(MbedTLS::mbedtls UNKNOWN IMPORTED)
set_target_properties(MbedTLS::mbedtls PROPERTIES
IMPORTED_LOCATION "${MBEDTLS_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${MBEDTLS_INCLUDE_DIR}"
INTERFACE_LINK_LIBRARIES MbedTLS::mbedx509
)
endif()

View File

@ -5,14 +5,17 @@ find_path(MINIUPNPC_INCLUDE_DIR miniupnpc.h PATH_SUFFIXES miniupnpc)
find_library(MINIUPNPC_LIBRARY miniupnpc)
if(MINIUPNPC_INCLUDE_DIR)
file(STRINGS "${MINIUPNPC_INCLUDE_DIR}/miniupnpc.h" MINIUPNPC_API_VERSION_STR REGEX "^#define[\t ]+MINIUPNPC_API_VERSION[\t ]+[0-9]+")
if(MINIUPNPC_API_VERSION_STR)
string(REGEX REPLACE "^#define[\t ]+MINIUPNPC_API_VERSION[\t ]+([0-9]+)" "\\1" MINIUPNPC_API_VERSION ${MINIUPNPC_API_VERSION_STR})
file(STRINGS "${MINIUPNPC_INCLUDE_DIR}/miniupnpc.h" MINIUPNPC_VERSION_STR REGEX "^#define[\t ]+MINIUPNPC_VERSION[\t ]+.*")
if(MINIUPNPC_VERSION_STR)
string(REGEX REPLACE "^#define[\t ]+MINIUPNPC_VERSION[\t ]+\"([.0-9]+)\"" "\\1" MINIUPNPC_VERSION ${MINIUPNPC_VERSION_STR})
endif()
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(MINIUPNPC DEFAULT_MSG MINIUPNPC_INCLUDE_DIR MINIUPNPC_LIBRARY MINIUPNPC_API_VERSION)
find_package_handle_standard_args(MINIUPNPC
REQUIRED_VARS MINIUPNPC_INCLUDE_DIR MINIUPNPC_LIBRARY
VERSION_VAR MINIUPNPC_VERSION
)
set(MINIUPNPC_LIBRARIES ${MINIUPNPC_LIBRARY})
set(MINIUPNPC_INCLUDE_DIRS ${MINIUPNPC_INCLUDE_DIR})

View File

@ -206,4 +206,20 @@ endif()
# handle success
if(SFML_FOUND)
message(STATUS "Found SFML ${SFML_VERSION_MAJOR}.${SFML_VERSION_MINOR} in ${SFML_INCLUDE_DIR}")
foreach(FIND_SFML_COMPONENT ${SFML_FIND_COMPONENTS})
string(TOLOWER ${FIND_SFML_COMPONENT} FIND_SFML_COMPONENT_LOWER)
string(TOUPPER ${FIND_SFML_COMPONENT} FIND_SFML_COMPONENT_UPPER)
if(NOT TARGET sfml-${FIND_SFML_COMPONENT_LOWER})
add_library(sfml-${FIND_SFML_COMPONENT_LOWER} UNKNOWN IMPORTED)
set_target_properties(sfml-${FIND_SFML_COMPONENT_LOWER} PROPERTIES
IMPORTED_LOCATION "${SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${SFML_INCLUDE_DIR}"
)
if(NOT ${FIND_SFML_COMPONENT_LOWER} STREQUAL system)
set_target_properties(sfml-${FIND_SFML_COMPONENT_LOWER} PROPERTIES
INTERFACE_LINK_LIBRARIES sfml-system
)
endif()
endif()
endforeach()
endif()

61
CMake/ScmRevGen.cmake Normal file
View File

@ -0,0 +1,61 @@
cmake_minimum_required(VERSION 3.13)
# for revision info
if(GIT_FOUND)
# defines DOLPHIN_WC_REVISION
execute_process(WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} COMMAND ${GIT_EXECUTABLE} rev-parse HEAD
OUTPUT_VARIABLE DOLPHIN_WC_REVISION
OUTPUT_STRIP_TRAILING_WHITESPACE)
# defines DOLPHIN_WC_DESCRIBE
execute_process(WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} COMMAND ${GIT_EXECUTABLE} describe --always --long --dirty
OUTPUT_VARIABLE DOLPHIN_WC_DESCRIBE
OUTPUT_STRIP_TRAILING_WHITESPACE)
# remove hash (and trailing "-0" if needed) from description
string(REGEX REPLACE "(-0)?-[^-]+((-dirty)?)$" "\\2" DOLPHIN_WC_DESCRIBE "${DOLPHIN_WC_DESCRIBE}")
# defines DOLPHIN_WC_BRANCH
execute_process(WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} COMMAND ${GIT_EXECUTABLE} rev-parse --abbrev-ref HEAD
OUTPUT_VARIABLE DOLPHIN_WC_BRANCH
OUTPUT_STRIP_TRAILING_WHITESPACE)
# defines DOLPHIN_WC_COMMITS_AHEAD_MASTER
execute_process(WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} COMMAND ${GIT_EXECUTABLE} rev-list --count HEAD ^master
OUTPUT_VARIABLE DOLPHIN_WC_COMMITS_AHEAD_MASTER
OUTPUT_STRIP_TRAILING_WHITESPACE)
endif()
# version number
set(DOLPHIN_VERSION_MAJOR "5")
set(DOLPHIN_VERSION_MINOR "0")
if(DOLPHIN_WC_BRANCH STREQUAL "stable")
set(DOLPHIN_VERSION_PATCH "0")
else()
set(DOLPHIN_VERSION_PATCH ${DOLPHIN_WC_REVISION})
endif()
# If Dolphin is not built from a Git repository, default the version info to
# reasonable values.
if(NOT DOLPHIN_WC_REVISION)
set(DOLPHIN_WC_DESCRIBE "${DOLPHIN_VERSION_MAJOR}.${DOLPHIN_VERSION_MINOR}")
set(DOLPHIN_WC_REVISION "${DOLPHIN_WC_DESCRIBE} (no further info)")
set(DOLPHIN_WC_BRANCH "master")
set(DOLPHIN_WC_COMMITS_AHEAD_MASTER 0)
endif()
function(configure_source_file path)
configure_file(
"${PROJECT_SOURCE_DIR}/${path}.in"
"${PROJECT_BINARY_DIR}/${path}.tmp"
)
execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different "${PROJECT_BINARY_DIR}/${path}.tmp" "${PROJECT_BINARY_DIR}/${path}")
file(REMOVE "${PROJECT_BINARY_DIR}/${path}.tmp")
endfunction()
configure_source_file("Source/Core/Common/scmrev.h")
if(APPLE)
configure_source_file("Source/Core/DolphinQt/Info.plist")
configure_source_file("Source/Core/MacUpdater/Info.plist")
endif()

View File

@ -26,7 +26,7 @@ endif()
# This is inserted into the Info.plist as well.
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.15.0" CACHE STRING "")
set(CMAKE_USER_MAKE_RULES_OVERRIDE "CMake/FlagsOverride.cmake")
set(CMAKE_USER_MAKE_RULES_OVERRIDE "${CMAKE_CURRENT_SOURCE_DIR}/CMake/FlagsOverride.cmake")
project(dolphin-emu)
@ -47,13 +47,13 @@ if (COMPILER STREQUAL "GNU")
set(COMPILER "GCC") # perfer printing GCC instead of GNU
endif()
# Enforce minimium compiler versions that support the c++20 features we use
set (GCC_min_version 10)
set (Clang_min_version 12)
set (AppleClang_min_version 13.0.0)
set (min_xcode_version "13.0") # corrosponding xcode version for AppleClang_min_version
# Enforce minimum compiler versions that support the c++20 features we use
set (GCC_min_version 11)
set (Clang_min_version 14)
set (AppleClang_min_version 14.0.3)
set (min_xcode_version "14.0") # corresponding xcode version for AppleClang_min_version
set (MSVC_min_version 14.32)
set (min_vs_version "2022 17.2.3") # corrosponding Visual Studio version for MSVC_min_version
set (min_vs_version "2022 17.2.3") # corresponding Visual Studio version for MSVC_min_version
message(STATUS "Using ${COMPILER} ${CMAKE_CXX_COMPILER_VERSION}")
@ -85,7 +85,11 @@ if(NOT ANDROID)
option(ENABLE_CLI_TOOL "Enable dolphin-tool, a CLI-based utility for functions such as managing disc images" ON)
endif()
option(USE_SHARED_ENET "Use shared libenet if found rather than Dolphin's soon-to-compatibly-diverge version" OFF)
set(USE_SYSTEM_LIBS "AUTO" CACHE STRING "Use system libraries instead of bundled libraries. ON - Always use system and fail if unavailable, OFF - Always use bundled, AUTO - Use system if available, otherwise use bundled. Default is AUTO")
if(APPROVED_VENDORED_DEPENDENCIES)
message(WARNING "APPROVED_VENDORED_DEPENDENCIES is deprecated. Please migrate to setting USE_SYSTEM_LIBS to ON and setting USE_SYSTEM_<dependency> to either AUTO or OFF to allow bundled libs.")
endif()
option(USE_UPNP "Enables UPnP port mapping support" ON)
option(ENABLE_NOGUI "Enable NoGUI frontend" ON)
option(ENABLE_QT "Enable Qt (Default)" ON)
@ -120,8 +124,8 @@ option(OPROFILING "Enable profiling" OFF)
# TODO: Add DSPSpy
option(DSPTOOL "Build dsptool" OFF)
# Enable SDL for default on operating systems that aren't Android or Linux.
if(NOT ANDROID AND NOT CMAKE_SYSTEM_NAME STREQUAL "Linux")
# Enable SDL by default on operating systems that aren't Android.
if(NOT ANDROID)
option(ENABLE_SDL "Enables SDL as a generic controller backend" ON)
else()
option(ENABLE_SDL "Enables SDL as a generic controller backend" OFF)
@ -152,13 +156,12 @@ if(UNIX)
endif()
list(APPEND CMAKE_MODULE_PATH
${CMAKE_SOURCE_DIR}/CMake
${CMAKE_CURRENT_SOURCE_DIR}/CMake
)
# Support functions
include(CheckAndAddFlag)
include(CheckCCompilerFlag)
include(CheckVendoringApproved)
include(DolphinCompileDefinitions)
include(DolphinDisableWarningsMSVC)
include(DolphinLibraryTools)
@ -196,59 +199,6 @@ endif()
# setup CCache
include(CCache)
# for revision info
find_package(Git)
if(GIT_FOUND)
# make sure version information gets re-run when the current Git HEAD changes
execute_process(WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} COMMAND ${GIT_EXECUTABLE} rev-parse --git-path HEAD
OUTPUT_VARIABLE dolphin_git_head_filename
OUTPUT_STRIP_TRAILING_WHITESPACE)
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${dolphin_git_head_filename}")
execute_process(WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} COMMAND ${GIT_EXECUTABLE} rev-parse --symbolic-full-name HEAD
OUTPUT_VARIABLE dolphin_git_head_symbolic
OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
COMMAND ${GIT_EXECUTABLE} rev-parse --git-path ${dolphin_git_head_symbolic}
OUTPUT_VARIABLE dolphin_git_head_symbolic_filename
OUTPUT_STRIP_TRAILING_WHITESPACE)
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${dolphin_git_head_symbolic_filename}")
# defines DOLPHIN_WC_REVISION
execute_process(WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} COMMAND ${GIT_EXECUTABLE} rev-parse HEAD
OUTPUT_VARIABLE DOLPHIN_WC_REVISION
OUTPUT_STRIP_TRAILING_WHITESPACE)
# defines DOLPHIN_WC_DESCRIBE
execute_process(WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} COMMAND ${GIT_EXECUTABLE} describe --always --long --dirty
OUTPUT_VARIABLE DOLPHIN_WC_DESCRIBE
OUTPUT_STRIP_TRAILING_WHITESPACE)
# remove hash (and trailing "-0" if needed) from description
string(REGEX REPLACE "(-0)?-[^-]+((-dirty)?)$" "\\2" DOLPHIN_WC_DESCRIBE "${DOLPHIN_WC_DESCRIBE}")
# defines DOLPHIN_WC_BRANCH
execute_process(WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} COMMAND ${GIT_EXECUTABLE} rev-parse --abbrev-ref HEAD
OUTPUT_VARIABLE DOLPHIN_WC_BRANCH
OUTPUT_STRIP_TRAILING_WHITESPACE)
endif()
# version number
set(DOLPHIN_VERSION_MAJOR "5")
set(DOLPHIN_VERSION_MINOR "0")
if(DOLPHIN_WC_BRANCH STREQUAL "stable")
set(DOLPHIN_VERSION_PATCH "0")
else()
set(DOLPHIN_VERSION_PATCH ${DOLPHIN_WC_REVISION})
endif()
# If Dolphin is not built from a Git repository, default the version info to
# reasonable values.
if(NOT DOLPHIN_WC_REVISION)
set(DOLPHIN_WC_DESCRIBE "${DOLPHIN_VERSION_MAJOR}.${DOLPHIN_VERSION_MINOR}")
set(DOLPHIN_WC_REVISION "${DOLPHIN_WC_DESCRIBE} (no further info)")
set(DOLPHIN_WC_BRANCH "master")
endif()
# Architecture detection and arch specific settings
message(STATUS "Detected architecture: ${CMAKE_SYSTEM_PROCESSOR}")
@ -269,9 +219,7 @@ if(ENABLE_GENERIC)
set(_M_GENERIC 1)
add_definitions(-D_M_GENERIC=1)
elseif(_ARCH_64 AND CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|amd64|AMD64")
set(_M_X86 1)
set(_M_X86_64 1)
add_definitions(-D_M_X86=1)
add_definitions(-D_M_X86_64=1)
check_and_add_flag(HAVE_SSE2 -msse2)
elseif(_ARCH_64 AND CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64|arm64")
@ -372,7 +320,7 @@ else()
check_and_add_flag(VISIBILITY_INLINES_HIDDEN -fvisibility-inlines-hidden)
check_and_add_flag(VISIBILITY_HIDDEN -fvisibility=hidden)
check_and_add_flag(FOMIT_FRAME_POINTER -fomit-frame-pointer RELEASE_ONLY)
check_and_add_flag(FOMIT_FRAME_POINTER -fomit-frame-pointer NO_DEBINFO_ONLY)
dolphin_compile_definitions(_DEBUG DEBUG_ONLY)
check_and_add_flag(GGDB -ggdb DEBUG_ONLY)
@ -454,7 +402,7 @@ endif()
# All commands and submodule commands also need to see these
# changes, so just setting them in the project scope via
# include_directories and link_directories is not sufficient
if(CMAKE_SYSTEM_NAME MATCHES "FreeBSD|NetBSD")
if(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
set(CMAKE_PREFIX_PATH "${CMAKE_PREFIX_PATH};/usr/local")
set(CMAKE_REQUIRED_INCLUDES "/usr/local/include")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L/usr/local/lib")
@ -556,14 +504,14 @@ if (OPENGL_GL)
endif()
if(ENABLE_X11)
find_package(X11)
pkg_check_modules(X11 x11 IMPORTED_TARGET)
if(X11_FOUND)
add_definitions(-DHAVE_X11=1)
check_lib(XRANDR xrandr Xrandr)
pkg_check_modules(XRANDR xrandr IMPORTED_TARGET)
if(XRANDR_FOUND)
add_definitions(-DHAVE_XRANDR=1)
endif()
pkg_check_modules(X11_INPUT REQUIRED xi>=1.5.0)
pkg_check_modules(X11_INPUT REQUIRED xi>=1.5.0 IMPORTED_TARGET)
message(STATUS "X11 support enabled")
else()
message(WARNING "X11 support enabled but not found. This build will not support X11.")
@ -639,32 +587,7 @@ if(UNIX)
endif()
if(ENABLE_SDL)
find_package(SDL2)
if(SDL2_FOUND)
message(STATUS "Using system SDL2")
else()
message(STATUS "Using static SDL2 from Externals")
option(SDL2_DISABLE_SDL2MAIN "" ON)
option(SDL2_DISABLE_INSTALL "" ON)
option(SDL2_DISABLE_UNINSTALL "" ON)
set(SDL_SHARED OFF)
set(SDL_SHARED_ENABLED_BY_DEFAULT OFF)
set(SDL_STATIC ON)
set(SDL_STATIC_ENABLED_BY_DEFAULT ON)
set(SDL_TEST OFF)
set(SDL_TEST_ENABLED_BY_DEFAULT OFF)
set(OPT_DEF_LIBC ON)
add_subdirectory(Externals/SDL/SDL)
if (TARGET SDL2)
dolphin_disable_warnings_msvc(SDL2)
endif()
if (TARGET SDL2-static)
dolphin_disable_warnings_msvc(SDL2-static)
endif()
set(SDL2_FOUND TRUE)
endif()
add_definitions(-DHAVE_SDL2=1)
dolphin_find_optional_system_library(SDL2 Externals/SDL 2.26.0)
endif()
if(ENABLE_ANALYTICS)
@ -700,19 +623,15 @@ endif()
# - place the CMakeLists.txt in the first-level subdirectory, e.g.
# Externals/zlib/CMakeLists.txt (that is: NOT in some Src/ subdirectory)
#
if (_M_X86)
if (_M_X86_64)
add_subdirectory(Externals/Bochs_disasm)
endif()
add_subdirectory(Externals/cpp-optparse)
find_package(fmt 8)
if(fmt_FOUND)
message(STATUS "Using shared fmt ${fmt_VERSION}")
else()
check_vendoring_approved(fmt)
message(STATUS "Using static fmt from Externals")
add_subdirectory(Externals/fmt EXCLUDE_FROM_ALL)
endif()
dolphin_find_optional_system_library_pkgconfig(FMT
fmt>=10.1 fmt::fmt Externals/fmt
)
add_subdirectory(Externals/imgui)
add_subdirectory(Externals/implot)
add_subdirectory(Externals/glslang)
@ -721,6 +640,7 @@ add_subdirectory(Externals/glslang)
if(WIN32 OR APPLE)
add_subdirectory(Externals/spirv_cross)
endif()
add_subdirectory(Externals/tinygltf)
if(ENABLE_VULKAN)
add_definitions(-DHAS_VULKAN)
@ -728,6 +648,11 @@ if(ENABLE_VULKAN)
if(APPLE AND USE_BUNDLED_MOLTENVK)
add_subdirectory(Externals/MoltenVK)
endif()
if (ANDROID AND _M_ARM_64)
add_subdirectory(Externals/libadrenotools)
endif()
endif()
if(NOT WIN32 OR (NOT (CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64")))
@ -735,111 +660,31 @@ if(NOT WIN32 OR (NOT (CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64")))
add_definitions(-DHAS_OPENGL)
endif()
find_package(pugixml)
if(NOT pugixml_FOUND)
check_vendoring_approved(pugixml)
message(STATUS "Using static pugixml from Externals")
add_subdirectory(Externals/pugixml)
endif()
dolphin_find_optional_system_library(pugixml Externals/pugixml)
if(USE_SHARED_ENET)
check_lib(ENET libenet enet enet/enet.h QUIET)
include(CheckSymbolExists)
if (ENET_FOUND)
set(CMAKE_REQUIRED_INCLUDES ${ENET_INCLUDE_DIRS})
# hack: LDFLAGS already contains -lenet but all flags but the first are
# dropped; ugh, cmake
set(CMAKE_REQUIRED_FLAGS ${ENET_LDFLAGS})
set(CMAKE_REQUIRED_LIBRARIES ${ENET_LIBRARIES})
check_symbol_exists(enet_socket_get_address enet/enet.h ENET_HAVE_SGA)
set(CMAKE_REQUIRED_INCLUDES)
set(CMAKE_REQUIRED_FLAGS)
set(CMAKE_REQUIRED_LIBRARIES)
if (NOT ENET_HAVE_SGA)
# enet is too old
set(ENET_FOUND FALSE)
endif()
endif()
endif()
if (ENET_FOUND)
message(STATUS "Using shared enet")
else()
check_vendoring_approved(enet)
message(STATUS "Using static enet from Externals")
include_directories(Externals/enet/include)
add_subdirectory(Externals/enet)
endif()
dolphin_find_optional_system_library_pkgconfig(ENET libenet>=1.3.18 enet::enet Externals/enet)
if(NOT XXHASH_FOUND)
message(STATUS "Using static xxhash from Externals")
add_subdirectory(Externals/xxhash)
endif()
dolphin_find_optional_system_library_pkgconfig(xxhash libxxhash>=0.8.2 xxhash::xxhash Externals/xxhash)
find_package(BZip2)
if(BZIP2_FOUND)
message(STATUS "Using shared bzip2")
else()
check_vendoring_approved(bzip2)
message(STATUS "Shared bzip2 not found, falling back to the static library")
add_subdirectory(Externals/bzip2)
endif()
dolphin_find_optional_system_library(BZip2 Externals/bzip2)
# macOS ships with liblzma.dylib but no headers, so check for the headers too
find_package(LibLZMA)
if(LIBLZMA_FOUND)
dolphin_find_optional_system_library(LibLZMA Externals/liblzma)
# Imported target added in CMake 3.14
dolphin_make_imported_target_if_missing(LibLZMA::LibLZMA LIBLZMA)
message(STATUS "Using shared lzma")
else()
check_vendoring_approved(lzma)
message(STATUS "Shared lzma not found, falling back to the static library")
add_subdirectory(Externals/liblzma)
endif()
pkg_check_modules(ZSTD QUIET libzstd>=1.4.0 IMPORTED_TARGET)
if(ZSTD_FOUND)
message(STATUS "Using shared zstd version: " ${ZSTD_VERSION})
dolphin_alias_library(zstd::zstd PkgConfig::ZSTD)
else()
check_vendoring_approved(zstd)
message(STATUS "Shared zstd not found, falling back to the static library")
add_subdirectory(Externals/zstd)
endif()
dolphin_find_optional_system_library_pkgconfig(ZSTD libzstd>=1.4.0 zstd::zstd Externals/zstd)
add_subdirectory(Externals/zlib-ng)
dolphin_find_optional_system_library_pkgconfig(ZLIB zlib-ng ZLIB::ZLIB Externals/zlib-ng)
pkg_check_modules(MINIZIP minizip>=3.0.0)
if(MINIZIP_FOUND)
message(STATUS "Using shared minizip")
include_directories(${MINIZIP_INCLUDE_DIRS})
else()
check_vendoring_approved(minizip)
message(STATUS "Shared minizip not found, falling back to the static library")
add_subdirectory(Externals/minizip)
include_directories(External/minizip)
endif()
dolphin_find_optional_system_library_pkgconfig(MINIZIP
"minizip-ng>=4.0.4;minizip>=4.0.4" minizip::minizip Externals/minizip-ng
)
if(NOT APPLE)
check_lib(LZO "(no .pc for lzo2)" lzo2 lzo/lzo1x.h QUIET)
endif()
if(LZO_FOUND)
message(STATUS "Using shared lzo")
else()
check_vendoring_approved(lzo)
message(STATUS "Using static lzo from Externals")
add_subdirectory(Externals/LZO)
set(LZO lzo2)
endif()
dolphin_find_optional_system_library(LZO Externals/LZO)
pkg_check_modules(pc_spng IMPORTED_TARGET spng)
if (pc_spng_FOUND AND TARGET PkgConfig::pc_spng)
message(STATUS "Using the system libspng")
set(spng_target PkgConfig::pc_spng)
else()
message(STATUS "Using static libspng from Externals")
add_subdirectory(Externals/libspng)
set(spng_target spng)
endif()
dolphin_find_optional_system_library_pkgconfig(lz4 liblz4>=1.8 LZ4::LZ4 Externals/lz4)
dolphin_find_optional_system_library_pkgconfig(SPNG spng spng::spng Externals/libspng)
# Using static FreeSurround from Externals
# There is no system FreeSurround library.
@ -857,105 +702,35 @@ endif()
add_subdirectory(Externals/soundtouch)
include_directories(Externals/soundtouch)
find_package(CUBEB)
if(CUBEB_FOUND)
message(STATUS "Using the system cubeb")
else()
check_vendoring_approved(cubeb)
message(STATUS "Using static cubeb from Externals")
add_subdirectory(Externals/cubeb EXCLUDE_FROM_ALL)
endif()
dolphin_find_optional_system_library(CUBEB Externals/cubeb)
if(NOT ANDROID)
dolphin_find_optional_system_library_pkgconfig(
LibUSB libusb-1.0 LibUSB::LibUSB Externals/libusb
)
add_definitions(-D__LIBUSB__)
if(NOT APPLE)
find_package(LibUSB)
endif()
if(LIBUSB_FOUND AND NOT APPLE)
message(STATUS "Using shared LibUSB")
include_directories(${LIBUSB_INCLUDE_DIR})
else()
check_vendoring_approved(libusb)
message(STATUS "Using static LibUSB from Externals")
add_subdirectory(Externals/libusb)
set(LIBUSB_LIBRARIES usb)
endif()
set(LIBUSB_FOUND true)
endif()
set(SFML_REQD_VERSION 2.1)
if(NOT APPLE)
find_package(SFML ${SFML_REQD_VERSION} COMPONENTS network system)
endif()
if(SFML_FOUND)
message(STATUS "Using shared SFML")
else()
check_vendoring_approved(sfml)
message(STATUS "Using static SFML ${SFML_REQD_VERSION} from Externals")
add_definitions(-DSFML_STATIC)
add_subdirectory(Externals/SFML)
include_directories(BEFORE Externals/SFML/include)
endif()
dolphin_find_optional_system_library(SFML Externals/SFML 2.1 COMPONENTS network system)
if(USE_UPNP)
if(NOT APPLE)
find_package(MINIUPNPC)
endif()
if(MINIUPNPC_FOUND AND MINIUPNPC_API_VERSION GREATER 8)
message(STATUS "Using shared miniupnpc")
else()
check_vendoring_approved(miniupnpc)
message(STATUS "Using static miniupnpc from Externals")
add_subdirectory(Externals/miniupnpc)
endif()
dolphin_find_optional_system_library(MINIUPNPC Externals/miniupnpc 1.6)
add_definitions(-DUSE_UPNP)
endif()
if(NOT APPLE)
find_package(MBEDTLS)
endif()
if(MBEDTLS_FOUND)
message(STATUS "Using shared mbed TLS")
include_directories(${MBEDTLS_INCLUDE_DIRS})
else()
check_vendoring_approved(mbedtls)
message(STATUS "Using static mbed TLS from Externals")
set(MBEDTLS_LIBRARIES mbedtls mbedcrypto mbedx509)
add_subdirectory(Externals/mbedtls/ EXCLUDE_FROM_ALL)
include_directories(Externals/mbedtls/include)
endif()
dolphin_find_optional_system_library(MBEDTLS Externals/mbedtls 2.28)
find_package(CURL)
if(CURL_FOUND)
message(STATUS "Using shared libcurl")
include_directories(${CURL_INCLUDE_DIRS})
else()
check_vendoring_approved(curl)
message(STATUS "Using static libcurl from Externals")
add_subdirectory(Externals/curl)
set(CURL_LIBRARIES curl)
include_directories(BEFORE Externals/curl/include)
endif()
dolphin_find_optional_system_library(CURL Externals/curl)
if(NOT ANDROID)
find_package(Iconv)
endif()
if(TARGET Iconv::Iconv)
message(STATUS "Using shared iconv")
dolphin_find_optional_system_library(Iconv Externals/libiconv-1.14)
else()
check_vendoring_approved(iconv)
message(STATUS "Using static iconv from Externals")
add_subdirectory(Externals/libiconv-1.14)
add_subdirectory(Externals/libiconv-1.14 EXCLUDE_FROM_ALL)
endif()
if(NOT ANDROID)
find_package(HIDAPI)
if(NOT HIDAPI_FOUND)
check_vendoring_approved(hidapi)
message(STATUS "Using static HIDAPI from Externals")
add_subdirectory(Externals/hidapi EXCLUDE_FROM_ALL)
endif()
dolphin_find_optional_system_library(HIDAPI Externals/hidapi)
endif()
if(USE_DISCORD_PRESENCE)
@ -968,11 +743,7 @@ if(NOT ENABLE_QT)
set(USE_MGBA 0)
endif()
if(USE_MGBA)
find_package(LIBMGBA)
if(NOT LIBMGBA_FOUND)
message(STATUS "Using static libmgba from Externals")
add_subdirectory(Externals/mGBA)
endif()
dolphin_find_optional_system_library(LIBMGBA Externals/mGBA)
endif()
find_package(SYSTEMD)
@ -1007,30 +778,57 @@ endif()
########################################
# Pre-build events: Define configuration variables and write SCM info header
#
if(DOLPHIN_WC_BRANCH STREQUAL "master" OR DOLPHIN_WC_BRANCH STREQUAL "stable")
set(DOLPHIN_WC_IS_STABLE "1")
else()
set(DOLPHIN_WC_IS_STABLE "0")
endif()
# Remove in-tree revision information generated by Visual Studio
# This is because the compiler will check in-tree first and use this, even if it is outdated
file(REMOVE "${PROJECT_SOURCE_DIR}/Source/Core/Common/scmrev.h")
configure_file(
"${PROJECT_SOURCE_DIR}/Source/Core/Common/scmrev.h.in"
"${PROJECT_BINARY_DIR}/Source/Core/Common/scmrev.h"
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/Source/Core/Common)
if (NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/Source/Core/Common/scmrev.h)
file(TOUCH ${CMAKE_CURRENT_BINARY_DIR}/Source/Core/Common/scmrev.h)
endif()
if(APPLE)
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/Source/Core/DolphinQt)
if (NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/Source/Core/DolphinQt/Info.plist)
file(TOUCH ${CMAKE_CURRENT_BINARY_DIR}/Source/Core/DolphinQt/Info.plist)
endif()
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/Source/Core/MacUpdater)
if (NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/Source/Core/MacUpdater/Info.plist)
file(TOUCH ${CMAKE_CURRENT_BINARY_DIR}/Source/Core/MacUpdater/Info.plist)
endif()
endif()
find_package(Git)
if(NOT GIT_FOUND)
set(GIT_EXECUTABLE "")
endif()
add_custom_target(
dolphin_scmrev
${CMAKE_COMMAND} -DPROJECT_SOURCE_DIR=${PROJECT_SOURCE_DIR} -DPROJECT_BINARY_DIR=${PROJECT_BINARY_DIR} -DDISTRIBUTOR=${DISTRIBUTOR} -DDOLPHIN_DEFAULT_UPDATE_TRACK=${DOLPHIN_DEFAULT_UPDATE_TRACK} -DGIT_FOUND=${GIT_FOUND} -DGIT_EXECUTABLE=${GIT_EXECUTABLE} -DDOLPHIN_WC_REVISION=${DOLPHIN_WC_REVISION} -DDOLPHIN_WC_DESCRIBE=${DOLPHIN_WC_DESCRIBE} -DDOLPHIN_WC_BRANCH=${DOLPHIN_WC_BRANCH} -DCMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET} -P ${CMAKE_CURRENT_SOURCE_DIR}/CMake/ScmRevGen.cmake
BYPRODUCTS "${CMAKE_CURRENT_BINARY_DIR}/Source/Core/Common/scmrev.h" "${CMAKE_CURRENT_BINARY_DIR}/Source/Core/DolphinQt/Info.plist" "${CMAKE_CURRENT_BINARY_DIR}/Source/Core/MacUpdater/Info.plist"
VERBATIM
)
# This is here so #include "Common/scmrev.h" finds the generated header.
include_directories("${PROJECT_BINARY_DIR}/Source/Core")
########################################
# Unit testing.
#
if(ENABLE_TESTS)
message(STATUS "Using static gtest from Externals")
# Force gtest to link the C runtime dynamically on Windows in order to avoid runtime mismatches.
dolphin_find_optional_system_library_pkgconfig(GTEST
gtest gtest::gtest Externals/gtest
)
# dolphin_find_optional_system_library_pkgconfig() doesn't add an alias if it
# uses the bundled libraries, so we add one ourselves.
if (NOT TARGET gtest::gtest)
add_library(gtest::gtest ALIAS gtest)
endif()
# Force gtest to link the C runtime dynamically on Windows in order to avoid
# runtime mismatches.
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
add_subdirectory(Externals/gtest EXCLUDE_FROM_ALL)
else()
message(STATUS "Unit tests are disabled")
endif()

View File

@ -1,17 +1,32 @@
# <a name="main-heading"></a>Dolphin Coding Style & Licensing
# <a name="main-section-overview"></a>Dolphin Coding Style & Legal Requirements
If you make any contributions to Dolphin after December 1st, 2014, you are agreeing that any code you have contributed will be licensed under the GNU GPL version 2 (or any later version).
# <a name="main-section-overview"></a>Main sections
- [Introduction](#introduction)
- [Legal](#legal)
- [Coding style introduction](#introduction)
- [C++ coding style and formatting](#cpp-coding-style-and-formatting)
- [C++ code-specific guidelines](#cpp-code-specific-guidelines)
- [Android](#android)
- [Help](#help)
# <a name="legal"></a>Legal
# <a name="introduction"></a>Introduction
Summary:
- [Trade secrets](#trade-secrets)
- [Code licensing](#code-licensing)
## <a name="trade-secrets"></a>Trade secrets
Following all relevant laws is of utmost importance for an emulation project like Dolphin.
If you know any confidential information related to the GameCube, Wii, or Triforce, either because you signed a non-disclosure agreement or because you looked at leaked materials, we ask that you don't contribute code to Dolphin **at all**. While accepting code from contributors who know confidential information is legal if the code is unrelated to the confidential information, we refuse to accept code from such contributors because it greatly increases our review burden and increases the legal risk we take.
Also, this probably goes without saying, but piracy is strictly forbidden both on GitHub and in all other Dolphin channels.
## <a name="code-licensing"></a>Code licensing
If you make any contributions to Dolphin after December 1st, 2014, you are agreeing that any code you have contributed will be licensed under the GNU GPL version 2 (or any later version).
# <a name="introduction"></a>Coding style introduction
Summary:

View File

@ -0,0 +1,16 @@
# G2BE5G - Black & Bruised
[Core]
# Values set here will override the main Dolphin settings.
[OnLoad]
# Add memory patches to be loaded once on boot here.
[OnFrame]
# Add memory patches to be applied every frame here.
$Disable interlaced rendering
0x800D8520:dword:0x38600000
[ActionReplay]
# Add action replay cheats here.

View File

@ -0,0 +1,16 @@
# G2BP7D - Black & Bruised
[Core]
# Values set here will override the main Dolphin settings.
[OnLoad]
# Add memory patches to be loaded once on boot here.
[OnFrame]
# Add memory patches to be applied every frame here.
$Disable interlaced rendering
0x800D9E68:dword:0x38600000
[ActionReplay]
# Add action replay cheats here.

View File

@ -0,0 +1,4 @@
# G5BE4Z - Strike Force Bowling
[Video_Hacks]
EFBToTextureEnable = False
DeferEFBCopies = False

View File

@ -0,0 +1,24 @@
# GC8JA4 - クラッシュ・バンディクー 爆走!ニトロカート
[Core]
# Values set here will override the main Dolphin settings.
[OnLoad]
# Add memory patches to be loaded once on boot here.
[OnFrame]
# Add memory patches to be applied every frame here.
[ActionReplay]
# Add action replay cheats here.
$Fix C4 texture tiling (used for buttons and some character icons)
0400328C 7D0340AE
04003290 5108452E
04003294 5508E13E
04003298 4E800020
040CA1B4 4BF390D9
[Video_Settings]
[Video_Hacks]
ImmediateXFBEnable = False

View File

@ -11,6 +11,12 @@
[ActionReplay]
# Add action replay cheats here.
$Fix C4 texture tiling (used for buttons and some character icons)
0400328C 7D0340AE
04003290 5108452E
04003294 5508E13E
04003298 4E800020
040CC574 4BF36D19
[Video_Settings]

View File

@ -14,3 +14,4 @@
[Video_Hacks]
EFBToTextureEnable = False
DeferEFBCopies = False

View File

@ -17,3 +17,7 @@
# for the "Pitfall!" and "Lost Cavern" Atari 2600 games to render correctly.
# Otherwise the retro games appear to be stuttering.
SafeTextureCacheColorSamples = 2048
# Fixes cutscenes playing in a different aspect ratio and gameplay flipping back and forth between 4:3 and 16:9.
WidescreenHeuristicStandardRatio = 1.17
WidescreenHeuristicWidescreenRatio = 1.56

View File

@ -12,6 +12,3 @@ CPUThread = False
[ActionReplay]
# Add action replay cheats here.
[Video_Hacks]
BBoxEnable = True

View File

@ -15,5 +15,10 @@
[Video_Hacks]
VertexRounding = True
[Video_Settings]
WidescreenHeuristicStandardRatio = 0.91
WidescreenHeuristicWidescreenRatio = 1.21
WidescreenHeuristicAspectRatioSlop = 0.15
[Video_Stereoscopy]
StereoConvergence = 1

View File

@ -0,0 +1,27 @@
# HAFE01, HAFJ01, HAFP01 - Forecast Channel
[OnFrame_Enabled]
$BufferPatch
[OnFrame]
$BufferPatch
0x8000AA9E:word:0x00000008
0x8000AAC6:word:0x00007000
0x8000AAD0:dword:0x3C600001
0x8000AE08:dword:0x3C000001
0x8000AE06:word:0x00000008
0x8000AE0E:word:0x00007000
0x8000AEEE:word:0x00000008
0x8000AEFE:word:0x00007000
0x8000AF5A:word:0x00000008
0x8000AF6A:word:0x00007000
0x8000AFEC:dword:0x3CC00001
0x8000B08E:word:0x00000008
0x8000B09E:word:0x00007000
[WC24Patch]
$Main
weather.wapp.wii.com:fore.wiilink24.com:1
[WC24Patch_Enabled]
$Main

View File

@ -0,0 +1,9 @@
# HAJE01, HAJJ01, HAPP01 - Everybody Votes Channel
[WC24Patch]
$Main
vt.wapp.wii.com:vt.wiilink24.com:1
vtp.wapp.wii.com:vtp.wiilink24.com:0
[WC24Patch_Enabled]
$Main

View File

@ -0,0 +1,19 @@
# HALE01, HALJ01, HALP01 - Region Select
[OnFrame_Enabled]
$RSAPatch
[OnFrame]
# This patch changes the flag in its nwc24dl.bin to not have an RSA signature.
# Although Dolphin doesn't validate the RSA signature, a real Wii does which is why we added this workaround.
$RSAPatch
0x80009DEC:dword:0x60000000
0x8001AB20:dword:0x38600001
0x8001AC68:dword:0x38600001
[WC24Patch]
$Main
cfh.wapp.wii.com:ch.wiilink24.com:1
[WC24Patch_Enabled]
$Main

View File

@ -1,4 +1,4 @@
# HATE01 - Nintendo Channel
# HATE01, HATJ01, HATP01 - Nintendo Channel
[Core]
# Values set here will override the main Dolphin settings.

View File

@ -0,0 +1,37 @@
# HATE01 - Nintendo Channel (NTSC-U)
[Gecko]
$SSL Patch [Palapeli]
2A35AB5C 00003A2F
80010000 0035AA4D
8A00570F 0035AA4C
80010000 0035AACD
8A00380F 0035AACC
80010000 0035AB0D
8A004A0F 0035AB0C
80010000 0035AB5D
8A00390F 0035AB5C
80010000 0035ABF9
8A00170F 0035ABF8
80010000 0035AC15
8A00170F 0035AC14
E2000001 00000000
[Gecko_Enabled]
$SSL Patch
[WC24Patch]
$Main
a248.e.akamai.net:dol.n.wiinoma.com:0
$Suggestions
entup.wapp.wii.com:post.n.wiinoma.com:0
$Info
entuc.wapp.wii.com:conf.n.wiinoma.com:0
$WC24
entu.wapp.wii.com:ncc.wiilink24.com:1
[WC24Patch_Enabled]
$Main
$Suggestions
$Info
$WC24

View File

@ -0,0 +1,35 @@
# HATJ01 - Nintendo Channel (NTSC-J)
[Gecko]
$SSL Patch [Palapeli]
2A390014 00003A2F
80010000 00390015
8A00570F 00390014
80010000 00390095
8A00380F 00390094
80010000 003900D5
8A00390F 003900D4
80010000 00390171
8A00170F 00390170
80010000 0039018D
8A00170F 0039018C
E2000001 00000000
[Gecko_Enabled]
$SSL Patch
[WC24Patch]
$Main
a248.e.akamai.net:dol.n.wiinoma.com:0
$Suggestions
entjp.wapp.wii.com:post.n.wiinoma.com:0
$Info
entjc.wapp.wii.com:conf.n.wiinoma.com:0
$WC24
entj.wapp.wii.com:ncc.wiilink24.com:1
[WC24Patch_Enabled]
$Main
$Suggestions
$Info
$WC24

View File

@ -0,0 +1,37 @@
# HATP01 - Nintendo Channel (PAL)
[Gecko]
$SSL Patch [Palapeli]
2A357D3C 00003A2F
80010000 00357D3D
8A00570F 00357D3C
80010000 00357DBD
8A00380F 00357DBC
80010000 00357DFD
8A004B0F 00357DFC
80010000 00357E4D
8A00390F 00357E4C
80010000 00357EE9
8A00170F 00357EE8
80010000 00357F05
8A00170F 00357F04
E2000001 00000000
[Gecko_Enabled]
$SSL Patch
[WC24Patch]
$Main
a248.e.akamai.net:dol.n.wiinoma.com:0
$Suggestions
entep.wapp.wii.com:post.n.wiinoma.com:0
$Info
entec.wapp.wii.com:conf.n.wiinoma.com:0
$WC24
ente.wapp.wii.com:ncc.wiilink24.com:1
[WC24Patch_Enabled]
$Main
$Suggestions
$Info
$WC24

View File

@ -14,7 +14,3 @@
[Video_Settings]
SafeTextureCacheColorSamples = 512
[Video_Hacks]
EFBToTextureEnable = False

View File

@ -0,0 +1,4 @@
# REGE36, REGP36 - Emergency Mayhem
[Core]
# Dual core causes hang on loading
CPUThread = False

View File

@ -12,8 +12,13 @@
[ActionReplay]
# Add action replay cheats here.
[Video_Enhancements]
ForceTextureFiltering = False
[Video_Settings]
SafeTextureCacheColorSamples = 512
SafeTextureCacheColorSamples = 0
[Video_Hacks]
# Fixes visible lines in air vents/fans.
VertexRounding = True
ImmediateXFBEnable = False

View File

@ -0,0 +1,17 @@
# RJ3E20, RJ3P7J - Jeep Thrills
[Core]
# Values set here will override the main Dolphin settings.
# Fixes the blue screen problem. See issue 13118 for more info.
AccurateNaNs = True
[OnLoad]
# Add memory patches to be loaded once on boot here.
[OnFrame]
# Add memory patches to be applied every frame here.
[ActionReplay]
# Add action replay cheats here.
[Video_Settings]

View File

@ -13,5 +13,9 @@ CPUThread = False
[ActionReplay]
# Add action replay cheats here.
[Video_Enhancements]
ForceTextureFiltering = False
[Video_Settings]
SuggestedAspectRatio = 2
SafeTextureCacheColorSamples = 512

View File

@ -8,6 +8,8 @@
[OnFrame]
# Add memory patches to be applied every frame here.
$Disable blur
0x8015b900:dword:0x60000000
[ActionReplay]
# Add action replay cheats here.

View File

@ -2,3 +2,5 @@
[Video_Settings]
SuggestedAspectRatio = 2
# Needs safe texture cache for text to render correctly.
SafeTextureCacheColorSamples = 0

View File

@ -1,4 +1,20 @@
# RY2E41, RY2J41, RY2K41, RY2P41, RY2R41 - Rayman Raving Rabbids 2
[Core]
# Values set here will override the main Dolphin settings.
[OnLoad]
# Add memory patches to be loaded once on boot here.
[OnFrame]
# Add memory patches to be applied every frame here.
[ActionReplay]
# Add action replay cheats here.
[Video_Enhancements]
ForceTextureFiltering = False
[Video_Settings]
SuggestedAspectRatio = 2
SafeTextureCacheColorSamples = 512

View File

@ -1,4 +1,17 @@
# RY3E41, RY3J41, RY3K41, RY3P41 - Rayman Raving Rabbids TV Party
# RY3E41, RY3J41, RY3K41, RY3P41 - Rayman Raving Rabbids: TV Party
[Core]
# Values set here will override the main Dolphin settings.
[OnLoad]
# Add memory patches to be loaded once on boot here.
[OnFrame]
# Add memory patches to be applied every frame here.
[ActionReplay]
# Add action replay cheats here.
[Video_Settings]
SuggestedAspectRatio = 2
SafeTextureCacheColorSamples = 512

View File

@ -12,9 +12,9 @@
[ActionReplay]
# Add action replay cheats here.
[Video_Settings]
SafeTextureCacheColorSamples = 512
[Video_Hacks]
# Needed for cutscenes and the book to work properly (https://bugs.dolphin-emu.org/issues/4723)
ImmediateXFBEnable = False
# Needed for the book to work properly (https://bugs.dolphin-emu.org/issues/13356)
EFBToTextureEnable = False

View File

@ -0,0 +1,8 @@
# SGLPA4 - Gormiti: The Lords of Nature!
[OnFrame]
# Fixes black screen ingame, see https://bugs.dolphin-emu.org/issues/12436
# This NOPs out UpdateFade's call to RenderFade. We are probably emulating the way the fade works
# incorrectly, but for now this patch makes the game playable.
$Fix black screen
0x801D59C8:dword:0x60000000

View File

@ -0,0 +1,19 @@
# SOJE41, SOJP41 - Rayman Origins
[Core]
# Values set here will override the main Dolphin settings.
[OnLoad]
# Add memory patches to be loaded once on boot here.
[OnFrame]
# Add memory patches to be applied every frame here.
[ActionReplay]
# Add action replay cheats here.
[Video_Enhancements]
ForceTextureFiltering = False
[Video_Hacks]
ImmediateXFBEnable = False

View File

@ -0,0 +1,16 @@
# SR4E41, SR4J41, SR4P41 - Raving Rabbids: Travel in Time
[Core]
# Values set here will override the main Dolphin settings.
[OnLoad]
# Add memory patches to be loaded once on boot here.
[OnFrame]
# Add memory patches to be applied every frame here.
[ActionReplay]
# Add action replay cheats here.
[Video_Enhancements]
ForceTextureFiltering = False

View File

@ -1,4 +1,23 @@
# SR5E41, SR5P41 - Raving Rabbids Party Collection
[Core]
# Values set here will override the main Dolphin settings.
[OnLoad]
# Add memory patches to be loaded once on boot here.
[OnFrame]
# Add memory patches to be applied every frame here.
[ActionReplay]
# Add action replay cheats here.
[Video_Enhancements]
ForceTextureFiltering = False
[Video_Settings]
SuggestedAspectRatio = 2
SafeTextureCacheColorSamples = 512
[Video_Hacks]
ImmediateXFBEnable = False

View File

@ -0,0 +1,17 @@
# SRQE41, SRQP41 - Racquet Sports
[Core]
# Values set here will override the main Dolphin settings.
[OnLoad]
# Add memory patches to be loaded once on boot here.
[OnFrame]
# Add memory patches to be applied every frame here.
[ActionReplay]
# Add action replay cheats here.
[Video_Hacks]
#This prevents the loading screen from running uncapped
ImmediateXFBEnable = False

View File

@ -0,0 +1,24 @@
# WR2E41, WR2P41 - Rabbids Lab
[Core]
# Values set here will override the main Dolphin settings.
[OnLoad]
# Add memory patches to be loaded once on boot here.
[OnFrame]
# Add memory patches to be applied every frame here.
[ActionReplay]
# Add action replay cheats here.
[Video_Enhancements]
ForceTextureFiltering = False
[Video_Settings]
SafeTextureCacheColorSamples = 0
[Video_Hacks]
# Fixes visible lines in air vents/fans.
VertexRounding = True
ImmediateXFBEnable = False

View File

@ -0,0 +1,307 @@
{
"meta":
{
"title": "Dragon Ball Z: Budokai Tenkaichi 3 Definitions",
"author": "Seedonator"
},
"groups":
[
{
"name": "Bloom",
"targets": [
{
"type": "efb",
"texture_filename": "efb1_n000014_128x128_4"
}
]
},
{
"name": "HUD",
"targets": [
{
"type": "draw_started",
"prettyname": "HUD Backdrop",
"texture_filename": "tex1_256x64_50e9493ab5ecd6e9_5efd0133152917bc_9"
},
{
"type": "draw_started",
"prettyname": "Max Power Lightning",
"texture_filename": "tex1_256x128_76ee22f289405f4f_0a3363fc16e5200b_9"
},
{
"type": "draw_started",
"prettyname": "Timer Backdrop",
"texture_filename": "tex1_64x64_1b0bd43920520089_894789000b300d35_9"
},
{
"type": "draw_started",
"prettyname": "Teammate Backdrop",
"texture_filename": "tex1_64x64_76189a0850bac928_d5586441a9651de1_9"
},
{
"type": "draw_started",
"prettyname": "HUD Backdrop 2",
"texture_filename": "tex1_256x64_4751a5dd9b515483_6ef5db463bf9b5fe_9"
},
{
"type": "draw_started",
"prettyname": "Meters Colored",
"texture_filename": "tex1_256x64_974aae7fb39dd3fe_dc826162c7781cf3_9"
},
{
"type": "draw_started",
"prettyname": "Meters Colored 2",
"texture_filename": "tex1_256x64_974aae7fb39dd3fe_c0adc9c4480c91c1_9"
},
{
"type": "draw_started",
"prettyname": "Meters Red",
"texture_filename": "tex1_256x64_974aae7fb39dd3fe_65f3d25263258092_9"
},
{
"type": "draw_started",
"prettyname": "Meters Overlay",
"texture_filename": "tex1_256x64_974aae7fb39dd3fe_37c76c0d16ef044d_9"
},
{
"type": "draw_started",
"prettyname": "Meter Glow",
"texture_filename": "tex1_64x64_1c31b3c28a7aef47_1c42ae23afd2f40f_9"
},
{
"type": "draw_started",
"prettyname": "Meter Teammate",
"texture_filename": "tex1_128x32_277ce02a6f60e609_30b338ab0d636ab2_9"
},
{
"type": "draw_started",
"prettyname": "Stat Bonus Ki Damage",
"texture_filename": "tex1_32x32_20bc4452577d1f49_85422f750ab42532_8"
},
{
"type": "draw_started",
"prettyname": "Stat Bonus Charge Speed",
"texture_filename": "tex1_32x32_af9478cb6ebc0b7a_5ba8f3ea380bfdcf_8"
},
{
"type": "draw_started",
"prettyname": "Stat Bonus Defense",
"texture_filename": "tex1_32x32_c7cf9020318a2959_5d41872b1fcd6199_8"
},
{
"type": "draw_started",
"prettyname": "Stat Bonus Melee Damage",
"texture_filename": "tex1_32x32_e4c8e81a7318fa25_6e21f60b0c990c98_8"
},
{
"type": "draw_started",
"prettyname": "Blast Stock Number",
"texture_filename": "tex1_128x64_00ba91db7d176946_0ecdf6905c577ddb_9"
},
{
"type": "draw_started",
"prettyname": "Blast Stock Number Glow",
"texture_filename": "tex1_128x64_53d69bea13e150ab_24a4df43c24b0515_9"
},
{
"type": "draw_started",
"prettyname": "Timer Value",
"texture_filename": "tex1_128x128_6976151439efad50_501b3bc09a6958d7_8"
},
{
"type": "draw_started",
"prettyname": "Hit Text",
"texture_filename": "tex1_128x64_9366938c3344b862_83be965a88f28a40_9"
},
{
"type": "draw_started",
"prettyname": "Hit Counter",
"texture_filename": "tex1_128x128_273f16293f4d7a40_8a29b5887317abf8_8"
},
{
"type": "draw_started",
"prettyname": "Damage Counter",
"texture_filename": "tex1_128x128_1588ef89e137fc24_1cce6b863d92c9a0_8"
},
{
"type": "draw_started",
"prettyname": "Announcer Max Power",
"texture_filename": "tex1_128x64_482f78c5dfc14eab_0e7513b77d82c9ae_9"
},
{
"type": "draw_started",
"prettyname": "Announcer First Attack",
"texture_filename": "tex1_128x64_b92d24567ae12b3a_14d61fafa74e6334_9"
},
{
"type": "draw_started",
"prettyname": "Announcer Counter",
"texture_filename": "tex1_128x64_bbdfacdc36d171ec_85047913fd8df9aa_9"
},
{
"type": "draw_started",
"prettyname": "Announcer Lock On",
"texture_filename": "tex1_128x64_3ba4b1f803afd256_93ba5384bd764946_9"
},
{
"type": "draw_started",
"prettyname": "Announcer Boost",
"texture_filename": "tex1_128x64_09d5b89f7dbf0590_2abc7134cbb2138b_9"
},
{
"type": "draw_started",
"prettyname": "Buttom Prompt Y",
"texture_filename": "tex1_32x32_15f350b2b7f46481_66860824280a89bf_8"
},
{
"type": "draw_started",
"prettyname": "Button Prompt Y Hold",
"texture_filename": "tex1_32x32_00d2fb316a25d017_a889bebad6535a02_8"
},
{
"type": "draw_started",
"prettyname": "Button Prompt Y Mash",
"texture_filename": "tex1_64x64_8934f812b54f87c4_66860824280a89bf_8"
},
{
"type": "draw_started",
"prettyname": "Buttom Prompt B",
"texture_filename": "tex1_32x32_ce62786fc1170192_70b585e07941e91c_8"
},
{
"type": "draw_started",
"prettyname": "Button Prompt B Hold",
"texture_filename": "tex1_32x32_2841b917a7c23834_bdbd0425eb2f4b52_8"
},
{
"type": "draw_started",
"prettyname": "Button Prompt B Mash",
"texture_filename": "tex1_64x64_23b176984035b44c_8204be59ecb7c469_8"
},
{
"type": "draw_started",
"prettyname": "Buttom Prompt X",
"texture_filename": "tex1_32x32_b52817e68be0e2d7_d1b283ce04ce1c7c_8"
},
{
"type": "draw_started",
"prettyname": "Button Prompt X Mash",
"texture_filename": "tex1_64x64_cb8aa5843b3cc31c_ccbcbdf9c811ed5d_8"
},
{
"type": "draw_started",
"prettyname": "Buttom Prompt A",
"texture_filename": "tex1_32x32_630cfa888a9d005a_d95570935377e345_8"
},
{
"type": "draw_started",
"prettyname": "Button Prompt A Mash",
"texture_filename": "tex1_64x64_eef97dc696b0edd6_758bf7c8a0397add_8"
},
{
"type": "draw_started",
"prettyname": "Button Prompt Hold Hand",
"texture_filename": "tex1_32x32_80eec4ab54c12b14_2fbe88721f145bc3_8"
},
{
"type": "draw_started",
"prettyname": "Button Prompt LStick Up",
"texture_filename": "tex1_32x32_56eb18736158692a_831cb2dcaee7d9c7_8"
},
{
"type": "draw_started",
"prettyname": "Button Prompt LStick Down",
"texture_filename": "tex1_32x32_4f6911885cbfd6b7_b01602f981cf7194_8"
},
{
"type": "draw_started",
"prettyname": "Button Prompt LStick Left",
"texture_filename": "tex1_32x32_de66fb7b17f39fb2_723568783ce8af39_8"
},
{
"type": "draw_started",
"prettyname": "Button Prompt LStick Right",
"texture_filename": "tex1_32x32_4a3ce686c4d7d216_d9a6c961c9883e00_8"
},
{
"type": "draw_started",
"prettyname": "Button Prompt LStick Clash N",
"texture_filename": "tex1_64x64_0e45133195ab2db7_8061698fc3e81ec4_8"
},
{
"type": "draw_started",
"prettyname": "Button Prompt LStick Clash NE",
"texture_filename": "tex1_64x64_23a7ebdcad6f294c_961413a3996f1955_8"
},
{
"type": "draw_started",
"prettyname": "Button Prompt LStick Clash E",
"texture_filename": "tex1_64x64_fc736187474b6d87_5db58dd7fedde1e4_8"
},
{
"type": "draw_started",
"prettyname": "Button Prompt LStick Clash SE",
"texture_filename": "tex1_64x64_847d2a027ba61a6d_da6f9db59fa7a52b_8"
},
{
"type": "draw_started",
"prettyname": "Button Prompt LStick Clash S",
"texture_filename": "tex1_64x64_2fd46476d6eeb2a5_8cf71f59f3f4f61d_8"
},
{
"type": "draw_started",
"prettyname": "Button Prompt LStick Clash Neutral",
"texture_filename": "tex1_64x64_e63e59943072d5ba_13e4b338982e9dbc_8"
},
{
"type": "draw_started",
"prettyname": "Button Prompt Plus",
"texture_filename": "tex1_32x32_214dbb89f41af76c_ee10bcb01a356553_8"
},
{
"type": "draw_started",
"prettyname": "Button Prompt Mash Backdrop",
"texture_filename": "tex1_64x64_c7be948af15370ea_104c0c86a865a442_9"
},
{
"type": "draw_started",
"prettyname": "Text Font Main",
"texture_filename": "tex1_512x128_b38c0db36dfc6ac3_71a440118950d6cd_8"
},
{
"type": "draw_started",
"prettyname": "Text Font Special",
"texture_filename": "tex1_512x128_b38c0db36dfc6ac3_561056e6b4e21980_8"
}
]
}
]
}

View File

@ -0,0 +1,19 @@
{
"meta":
{
"title": "Bloom Texture Definitions",
"author": "SuperSamus"
},
"groups":
[
{
"name": "Bloom",
"targets": [
{
"type": "efb",
"texture_filename": "efb1_n000007_80x57_6"
}
]
}
]
}

View File

@ -0,0 +1,19 @@
{
"meta":
{
"title": "Bloom Texture Definitions",
"author": "SuperSamus"
},
"groups":
[
{
"name": "Bloom",
"targets": [
{
"type": "efb",
"texture_filename": "efb1_n000008_80x57_6"
}
]
}
]
}

View File

@ -0,0 +1,19 @@
{
"meta":
{
"title": "Bloom Texture Definitions",
"author": "SuperSamus"
},
"groups":
[
{
"name": "Bloom",
"targets": [
{
"type": "efb",
"texture_filename": "efb1_n000005_320x228_6"
}
]
}
]
}

View File

@ -49,6 +49,10 @@
{
"type": "efb",
"texture_filename": "efb1_n000000_256x256_1"
},
{
"type": "efb",
"texture_filename": "efb1_n000000_512x512_1"
}
]
}

View File

@ -7,6 +7,19 @@ Buttons/2 = `2`
Buttons/- = `-`
Buttons/+ = `+`
Buttons/Home = `HOME`
IRPassthrough/Enabled = False
IRPassthrough/Object 1 X = `IR Object 1 X`
IRPassthrough/Object 1 Y = `IR Object 1 Y`
IRPassthrough/Object 1 Size = `IR Object 1 Size`
IRPassthrough/Object 2 X = `IR Object 2 X`
IRPassthrough/Object 2 Y = `IR Object 2 Y`
IRPassthrough/Object 2 Size = `IR Object 2 Size`
IRPassthrough/Object 3 X = `IR Object 3 X`
IRPassthrough/Object 3 Y = `IR Object 3 Y`
IRPassthrough/Object 3 Size = `IR Object 3 Size`
IRPassthrough/Object 4 X = `IR Object 4 X`
IRPassthrough/Object 4 Y = `IR Object 4 Y`
IRPassthrough/Object 4 Size = `IR Object 4 Size`
IMUAccelerometer/Up = `Accel Up`
IMUAccelerometer/Down = `Accel Down`
IMUAccelerometer/Left = `Accel Left`

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 560 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 583 B

View File

@ -0,0 +1,69 @@
// Based on https://github.com/Filoppi/PumboAutoHDR
/*
[configuration]
[OptionRangeFloat]
GUIName = HDR Display Max Nits
OptionName = HDR_DISPLAY_MAX_NITS
MinValue = 80
MaxValue = 2000
StepAmount = 1
DefaultValue = 400
[OptionRangeFloat]
GUIName = Shoulder Start Alpha
OptionName = AUTO_HDR_SHOULDER_START_ALPHA
MinValue = 0
MaxValue = 1
StepAmount = 0.01
DefaultValue = 0
[OptionRangeFloat]
GUIName = Shoulder Pow
OptionName = AUTO_HDR_SHOULDER_POW
MinValue = 1
MaxValue = 10
StepAmount = 0.05
DefaultValue = 2.5
[/configuration]
*/
float luminance(float3 color)
{
return dot(color, float3(0.2126f, 0.7152f, 0.0722f));
}
void main()
{
float4 color = Sample();
// Nothing to do here, we are in SDR
if (!OptionEnabled(hdr_output) || !OptionEnabled(linear_space_output))
{
SetOutput(color);
return;
}
const float hdr_paper_white = hdr_paper_white_nits / hdr_sdr_white_nits;
// Restore the original SDR (0-1) brightness (we might or might not restore it later)
color.rgb /= hdr_paper_white;
// Find the color luminance (it works better than average)
float sdr_ratio = luminance(color.rgb);
const float auto_hdr_max_white = max(HDR_DISPLAY_MAX_NITS / (hdr_paper_white_nits / hdr_sdr_white_nits), hdr_sdr_white_nits) / hdr_sdr_white_nits;
if (sdr_ratio > AUTO_HDR_SHOULDER_START_ALPHA && AUTO_HDR_SHOULDER_START_ALPHA < 1.0)
{
const float auto_hdr_shoulder_ratio = 1.0 - (max(1.0 - sdr_ratio, 0.0) / (1.0 - AUTO_HDR_SHOULDER_START_ALPHA));
const float auto_hdr_extra_ratio = pow(auto_hdr_shoulder_ratio, AUTO_HDR_SHOULDER_POW) * (auto_hdr_max_white - 1.0);
const float auto_hdr_total_ratio = sdr_ratio + auto_hdr_extra_ratio;
color.rgb *= auto_hdr_total_ratio / sdr_ratio;
}
color.rgb *= hdr_paper_white;
SetOutput(color);
}

View File

@ -0,0 +1,129 @@
/*
[configuration]
[OptionRangeFloat]
GUIName = Amplificiation
OptionName = AMPLIFICATION
MinValue = 1.0
MaxValue = 6.0
StepAmount = 0.25
DefaultValue = 2.5
[/configuration]
*/
// ICtCP Colorspace as defined by Dolby here:
// https://professional.dolby.com/siteassets/pdfs/ictcp_dolbywhitepaper_v071.pdf
/***** Transfer Function *****/
const float a = 0.17883277;
const float b = 1.0 - 4.0 * a;
const float c = 0.5 - a * log(4.0 * a);
float HLG_f(float x)
{
if (x < 0.0) {
return 0.0;
}
else if (x < 1.0 / 12.0) {
return sqrt(3.0 * x);
}
return a * log(12.0 * x - b) + c;
}
float HLG_inv_f(float x)
{
if (x < 0.0) {
return 0.0;
}
else if (x < 1.0 / 2.0) {
return x * x / 3.0;
}
return (exp((x - c) / a) + b) / 12.0;
}
float4 HLG(float4 lms)
{
return float4(HLG_f(lms.x), HLG_f(lms.y), HLG_f(lms.z), lms.w);
}
float4 HLG_inv(float4 lms)
{
return float4(HLG_inv_f(lms.x), HLG_inv_f(lms.y), HLG_inv_f(lms.z), lms.w);
}
/***** Linear <--> ICtCp *****/
const mat4 RGBtoLMS = mat4(
1688.0, 683.0, 99.0, 0.0,
2146.0, 2951.0, 309.0, 0.0,
262.0, 462.0, 3688.0, 0.0,
0.0, 0.0, 0.0, 4096.0)
/ 4096.0;
const mat4 LMStoICtCp = mat4(
+2048.0, +3625.0, +9500.0, 0.0,
+2048.0, -7465.0, -9212.0, 0.0,
+0.0, +3840.0, -288.0, 0.0,
+0.0, +0.0, +0.0, 4096.0)
/ 4096.0;
float4 LinearRGBToICtCP(float4 c)
{
return LMStoICtCp * HLG(RGBtoLMS * c);
}
/***** ICtCp <--> Linear *****/
mat4 ICtCptoLMS = inverse(LMStoICtCp);
mat4 LMStoRGB = inverse(RGBtoLMS);
float4 ICtCpToLinearRGB(float4 c)
{
return LMStoRGB * HLG_inv(ICtCptoLMS * c);
}
void main()
{
float4 color = Sample();
// Nothing to do here, we are in SDR
if (!OptionEnabled(hdr_output) || !OptionEnabled(linear_space_output)) {
SetOutput(color);
return;
}
// Renormalize Color to be in [0.0 - 1.0] SDR Space. We will revert this later.
const float hdr_paper_white = hdr_paper_white_nits / hdr_sdr_white_nits;
color.rgb /= hdr_paper_white;
// Convert Color to Perceptual Color Space. This will allow us to do perceptual
// scaling while also being able to use the luminance channel.
float4 ictcp_color = LinearRGBToICtCP(color);
// Scale the color in perceptual space depending on the percieved luminance.
//
// At low luminances, ~0.0, pow(AMPLIFICATION, ~0.0) ~= 1.0, so the
// color will appear to be unchanged. This is important as we don't want to
// over expose dark colors which would not have otherwise been seen.
//
// At high luminances, ~1.0, pow(AMPLIFICATION, ~1.0) ~= AMPLIFICATION,
// which is equivilant to scaling the color by AMPLIFICATION. This is
// important as we want to get the most out of the display, and we want to
// get bright colors to hit their target brightness.
//
// For more information, see this desmos demonstrating this scaling process:
// https://www.desmos.com/calculator/syjyrjsj5c
float exposure = length(ictcp_color.xyz);
ictcp_color *= pow(HLG_f(AMPLIFICATION), exposure);
// Convert back to Linear RGB and output the color to the display.
// We use hdr_paper_white to renormalize the color to the comfortable
// SDR viewing range.
SetOutput(hdr_paper_white * ICtCpToLinearRGB(ictcp_color));
}

View File

@ -0,0 +1,408 @@
/***** COLOR CORRECTION *****/
// Color Space references:
// https://www.unravel.com.au/understanding-color-spaces
// SMPTE 170M - BT.601 (NTSC-M) -> BT.709
mat3 from_NTSCM = transpose(mat3(
0.939497225737661, 0.0502268452914346, 0.0102759289709032,
0.0177558637510127, 0.965824605885027, 0.0164195303639603,
-0.00162163209967010, -0.00437400622653655, 1.00599563832621));
// ARIB TR-B9 (9300K+27MPCD with chromatic adaptation) (NTSC-J) -> BT.709
mat3 from_NTSCJ = transpose(mat3(
0.823613036967492, -0.0943227111084757, 0.00799341532931119,
0.0289258355537324, 1.02310733489462, 0.00243547111576797,
-0.00569501554980891, 0.0161828357559315, 1.22328453915712));
// EBU - BT.470BG/BT.601 (PAL) -> BT.709
mat3 from_PAL = transpose(mat3(
1.04408168421813, -0.0440816842181253, 0.000000000000000,
0.000000000000000, 1.00000000000000, 0.000000000000000,
0.000000000000000, 0.0118044782106489, 0.988195521789351));
float3 LinearTosRGBGamma(float3 color)
{
const float a = 0.055;
for (int i = 0; i < 3; ++i)
{
float x = color[i];
if (x <= 0.0031308)
x = x * 12.92;
else
x = (1.0 + a) * pow(x, 1.0 / 2.4) - a;
color[i] = x;
}
return color;
}
/***** COLOR SAMPLING *****/
// Non filtered gamma corrected sample (nearest neighbor)
float4 QuickSample(float3 uvw, float gamma)
{
#if 0 // Test sampling range
const float threshold = 0.00000001;
float2 xy = uvw.xy * GetResolution();
// Sampling outside the valid range, draw in yellow
if (xy.x < (0.0 - threshold) || xy.x > (GetResolution().x + threshold) || xy.y < (0.0 - threshold) || xy.y > (GetResolution().y + threshold))
return float4(1.0, 1.0, 0.0, 1);
// Sampling at the edges, draw in purple
if (xy.x < 1.0 || xy.x > (GetResolution().x - 1.0) || xy.y < 1.0 || xy.y > (GetResolution().y - 1.0))
return float4(0.5, 0, 0.5, 1);
#endif
float4 color = texture(samp1, uvw);
color.rgb = pow(color.rgb, float3(gamma));
return color;
}
float4 QuickSample(float2 uv, float w, float gamma)
{
return QuickSample(float3(uv, w), gamma);
}
float4 QuickSampleByPixel(float2 xy, float w, float gamma)
{
float3 uvw = float3(xy * GetInvResolution(), w);
return QuickSample(uvw, gamma);
}
/***** Bilinear Interpolation *****/
float4 BilinearSample(float3 uvw, float gamma)
{
// This emulates the (bi)linear filtering done directly from GPUs HW.
// Note that GPUs might natively filter red green and blue differently, but we don't do it.
// They might also use different filtering between upscaling and downscaling.
float2 source_size = GetResolution();
float2 pixel = (uvw.xy * source_size) - 0.5; // Try to find the matching pixel top left corner
// Find the integer and floating point parts
float2 int_pixel = floor(pixel);
float2 frac_pixel = fract(pixel);
// Take 4 samples around the original uvw
float4 c11 = QuickSampleByPixel(int_pixel + float2(0.5, 0.5), uvw.z, gamma);
float4 c21 = QuickSampleByPixel(int_pixel + float2(1.5, 0.5), uvw.z, gamma);
float4 c12 = QuickSampleByPixel(int_pixel + float2(0.5, 1.5), uvw.z, gamma);
float4 c22 = QuickSampleByPixel(int_pixel + float2(1.5, 1.5), uvw.z, gamma);
// Blend the 4 samples by their weight
return lerp(lerp(c11, c21, frac_pixel.x), lerp(c12, c22, frac_pixel.x), frac_pixel.y);
}
/***** Bicubic Interpolation *****/
// Formula derived from:
// https://en.wikipedia.org/wiki/Mitchell%E2%80%93Netravali_filters#Definition
// Values from:
// https://guideencodemoe-mkdocs.readthedocs.io/encoding/resampling/#mitchell-netravali-bicubic
// Other references:
// https://www.codeproject.com/Articles/236394/Bi-Cubic-and-Bi-Linear-Interpolation-with-GLSL
// https://github.com/ValveSoftware/gamescope/pull/740
// https://stackoverflow.com/questions/13501081/efficient-bicubic-filtering-code-in-glsl
#define CUBIC_COEFF_GEN(B, C) \
(mat4(/* t^0 */ ((B) / 6.0), (-(B) / 3.0 + 1.0), ((B) / 6.0), (0.0), \
/* t^1 */ (-(B) / 2.0 - (C)), (0.0), ((B) / 2.0 + (C)), (0.0), \
/* t^2 */ ((B) / 2.0 + 2.0 * (C)), (2.0 * (B) + (C)-3.0), \
(-5.0 * (B) / 2.0 - 2.0 * (C) + 3.0), (-(C)), \
/* t^3 */ (-(B) / 6.0 - (C)), (-3.0 * (B) / 2.0 - (C) + 2.0), \
(3.0 * (B) / 2.0 + (C)-2.0), ((B) / 6.0 + (C))))
float4 CubicCoeffs(float t, mat4 coeffs)
{
return coeffs * float4(1.0, t, t * t, t * t * t);
}
float4 CubicMix(float4 c0, float4 c1, float4 c2, float4 c3, float4 coeffs)
{
return c0 * coeffs[0] + c1 * coeffs[1] + c2 * coeffs[2] + c3 * coeffs[3];
}
// By Sam Belliveau. Public Domain license.
// Simple 16 tap, gamma correct, implementation of bicubic filtering.
float4 BicubicSample(float3 uvw, float gamma, mat4 coeffs)
{
float2 pixel = (uvw.xy * GetResolution()) - 0.5;
float2 int_pixel = floor(pixel);
float2 frac_pixel = fract(pixel);
float4 c00 = QuickSampleByPixel(int_pixel + float2(-0.5, -0.5), uvw.z, gamma);
float4 c10 = QuickSampleByPixel(int_pixel + float2(+0.5, -0.5), uvw.z, gamma);
float4 c20 = QuickSampleByPixel(int_pixel + float2(+1.5, -0.5), uvw.z, gamma);
float4 c30 = QuickSampleByPixel(int_pixel + float2(+2.5, -0.5), uvw.z, gamma);
float4 c01 = QuickSampleByPixel(int_pixel + float2(-0.5, +0.5), uvw.z, gamma);
float4 c11 = QuickSampleByPixel(int_pixel + float2(+0.5, +0.5), uvw.z, gamma);
float4 c21 = QuickSampleByPixel(int_pixel + float2(+1.5, +0.5), uvw.z, gamma);
float4 c31 = QuickSampleByPixel(int_pixel + float2(+2.5, +0.5), uvw.z, gamma);
float4 c02 = QuickSampleByPixel(int_pixel + float2(-0.5, +1.5), uvw.z, gamma);
float4 c12 = QuickSampleByPixel(int_pixel + float2(+0.5, +1.5), uvw.z, gamma);
float4 c22 = QuickSampleByPixel(int_pixel + float2(+1.5, +1.5), uvw.z, gamma);
float4 c32 = QuickSampleByPixel(int_pixel + float2(+2.5, +1.5), uvw.z, gamma);
float4 c03 = QuickSampleByPixel(int_pixel + float2(-0.5, +2.5), uvw.z, gamma);
float4 c13 = QuickSampleByPixel(int_pixel + float2(+0.5, +2.5), uvw.z, gamma);
float4 c23 = QuickSampleByPixel(int_pixel + float2(+1.5, +2.5), uvw.z, gamma);
float4 c33 = QuickSampleByPixel(int_pixel + float2(+2.5, +2.5), uvw.z, gamma);
float4 cx = CubicCoeffs(frac_pixel.x, coeffs);
float4 cy = CubicCoeffs(frac_pixel.y, coeffs);
float4 x0 = CubicMix(c00, c10, c20, c30, cx);
float4 x1 = CubicMix(c01, c11, c21, c31, cx);
float4 x2 = CubicMix(c02, c12, c22, c32, cx);
float4 x3 = CubicMix(c03, c13, c23, c33, cx);
return CubicMix(x0, x1, x2, x3, cy);
}
/***** Sharp Bilinear Filtering *****/
// Based on https://github.com/libretro/slang-shaders/blob/master/interpolation/shaders/sharp-bilinear.slang
// by Themaister, Public Domain license
// Does a bilinear stretch, with a preapplied Nx nearest-neighbor scale,
// giving a sharper image than plain bilinear.
float4 SharpBilinearSample(float3 uvw, float gamma)
{
float2 source_size = GetResolution();
float2 inverted_source_size = GetInvResolution();
float2 target_size = GetWindowResolution();
float2 texel = uvw.xy * source_size;
float2 texel_floored = floor(texel);
float2 s = fract(texel);
float scale = max(floor(max(target_size.x * inverted_source_size.x, target_size.y * inverted_source_size.y)), 1.f);
float region_range = 0.5 - (0.5 / scale);
// Figure out where in the texel to sample to get correct pre-scaled bilinear.
float2 center_dist = s - 0.5;
float2 f = ((center_dist - clamp(center_dist, -region_range, region_range)) * scale) + 0.5;
float2 mod_texel = texel_floored + f;
uvw.xy = mod_texel * inverted_source_size;
return BilinearSample(uvw, gamma);
}
/***** Area Sampling *****/
// By Sam Belliveau and Filippo Tarpini. Public Domain license.
// Effectively a more accurate sharp bilinear filter when upscaling,
// that also works as a mathematically perfect downscale filter.
// https://entropymine.com/imageworsener/pixelmixing/
// https://github.com/obsproject/obs-studio/pull/1715
// https://legacy.imagemagick.org/Usage/filter/
float4 AreaSampling(float3 uvw, float gamma)
{
// Determine the sizes of the source and target images.
float2 source_size = GetResolution();
float2 target_size = GetWindowResolution();
float2 inverted_target_size = GetInvWindowResolution();
// Compute the top-left and bottom-right corners of the target pixel box.
float2 t_beg = floor(uvw.xy * target_size);
float2 t_end = t_beg + float2(1.0, 1.0);
// Convert the target pixel box to source pixel box.
float2 beg = t_beg * inverted_target_size * source_size;
float2 end = t_end * inverted_target_size * source_size;
// Compute the top-left and bottom-right corners of the pixel box.
float2 f_beg = floor(beg);
float2 f_end = floor(end);
// Compute how much of the start and end pixels are covered horizontally & vertically.
float area_w = 1.0 - fract(beg.x);
float area_n = 1.0 - fract(beg.y);
float area_e = fract(end.x);
float area_s = fract(end.y);
// Compute the areas of the corner pixels in the pixel box.
float area_nw = area_n * area_w;
float area_ne = area_n * area_e;
float area_sw = area_s * area_w;
float area_se = area_s * area_e;
// Initialize the color accumulator.
float4 avg_color = float4(0.0, 0.0, 0.0, 0.0);
// Prevents rounding errors due to the coordinates flooring above
const float2 offset = float2(0.5, 0.5);
// Accumulate corner pixels.
avg_color += area_nw * QuickSampleByPixel(float2(f_beg.x, f_beg.y) + offset, uvw.z, gamma);
avg_color += area_ne * QuickSampleByPixel(float2(f_end.x, f_beg.y) + offset, uvw.z, gamma);
avg_color += area_sw * QuickSampleByPixel(float2(f_beg.x, f_end.y) + offset, uvw.z, gamma);
avg_color += area_se * QuickSampleByPixel(float2(f_end.x, f_end.y) + offset, uvw.z, gamma);
// Determine the size of the pixel box.
int x_range = int(f_end.x - f_beg.x - 0.5);
int y_range = int(f_end.y - f_beg.y - 0.5);
// Workaround to compile the shader with DX11/12.
// If this isn't done, it will complain that the loop could have too many iterations.
// This number should be enough to guarantee downscaling from very high to very small resolutions.
// Note that this number might be referenced in the UI.
const int max_iterations = 16;
// Fix up the average calculations in case we reached the upper limit
x_range = min(x_range, max_iterations);
y_range = min(y_range, max_iterations);
// Accumulate top and bottom edge pixels.
for (int ix = 0; ix < max_iterations; ++ix)
{
if (ix < x_range)
{
float x = f_beg.x + 1.0 + float(ix);
avg_color += area_n * QuickSampleByPixel(float2(x, f_beg.y) + offset, uvw.z, gamma);
avg_color += area_s * QuickSampleByPixel(float2(x, f_end.y) + offset, uvw.z, gamma);
}
}
// Accumulate left and right edge pixels and all the pixels in between.
for (int iy = 0; iy < max_iterations; ++iy)
{
if (iy < y_range)
{
float y = f_beg.y + 1.0 + float(iy);
avg_color += area_w * QuickSampleByPixel(float2(f_beg.x, y) + offset, uvw.z, gamma);
avg_color += area_e * QuickSampleByPixel(float2(f_end.x, y) + offset, uvw.z, gamma);
for (int ix = 0; ix < max_iterations; ++ix)
{
if (ix < x_range)
{
float x = f_beg.x + 1.0 + float(ix);
avg_color += QuickSampleByPixel(float2(x, y) + offset, uvw.z, gamma);
}
}
}
}
// Compute the area of the pixel box that was sampled.
float area_corners = area_nw + area_ne + area_sw + area_se;
float area_edges = float(x_range) * (area_n + area_s) + float(y_range) * (area_w + area_e);
float area_center = float(x_range) * float(y_range);
// Return the normalized average color.
return avg_color / (area_corners + area_edges + area_center);
}
/***** Main Functions *****/
// Returns an accurate (gamma corrected) sample of a gamma space space texture.
// Outputs in linear space for simplicity.
float4 LinearGammaCorrectedSample(float gamma)
{
float3 uvw = v_tex0;
float4 color = float4(0, 0, 0, 1);
if (resampling_method <= 1) // Bilinear
{
color = BilinearSample(uvw, gamma);
}
else if (resampling_method == 2) // Bicubic: B-Spline
{
color = BicubicSample(uvw, gamma, CUBIC_COEFF_GEN(1.0, 0.0));
}
else if (resampling_method == 3) // Bicubic: Mitchell-Netravali
{
color = BicubicSample(uvw, gamma, CUBIC_COEFF_GEN(1.0 / 3.0, 1.0 / 3.0));
}
else if (resampling_method == 4) // Bicubic: Catmull-Rom
{
color = BicubicSample(uvw, gamma, CUBIC_COEFF_GEN(0.0, 0.5));
}
else if (resampling_method == 5) // Sharp Bilinear
{
color = SharpBilinearSample(uvw, gamma);
}
else if (resampling_method == 6) // Area Sampling
{
color = AreaSampling(uvw, gamma);
}
else if (resampling_method == 7) // Nearest Neighbor
{
color = QuickSample(uvw, gamma);
}
else if (resampling_method == 8) // Bicubic: Hermite
{
color = BicubicSample(uvw, gamma, CUBIC_COEFF_GEN(0.0, 0.0));
}
return color;
}
void main()
{
// This tries to fall back on GPU HW sampling if it can (it won't be gamma corrected).
bool raw_resampling = resampling_method <= 0;
bool needs_rescaling = GetResolution() != GetWindowResolution();
bool needs_resampling = needs_rescaling && (OptionEnabled(hdr_output) || OptionEnabled(correct_gamma) || !raw_resampling);
float4 color;
if (needs_resampling)
{
// Doing linear sampling in "gamma space" on linear texture formats isn't correct.
// If the source and target resolutions don't match, the GPU will return a color
// that is the average of 4 gamma space colors, but gamma space colors can't be blended together,
// gamma neeeds to be de-applied first. This makes a big difference if colors change
// drastically between two pixels.
color = LinearGammaCorrectedSample(game_gamma);
}
else
{
// Default GPU HW sampling. Bilinear is identical to Nearest Neighbor if the input and output resolutions match.
if (needs_rescaling)
color = texture(samp0, v_tex0);
else
color = texture(samp1, v_tex0);
// Convert to linear before doing any other of follow up operations.
color.rgb = pow(color.rgb, float3(game_gamma));
}
if (OptionEnabled(correct_color_space))
{
if (game_color_space == 0)
color.rgb = color.rgb * from_NTSCM;
else if (game_color_space == 1)
color.rgb = color.rgb * from_NTSCJ;
else if (game_color_space == 2)
color.rgb = color.rgb * from_PAL;
}
if (OptionEnabled(hdr_output))
{
float hdr_paper_white = hdr_paper_white_nits / hdr_sdr_white_nits;
color.rgb *= hdr_paper_white;
}
if (OptionEnabled(linear_space_output))
{
// Nothing to do here
}
// Correct the SDR gamma for sRGB (PC/Monitor) or ~2.2 (Common TV gamma)
else if (OptionEnabled(correct_gamma))
{
if (OptionEnabled(sdr_display_gamma_sRGB))
color.rgb = LinearTosRGBGamma(color.rgb);
else
color.rgb = pow(color.rgb, float3(1.0 / sdr_display_custom_gamma));
}
// Restore the original gamma without changes
else
{
color.rgb = pow(color.rgb, float3(1.0 / game_gamma));
}
SetOutput(color);
}

View File

@ -1,47 +0,0 @@
// Based on https://github.com/libretro/slang-shaders/blob/master/interpolation/shaders/sharp-bilinear.slang
// by Themaister, Public Domain license
// Does a bilinear stretch, with a preapplied Nx nearest-neighbor scale,
// giving a sharper image than plain bilinear.
/*
[configuration]
[OptionRangeFloat]
GUIName = Prescale Factor (set to 0 for automatic)
OptionName = PRESCALE_FACTOR
MinValue = 0.0
MaxValue = 16.0
StepAmount = 1.0
DefaultValue = 0.0
[/configuration]
*/
float CalculatePrescale(float config_scale) {
if (config_scale == 0.0) {
float2 source_size = GetResolution();
float2 window_size = GetWindowResolution();
return ceil(max(window_size.x / source_size.x, window_size.y / source_size.y));
} else {
return config_scale;
}
}
void main()
{
float2 source_size = GetResolution();
float2 texel = GetCoordinates() * source_size;
float2 texel_floored = floor(texel);
float2 s = fract(texel);
float config_scale = GetOption(PRESCALE_FACTOR);
float scale = CalculatePrescale(config_scale);
float region_range = 0.5 - 0.5 / scale;
// Figure out where in the texel to sample to get correct pre-scaled bilinear.
// Uses the hardware bilinear interpolator to avoid having to sample 4 times manually.
float2 center_dist = s - 0.5;
float2 f = (center_dist - clamp(center_dist, -region_range, region_range)) * scale + 0.5;
float2 mod_texel = texel_floored + f;
SetOutput(SampleLocation(mod_texel / source_size));
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Some files were not shown because too many files have changed in this diff Show More