Compare commits
No commits in common. "tx-update-20230601030142" and "master" have entirely different histories.
tx-update-
...
master
|
|
@ -22,7 +22,6 @@ cmake .. \
|
|||
-DUSE_DISCORD_PRESENCE=ON \
|
||||
-DYUZU_ENABLE_COMPATIBILITY_REPORTING=${ENABLE_COMPATIBILITY_REPORTING:-"OFF"} \
|
||||
-DYUZU_USE_BUNDLED_FFMPEG=ON \
|
||||
-DYUZU_ENABLE_LTO=ON \
|
||||
-GNinja
|
||||
|
||||
ninja
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ def parse_imports(file_name):
|
|||
|
||||
def parse_imports_recursive(file_name, path_list=[]):
|
||||
q = queue.Queue() # create a FIFO queue
|
||||
# file_name can be a string or a list for the convenience
|
||||
# file_name can be a string or a list for the convience
|
||||
if isinstance(file_name, str):
|
||||
q.put(file_name)
|
||||
elif isinstance(file_name, list):
|
||||
|
|
|
|||
|
|
@ -26,11 +26,7 @@ $env:BUILD_ZIP = $MSVC_BUILD_ZIP
|
|||
$env:BUILD_SYMBOLS = $MSVC_BUILD_PDB
|
||||
$env:BUILD_UPDATE = $MSVC_SEVENZIP
|
||||
|
||||
if (Test-Path -Path ".\build\bin\Release") {
|
||||
$BUILD_DIR = ".\build\bin\Release"
|
||||
} else {
|
||||
$BUILD_DIR = ".\build\bin\"
|
||||
}
|
||||
$BUILD_DIR = ".\build\bin\Release"
|
||||
|
||||
# Cleanup unneeded data in submodules
|
||||
git submodule foreach git clean -fxd
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ parameters:
|
|||
steps:
|
||||
- script: choco install vulkan-sdk
|
||||
displayName: 'Install vulkan-sdk'
|
||||
- script: refreshenv && mkdir build && cd build && cmake -E env CXXFLAGS="/Gw /GA /Gr /Ob2" cmake -G "Visual Studio 17 2022" -A x64 -DCMAKE_POLICY_DEFAULT_CMP0069=NEW -DYUZU_ENABLE_LTO=ON -DYUZU_USE_BUNDLED_QT=1 -DYUZU_USE_BUNDLED_SDL2=1 -DYUZU_USE_QT_WEB_ENGINE=ON -DENABLE_COMPATIBILITY_LIST_DOWNLOAD=ON -DYUZU_ENABLE_COMPATIBILITY_REPORTING=${COMPAT} -DYUZU_TESTS=OFF -DUSE_DISCORD_PRESENCE=ON -DENABLE_QT_TRANSLATION=ON -DDISPLAY_VERSION=${{ parameters['version'] }} -DCMAKE_BUILD_TYPE=Release -DYUZU_CRASH_DUMPS=ON .. && cd ..
|
||||
- script: refreshenv && mkdir build && cd build && cmake -E env CXXFLAGS="/Gw /GA /Gr /Ob2" cmake -G "Visual Studio 17 2022" -A x64 -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON -DCMAKE_POLICY_DEFAULT_CMP0069=NEW -DYUZU_USE_BUNDLED_QT=1 -DYUZU_USE_BUNDLED_SDL2=1 -DYUZU_USE_QT_WEB_ENGINE=ON -DENABLE_COMPATIBILITY_LIST_DOWNLOAD=ON -DYUZU_ENABLE_COMPATIBILITY_REPORTING=${COMPAT} -DYUZU_TESTS=OFF -DUSE_DISCORD_PRESENCE=ON -DENABLE_QT_TRANSLATION=ON -DDISPLAY_VERSION=${{ parameters['version'] }} -DCMAKE_BUILD_TYPE=Release -DYUZU_CRASH_DUMPS=ON .. && cd ..
|
||||
displayName: 'Configure CMake'
|
||||
- task: MSBuild@1
|
||||
displayName: 'Build'
|
||||
|
|
|
|||
|
|
@ -1,6 +0,0 @@
|
|||
; SPDX-FileCopyrightText: 2023 yuzu Emulator Project
|
||||
; SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
[codespell]
|
||||
skip = ./.git,./build,./dist,./Doxyfile,./externals,./LICENSES
|
||||
ignore-words-list = aci,allright,ba,deques,froms,hda,inout,lod,masia,nam,nax,nd,pullrequests,pullrequest,te,transfered,unstall,uscaled,zink
|
||||
17
.github/workflows/codespell.yml
vendored
17
.github/workflows/codespell.yml
vendored
|
|
@ -1,17 +0,0 @@
|
|||
# SPDX-FileCopyrightText: 2023 yuzu Emulator Project
|
||||
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||
# GitHub Action to automate the identification of common misspellings in text files.
|
||||
# https://github.com/codespell-project/actions-codespell
|
||||
# https://github.com/codespell-project/codespell
|
||||
name: codespell
|
||||
on: pull_request
|
||||
permissions: {}
|
||||
jobs:
|
||||
codespell:
|
||||
name: Check for spelling errors
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
persist-credentials: false
|
||||
- uses: codespell-project/actions-codespell@master
|
||||
3
.gitmodules
vendored
3
.gitmodules
vendored
|
|
@ -13,6 +13,9 @@
|
|||
[submodule "dynarmic"]
|
||||
path = externals/dynarmic
|
||||
url = https://github.com/MerryMage/dynarmic.git
|
||||
[submodule "libressl"]
|
||||
path = externals/libressl
|
||||
url = https://github.com/citra-emu/ext-libressl-portable.git
|
||||
[submodule "libusb"]
|
||||
path = externals/libusb/libusb
|
||||
url = https://github.com/libusb/libusb.git
|
||||
|
|
|
|||
13
.lgtm.yml
Normal file
13
.lgtm.yml
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
# SPDX-FileCopyrightText: 2020 yuzu Emulator Project
|
||||
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
path_classifiers:
|
||||
library: "externals"
|
||||
extraction:
|
||||
cpp:
|
||||
prepare:
|
||||
packages:
|
||||
- "libsdl2-dev"
|
||||
- "qtmultimedia5-dev"
|
||||
- "libtbb-dev"
|
||||
- "libjack-jackd2-dev"
|
||||
|
|
@ -56,8 +56,6 @@ option(YUZU_USE_BUNDLED_VCPKG "Use vcpkg for yuzu dependencies" "${MSVC}")
|
|||
|
||||
option(YUZU_CHECK_SUBMODULES "Check if submodules are present" ON)
|
||||
|
||||
option(YUZU_ENABLE_LTO "Enable link-time optimization" OFF)
|
||||
|
||||
CMAKE_DEPENDENT_OPTION(YUZU_USE_FASTER_LD "Check if a faster linker is available" ON "NOT WIN32" OFF)
|
||||
|
||||
if (YUZU_USE_BUNDLED_VCPKG)
|
||||
|
|
@ -67,9 +65,6 @@ if (YUZU_USE_BUNDLED_VCPKG)
|
|||
if (YUZU_CRASH_DUMPS)
|
||||
list(APPEND VCPKG_MANIFEST_FEATURES "dbghelp")
|
||||
endif()
|
||||
if (ENABLE_WEB_SERVICE)
|
||||
list(APPEND VCPKG_MANIFEST_FEATURES "web-service")
|
||||
endif()
|
||||
|
||||
include(${CMAKE_SOURCE_DIR}/externals/vcpkg/scripts/buildsystems/vcpkg.cmake)
|
||||
elseif(NOT "$ENV{VCPKG_TOOLCHAIN_FILE}" STREQUAL "")
|
||||
|
|
@ -210,11 +205,10 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin)
|
|||
# =======================================================================
|
||||
|
||||
# Enforce the search mode of non-required packages for better and shorter failure messages
|
||||
find_package(Boost 1.79.0 REQUIRED context)
|
||||
find_package(enet 1.3 MODULE)
|
||||
find_package(fmt 9 REQUIRED)
|
||||
find_package(inih 52 MODULE COMPONENTS INIReader)
|
||||
find_package(LLVM MODULE COMPONENTS Demangle)
|
||||
find_package(inih MODULE)
|
||||
find_package(LLVM MODULE)
|
||||
find_package(lz4 REQUIRED)
|
||||
find_package(nlohmann_json 3.8 REQUIRED)
|
||||
find_package(Opus 1.3 MODULE)
|
||||
|
|
@ -222,7 +216,7 @@ find_package(ZLIB 1.2 REQUIRED)
|
|||
find_package(zstd 1.5 REQUIRED)
|
||||
|
||||
if (NOT YUZU_USE_EXTERNAL_VULKAN_HEADERS)
|
||||
find_package(Vulkan 1.3.246 REQUIRED)
|
||||
find_package(Vulkan 1.3.238 REQUIRED)
|
||||
endif()
|
||||
|
||||
if (ENABLE_LIBUSB)
|
||||
|
|
@ -247,13 +241,26 @@ endif()
|
|||
|
||||
if (ENABLE_WEB_SERVICE)
|
||||
find_package(cpp-jwt 1.4 CONFIG)
|
||||
find_package(httplib 0.12 MODULE COMPONENTS OpenSSL)
|
||||
find_package(httplib 0.11 MODULE)
|
||||
endif()
|
||||
|
||||
if (YUZU_TESTS)
|
||||
find_package(Catch2 3.0.1 REQUIRED)
|
||||
endif()
|
||||
|
||||
find_package(Boost 1.73.0 COMPONENTS context)
|
||||
if (Boost_FOUND)
|
||||
set(Boost_LIBRARIES Boost::boost)
|
||||
# Conditionally add Boost::context only if the found Boost package provides it
|
||||
# The old version is missing Boost::context, so we want to avoid adding in that case
|
||||
# The new version requires adding Boost::context to prevent linking issues
|
||||
if (TARGET Boost::context)
|
||||
list(APPEND Boost_LIBRARIES Boost::context)
|
||||
endif()
|
||||
else()
|
||||
message(FATAL_ERROR "Boost 1.73.0 or newer not found")
|
||||
endif()
|
||||
|
||||
# boost:asio has functions that require AcceptEx et al
|
||||
if (MINGW)
|
||||
find_library(MSWSOCK_LIBRARY mswsock REQUIRED)
|
||||
|
|
@ -344,12 +351,12 @@ if(ENABLE_QT)
|
|||
find_package(PkgConfig REQUIRED)
|
||||
pkg_check_modules(QT_DEP_GLU QUIET glu>=9.0.0)
|
||||
if (NOT QT_DEP_GLU_FOUND)
|
||||
message(FATAL_ERROR "Qt bundled package dependency `glu` not found. \
|
||||
message(FATAL_ERROR "Qt bundled pacakge dependency `glu` not found. \
|
||||
Perhaps `libglu1-mesa-dev` needs to be installed?")
|
||||
endif()
|
||||
pkg_check_modules(QT_DEP_MESA QUIET dri>=20.0.8)
|
||||
if (NOT QT_DEP_MESA_FOUND)
|
||||
message(FATAL_ERROR "Qt bundled package dependency `dri` not found. \
|
||||
message(FATAL_ERROR "Qt bundled pacakge dependency `dri` not found. \
|
||||
Perhaps `mesa-common-dev` needs to be installed?")
|
||||
endif()
|
||||
|
||||
|
|
@ -450,10 +457,17 @@ if (ENABLE_SDL2)
|
|||
endif()
|
||||
endif()
|
||||
|
||||
# Reexport some targets that are named differently when using the upstream CmakeConfig
|
||||
# In order to ALIAS targets to a new name, they first need to be IMPORTED_GLOBAL
|
||||
# Dynarmic checks for target `boost` and so we want to make sure it can find it through our system instead of using their external
|
||||
if (TARGET Boost::boost)
|
||||
set_target_properties(Boost::boost PROPERTIES IMPORTED_GLOBAL TRUE)
|
||||
add_library(boost ALIAS Boost::boost)
|
||||
endif()
|
||||
|
||||
# List of all FFmpeg components required
|
||||
set(FFmpeg_COMPONENTS
|
||||
avcodec
|
||||
avfilter
|
||||
avutil
|
||||
swscale)
|
||||
|
||||
|
|
@ -478,8 +492,8 @@ if (APPLE)
|
|||
find_library(COCOA_LIBRARY Cocoa)
|
||||
set(PLATFORM_LIBRARIES ${COCOA_LIBRARY} ${IOKIT_LIBRARY} ${COREVIDEO_LIBRARY})
|
||||
elseif (WIN32)
|
||||
# Target Windows 10
|
||||
add_definitions(-D_WIN32_WINNT=0x0A00 -DWINVER=0x0A00)
|
||||
# WSAPoll and SHGetKnownFolderPath (AppData/Roaming) didn't exist before WinNT 6.x (Vista)
|
||||
add_definitions(-D_WIN32_WINNT=0x0600 -DWINVER=0x0600)
|
||||
set(PLATFORM_LIBRARIES winmm ws2_32 iphlpapi)
|
||||
if (MINGW)
|
||||
# PSAPI is the Process Status API
|
||||
|
|
@ -566,7 +580,11 @@ function(create_target_directory_groups target_name)
|
|||
endfunction()
|
||||
|
||||
# Prevent boost from linking against libs when building
|
||||
target_link_libraries(Boost::headers INTERFACE Boost::disable_autolinking)
|
||||
add_definitions(-DBOOST_ERROR_CODE_HEADER_ONLY
|
||||
-DBOOST_SYSTEM_NO_LIB
|
||||
-DBOOST_DATE_TIME_NO_LIB
|
||||
-DBOOST_REGEX_NO_LIB
|
||||
)
|
||||
# Adjustments for MSVC + Ninja
|
||||
if (MSVC AND CMAKE_GENERATOR STREQUAL "Ninja")
|
||||
add_compile_options(
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
function(copy_yuzu_FFmpeg_deps target_dir)
|
||||
include(WindowsCopyFiles)
|
||||
set(DLL_DEST "$<TARGET_FILE_DIR:${target_dir}>/")
|
||||
set(DLL_DEST "${CMAKE_BINARY_DIR}/bin/$<CONFIG>/")
|
||||
file(READ "${FFmpeg_PATH}/requirements.txt" FFmpeg_REQUIRED_DLLS)
|
||||
string(STRIP "${FFmpeg_REQUIRED_DLLS}" FFmpeg_REQUIRED_DLLS)
|
||||
windows_copy_files(${target_dir} ${FFmpeg_DLL_DIR} ${DLL_DEST} ${FFmpeg_REQUIRED_DLLS})
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
function(copy_yuzu_Qt5_deps target_dir)
|
||||
include(WindowsCopyFiles)
|
||||
if (MSVC)
|
||||
set(DLL_DEST "$<TARGET_FILE_DIR:${target_dir}>/")
|
||||
set(DLL_DEST "${CMAKE_BINARY_DIR}/bin/$<CONFIG>/")
|
||||
set(Qt5_DLL_DIR "${Qt5_DIR}/../../../bin")
|
||||
else()
|
||||
set(DLL_DEST "${CMAKE_BINARY_DIR}/bin/")
|
||||
|
|
|
|||
|
|
@ -3,6 +3,6 @@
|
|||
|
||||
function(copy_yuzu_SDL_deps target_dir)
|
||||
include(WindowsCopyFiles)
|
||||
set(DLL_DEST "$<TARGET_FILE_DIR:${target_dir}>/")
|
||||
set(DLL_DEST "${CMAKE_BINARY_DIR}/bin/$<CONFIG>/")
|
||||
windows_copy_files(${target_dir} ${SDL2_DLL_DIR} ${DLL_DEST} SDL2.dll)
|
||||
endfunction(copy_yuzu_SDL_deps)
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
# FFmpeg_LIBRARIES: aggregate all the paths to the libraries
|
||||
# FFmpeg_FOUND: True if all components have been found
|
||||
#
|
||||
# This module defines the following targets, which are preferred over variables:
|
||||
# This module defines the following targets, which are prefered over variables:
|
||||
#
|
||||
# FFmpeg::<component>: Target to use <component> directly, with include path,
|
||||
# library and dependencies set up. If you are using a static build, you are
|
||||
|
|
|
|||
|
|
@ -2,25 +2,15 @@
|
|||
#
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
find_package(LLVM QUIET COMPONENTS CONFIG)
|
||||
if (LLVM_FOUND)
|
||||
separate_arguments(LLVM_DEFINITIONS)
|
||||
if (LLVMDemangle IN_LIST LLVM_AVAILABLE_LIBS)
|
||||
set(LLVM_Demangle_FOUND TRUE)
|
||||
endif()
|
||||
endif()
|
||||
find_package(LLVM QUIET CONFIG)
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(LLVM HANDLE_COMPONENTS CONFIG_MODE)
|
||||
find_package_handle_standard_args(LLVM CONFIG_MODE)
|
||||
|
||||
if (LLVM_FOUND AND LLVM_Demangle_FOUND AND NOT TARGET LLVM::Demangle)
|
||||
if (LLVM_FOUND AND NOT TARGET LLVM::Demangle)
|
||||
add_library(LLVM::Demangle INTERFACE IMPORTED)
|
||||
llvm_map_components_to_libnames(LLVM_LIBRARIES demangle)
|
||||
target_compile_definitions(LLVM::Demangle INTERFACE ${LLVM_DEFINITIONS})
|
||||
target_include_directories(LLVM::Demangle INTERFACE ${LLVM_INCLUDE_DIRS})
|
||||
# prefer shared LLVM: https://github.com/llvm/llvm-project/issues/34593
|
||||
# but use ugly hack because llvm_config doesn't support interface library
|
||||
add_library(_dummy_lib SHARED EXCLUDE_FROM_ALL src/yuzu/main.cpp)
|
||||
llvm_config(_dummy_lib USE_SHARED demangle)
|
||||
get_target_property(LLVM_LIBRARIES _dummy_lib LINK_LIBRARIES)
|
||||
target_link_libraries(LLVM::Demangle INTERFACE ${LLVM_LIBRARIES})
|
||||
endif()
|
||||
|
|
|
|||
|
|
@ -6,23 +6,13 @@ include(FindPackageHandleStandardArgs)
|
|||
|
||||
find_package(httplib QUIET CONFIG)
|
||||
if (httplib_CONSIDERED_CONFIGS)
|
||||
find_package_handle_standard_args(httplib HANDLE_COMPONENTS CONFIG_MODE)
|
||||
find_package_handle_standard_args(httplib CONFIG_MODE)
|
||||
else()
|
||||
find_package(PkgConfig QUIET)
|
||||
pkg_search_module(HTTPLIB QUIET IMPORTED_TARGET cpp-httplib)
|
||||
if ("-DCPPHTTPLIB_OPENSSL_SUPPORT" IN_LIST HTTPLIB_CFLAGS_OTHER)
|
||||
set(httplib_OpenSSL_FOUND TRUE)
|
||||
endif()
|
||||
if ("-DCPPHTTPLIB_ZLIB_SUPPORT" IN_LIST HTTPLIB_CFLAGS_OTHER)
|
||||
set(httplib_ZLIB_FOUND TRUE)
|
||||
endif()
|
||||
if ("-DCPPHTTPLIB_BROTLI_SUPPORT" IN_LIST HTTPLIB_CFLAGS_OTHER)
|
||||
set(httplib_Brotli_FOUND TRUE)
|
||||
endif()
|
||||
find_package_handle_standard_args(httplib
|
||||
REQUIRED_VARS HTTPLIB_INCLUDEDIR
|
||||
VERSION_VAR HTTPLIB_VERSION
|
||||
HANDLE_COMPONENTS
|
||||
)
|
||||
endif()
|
||||
|
||||
|
|
|
|||
|
|
@ -3,25 +3,14 @@
|
|||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
find_package(PkgConfig QUIET)
|
||||
pkg_search_module(INIH QUIET IMPORTED_TARGET inih)
|
||||
if (INIReader IN_LIST inih_FIND_COMPONENTS)
|
||||
pkg_search_module(INIREADER QUIET IMPORTED_TARGET INIReader)
|
||||
if (INIREADER_FOUND)
|
||||
set(inih_INIReader_FOUND TRUE)
|
||||
endif()
|
||||
endif()
|
||||
pkg_search_module(INIREADER QUIET IMPORTED_TARGET INIReader)
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(inih
|
||||
REQUIRED_VARS INIH_LINK_LIBRARIES
|
||||
VERSION_VAR INIH_VERSION
|
||||
HANDLE_COMPONENTS
|
||||
REQUIRED_VARS INIREADER_LINK_LIBRARIES
|
||||
VERSION_VAR INIREADER_VERSION
|
||||
)
|
||||
|
||||
if (inih_FOUND AND NOT TARGET inih::inih)
|
||||
add_library(inih::inih ALIAS PkgConfig::INIH)
|
||||
endif()
|
||||
|
||||
if (inih_FOUND AND inih_INIReader_FOUND AND NOT TARGET inih::INIReader)
|
||||
if (inih_FOUND AND NOT TARGET inih::INIReader)
|
||||
add_library(inih::INIReader ALIAS PkgConfig::INIREADER)
|
||||
endif()
|
||||
|
|
|
|||
|
|
@ -83,3 +83,5 @@ If you wish to support us a different way, please join our [Discord](https://dis
|
|||
## License
|
||||
|
||||
yuzu is licensed under the GPLv3 (or any later version). Refer to the [LICENSE.txt](https://github.com/yuzu-emu/yuzu/blob/master/LICENSE.txt) file.
|
||||
|
||||
The [Skyline-Emulator Team](https://github.com/skyline-emu/skyline) may choose to use the code from these contributors under the GPL-3.0-or-later OR MPL-2.0: [FernandoS27](https://github.com/FernandoS27), [lioncash](https://github.com/lioncash), [bunnei](https://github.com/bunnei), [ReinUsesLisp](https://github.com/ReinUsesLisp), [Morph1984](https://github.com/Morph1984), [ogniK5377](https://github.com/ogniK5377), [german77](https://github.com/german77), [ameerj](https://github.com/ameerj), [Kelebek1](https://github.com/Kelebek1) and [lat9nq](https://github.com/lat9nq)
|
||||
|
|
|
|||
1913
dist/languages/ca.ts
vendored
1913
dist/languages/ca.ts
vendored
File diff suppressed because it is too large
Load diff
1909
dist/languages/cs.ts
vendored
1909
dist/languages/cs.ts
vendored
File diff suppressed because it is too large
Load diff
1907
dist/languages/da.ts
vendored
1907
dist/languages/da.ts
vendored
File diff suppressed because it is too large
Load diff
2030
dist/languages/de.ts
vendored
2030
dist/languages/de.ts
vendored
File diff suppressed because it is too large
Load diff
1983
dist/languages/el.ts
vendored
1983
dist/languages/el.ts
vendored
File diff suppressed because it is too large
Load diff
2064
dist/languages/es.ts
vendored
2064
dist/languages/es.ts
vendored
File diff suppressed because it is too large
Load diff
1967
dist/languages/fr.ts
vendored
1967
dist/languages/fr.ts
vendored
File diff suppressed because it is too large
Load diff
1905
dist/languages/id.ts
vendored
1905
dist/languages/id.ts
vendored
File diff suppressed because it is too large
Load diff
1959
dist/languages/it.ts
vendored
1959
dist/languages/it.ts
vendored
File diff suppressed because it is too large
Load diff
2113
dist/languages/ja_JP.ts
vendored
2113
dist/languages/ja_JP.ts
vendored
File diff suppressed because it is too large
Load diff
1995
dist/languages/ko_KR.ts
vendored
1995
dist/languages/ko_KR.ts
vendored
File diff suppressed because it is too large
Load diff
2750
dist/languages/nb.ts
vendored
2750
dist/languages/nb.ts
vendored
File diff suppressed because it is too large
Load diff
3943
dist/languages/nl.ts
vendored
3943
dist/languages/nl.ts
vendored
File diff suppressed because it is too large
Load diff
2315
dist/languages/pl.ts
vendored
2315
dist/languages/pl.ts
vendored
File diff suppressed because it is too large
Load diff
2301
dist/languages/pt_BR.ts
vendored
2301
dist/languages/pt_BR.ts
vendored
File diff suppressed because it is too large
Load diff
2305
dist/languages/pt_PT.ts
vendored
2305
dist/languages/pt_PT.ts
vendored
File diff suppressed because it is too large
Load diff
2172
dist/languages/ru_RU.ts
vendored
2172
dist/languages/ru_RU.ts
vendored
File diff suppressed because it is too large
Load diff
1969
dist/languages/sv.ts
vendored
1969
dist/languages/sv.ts
vendored
File diff suppressed because it is too large
Load diff
2179
dist/languages/tr_TR.ts
vendored
2179
dist/languages/tr_TR.ts
vendored
File diff suppressed because it is too large
Load diff
2156
dist/languages/uk.ts
vendored
2156
dist/languages/uk.ts
vendored
File diff suppressed because it is too large
Load diff
2033
dist/languages/vi.ts
vendored
2033
dist/languages/vi.ts
vendored
File diff suppressed because it is too large
Load diff
2033
dist/languages/vi_VN.ts
vendored
2033
dist/languages/vi_VN.ts
vendored
File diff suppressed because it is too large
Load diff
2005
dist/languages/zh_CN.ts
vendored
2005
dist/languages/zh_CN.ts
vendored
File diff suppressed because it is too large
Load diff
1931
dist/languages/zh_TW.ts
vendored
1931
dist/languages/zh_TW.ts
vendored
File diff suppressed because it is too large
Load diff
6
dist/yuzu.manifest
vendored
6
dist/yuzu.manifest
vendored
|
|
@ -36,6 +36,12 @@ SPDX-License-Identifier: GPL-2.0-or-later
|
|||
<application>
|
||||
<!-- Windows 10 -->
|
||||
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>
|
||||
<!-- Windows 8.1 -->
|
||||
<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>
|
||||
<!-- Windows 8 -->
|
||||
<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/>
|
||||
<!-- Windows 7 -->
|
||||
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
|
||||
</application>
|
||||
</compatibility>
|
||||
<trustInfo
|
||||
|
|
|
|||
75
externals/CMakeLists.txt
vendored
75
externals/CMakeLists.txt
vendored
|
|
@ -8,21 +8,15 @@ set(CMAKE_POLICY_DEFAULT_CMP0077 NEW)
|
|||
# Disable tests in all externals supporting the standard option name
|
||||
set(BUILD_TESTING OFF)
|
||||
|
||||
# Build only static externals
|
||||
set(BUILD_SHARED_LIBS OFF)
|
||||
|
||||
# Skip install rules for all externals
|
||||
set_directory_properties(PROPERTIES EXCLUDE_FROM_ALL ON)
|
||||
|
||||
# xbyak
|
||||
if ((ARCHITECTURE_x86 OR ARCHITECTURE_x86_64) AND NOT TARGET xbyak::xbyak)
|
||||
add_subdirectory(xbyak)
|
||||
add_subdirectory(xbyak EXCLUDE_FROM_ALL)
|
||||
endif()
|
||||
|
||||
# Dynarmic
|
||||
if ((ARCHITECTURE_x86_64 OR ARCHITECTURE_arm64) AND NOT TARGET dynarmic::dynarmic)
|
||||
set(DYNARMIC_IGNORE_ASSERTS ON)
|
||||
add_subdirectory(dynarmic)
|
||||
add_subdirectory(dynarmic EXCLUDE_FROM_ALL)
|
||||
add_library(dynarmic::dynarmic ALIAS dynarmic)
|
||||
endif()
|
||||
|
||||
|
|
@ -40,7 +34,7 @@ if (NOT TARGET inih::INIReader)
|
|||
endif()
|
||||
|
||||
# mbedtls
|
||||
add_subdirectory(mbedtls)
|
||||
add_subdirectory(mbedtls EXCLUDE_FROM_ALL)
|
||||
target_include_directories(mbedtls PUBLIC ./mbedtls/include)
|
||||
|
||||
# MicroProfile
|
||||
|
|
@ -54,7 +48,7 @@ endif()
|
|||
|
||||
# libusb
|
||||
if (ENABLE_LIBUSB AND NOT TARGET libusb::usb)
|
||||
add_subdirectory(libusb)
|
||||
add_subdirectory(libusb EXCLUDE_FROM_ALL)
|
||||
endif()
|
||||
|
||||
# SDL2
|
||||
|
|
@ -73,16 +67,18 @@ if (YUZU_USE_EXTERNAL_SDL2)
|
|||
|
||||
set(HIDAPI ON)
|
||||
endif()
|
||||
set(SDL_STATIC ON)
|
||||
set(SDL_SHARED OFF)
|
||||
if (APPLE)
|
||||
set(SDL_FILE ON)
|
||||
endif()
|
||||
|
||||
add_subdirectory(SDL)
|
||||
add_subdirectory(SDL EXCLUDE_FROM_ALL)
|
||||
endif()
|
||||
|
||||
# ENet
|
||||
if (NOT TARGET enet::enet)
|
||||
add_subdirectory(enet)
|
||||
add_subdirectory(enet EXCLUDE_FROM_ALL)
|
||||
target_include_directories(enet INTERFACE ./enet/include)
|
||||
add_library(enet::enet ALIAS enet)
|
||||
endif()
|
||||
|
|
@ -90,39 +86,62 @@ endif()
|
|||
# Cubeb
|
||||
if (ENABLE_CUBEB AND NOT TARGET cubeb::cubeb)
|
||||
set(BUILD_TESTS OFF)
|
||||
set(BUILD_TOOLS OFF)
|
||||
add_subdirectory(cubeb)
|
||||
add_subdirectory(cubeb EXCLUDE_FROM_ALL)
|
||||
add_library(cubeb::cubeb ALIAS cubeb)
|
||||
endif()
|
||||
|
||||
# DiscordRPC
|
||||
if (USE_DISCORD_PRESENCE AND NOT TARGET DiscordRPC::discord-rpc)
|
||||
set(BUILD_EXAMPLES OFF)
|
||||
add_subdirectory(discord-rpc)
|
||||
add_subdirectory(discord-rpc EXCLUDE_FROM_ALL)
|
||||
target_include_directories(discord-rpc INTERFACE ./discord-rpc/include)
|
||||
add_library(DiscordRPC::discord-rpc ALIAS discord-rpc)
|
||||
endif()
|
||||
|
||||
# Sirit
|
||||
add_subdirectory(sirit)
|
||||
add_subdirectory(sirit EXCLUDE_FROM_ALL)
|
||||
|
||||
# httplib
|
||||
if (ENABLE_WEB_SERVICE AND NOT TARGET httplib::httplib)
|
||||
set(HTTPLIB_REQUIRE_OPENSSL ON)
|
||||
add_subdirectory(cpp-httplib)
|
||||
if (NOT WIN32)
|
||||
find_package(OpenSSL 1.1)
|
||||
if (OPENSSL_FOUND)
|
||||
set(OPENSSL_LIBRARIES OpenSSL::SSL OpenSSL::Crypto)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (WIN32 OR NOT OPENSSL_FOUND)
|
||||
# LibreSSL
|
||||
set(LIBRESSL_SKIP_INSTALL ON)
|
||||
set(OPENSSLDIR "/etc/ssl/")
|
||||
add_subdirectory(libressl EXCLUDE_FROM_ALL)
|
||||
target_include_directories(ssl INTERFACE ./libressl/include)
|
||||
target_compile_definitions(ssl PRIVATE -DHAVE_INET_NTOP)
|
||||
get_directory_property(OPENSSL_LIBRARIES
|
||||
DIRECTORY libressl
|
||||
DEFINITION OPENSSL_LIBS)
|
||||
endif()
|
||||
|
||||
add_library(httplib INTERFACE)
|
||||
target_include_directories(httplib INTERFACE ./cpp-httplib)
|
||||
target_compile_definitions(httplib INTERFACE -DCPPHTTPLIB_OPENSSL_SUPPORT)
|
||||
target_link_libraries(httplib INTERFACE ${OPENSSL_LIBRARIES})
|
||||
if (WIN32)
|
||||
target_link_libraries(httplib INTERFACE crypt32 cryptui ws2_32)
|
||||
endif()
|
||||
add_library(httplib::httplib ALIAS httplib)
|
||||
endif()
|
||||
|
||||
# cpp-jwt
|
||||
if (ENABLE_WEB_SERVICE AND NOT TARGET cpp-jwt::cpp-jwt)
|
||||
set(CPP_JWT_BUILD_EXAMPLES OFF)
|
||||
set(CPP_JWT_BUILD_TESTS OFF)
|
||||
set(CPP_JWT_USE_VENDORED_NLOHMANN_JSON OFF)
|
||||
add_subdirectory(cpp-jwt)
|
||||
add_library(cpp-jwt INTERFACE)
|
||||
target_include_directories(cpp-jwt INTERFACE ./cpp-jwt/include)
|
||||
target_compile_definitions(cpp-jwt INTERFACE CPP_JWT_USE_VENDORED_NLOHMANN_JSON)
|
||||
add_library(cpp-jwt::cpp-jwt ALIAS cpp-jwt)
|
||||
endif()
|
||||
|
||||
# Opus
|
||||
if (NOT TARGET Opus::opus)
|
||||
add_subdirectory(opus)
|
||||
add_subdirectory(opus EXCLUDE_FROM_ALL)
|
||||
endif()
|
||||
|
||||
# FFMpeg
|
||||
|
|
@ -136,14 +155,12 @@ endif()
|
|||
|
||||
# Vulkan-Headers
|
||||
if (YUZU_USE_EXTERNAL_VULKAN_HEADERS)
|
||||
add_subdirectory(Vulkan-Headers)
|
||||
add_subdirectory(Vulkan-Headers EXCLUDE_FROM_ALL)
|
||||
endif()
|
||||
|
||||
if (NOT TARGET LLVM::Demangle)
|
||||
add_library(demangle demangle/ItaniumDemangle.cpp)
|
||||
add_library(demangle STATIC)
|
||||
target_include_directories(demangle PUBLIC ./demangle)
|
||||
target_sources(demangle PRIVATE demangle/ItaniumDemangle.cpp)
|
||||
add_library(LLVM::Demangle ALIAS demangle)
|
||||
endif()
|
||||
|
||||
add_library(stb stb/stb_dxt.cpp)
|
||||
target_include_directories(stb PUBLIC ./stb)
|
||||
|
|
|
|||
2
externals/Vulkan-Headers
vendored
2
externals/Vulkan-Headers
vendored
|
|
@ -1 +1 @@
|
|||
Subproject commit 63af1cf1ee906ba4dcd5a324bdd0201d4f4bfd12
|
||||
Subproject commit 00671c64ba5c488ade22ad572a0ef81d5e64c803
|
||||
2
externals/cpp-httplib
vendored
2
externals/cpp-httplib
vendored
|
|
@ -1 +1 @@
|
|||
Subproject commit 6d963fbe8d415399d65e94db7910bbd22fe3741c
|
||||
Subproject commit 305a7abcb9b4e9e349843c6d563212e6c1bbbf21
|
||||
2
externals/cubeb
vendored
2
externals/cubeb
vendored
|
|
@ -1 +1 @@
|
|||
Subproject commit 48689ae7a73caeb747953f9ed664dc71d2f918d8
|
||||
Subproject commit 75d9d125ee655ef80f3bfcd97ae5a805931042b8
|
||||
2
externals/dynarmic
vendored
2
externals/dynarmic
vendored
|
|
@ -1 +1 @@
|
|||
Subproject commit 7da378033a7764f955516f75194856d87bbcd7a5
|
||||
Subproject commit befe547d5631024a70d81d2ccee808bbfcb3854e
|
||||
5
externals/ffmpeg/CMakeLists.txt
vendored
5
externals/ffmpeg/CMakeLists.txt
vendored
|
|
@ -131,6 +131,7 @@ if (NOT WIN32)
|
|||
COMMAND
|
||||
/bin/bash ${FFmpeg_PREFIX}/configure
|
||||
--disable-avdevice
|
||||
--disable-avfilter
|
||||
--disable-avformat
|
||||
--disable-doc
|
||||
--disable-everything
|
||||
|
|
@ -142,7 +143,6 @@ if (NOT WIN32)
|
|||
--enable-decoder=h264
|
||||
--enable-decoder=vp8
|
||||
--enable-decoder=vp9
|
||||
--enable-filter=yadif
|
||||
--cc="${FFmpeg_CC}"
|
||||
--cxx="${FFmpeg_CXX}"
|
||||
${FFmpeg_HWACCEL_FLAGS}
|
||||
|
|
@ -199,7 +199,7 @@ if (NOT WIN32)
|
|||
endif()
|
||||
else(WIN32)
|
||||
# Use yuzu FFmpeg binaries
|
||||
set(FFmpeg_EXT_NAME "ffmpeg-5.1.3")
|
||||
set(FFmpeg_EXT_NAME "ffmpeg-4.4")
|
||||
set(FFmpeg_PATH "${CMAKE_BINARY_DIR}/externals/${FFmpeg_EXT_NAME}")
|
||||
download_bundled_external("ffmpeg/" ${FFmpeg_EXT_NAME} "")
|
||||
set(FFmpeg_FOUND YES)
|
||||
|
|
@ -210,7 +210,6 @@ else(WIN32)
|
|||
set(FFmpeg_LIBRARIES
|
||||
${FFmpeg_LIBRARY_DIR}/swscale.lib
|
||||
${FFmpeg_LIBRARY_DIR}/avcodec.lib
|
||||
${FFmpeg_LIBRARY_DIR}/avfilter.lib
|
||||
${FFmpeg_LIBRARY_DIR}/avutil.lib
|
||||
CACHE PATH "Paths to FFmpeg libraries" FORCE)
|
||||
# exported variables
|
||||
|
|
|
|||
2
externals/glad/CMakeLists.txt
vendored
2
externals/glad/CMakeLists.txt
vendored
|
|
@ -1,7 +1,7 @@
|
|||
# SPDX-FileCopyrightText: 2015 Yuri Kunde Schlesner <yuriks@yuriks.net>
|
||||
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
add_library(glad
|
||||
add_library(glad STATIC
|
||||
src/glad.c
|
||||
include/KHR/khrplatform.h
|
||||
include/glad/glad.h
|
||||
|
|
|
|||
1
externals/libressl
vendored
Submodule
1
externals/libressl
vendored
Submodule
|
|
@ -0,0 +1 @@
|
|||
Subproject commit 8929f818fd748fd31a34fec7c04558399e13014a
|
||||
2
externals/libusb/CMakeLists.txt
vendored
2
externals/libusb/CMakeLists.txt
vendored
|
|
@ -122,7 +122,7 @@ else() # MINGW OR (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
|||
add_compile_options(/utf-8)
|
||||
endif()
|
||||
|
||||
add_library(usb
|
||||
add_library(usb STATIC EXCLUDE_FROM_ALL
|
||||
libusb/libusb/core.c
|
||||
libusb/libusb/core.c
|
||||
libusb/libusb/descriptor.c
|
||||
|
|
|
|||
8
externals/microprofile/microprofile.h
vendored
8
externals/microprofile/microprofile.h
vendored
|
|
@ -1697,13 +1697,7 @@ void MicroProfileFlip()
|
|||
{
|
||||
int nTimer = MicroProfileLogTimerIndex(LE);
|
||||
uint8_t nGroup = pTimerToGroup[nTimer];
|
||||
|
||||
// To avoid crashing due to OOB memory accesses/asserts
|
||||
// simply skip this iteration
|
||||
// MP_ASSERT(nStackPos < MICROPROFILE_STACK_MAX);
|
||||
if (nStackPos >= MICROPROFILE_STACK_MAX) {
|
||||
break;
|
||||
}
|
||||
MP_ASSERT(nStackPos < MICROPROFILE_STACK_MAX);
|
||||
MP_ASSERT(nGroup < MICROPROFILE_MAX_GROUPS);
|
||||
pGroupStackPos[nGroup]++;
|
||||
pStack[nStackPos++] = k;
|
||||
|
|
|
|||
2
externals/opus/CMakeLists.txt
vendored
2
externals/opus/CMakeLists.txt
vendored
|
|
@ -23,7 +23,7 @@ else()
|
|||
endif()
|
||||
endif()
|
||||
|
||||
add_library(opus
|
||||
add_library(opus STATIC
|
||||
# CELT sources
|
||||
opus/celt/bands.c
|
||||
opus/celt/celt.c
|
||||
|
|
|
|||
765
externals/stb/stb_dxt.cpp
vendored
765
externals/stb/stb_dxt.cpp
vendored
|
|
@ -1,765 +0,0 @@
|
|||
// SPDX-FileCopyrightText: fabian "ryg" giesen
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
// stb_dxt.h - v1.12 - DXT1/DXT5 compressor
|
||||
|
||||
#include <stb_dxt.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#if !defined(STBD_FABS)
|
||||
#include <math.h>
|
||||
#endif
|
||||
|
||||
#ifndef STBD_FABS
|
||||
#define STBD_FABS(x) fabs(x)
|
||||
#endif
|
||||
|
||||
static const unsigned char stb__OMatch5[256][2] = {
|
||||
{0, 0}, {0, 0}, {0, 1}, {0, 1}, {1, 0}, {1, 0}, {1, 0}, {1, 1}, {1, 1},
|
||||
{1, 1}, {1, 2}, {0, 4}, {2, 1}, {2, 1}, {2, 1}, {2, 2}, {2, 2}, {2, 2},
|
||||
{2, 3}, {1, 5}, {3, 2}, {3, 2}, {4, 0}, {3, 3}, {3, 3}, {3, 3}, {3, 4},
|
||||
{3, 4}, {3, 4}, {3, 5}, {4, 3}, {4, 3}, {5, 2}, {4, 4}, {4, 4}, {4, 5},
|
||||
{4, 5}, {5, 4}, {5, 4}, {5, 4}, {6, 3}, {5, 5}, {5, 5}, {5, 6}, {4, 8},
|
||||
{6, 5}, {6, 5}, {6, 5}, {6, 6}, {6, 6}, {6, 6}, {6, 7}, {5, 9}, {7, 6},
|
||||
{7, 6}, {8, 4}, {7, 7}, {7, 7}, {7, 7}, {7, 8}, {7, 8}, {7, 8}, {7, 9},
|
||||
{8, 7}, {8, 7}, {9, 6}, {8, 8}, {8, 8}, {8, 9}, {8, 9}, {9, 8}, {9, 8},
|
||||
{9, 8}, {10, 7}, {9, 9}, {9, 9}, {9, 10}, {8, 12}, {10, 9}, {10, 9}, {10, 9},
|
||||
{10, 10}, {10, 10}, {10, 10}, {10, 11}, {9, 13}, {11, 10}, {11, 10}, {12, 8}, {11, 11},
|
||||
{11, 11}, {11, 11}, {11, 12}, {11, 12}, {11, 12}, {11, 13}, {12, 11}, {12, 11}, {13, 10},
|
||||
{12, 12}, {12, 12}, {12, 13}, {12, 13}, {13, 12}, {13, 12}, {13, 12}, {14, 11}, {13, 13},
|
||||
{13, 13}, {13, 14}, {12, 16}, {14, 13}, {14, 13}, {14, 13}, {14, 14}, {14, 14}, {14, 14},
|
||||
{14, 15}, {13, 17}, {15, 14}, {15, 14}, {16, 12}, {15, 15}, {15, 15}, {15, 15}, {15, 16},
|
||||
{15, 16}, {15, 16}, {15, 17}, {16, 15}, {16, 15}, {17, 14}, {16, 16}, {16, 16}, {16, 17},
|
||||
{16, 17}, {17, 16}, {17, 16}, {17, 16}, {18, 15}, {17, 17}, {17, 17}, {17, 18}, {16, 20},
|
||||
{18, 17}, {18, 17}, {18, 17}, {18, 18}, {18, 18}, {18, 18}, {18, 19}, {17, 21}, {19, 18},
|
||||
{19, 18}, {20, 16}, {19, 19}, {19, 19}, {19, 19}, {19, 20}, {19, 20}, {19, 20}, {19, 21},
|
||||
{20, 19}, {20, 19}, {21, 18}, {20, 20}, {20, 20}, {20, 21}, {20, 21}, {21, 20}, {21, 20},
|
||||
{21, 20}, {22, 19}, {21, 21}, {21, 21}, {21, 22}, {20, 24}, {22, 21}, {22, 21}, {22, 21},
|
||||
{22, 22}, {22, 22}, {22, 22}, {22, 23}, {21, 25}, {23, 22}, {23, 22}, {24, 20}, {23, 23},
|
||||
{23, 23}, {23, 23}, {23, 24}, {23, 24}, {23, 24}, {23, 25}, {24, 23}, {24, 23}, {25, 22},
|
||||
{24, 24}, {24, 24}, {24, 25}, {24, 25}, {25, 24}, {25, 24}, {25, 24}, {26, 23}, {25, 25},
|
||||
{25, 25}, {25, 26}, {24, 28}, {26, 25}, {26, 25}, {26, 25}, {26, 26}, {26, 26}, {26, 26},
|
||||
{26, 27}, {25, 29}, {27, 26}, {27, 26}, {28, 24}, {27, 27}, {27, 27}, {27, 27}, {27, 28},
|
||||
{27, 28}, {27, 28}, {27, 29}, {28, 27}, {28, 27}, {29, 26}, {28, 28}, {28, 28}, {28, 29},
|
||||
{28, 29}, {29, 28}, {29, 28}, {29, 28}, {30, 27}, {29, 29}, {29, 29}, {29, 30}, {29, 30},
|
||||
{30, 29}, {30, 29}, {30, 29}, {30, 30}, {30, 30}, {30, 30}, {30, 31}, {30, 31}, {31, 30},
|
||||
{31, 30}, {31, 30}, {31, 31}, {31, 31},
|
||||
};
|
||||
static const unsigned char stb__OMatch6[256][2] = {
|
||||
{0, 0}, {0, 1}, {1, 0}, {1, 1}, {1, 1}, {1, 2}, {2, 1}, {2, 2}, {2, 2},
|
||||
{2, 3}, {3, 2}, {3, 3}, {3, 3}, {3, 4}, {4, 3}, {4, 4}, {4, 4}, {4, 5},
|
||||
{5, 4}, {5, 5}, {5, 5}, {5, 6}, {6, 5}, {6, 6}, {6, 6}, {6, 7}, {7, 6},
|
||||
{7, 7}, {7, 7}, {7, 8}, {8, 7}, {8, 8}, {8, 8}, {8, 9}, {9, 8}, {9, 9},
|
||||
{9, 9}, {9, 10}, {10, 9}, {10, 10}, {10, 10}, {10, 11}, {11, 10}, {8, 16}, {11, 11},
|
||||
{11, 12}, {12, 11}, {9, 17}, {12, 12}, {12, 13}, {13, 12}, {11, 16}, {13, 13}, {13, 14},
|
||||
{14, 13}, {12, 17}, {14, 14}, {14, 15}, {15, 14}, {14, 16}, {15, 15}, {15, 16}, {16, 14},
|
||||
{16, 15}, {17, 14}, {16, 16}, {16, 17}, {17, 16}, {18, 15}, {17, 17}, {17, 18}, {18, 17},
|
||||
{20, 14}, {18, 18}, {18, 19}, {19, 18}, {21, 15}, {19, 19}, {19, 20}, {20, 19}, {20, 20},
|
||||
{20, 20}, {20, 21}, {21, 20}, {21, 21}, {21, 21}, {21, 22}, {22, 21}, {22, 22}, {22, 22},
|
||||
{22, 23}, {23, 22}, {23, 23}, {23, 23}, {23, 24}, {24, 23}, {24, 24}, {24, 24}, {24, 25},
|
||||
{25, 24}, {25, 25}, {25, 25}, {25, 26}, {26, 25}, {26, 26}, {26, 26}, {26, 27}, {27, 26},
|
||||
{24, 32}, {27, 27}, {27, 28}, {28, 27}, {25, 33}, {28, 28}, {28, 29}, {29, 28}, {27, 32},
|
||||
{29, 29}, {29, 30}, {30, 29}, {28, 33}, {30, 30}, {30, 31}, {31, 30}, {30, 32}, {31, 31},
|
||||
{31, 32}, {32, 30}, {32, 31}, {33, 30}, {32, 32}, {32, 33}, {33, 32}, {34, 31}, {33, 33},
|
||||
{33, 34}, {34, 33}, {36, 30}, {34, 34}, {34, 35}, {35, 34}, {37, 31}, {35, 35}, {35, 36},
|
||||
{36, 35}, {36, 36}, {36, 36}, {36, 37}, {37, 36}, {37, 37}, {37, 37}, {37, 38}, {38, 37},
|
||||
{38, 38}, {38, 38}, {38, 39}, {39, 38}, {39, 39}, {39, 39}, {39, 40}, {40, 39}, {40, 40},
|
||||
{40, 40}, {40, 41}, {41, 40}, {41, 41}, {41, 41}, {41, 42}, {42, 41}, {42, 42}, {42, 42},
|
||||
{42, 43}, {43, 42}, {40, 48}, {43, 43}, {43, 44}, {44, 43}, {41, 49}, {44, 44}, {44, 45},
|
||||
{45, 44}, {43, 48}, {45, 45}, {45, 46}, {46, 45}, {44, 49}, {46, 46}, {46, 47}, {47, 46},
|
||||
{46, 48}, {47, 47}, {47, 48}, {48, 46}, {48, 47}, {49, 46}, {48, 48}, {48, 49}, {49, 48},
|
||||
{50, 47}, {49, 49}, {49, 50}, {50, 49}, {52, 46}, {50, 50}, {50, 51}, {51, 50}, {53, 47},
|
||||
{51, 51}, {51, 52}, {52, 51}, {52, 52}, {52, 52}, {52, 53}, {53, 52}, {53, 53}, {53, 53},
|
||||
{53, 54}, {54, 53}, {54, 54}, {54, 54}, {54, 55}, {55, 54}, {55, 55}, {55, 55}, {55, 56},
|
||||
{56, 55}, {56, 56}, {56, 56}, {56, 57}, {57, 56}, {57, 57}, {57, 57}, {57, 58}, {58, 57},
|
||||
{58, 58}, {58, 58}, {58, 59}, {59, 58}, {59, 59}, {59, 59}, {59, 60}, {60, 59}, {60, 60},
|
||||
{60, 60}, {60, 61}, {61, 60}, {61, 61}, {61, 61}, {61, 62}, {62, 61}, {62, 62}, {62, 62},
|
||||
{62, 63}, {63, 62}, {63, 63}, {63, 63},
|
||||
};
|
||||
|
||||
static int stb__Mul8Bit(int a, int b) {
|
||||
int t = a * b + 128;
|
||||
return (t + (t >> 8)) >> 8;
|
||||
}
|
||||
|
||||
static void stb__From16Bit(unsigned char* out, unsigned short v) {
|
||||
int rv = (v & 0xf800) >> 11;
|
||||
int gv = (v & 0x07e0) >> 5;
|
||||
int bv = (v & 0x001f) >> 0;
|
||||
|
||||
// expand to 8 bits via bit replication
|
||||
out[0] = static_cast<unsigned char>((rv * 33) >> 2);
|
||||
out[1] = static_cast<unsigned char>((gv * 65) >> 4);
|
||||
out[2] = static_cast<unsigned char>((bv * 33) >> 2);
|
||||
out[3] = 0;
|
||||
}
|
||||
|
||||
static unsigned short stb__As16Bit(int r, int g, int b) {
|
||||
return (unsigned short)((stb__Mul8Bit(r, 31) << 11) + (stb__Mul8Bit(g, 63) << 5) +
|
||||
stb__Mul8Bit(b, 31));
|
||||
}
|
||||
|
||||
// linear interpolation at 1/3 point between a and b, using desired rounding
|
||||
// type
|
||||
static int stb__Lerp13(int a, int b) {
|
||||
#ifdef STB_DXT_USE_ROUNDING_BIAS
|
||||
// with rounding bias
|
||||
return a + stb__Mul8Bit(b - a, 0x55);
|
||||
#else
|
||||
// without rounding bias
|
||||
// replace "/ 3" by "* 0xaaab) >> 17" if your compiler sucks or you really
|
||||
// need every ounce of speed.
|
||||
return (2 * a + b) / 3;
|
||||
#endif
|
||||
}
|
||||
|
||||
// linear interpolation at 1/2 point between a and b
|
||||
static int stb__Lerp12(int a, int b) {
|
||||
return (a + b) / 2;
|
||||
}
|
||||
|
||||
// lerp RGB color
|
||||
static void stb__Lerp13RGB(unsigned char* out, unsigned char* p1, unsigned char* p2) {
|
||||
out[0] = (unsigned char)stb__Lerp13(p1[0], p2[0]);
|
||||
out[1] = (unsigned char)stb__Lerp13(p1[1], p2[1]);
|
||||
out[2] = (unsigned char)stb__Lerp13(p1[2], p2[2]);
|
||||
}
|
||||
|
||||
static void stb__Lerp12RGB(unsigned char* out, unsigned char* p1, unsigned char* p2) {
|
||||
out[0] = (unsigned char)stb__Lerp12(p1[0], p2[0]);
|
||||
out[1] = (unsigned char)stb__Lerp12(p1[1], p2[1]);
|
||||
out[2] = (unsigned char)stb__Lerp12(p1[2], p2[2]);
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
static void stb__Eval4Colors(unsigned char* color, unsigned short c0, unsigned short c1) {
|
||||
stb__From16Bit(color + 0, c0);
|
||||
stb__From16Bit(color + 4, c1);
|
||||
stb__Lerp13RGB(color + 8, color + 0, color + 4);
|
||||
stb__Lerp13RGB(color + 12, color + 4, color + 0);
|
||||
}
|
||||
|
||||
static void stb__Eval3Colors(unsigned char* color, unsigned short c0, unsigned short c1) {
|
||||
stb__From16Bit(color + 0, c0);
|
||||
stb__From16Bit(color + 4, c1);
|
||||
stb__Lerp12RGB(color + 8, color + 0, color + 4);
|
||||
}
|
||||
|
||||
// The color matching function
|
||||
static unsigned int stb__MatchColorsBlock(unsigned char* block, unsigned char* color) {
|
||||
unsigned int mask = 0;
|
||||
int dirr = color[0 * 4 + 0] - color[1 * 4 + 0];
|
||||
int dirg = color[0 * 4 + 1] - color[1 * 4 + 1];
|
||||
int dirb = color[0 * 4 + 2] - color[1 * 4 + 2];
|
||||
int dots[16];
|
||||
int stops[4];
|
||||
int i;
|
||||
int c0Point, halfPoint, c3Point;
|
||||
|
||||
for (i = 0; i < 16; i++)
|
||||
dots[i] = block[i * 4 + 0] * dirr + block[i * 4 + 1] * dirg + block[i * 4 + 2] * dirb;
|
||||
|
||||
for (i = 0; i < 4; i++)
|
||||
stops[i] = color[i * 4 + 0] * dirr + color[i * 4 + 1] * dirg + color[i * 4 + 2] * dirb;
|
||||
|
||||
// think of the colors as arranged on a line; project point onto that line,
|
||||
// then choose next color out of available ones. we compute the crossover
|
||||
// points for "best color in top half"/"best in bottom half" and then the same
|
||||
// inside that subinterval.
|
||||
//
|
||||
// relying on this 1d approximation isn't always optimal in terms of euclidean
|
||||
// distance, but it's very close and a lot faster.
|
||||
// http://cbloomrants.blogspot.com/2008/12/12-08-08-dxtc-summary.html
|
||||
|
||||
c0Point = (stops[1] + stops[3]);
|
||||
halfPoint = (stops[3] + stops[2]);
|
||||
c3Point = (stops[2] + stops[0]);
|
||||
|
||||
for (i = 15; i >= 0; i--) {
|
||||
int dot = dots[i] * 2;
|
||||
mask <<= 2;
|
||||
|
||||
if (dot < halfPoint)
|
||||
mask |= (dot < c0Point) ? 1 : 3;
|
||||
else
|
||||
mask |= (dot < c3Point) ? 2 : 0;
|
||||
}
|
||||
|
||||
return mask;
|
||||
}
|
||||
|
||||
static unsigned int stb__MatchColorsAlphaBlock(unsigned char* block, unsigned char* color) {
|
||||
unsigned int mask = 0;
|
||||
int dirr = color[0 * 4 + 0] - color[1 * 4 + 0];
|
||||
int dirg = color[0 * 4 + 1] - color[1 * 4 + 1];
|
||||
int dirb = color[0 * 4 + 2] - color[1 * 4 + 2];
|
||||
int dots[16];
|
||||
int stops[3];
|
||||
int i;
|
||||
int c0Point, c2Point;
|
||||
|
||||
for (i = 0; i < 16; i++)
|
||||
dots[i] = block[i * 4 + 0] * dirr + block[i * 4 + 1] * dirg + block[i * 4 + 2] * dirb;
|
||||
|
||||
for (i = 0; i < 3; i++)
|
||||
stops[i] = color[i * 4 + 0] * dirr + color[i * 4 + 1] * dirg + color[i * 4 + 2] * dirb;
|
||||
|
||||
c0Point = (stops[1] + stops[2]);
|
||||
c2Point = (stops[2] + stops[0]);
|
||||
|
||||
for (i = 15; i >= 0; i--) {
|
||||
int dot = dots[i] * 2;
|
||||
mask <<= 2;
|
||||
|
||||
if (block[i * 4 + 3] == 0)
|
||||
mask |= 3;
|
||||
else if (dot < c2Point)
|
||||
mask |= (dot < c0Point) ? 0 : 2;
|
||||
else
|
||||
mask |= (dot < c0Point) ? 1 : 0;
|
||||
}
|
||||
|
||||
return mask;
|
||||
}
|
||||
|
||||
static void stb__ReorderColors(unsigned short* pmax16, unsigned short* pmin16) {
|
||||
if (*pmin16 < *pmax16) {
|
||||
unsigned short t = *pmin16;
|
||||
*pmin16 = *pmax16;
|
||||
*pmax16 = t;
|
||||
}
|
||||
}
|
||||
|
||||
static void stb__FinalizeColors(unsigned short* pmax16, unsigned short* pmin16,
|
||||
unsigned int* pmask) {
|
||||
if (*pmax16 < *pmin16) {
|
||||
unsigned short t = *pmin16;
|
||||
*pmin16 = *pmax16;
|
||||
*pmax16 = t;
|
||||
*pmask ^= 0x55555555;
|
||||
}
|
||||
}
|
||||
|
||||
// The color optimization function. (Clever code, part 1)
|
||||
static void stb__OptimizeColorsBlock(unsigned char* block, unsigned short* pmax16,
|
||||
unsigned short* pmin16) {
|
||||
int mind, maxd;
|
||||
unsigned char *minp, *maxp;
|
||||
double magn;
|
||||
int v_r, v_g, v_b;
|
||||
static const int nIterPower = 4;
|
||||
float covf[6], vfr, vfg, vfb;
|
||||
|
||||
// determine color distribution
|
||||
int cov[6];
|
||||
int mu[3], min[3], max[3];
|
||||
int ch, i, iter;
|
||||
|
||||
for (ch = 0; ch < 3; ch++) {
|
||||
const unsigned char* bp = ((const unsigned char*)block) + ch;
|
||||
int muv, minv, maxv;
|
||||
|
||||
muv = minv = maxv = bp[0];
|
||||
for (i = 4; i < 64; i += 4) {
|
||||
muv += bp[i];
|
||||
if (bp[i] < minv)
|
||||
minv = bp[i];
|
||||
else if (bp[i] > maxv)
|
||||
maxv = bp[i];
|
||||
}
|
||||
|
||||
mu[ch] = (muv + 8) >> 4;
|
||||
min[ch] = minv;
|
||||
max[ch] = maxv;
|
||||
}
|
||||
|
||||
// determine covariance matrix
|
||||
for (i = 0; i < 6; i++)
|
||||
cov[i] = 0;
|
||||
|
||||
for (i = 0; i < 16; i++) {
|
||||
int r = block[i * 4 + 0] - mu[0];
|
||||
int g = block[i * 4 + 1] - mu[1];
|
||||
int b = block[i * 4 + 2] - mu[2];
|
||||
|
||||
cov[0] += r * r;
|
||||
cov[1] += r * g;
|
||||
cov[2] += r * b;
|
||||
cov[3] += g * g;
|
||||
cov[4] += g * b;
|
||||
cov[5] += b * b;
|
||||
}
|
||||
|
||||
// convert covariance matrix to float, find principal axis via power iter
|
||||
for (i = 0; i < 6; i++)
|
||||
covf[i] = static_cast<float>(cov[i]) / 255.0f;
|
||||
|
||||
vfr = (float)(max[0] - min[0]);
|
||||
vfg = (float)(max[1] - min[1]);
|
||||
vfb = (float)(max[2] - min[2]);
|
||||
|
||||
for (iter = 0; iter < nIterPower; iter++) {
|
||||
float r = vfr * covf[0] + vfg * covf[1] + vfb * covf[2];
|
||||
float g = vfr * covf[1] + vfg * covf[3] + vfb * covf[4];
|
||||
float b = vfr * covf[2] + vfg * covf[4] + vfb * covf[5];
|
||||
|
||||
vfr = r;
|
||||
vfg = g;
|
||||
vfb = b;
|
||||
}
|
||||
|
||||
magn = STBD_FABS(vfr);
|
||||
if (STBD_FABS(vfg) > magn)
|
||||
magn = STBD_FABS(vfg);
|
||||
if (STBD_FABS(vfb) > magn)
|
||||
magn = STBD_FABS(vfb);
|
||||
|
||||
if (magn < 4.0f) { // too small, default to luminance
|
||||
v_r = 299; // JPEG YCbCr luma coefs, scaled by 1000.
|
||||
v_g = 587;
|
||||
v_b = 114;
|
||||
} else {
|
||||
magn = 512.0 / magn;
|
||||
v_r = (int)(vfr * magn);
|
||||
v_g = (int)(vfg * magn);
|
||||
v_b = (int)(vfb * magn);
|
||||
}
|
||||
|
||||
minp = maxp = block;
|
||||
mind = maxd = block[0] * v_r + block[1] * v_g + block[2] * v_b;
|
||||
// Pick colors at extreme points
|
||||
for (i = 1; i < 16; i++) {
|
||||
int dot = block[i * 4 + 0] * v_r + block[i * 4 + 1] * v_g + block[i * 4 + 2] * v_b;
|
||||
|
||||
if (dot < mind) {
|
||||
mind = dot;
|
||||
minp = block + i * 4;
|
||||
}
|
||||
|
||||
if (dot > maxd) {
|
||||
maxd = dot;
|
||||
maxp = block + i * 4;
|
||||
}
|
||||
}
|
||||
|
||||
*pmax16 = stb__As16Bit(maxp[0], maxp[1], maxp[2]);
|
||||
*pmin16 = stb__As16Bit(minp[0], minp[1], minp[2]);
|
||||
stb__ReorderColors(pmax16, pmin16);
|
||||
}
|
||||
|
||||
static void stb__OptimizeColorsAlphaBlock(unsigned char* block, unsigned short* pmax16,
|
||||
unsigned short* pmin16) {
|
||||
int mind, maxd;
|
||||
unsigned char *minp, *maxp;
|
||||
double magn;
|
||||
int v_r, v_g, v_b;
|
||||
static const int nIterPower = 4;
|
||||
float covf[6], vfr, vfg, vfb;
|
||||
|
||||
// determine color distribution
|
||||
int cov[6];
|
||||
int mu[3], min[3], max[3];
|
||||
int ch, i, iter;
|
||||
|
||||
for (ch = 0; ch < 3; ch++) {
|
||||
const unsigned char* bp = ((const unsigned char*)block) + ch;
|
||||
int muv = 0, minv = 256, maxv = -1;
|
||||
int num = 0;
|
||||
|
||||
for (i = 0; i < 64; i += 4) {
|
||||
if (bp[3 - ch] == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
muv += bp[i];
|
||||
if (bp[i] < minv)
|
||||
minv = bp[i];
|
||||
else if (bp[i] > maxv)
|
||||
maxv = bp[i];
|
||||
|
||||
num++;
|
||||
}
|
||||
|
||||
mu[ch] = num > 0 ? (muv + 8) / num : 0;
|
||||
min[ch] = minv;
|
||||
max[ch] = maxv;
|
||||
}
|
||||
|
||||
// determine covariance matrix
|
||||
for (i = 0; i < 6; i++)
|
||||
cov[i] = 0;
|
||||
|
||||
for (i = 0; i < 16; i++) {
|
||||
if (block[i * 4 + 3] == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
int r = block[i * 4 + 0] - mu[0];
|
||||
int g = block[i * 4 + 1] - mu[1];
|
||||
int b = block[i * 4 + 2] - mu[2];
|
||||
|
||||
cov[0] += r * r;
|
||||
cov[1] += r * g;
|
||||
cov[2] += r * b;
|
||||
cov[3] += g * g;
|
||||
cov[4] += g * b;
|
||||
cov[5] += b * b;
|
||||
}
|
||||
|
||||
// convert covariance matrix to float, find principal axis via power iter
|
||||
for (i = 0; i < 6; i++)
|
||||
covf[i] = static_cast<float>(cov[i]) / 255.0f;
|
||||
|
||||
vfr = (float)(max[0] - min[0]);
|
||||
vfg = (float)(max[1] - min[1]);
|
||||
vfb = (float)(max[2] - min[2]);
|
||||
|
||||
for (iter = 0; iter < nIterPower; iter++) {
|
||||
float r = vfr * covf[0] + vfg * covf[1] + vfb * covf[2];
|
||||
float g = vfr * covf[1] + vfg * covf[3] + vfb * covf[4];
|
||||
float b = vfr * covf[2] + vfg * covf[4] + vfb * covf[5];
|
||||
|
||||
vfr = r;
|
||||
vfg = g;
|
||||
vfb = b;
|
||||
}
|
||||
|
||||
magn = STBD_FABS(vfr);
|
||||
if (STBD_FABS(vfg) > magn)
|
||||
magn = STBD_FABS(vfg);
|
||||
if (STBD_FABS(vfb) > magn)
|
||||
magn = STBD_FABS(vfb);
|
||||
|
||||
if (magn < 4.0f) { // too small, default to luminance
|
||||
v_r = 299; // JPEG YCbCr luma coefs, scaled by 1000.
|
||||
v_g = 587;
|
||||
v_b = 114;
|
||||
} else {
|
||||
magn = 512.0 / magn;
|
||||
v_r = (int)(vfr * magn);
|
||||
v_g = (int)(vfg * magn);
|
||||
v_b = (int)(vfb * magn);
|
||||
}
|
||||
|
||||
minp = maxp = NULL;
|
||||
mind = 0x7fffffff;
|
||||
maxd = -0x80000000;
|
||||
|
||||
// Pick colors at extreme points
|
||||
for (i = 0; i < 16; i++) {
|
||||
if (block[i * 4 + 3] == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
int dot = block[i * 4 + 0] * v_r + block[i * 4 + 1] * v_g + block[i * 4 + 2] * v_b;
|
||||
|
||||
if (dot < mind) {
|
||||
mind = dot;
|
||||
minp = block + i * 4;
|
||||
}
|
||||
|
||||
if (dot > maxd) {
|
||||
maxd = dot;
|
||||
maxp = block + i * 4;
|
||||
}
|
||||
}
|
||||
|
||||
if (!maxp) {
|
||||
// all alpha, no color
|
||||
*pmin16 = 0xffff;
|
||||
*pmax16 = 0;
|
||||
} else {
|
||||
// endpoint colors found
|
||||
*pmax16 = stb__As16Bit(maxp[0], maxp[1], maxp[2]);
|
||||
*pmin16 = stb__As16Bit(minp[0], minp[1], minp[2]);
|
||||
|
||||
if (*pmax16 == *pmin16) {
|
||||
// modify the endpoints to indicate presence of an alpha block
|
||||
if (*pmax16 > 0) {
|
||||
(*pmax16)--;
|
||||
} else {
|
||||
(*pmin16)++;
|
||||
}
|
||||
}
|
||||
|
||||
stb__ReorderColors(pmax16, pmin16);
|
||||
}
|
||||
}
|
||||
|
||||
static const float stb__midpoints5[32] = {
|
||||
0.015686f, 0.047059f, 0.078431f, 0.111765f, 0.145098f, 0.176471f, 0.207843f, 0.241176f,
|
||||
0.274510f, 0.305882f, 0.337255f, 0.370588f, 0.403922f, 0.435294f, 0.466667f, 0.5f,
|
||||
0.533333f, 0.564706f, 0.596078f, 0.629412f, 0.662745f, 0.694118f, 0.725490f, 0.758824f,
|
||||
0.792157f, 0.823529f, 0.854902f, 0.888235f, 0.921569f, 0.952941f, 0.984314f, 1.0f};
|
||||
|
||||
static const float stb__midpoints6[64] = {
|
||||
0.007843f, 0.023529f, 0.039216f, 0.054902f, 0.070588f, 0.086275f, 0.101961f, 0.117647f,
|
||||
0.133333f, 0.149020f, 0.164706f, 0.180392f, 0.196078f, 0.211765f, 0.227451f, 0.245098f,
|
||||
0.262745f, 0.278431f, 0.294118f, 0.309804f, 0.325490f, 0.341176f, 0.356863f, 0.372549f,
|
||||
0.388235f, 0.403922f, 0.419608f, 0.435294f, 0.450980f, 0.466667f, 0.482353f, 0.500000f,
|
||||
0.517647f, 0.533333f, 0.549020f, 0.564706f, 0.580392f, 0.596078f, 0.611765f, 0.627451f,
|
||||
0.643137f, 0.658824f, 0.674510f, 0.690196f, 0.705882f, 0.721569f, 0.737255f, 0.754902f,
|
||||
0.772549f, 0.788235f, 0.803922f, 0.819608f, 0.835294f, 0.850980f, 0.866667f, 0.882353f,
|
||||
0.898039f, 0.913725f, 0.929412f, 0.945098f, 0.960784f, 0.976471f, 0.992157f, 1.0f};
|
||||
|
||||
static unsigned short stb__Quantize5(float x) {
|
||||
unsigned short q;
|
||||
x = x < 0 ? 0 : x > 1 ? 1 : x; // saturate
|
||||
q = (unsigned short)(x * 31);
|
||||
q += (x > stb__midpoints5[q]);
|
||||
return q;
|
||||
}
|
||||
|
||||
static unsigned short stb__Quantize6(float x) {
|
||||
unsigned short q;
|
||||
x = x < 0 ? 0 : x > 1 ? 1 : x; // saturate
|
||||
q = (unsigned short)(x * 63);
|
||||
q += (x > stb__midpoints6[q]);
|
||||
return q;
|
||||
}
|
||||
|
||||
// The refinement function. (Clever code, part 2)
|
||||
// Tries to optimize colors to suit block contents better.
|
||||
// (By solving a least squares system via normal equations+Cramer's rule)
|
||||
static int stb__RefineBlock(unsigned char* block, unsigned short* pmax16, unsigned short* pmin16,
|
||||
unsigned int mask) {
|
||||
static const int w1Tab[4] = {3, 0, 2, 1};
|
||||
static const int prods[4] = {0x090000, 0x000900, 0x040102, 0x010402};
|
||||
// ^some magic to save a lot of multiplies in the accumulating loop...
|
||||
// (precomputed products of weights for least squares system, accumulated
|
||||
// inside one 32-bit register)
|
||||
|
||||
float f;
|
||||
unsigned short oldMin, oldMax, min16, max16;
|
||||
int i, akku = 0, xx, xy, yy;
|
||||
int At1_r, At1_g, At1_b;
|
||||
int At2_r, At2_g, At2_b;
|
||||
unsigned int cm = mask;
|
||||
|
||||
oldMin = *pmin16;
|
||||
oldMax = *pmax16;
|
||||
|
||||
if ((mask ^ (mask << 2)) < 4) // all pixels have the same index?
|
||||
{
|
||||
// yes, linear system would be singular; solve using optimal
|
||||
// single-color match on average color
|
||||
int r = 8, g = 8, b = 8;
|
||||
for (i = 0; i < 16; ++i) {
|
||||
r += block[i * 4 + 0];
|
||||
g += block[i * 4 + 1];
|
||||
b += block[i * 4 + 2];
|
||||
}
|
||||
|
||||
r >>= 4;
|
||||
g >>= 4;
|
||||
b >>= 4;
|
||||
|
||||
max16 = static_cast<unsigned short>((stb__OMatch5[r][0] << 11) | (stb__OMatch6[g][0] << 5) |
|
||||
stb__OMatch5[b][0]);
|
||||
min16 = static_cast<unsigned short>((stb__OMatch5[r][1] << 11) | (stb__OMatch6[g][1] << 5) |
|
||||
stb__OMatch5[b][1]);
|
||||
} else {
|
||||
At1_r = At1_g = At1_b = 0;
|
||||
At2_r = At2_g = At2_b = 0;
|
||||
for (i = 0; i < 16; ++i, cm >>= 2) {
|
||||
int step = cm & 3;
|
||||
int w1 = w1Tab[step];
|
||||
int r = block[i * 4 + 0];
|
||||
int g = block[i * 4 + 1];
|
||||
int b = block[i * 4 + 2];
|
||||
|
||||
akku += prods[step];
|
||||
At1_r += w1 * r;
|
||||
At1_g += w1 * g;
|
||||
At1_b += w1 * b;
|
||||
At2_r += r;
|
||||
At2_g += g;
|
||||
At2_b += b;
|
||||
}
|
||||
|
||||
At2_r = 3 * At2_r - At1_r;
|
||||
At2_g = 3 * At2_g - At1_g;
|
||||
At2_b = 3 * At2_b - At1_b;
|
||||
|
||||
// extract solutions and decide solvability
|
||||
xx = akku >> 16;
|
||||
yy = (akku >> 8) & 0xff;
|
||||
xy = (akku >> 0) & 0xff;
|
||||
|
||||
f = 3.0f / 255.0f / static_cast<float>(xx * yy - xy * xy);
|
||||
|
||||
max16 = static_cast<unsigned short>(
|
||||
stb__Quantize5(static_cast<float>(At1_r * yy - At2_r * xy) * f) << 11);
|
||||
max16 |= static_cast<unsigned short>(
|
||||
stb__Quantize6(static_cast<float>(At1_g * yy - At2_g * xy) * f) << 5);
|
||||
max16 |= static_cast<unsigned short>(
|
||||
stb__Quantize5(static_cast<float>(At1_b * yy - At2_b * xy) * f) << 0);
|
||||
|
||||
min16 = static_cast<unsigned short>(
|
||||
stb__Quantize5(static_cast<float>(At2_r * xx - At1_r * xy) * f) << 11);
|
||||
min16 |= static_cast<unsigned short>(
|
||||
stb__Quantize6(static_cast<float>(At2_g * xx - At1_g * xy) * f) << 5);
|
||||
min16 |= static_cast<unsigned short>(
|
||||
stb__Quantize5(static_cast<float>(At2_b * xx - At1_b * xy) * f) << 0);
|
||||
}
|
||||
|
||||
*pmin16 = min16;
|
||||
*pmax16 = max16;
|
||||
stb__ReorderColors(pmax16, pmin16);
|
||||
|
||||
return oldMin != min16 || oldMax != max16;
|
||||
}
|
||||
|
||||
// Color block compression
|
||||
static void stb__CompressColorBlock(unsigned char* dest, unsigned char* block, int alpha,
|
||||
int mode) {
|
||||
unsigned int mask;
|
||||
int i;
|
||||
int refinecount;
|
||||
unsigned short max16, min16;
|
||||
unsigned char color[4 * 4];
|
||||
|
||||
refinecount = (mode & STB_DXT_HIGHQUAL) ? 2 : 1;
|
||||
|
||||
// check if block is constant
|
||||
for (i = 1; i < 16; i++)
|
||||
if (((unsigned int*)block)[i] != ((unsigned int*)block)[0])
|
||||
break;
|
||||
|
||||
if (i == 16 && block[3] == 0 && alpha) { // constant alpha
|
||||
mask = 0xffffffff;
|
||||
max16 = 0;
|
||||
min16 = 0xffff;
|
||||
} else if (i == 16) { // constant color
|
||||
int r = block[0], g = block[1], b = block[2];
|
||||
mask = 0xaaaaaaaa;
|
||||
max16 = static_cast<unsigned short>((stb__OMatch5[r][0] << 11) | (stb__OMatch6[g][0] << 5) |
|
||||
stb__OMatch5[b][0]);
|
||||
min16 = static_cast<unsigned short>((stb__OMatch5[r][1] << 11) | (stb__OMatch6[g][1] << 5) |
|
||||
stb__OMatch5[b][1]);
|
||||
} else if (alpha) {
|
||||
stb__OptimizeColorsAlphaBlock(block, &max16, &min16);
|
||||
stb__Eval3Colors(color, max16, min16);
|
||||
mask = stb__MatchColorsAlphaBlock(block, color);
|
||||
} else {
|
||||
// first step: PCA+map along principal axis
|
||||
stb__OptimizeColorsBlock(block, &max16, &min16);
|
||||
if (max16 != min16) {
|
||||
stb__Eval4Colors(color, max16, min16);
|
||||
mask = stb__MatchColorsBlock(block, color);
|
||||
} else
|
||||
mask = 0;
|
||||
|
||||
// third step: refine (multiple times if requested)
|
||||
for (i = 0; i < refinecount; i++) {
|
||||
unsigned int lastmask = mask;
|
||||
|
||||
if (stb__RefineBlock(block, &max16, &min16, mask)) {
|
||||
if (max16 != min16) {
|
||||
stb__Eval4Colors(color, max16, min16);
|
||||
mask = stb__MatchColorsBlock(block, color);
|
||||
} else {
|
||||
mask = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (mask == lastmask)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// write the color block
|
||||
if (!alpha)
|
||||
stb__FinalizeColors(&max16, &min16, &mask);
|
||||
|
||||
dest[0] = (unsigned char)(max16);
|
||||
dest[1] = (unsigned char)(max16 >> 8);
|
||||
dest[2] = (unsigned char)(min16);
|
||||
dest[3] = (unsigned char)(min16 >> 8);
|
||||
dest[4] = (unsigned char)(mask);
|
||||
dest[5] = (unsigned char)(mask >> 8);
|
||||
dest[6] = (unsigned char)(mask >> 16);
|
||||
dest[7] = (unsigned char)(mask >> 24);
|
||||
}
|
||||
|
||||
// Alpha block compression (this is easy for a change)
|
||||
static void stb__CompressAlphaBlock(unsigned char* dest, unsigned char* src, int stride) {
|
||||
int i, dist, bias, dist4, dist2, bits, mask;
|
||||
|
||||
// find min/max color
|
||||
int mn, mx;
|
||||
mn = mx = src[0];
|
||||
|
||||
for (i = 1; i < 16; i++) {
|
||||
if (src[i * stride] < mn)
|
||||
mn = src[i * stride];
|
||||
else if (src[i * stride] > mx)
|
||||
mx = src[i * stride];
|
||||
}
|
||||
|
||||
// encode them
|
||||
dest[0] = (unsigned char)mx;
|
||||
dest[1] = (unsigned char)mn;
|
||||
dest += 2;
|
||||
|
||||
// determine bias and emit color indices
|
||||
// given the choice of mx/mn, these indices are optimal:
|
||||
// http://fgiesen.wordpress.com/2009/12/15/dxt5-alpha-block-index-determination/
|
||||
dist = mx - mn;
|
||||
dist4 = dist * 4;
|
||||
dist2 = dist * 2;
|
||||
bias = (dist < 8) ? (dist - 1) : (dist / 2 + 2);
|
||||
bias -= mn * 7;
|
||||
bits = 0, mask = 0;
|
||||
|
||||
for (i = 0; i < 16; i++) {
|
||||
int a = src[i * stride] * 7 + bias;
|
||||
int ind, t;
|
||||
|
||||
// select index. this is a "linear scale" lerp factor between 0 (val=min)
|
||||
// and 7 (val=max).
|
||||
t = (a >= dist4) ? -1 : 0;
|
||||
ind = t & 4;
|
||||
a -= dist4 & t;
|
||||
t = (a >= dist2) ? -1 : 0;
|
||||
ind += t & 2;
|
||||
a -= dist2 & t;
|
||||
ind += (a >= dist);
|
||||
|
||||
// turn linear scale into DXT index (0/1 are extremal pts)
|
||||
ind = -ind & 7;
|
||||
ind ^= (2 > ind);
|
||||
|
||||
// write index
|
||||
mask |= ind << bits;
|
||||
if ((bits += 3) >= 8) {
|
||||
*dest++ = (unsigned char)mask;
|
||||
mask >>= 8;
|
||||
bits -= 8;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void stb_compress_bc1_block(unsigned char* dest, const unsigned char* src, int alpha, int mode) {
|
||||
stb__CompressColorBlock(dest, (unsigned char*)src, alpha, mode);
|
||||
}
|
||||
|
||||
void stb_compress_bc3_block(unsigned char* dest, const unsigned char* src, int mode) {
|
||||
unsigned char data[16][4];
|
||||
int i;
|
||||
|
||||
stb__CompressAlphaBlock(dest, (unsigned char*)src + 3, 4);
|
||||
dest += 8;
|
||||
// make a new copy of the data in which alpha is opaque,
|
||||
// because code uses a fast test for color constancy
|
||||
memcpy(data, src, 4 * 16);
|
||||
for (i = 0; i < 16; ++i)
|
||||
data[i][3] = 255;
|
||||
src = &data[0][0];
|
||||
|
||||
stb__CompressColorBlock(dest, (unsigned char*)src, 0, mode);
|
||||
}
|
||||
36
externals/stb/stb_dxt.h
vendored
36
externals/stb/stb_dxt.h
vendored
|
|
@ -1,36 +0,0 @@
|
|||
// SPDX-FileCopyrightText: fabian "ryg" giesen
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
// stb_dxt.h - v1.12 - DXT1/DXT5 compressor
|
||||
|
||||
#ifndef STB_INCLUDE_STB_DXT_H
|
||||
#define STB_INCLUDE_STB_DXT_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef STB_DXT_STATIC
|
||||
#define STBDDEF static
|
||||
#else
|
||||
#define STBDDEF extern
|
||||
#endif
|
||||
|
||||
// compression mode (bitflags)
|
||||
#define STB_DXT_NORMAL 0
|
||||
#define STB_DXT_DITHER 1 // use dithering. was always dubious, now deprecated. does nothing!
|
||||
#define STB_DXT_HIGHQUAL \
|
||||
2 // high quality mode, does two refinement steps instead of 1. ~30-40% slower.
|
||||
|
||||
STBDDEF void stb_compress_bc1_block(unsigned char* dest,
|
||||
const unsigned char* src_rgba_four_bytes_per_pixel, int alpha,
|
||||
int mode);
|
||||
|
||||
STBDDEF void stb_compress_bc3_block(unsigned char* dest, const unsigned char* src, int mode);
|
||||
|
||||
#define STB_COMPRESS_DXT_BLOCK
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif // STB_INCLUDE_STB_DXT_H
|
||||
2
externals/vcpkg
vendored
2
externals/vcpkg
vendored
|
|
@ -1 +1 @@
|
|||
Subproject commit 656fcc6ab2b05c6d999b7eaca717027ac3738f71
|
||||
Subproject commit 9b22b40c6c61bf0da2d46346dd44a11e90972cc9
|
||||
|
|
@ -83,7 +83,7 @@ if (MSVC)
|
|||
)
|
||||
|
||||
if (USE_CCACHE OR YUZU_USE_PRECOMPILED_HEADERS)
|
||||
# when caching, we need to use /Z7 to downgrade debug info to use an older but more cacheable format
|
||||
# when caching, we need to use /Z7 to downgrade debug info to use an older but more cachable format
|
||||
# Precompiled headers are deleted if not using /Z7. See https://github.com/nanoant/CMakePCHCompiler/issues/21
|
||||
add_compile_options(/Z7)
|
||||
else()
|
||||
|
|
@ -113,9 +113,6 @@ else()
|
|||
|
||||
$<$<CXX_COMPILER_ID:Clang>:-Wno-braced-scalar-init>
|
||||
$<$<CXX_COMPILER_ID:Clang>:-Wno-unused-private-field>
|
||||
$<$<CXX_COMPILER_ID:Clang>:-Werror=shadow-uncaptured-local>
|
||||
$<$<CXX_COMPILER_ID:Clang>:-Werror=implicit-fallthrough>
|
||||
$<$<CXX_COMPILER_ID:Clang>:-Werror=type-limits>
|
||||
$<$<CXX_COMPILER_ID:AppleClang>:-Wno-braced-scalar-init>
|
||||
$<$<CXX_COMPILER_ID:AppleClang>:-Wno-unused-private-field>
|
||||
)
|
||||
|
|
@ -129,17 +126,6 @@ else()
|
|||
add_compile_options("-stdlib=libc++")
|
||||
endif()
|
||||
|
||||
# GCC bugs
|
||||
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "12" AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||
# These diagnostics would be great if they worked, but are just completely broken
|
||||
# and produce bogus errors on external libraries like fmt.
|
||||
add_compile_options(
|
||||
-Wno-array-bounds
|
||||
-Wno-stringop-overread
|
||||
-Wno-stringop-overflow
|
||||
)
|
||||
endif()
|
||||
|
||||
# Set file offset size to 64 bits.
|
||||
#
|
||||
# On modern Unixes, this is typically already the case. The lone exception is
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ Manager::Manager(Core::System& system_) : system{system_} {
|
|||
Result Manager::AcquireSessionId(size_t& session_id) {
|
||||
if (num_free_sessions == 0) {
|
||||
LOG_ERROR(Service_Audio, "All 4 AudioIn sessions are in use, cannot create any more");
|
||||
return Service::Audio::ResultOutOfSessions;
|
||||
return Service::Audio::ERR_MAXIMUM_SESSIONS_REACHED;
|
||||
}
|
||||
session_id = session_ids[next_session_id];
|
||||
next_session_id = (next_session_id + 1) % MaxInSessions;
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ void AudioManager::Shutdown() {
|
|||
|
||||
Result AudioManager::SetOutManager(BufferEventFunc buffer_func) {
|
||||
if (!running) {
|
||||
return Service::Audio::ResultOperationFailed;
|
||||
return Service::Audio::ERR_OPERATION_FAILED;
|
||||
}
|
||||
|
||||
std::scoped_lock l{lock};
|
||||
|
|
@ -35,7 +35,7 @@ Result AudioManager::SetOutManager(BufferEventFunc buffer_func) {
|
|||
|
||||
Result AudioManager::SetInManager(BufferEventFunc buffer_func) {
|
||||
if (!running) {
|
||||
return Service::Audio::ResultOperationFailed;
|
||||
return Service::Audio::ERR_OPERATION_FAILED;
|
||||
}
|
||||
|
||||
std::scoped_lock l{lock};
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ Manager::Manager(Core::System& system_) : system{system_} {
|
|||
Result Manager::AcquireSessionId(size_t& session_id) {
|
||||
if (num_free_sessions == 0) {
|
||||
LOG_ERROR(Service_Audio, "All 12 Audio Out sessions are in use, cannot create any more");
|
||||
return Service::Audio::ResultOutOfSessions;
|
||||
return Service::Audio::ERR_MAXIMUM_SESSIONS_REACHED;
|
||||
}
|
||||
session_id = session_ids[next_session_id];
|
||||
next_session_id = (next_session_id + 1) % MaxOutSessions;
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ public:
|
|||
/**
|
||||
* Get a list of audio out device names.
|
||||
*
|
||||
* @param names - Output container to write names to.
|
||||
* @oaram names - Output container to write names to.
|
||||
* @return Number of names written.
|
||||
*/
|
||||
u32 GetAudioOutDeviceNames(
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ SystemManager& Manager::GetSystemManager() {
|
|||
Result Manager::GetWorkBufferSize(const AudioRendererParameterInternal& params,
|
||||
u64& out_count) const {
|
||||
if (!CheckValidRevision(params.revision)) {
|
||||
return Service::Audio::ResultInvalidRevision;
|
||||
return Service::Audio::ERR_INVALID_REVISION;
|
||||
}
|
||||
|
||||
out_count = System::GetWorkBufferSize(params);
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ struct AudioBuffer {
|
|||
s64 played_timestamp;
|
||||
/// Game memory address for these samples.
|
||||
VAddr samples;
|
||||
/// Unique identifier for this buffer.
|
||||
/// Unqiue identifier for this buffer.
|
||||
u64 tag;
|
||||
/// Size of the samples buffer.
|
||||
u64 size;
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ void DeviceSession::AppendBuffers(std::span<const AudioBuffer> buffers) const {
|
|||
stream->AppendBuffer(new_buffer, samples);
|
||||
} else {
|
||||
std::vector<s16> samples(buffer.size / sizeof(s16));
|
||||
system.ApplicationMemory().ReadBlockUnsafe(buffer.samples, samples.data(), buffer.size);
|
||||
system.Memory().ReadBlockUnsafe(buffer.samples, samples.data(), buffer.size);
|
||||
stream->AppendBuffer(new_buffer, samples);
|
||||
}
|
||||
}
|
||||
|
|
@ -102,7 +102,7 @@ void DeviceSession::AppendBuffers(std::span<const AudioBuffer> buffers) const {
|
|||
void DeviceSession::ReleaseBuffer(const AudioBuffer& buffer) const {
|
||||
if (type == Sink::StreamType::In) {
|
||||
auto samples{stream->ReleaseBuffer(buffer.size / sizeof(s16))};
|
||||
system.ApplicationMemory().WriteBlockUnsafe(buffer.samples, samples.data(), buffer.size);
|
||||
system.Memory().WriteBlockUnsafe(buffer.samples, samples.data(), buffer.size);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -121,7 +121,8 @@ u64 DeviceSession::GetPlayedSampleCount() const {
|
|||
}
|
||||
|
||||
std::optional<std::chrono::nanoseconds> DeviceSession::ThreadFunc() {
|
||||
played_sample_count = stream->GetExpectedPlayedSampleCount();
|
||||
// Add 5ms of samples at a 48K sample rate.
|
||||
played_sample_count += 48'000 * INCREMENT_TIME / 1s;
|
||||
if (type == Sink::StreamType::Out) {
|
||||
system.AudioCore().GetAudioManager().SetEvent(Event::Type::AudioOutManager, true);
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ Result In::AppendBuffer(const AudioInBuffer& buffer, u64 tag) {
|
|||
if (system.AppendBuffer(buffer, tag)) {
|
||||
return ResultSuccess;
|
||||
}
|
||||
return Service::Audio::ResultBufferCountReached;
|
||||
return Service::Audio::ERR_BUFFER_COUNT_EXCEEDED;
|
||||
}
|
||||
|
||||
void In::ReleaseAndRegisterBuffers() {
|
||||
|
|
|
|||
|
|
@ -45,11 +45,11 @@ Result System::IsConfigValid(const std::string_view device_name,
|
|||
const AudioInParameter& in_params) const {
|
||||
if ((device_name.size() > 0) &&
|
||||
(device_name != GetDefaultDeviceName() && device_name != GetDefaultUacDeviceName())) {
|
||||
return Service::Audio::ResultNotFound;
|
||||
return Service::Audio::ERR_INVALID_DEVICE_NAME;
|
||||
}
|
||||
|
||||
if (in_params.sample_rate != TargetSampleRate && in_params.sample_rate > 0) {
|
||||
return Service::Audio::ResultInvalidSampleRate;
|
||||
return Service::Audio::ERR_INVALID_SAMPLE_RATE;
|
||||
}
|
||||
|
||||
return ResultSuccess;
|
||||
|
|
@ -80,7 +80,7 @@ Result System::Initialize(std::string device_name, const AudioInParameter& in_pa
|
|||
|
||||
Result System::Start() {
|
||||
if (state != State::Stopped) {
|
||||
return Service::Audio::ResultOperationFailed;
|
||||
return Service::Audio::ERR_OPERATION_FAILED;
|
||||
}
|
||||
|
||||
session->Initialize(name, sample_format, channel_count, session_id, handle,
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ Result Out::AppendBuffer(const AudioOutBuffer& buffer, const u64 tag) {
|
|||
if (system.AppendBuffer(buffer, tag)) {
|
||||
return ResultSuccess;
|
||||
}
|
||||
return Service::Audio::ResultBufferCountReached;
|
||||
return Service::Audio::ERR_BUFFER_COUNT_EXCEEDED;
|
||||
}
|
||||
|
||||
void Out::ReleaseAndRegisterBuffers() {
|
||||
|
|
|
|||
|
|
@ -33,11 +33,11 @@ std::string_view System::GetDefaultOutputDeviceName() const {
|
|||
Result System::IsConfigValid(std::string_view device_name,
|
||||
const AudioOutParameter& in_params) const {
|
||||
if ((device_name.size() > 0) && (device_name != GetDefaultOutputDeviceName())) {
|
||||
return Service::Audio::ResultNotFound;
|
||||
return Service::Audio::ERR_INVALID_DEVICE_NAME;
|
||||
}
|
||||
|
||||
if (in_params.sample_rate != TargetSampleRate && in_params.sample_rate > 0) {
|
||||
return Service::Audio::ResultInvalidSampleRate;
|
||||
return Service::Audio::ERR_INVALID_SAMPLE_RATE;
|
||||
}
|
||||
|
||||
if (in_params.channel_count == 0 || in_params.channel_count == 2 ||
|
||||
|
|
@ -45,7 +45,7 @@ Result System::IsConfigValid(std::string_view device_name,
|
|||
return ResultSuccess;
|
||||
}
|
||||
|
||||
return Service::Audio::ResultInvalidChannelCount;
|
||||
return Service::Audio::ERR_INVALID_CHANNEL_COUNT;
|
||||
}
|
||||
|
||||
Result System::Initialize(std::string device_name, const AudioOutParameter& in_params, u32 handle_,
|
||||
|
|
@ -80,7 +80,7 @@ size_t System::GetSessionId() const {
|
|||
|
||||
Result System::Start() {
|
||||
if (state != State::Stopped) {
|
||||
return Service::Audio::ResultOperationFailed;
|
||||
return Service::Audio::ERR_OPERATION_FAILED;
|
||||
}
|
||||
|
||||
session->Initialize(name, sample_format, channel_count, session_id, handle,
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
namespace AudioCore::AudioRenderer::ADSP {
|
||||
|
||||
ADSP::ADSP(Core::System& system_, Sink::Sink& sink_)
|
||||
: system{system_}, memory{system.ApplicationMemory()}, sink{sink_} {}
|
||||
: system{system_}, memory{system.Memory()}, sink{sink_} {}
|
||||
|
||||
ADSP::~ADSP() {
|
||||
ClearCommandBuffers();
|
||||
|
|
|
|||
|
|
@ -132,10 +132,10 @@ void AudioRenderer::CreateSinkStreams() {
|
|||
}
|
||||
|
||||
void AudioRenderer::ThreadFunc() {
|
||||
static constexpr char name[]{"AudioRenderer"};
|
||||
constexpr char name[]{"AudioRenderer"};
|
||||
MicroProfileOnThreadCreate(name);
|
||||
Common::SetCurrentThreadName(name);
|
||||
Common::SetCurrentThreadPriority(Common::ThreadPriority::High);
|
||||
Common::SetCurrentThreadPriority(Common::ThreadPriority::Critical);
|
||||
if (mailbox->ADSPWaitMessage() != RenderMessage::AudioRenderer_InitializeOK) {
|
||||
LOG_ERROR(Service_Audio,
|
||||
"ADSP Audio Renderer -- Failed to receive initialize message from host!");
|
||||
|
|
@ -154,11 +154,6 @@ void AudioRenderer::ThreadFunc() {
|
|||
return;
|
||||
|
||||
case RenderMessage::AudioRenderer_Render: {
|
||||
if (system.IsShuttingDown()) [[unlikely]] {
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(5));
|
||||
mailbox->ADSPSendMessage(RenderMessage::AudioRenderer_RenderResponse);
|
||||
continue;
|
||||
}
|
||||
std::array<bool, MaxRendererSessions> buffers_reset{};
|
||||
std::array<u64, MaxRendererSessions> render_times_taken{};
|
||||
const auto start_time{system.CoreTiming().GetClockTicks()};
|
||||
|
|
@ -170,7 +165,7 @@ void AudioRenderer::ThreadFunc() {
|
|||
// Check this buffer is valid, as it may not be used.
|
||||
if (command_buffer.buffer != 0) {
|
||||
// If there are no remaining commands (from the previous list),
|
||||
// this is a new command list, initialize it.
|
||||
// this is a new command list, initalize it.
|
||||
if (command_buffer.remaining_command_count == 0) {
|
||||
command_list_processor.Initialize(system, command_buffer.buffer,
|
||||
command_buffer.size, streams[index]);
|
||||
|
|
@ -194,8 +189,6 @@ void AudioRenderer::ThreadFunc() {
|
|||
max_time = std::min(command_buffer.time_limit, max_time);
|
||||
command_list_processor.SetProcessTimeMax(max_time);
|
||||
|
||||
streams[index]->WaitFreeSpace();
|
||||
|
||||
// Process the command list
|
||||
{
|
||||
MICROPROFILE_SCOPE(Audio_Renderer);
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@
|
|||
#include "audio_core/renderer/adsp/command_buffer.h"
|
||||
#include "audio_core/renderer/adsp/command_list_processor.h"
|
||||
#include "common/common_types.h"
|
||||
#include "common/polyfill_thread.h"
|
||||
#include "common/reader_writer_queue.h"
|
||||
#include "common/thread.h"
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ namespace AudioCore::AudioRenderer::ADSP {
|
|||
void CommandListProcessor::Initialize(Core::System& system_, CpuAddr buffer, u64 size,
|
||||
Sink::SinkStream* stream_) {
|
||||
system = &system_;
|
||||
memory = &system->ApplicationMemory();
|
||||
memory = &system->Memory();
|
||||
stream = stream_;
|
||||
header = reinterpret_cast<CommandListHeader*>(buffer);
|
||||
commands = reinterpret_cast<u8*>(buffer + sizeof(CommandListHeader));
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ Result Renderer::Initialize(const AudioRendererParameterInternal& params,
|
|||
if (!manager.AddSystem(system)) {
|
||||
LOG_ERROR(Service_Audio,
|
||||
"Both Audio Render sessions are in use, cannot create any more");
|
||||
return Service::Audio::ResultOutOfSessions;
|
||||
return Service::Audio::ERR_MAXIMUM_SESSIONS_REACHED;
|
||||
}
|
||||
system_registered = true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -155,7 +155,7 @@ public:
|
|||
/**
|
||||
* Check if a variadic command buffer is supported.
|
||||
* As of Rev 5 with the added optional performance metric logging, the command
|
||||
* buffer can be a variable size, so take that into account for calculating its size.
|
||||
* buffer can be a variable size, so take that into account for calcualting its size.
|
||||
*
|
||||
* @return True if supported, otherwise false.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ Result InfoUpdater::UpdateVoiceChannelResources(VoiceContext& voice_context) {
|
|||
LOG_ERROR(Service_Audio,
|
||||
"Consumed an incorrect voice resource size, header size={}, consumed={}",
|
||||
in_header->voice_resources_size, consumed_input_size);
|
||||
return Service::Audio::ResultInvalidUpdateInfo;
|
||||
return Service::Audio::ERR_INVALID_UPDATE_DATA;
|
||||
}
|
||||
|
||||
input += consumed_input_size;
|
||||
|
|
@ -123,7 +123,7 @@ Result InfoUpdater::UpdateVoices(VoiceContext& voice_context,
|
|||
if (consumed_input_size != in_header->voices_size) {
|
||||
LOG_ERROR(Service_Audio, "Consumed an incorrect voices size, header size={}, consumed={}",
|
||||
in_header->voices_size, consumed_input_size);
|
||||
return Service::Audio::ResultInvalidUpdateInfo;
|
||||
return Service::Audio::ERR_INVALID_UPDATE_DATA;
|
||||
}
|
||||
|
||||
out_header->voices_size = consumed_output_size;
|
||||
|
|
@ -184,7 +184,7 @@ Result InfoUpdater::UpdateEffectsVersion1(EffectContext& effect_context, const b
|
|||
if (consumed_input_size != in_header->effects_size) {
|
||||
LOG_ERROR(Service_Audio, "Consumed an incorrect effects size, header size={}, consumed={}",
|
||||
in_header->effects_size, consumed_input_size);
|
||||
return Service::Audio::ResultInvalidUpdateInfo;
|
||||
return Service::Audio::ERR_INVALID_UPDATE_DATA;
|
||||
}
|
||||
|
||||
out_header->effects_size = consumed_output_size;
|
||||
|
|
@ -239,7 +239,7 @@ Result InfoUpdater::UpdateEffectsVersion2(EffectContext& effect_context, const b
|
|||
if (consumed_input_size != in_header->effects_size) {
|
||||
LOG_ERROR(Service_Audio, "Consumed an incorrect effects size, header size={}, consumed={}",
|
||||
in_header->effects_size, consumed_input_size);
|
||||
return Service::Audio::ResultInvalidUpdateInfo;
|
||||
return Service::Audio::ERR_INVALID_UPDATE_DATA;
|
||||
}
|
||||
|
||||
out_header->effects_size = consumed_output_size;
|
||||
|
|
@ -267,7 +267,7 @@ Result InfoUpdater::UpdateMixes(MixContext& mix_context, const u32 mix_buffer_co
|
|||
}
|
||||
|
||||
if (mix_buffer_count == 0) {
|
||||
return Service::Audio::ResultInvalidUpdateInfo;
|
||||
return Service::Audio::ERR_INVALID_UPDATE_DATA;
|
||||
}
|
||||
|
||||
std::span<const MixInfo::InParameter> in_params{
|
||||
|
|
@ -281,13 +281,13 @@ Result InfoUpdater::UpdateMixes(MixContext& mix_context, const u32 mix_buffer_co
|
|||
total_buffer_count += params.buffer_count;
|
||||
if (params.dest_mix_id > static_cast<s32>(mix_context.GetCount()) &&
|
||||
params.dest_mix_id != UnusedMixId && params.mix_id != FinalMixId) {
|
||||
return Service::Audio::ResultInvalidUpdateInfo;
|
||||
return Service::Audio::ERR_INVALID_UPDATE_DATA;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (total_buffer_count > mix_buffer_count) {
|
||||
return Service::Audio::ResultInvalidUpdateInfo;
|
||||
return Service::Audio::ERR_INVALID_UPDATE_DATA;
|
||||
}
|
||||
|
||||
bool mix_dirty{false};
|
||||
|
|
@ -317,7 +317,7 @@ Result InfoUpdater::UpdateMixes(MixContext& mix_context, const u32 mix_buffer_co
|
|||
if (mix_dirty) {
|
||||
if (behaviour.IsSplitterSupported() && splitter_context.UsingSplitter()) {
|
||||
if (!mix_context.TSortInfo(splitter_context)) {
|
||||
return Service::Audio::ResultInvalidUpdateInfo;
|
||||
return Service::Audio::ERR_INVALID_UPDATE_DATA;
|
||||
}
|
||||
} else {
|
||||
mix_context.SortInfo();
|
||||
|
|
@ -327,7 +327,7 @@ Result InfoUpdater::UpdateMixes(MixContext& mix_context, const u32 mix_buffer_co
|
|||
if (consumed_input_size != in_header->mix_size) {
|
||||
LOG_ERROR(Service_Audio, "Consumed an incorrect mixes size, header size={}, consumed={}",
|
||||
in_header->mix_size, consumed_input_size);
|
||||
return Service::Audio::ResultInvalidUpdateInfo;
|
||||
return Service::Audio::ERR_INVALID_UPDATE_DATA;
|
||||
}
|
||||
|
||||
input += mix_count * sizeof(MixInfo::InParameter);
|
||||
|
|
@ -384,7 +384,7 @@ Result InfoUpdater::UpdateSinks(SinkContext& sink_context, std::span<MemoryPoolI
|
|||
if (consumed_input_size != in_header->sinks_size) {
|
||||
LOG_ERROR(Service_Audio, "Consumed an incorrect sinks size, header size={}, consumed={}",
|
||||
in_header->sinks_size, consumed_input_size);
|
||||
return Service::Audio::ResultInvalidUpdateInfo;
|
||||
return Service::Audio::ERR_INVALID_UPDATE_DATA;
|
||||
}
|
||||
|
||||
input += consumed_input_size;
|
||||
|
|
@ -411,7 +411,7 @@ Result InfoUpdater::UpdateMemoryPools(std::span<MemoryPoolInfo> memory_pools,
|
|||
state != MemoryPoolInfo::ResultState::MapFailed &&
|
||||
state != MemoryPoolInfo::ResultState::InUse) {
|
||||
LOG_WARNING(Service_Audio, "Invalid ResultState from updating memory pools");
|
||||
return Service::Audio::ResultInvalidUpdateInfo;
|
||||
return Service::Audio::ERR_INVALID_UPDATE_DATA;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -423,7 +423,7 @@ Result InfoUpdater::UpdateMemoryPools(std::span<MemoryPoolInfo> memory_pools,
|
|||
LOG_ERROR(Service_Audio,
|
||||
"Consumed an incorrect memory pool size, header size={}, consumed={}",
|
||||
in_header->memory_pool_size, consumed_input_size);
|
||||
return Service::Audio::ResultInvalidUpdateInfo;
|
||||
return Service::Audio::ERR_INVALID_UPDATE_DATA;
|
||||
}
|
||||
|
||||
input += consumed_input_size;
|
||||
|
|
@ -453,7 +453,7 @@ Result InfoUpdater::UpdatePerformanceBuffer(std::span<u8> performance_output,
|
|||
LOG_ERROR(Service_Audio,
|
||||
"Consumed an incorrect performance size, header size={}, consumed={}",
|
||||
in_header->performance_buffer_size, consumed_input_size);
|
||||
return Service::Audio::ResultInvalidUpdateInfo;
|
||||
return Service::Audio::ERR_INVALID_UPDATE_DATA;
|
||||
}
|
||||
|
||||
input += consumed_input_size;
|
||||
|
|
@ -467,18 +467,18 @@ Result InfoUpdater::UpdateBehaviorInfo(BehaviorInfo& behaviour_) {
|
|||
const auto in_params{reinterpret_cast<const BehaviorInfo::InParameter*>(input)};
|
||||
|
||||
if (!CheckValidRevision(in_params->revision)) {
|
||||
return Service::Audio::ResultInvalidUpdateInfo;
|
||||
return Service::Audio::ERR_INVALID_UPDATE_DATA;
|
||||
}
|
||||
|
||||
if (in_params->revision != behaviour_.GetUserRevision()) {
|
||||
return Service::Audio::ResultInvalidUpdateInfo;
|
||||
return Service::Audio::ERR_INVALID_UPDATE_DATA;
|
||||
}
|
||||
|
||||
behaviour_.ClearError();
|
||||
behaviour_.UpdateFlags(in_params->flags);
|
||||
|
||||
if (in_header->behaviour_size != sizeof(BehaviorInfo::InParameter)) {
|
||||
return Service::Audio::ResultInvalidUpdateInfo;
|
||||
return Service::Audio::ERR_INVALID_UPDATE_DATA;
|
||||
}
|
||||
|
||||
input += sizeof(BehaviorInfo::InParameter);
|
||||
|
|
@ -500,7 +500,7 @@ Result InfoUpdater::UpdateErrorInfo(const BehaviorInfo& behaviour_) {
|
|||
Result InfoUpdater::UpdateSplitterInfo(SplitterContext& splitter_context) {
|
||||
u32 consumed_size{0};
|
||||
if (!splitter_context.Update(input, consumed_size)) {
|
||||
return Service::Audio::ResultInvalidUpdateInfo;
|
||||
return Service::Audio::ERR_INVALID_UPDATE_DATA;
|
||||
}
|
||||
|
||||
input += consumed_size;
|
||||
|
|
@ -529,9 +529,9 @@ Result InfoUpdater::UpdateRendererInfo(const u64 elapsed_frames) {
|
|||
|
||||
Result InfoUpdater::CheckConsumedSize() {
|
||||
if (CpuAddr(input) - CpuAddr(input_origin.data()) != expected_input_size) {
|
||||
return Service::Audio::ResultInvalidUpdateInfo;
|
||||
return Service::Audio::ERR_INVALID_UPDATE_DATA;
|
||||
} else if (CpuAddr(output) - CpuAddr(output_origin.data()) != expected_output_size) {
|
||||
return Service::Audio::ResultInvalidUpdateInfo;
|
||||
return Service::Audio::ERR_INVALID_UPDATE_DATA;
|
||||
}
|
||||
return ResultSuccess;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -251,8 +251,8 @@ void CommandBuffer::GenerateBiquadFilterCommand(const s32 node_id, EffectInfoBas
|
|||
|
||||
const auto& parameter{
|
||||
*reinterpret_cast<BiquadFilterInfo::ParameterVersion1*>(effect_info.GetParameter())};
|
||||
const auto state{reinterpret_cast<VoiceState::BiquadFilterState*>(
|
||||
effect_info.GetStateBuffer() + channel * sizeof(VoiceState::BiquadFilterState))};
|
||||
const auto state{
|
||||
reinterpret_cast<VoiceState::BiquadFilterState*>(effect_info.GetStateBuffer())};
|
||||
|
||||
cmd.input = buffer_offset + parameter.inputs[channel];
|
||||
cmd.output = buffer_offset + parameter.outputs[channel];
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ void CommandGenerator::GenerateDataSourceCommand(VoiceInfo& voice_info,
|
|||
while (destination != nullptr) {
|
||||
if (destination->IsConfigured()) {
|
||||
auto mix_id{destination->GetMixId()};
|
||||
if (mix_id < mix_context.GetCount() && mix_id != UnusedSplitterId) {
|
||||
if (mix_id < mix_context.GetCount()) {
|
||||
auto mix_info{mix_context.GetInfo(mix_id)};
|
||||
command_buffer.GenerateDepopPrepareCommand(
|
||||
voice_info.node_id, voice_state, render_context.depop_buffer,
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@
|
|||
#include "audio_core/renderer/adsp/command_list_processor.h"
|
||||
#include "audio_core/renderer/command/effect/aux_.h"
|
||||
#include "audio_core/renderer/effect/aux_.h"
|
||||
#include "core/core.h"
|
||||
#include "core/memory.h"
|
||||
|
||||
namespace AudioCore::AudioRenderer {
|
||||
|
|
@ -20,24 +19,10 @@ static void ResetAuxBufferDsp(Core::Memory::Memory& memory, const CpuAddr aux_in
|
|||
return;
|
||||
}
|
||||
|
||||
AuxInfo::AuxInfoDsp info{};
|
||||
auto info_ptr{&info};
|
||||
bool host_safe{(aux_info & Core::Memory::YUZU_PAGEMASK) <=
|
||||
(Core::Memory::YUZU_PAGESIZE - sizeof(AuxInfo::AuxInfoDsp))};
|
||||
|
||||
if (host_safe) [[likely]] {
|
||||
info_ptr = memory.GetPointer<AuxInfo::AuxInfoDsp>(aux_info);
|
||||
} else {
|
||||
memory.ReadBlockUnsafe(aux_info, info_ptr, sizeof(AuxInfo::AuxInfoDsp));
|
||||
}
|
||||
|
||||
info_ptr->read_offset = 0;
|
||||
info_ptr->write_offset = 0;
|
||||
info_ptr->total_sample_count = 0;
|
||||
|
||||
if (!host_safe) [[unlikely]] {
|
||||
memory.WriteBlockUnsafe(aux_info, info_ptr, sizeof(AuxInfo::AuxInfoDsp));
|
||||
}
|
||||
auto info{reinterpret_cast<AuxInfo::AuxInfoDsp*>(memory.GetPointer(aux_info))};
|
||||
info->read_offset = 0;
|
||||
info->write_offset = 0;
|
||||
info->total_sample_count = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -55,10 +40,11 @@ static void ResetAuxBufferDsp(Core::Memory::Memory& memory, const CpuAddr aux_in
|
|||
* @param update_count - If non-zero, send_info_ will be updated.
|
||||
* @return Number of samples written.
|
||||
*/
|
||||
static u32 WriteAuxBufferDsp(Core::Memory::Memory& memory, CpuAddr send_info_,
|
||||
[[maybe_unused]] u32 sample_count, CpuAddr send_buffer, u32 count_max,
|
||||
std::span<const s32> input, u32 write_count_, u32 write_offset,
|
||||
u32 update_count) {
|
||||
static u32 WriteAuxBufferDsp(Core::Memory::Memory& memory, const CpuAddr send_info_,
|
||||
[[maybe_unused]] u32 sample_count, const CpuAddr send_buffer,
|
||||
const u32 count_max, std::span<const s32> input,
|
||||
const u32 write_count_, const u32 write_offset,
|
||||
const u32 update_count) {
|
||||
if (write_count_ > count_max) {
|
||||
LOG_ERROR(Service_Audio,
|
||||
"write_count must be smaller than count_max! write_count {}, count_max {}",
|
||||
|
|
@ -66,11 +52,6 @@ static u32 WriteAuxBufferDsp(Core::Memory::Memory& memory, CpuAddr send_info_,
|
|||
return 0;
|
||||
}
|
||||
|
||||
if (send_info_ == 0) {
|
||||
LOG_ERROR(Service_Audio, "send_info_ is 0!");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (input.empty()) {
|
||||
LOG_ERROR(Service_Audio, "input buffer is empty!");
|
||||
return 0;
|
||||
|
|
@ -86,47 +67,33 @@ static u32 WriteAuxBufferDsp(Core::Memory::Memory& memory, CpuAddr send_info_,
|
|||
}
|
||||
|
||||
AuxInfo::AuxInfoDsp send_info{};
|
||||
auto send_ptr = &send_info;
|
||||
bool host_safe = (send_info_ & Core::Memory::YUZU_PAGEMASK) <=
|
||||
(Core::Memory::YUZU_PAGESIZE - sizeof(AuxInfo::AuxInfoDsp));
|
||||
memory.ReadBlockUnsafe(send_info_, &send_info, sizeof(AuxInfo::AuxInfoDsp));
|
||||
|
||||
if (host_safe) [[likely]] {
|
||||
send_ptr = memory.GetPointer<AuxInfo::AuxInfoDsp>(send_info_);
|
||||
} else {
|
||||
memory.ReadBlockUnsafe(send_info_, send_ptr, sizeof(AuxInfo::AuxInfoDsp));
|
||||
}
|
||||
|
||||
u32 target_write_offset{send_ptr->write_offset + write_offset};
|
||||
if (target_write_offset > count_max) {
|
||||
u32 target_write_offset{send_info.write_offset + write_offset};
|
||||
if (target_write_offset > count_max || write_count_ == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
u32 write_count{write_count_};
|
||||
u32 read_pos{0};
|
||||
u32 write_pos{0};
|
||||
while (write_count > 0) {
|
||||
u32 to_write{std::min(count_max - target_write_offset, write_count)};
|
||||
const auto write_addr = send_buffer + target_write_offset * sizeof(s32);
|
||||
bool write_safe{(write_addr & Core::Memory::YUZU_PAGEMASK) <=
|
||||
(Core::Memory::YUZU_PAGESIZE - (write_addr + to_write * sizeof(s32)))};
|
||||
if (write_safe) [[likely]] {
|
||||
auto ptr = memory.GetPointer(write_addr);
|
||||
std::memcpy(ptr, &input[read_pos], to_write * sizeof(s32));
|
||||
} else {
|
||||
|
||||
if (to_write > 0) {
|
||||
memory.WriteBlockUnsafe(send_buffer + target_write_offset * sizeof(s32),
|
||||
&input[read_pos], to_write * sizeof(s32));
|
||||
&input[write_pos], to_write * sizeof(s32));
|
||||
}
|
||||
|
||||
target_write_offset = (target_write_offset + to_write) % count_max;
|
||||
write_count -= to_write;
|
||||
read_pos += to_write;
|
||||
write_pos += to_write;
|
||||
}
|
||||
|
||||
if (update_count) {
|
||||
send_ptr->write_offset = (send_ptr->write_offset + update_count) % count_max;
|
||||
send_info.write_offset = (send_info.write_offset + update_count) % count_max;
|
||||
}
|
||||
|
||||
if (!host_safe) [[unlikely]] {
|
||||
memory.WriteBlockUnsafe(send_info_, send_ptr, sizeof(AuxInfo::AuxInfoDsp));
|
||||
}
|
||||
memory.WriteBlockUnsafe(send_info_, &send_info, sizeof(AuxInfo::AuxInfoDsp));
|
||||
|
||||
return write_count_;
|
||||
}
|
||||
|
|
@ -135,7 +102,7 @@ static u32 WriteAuxBufferDsp(Core::Memory::Memory& memory, CpuAddr send_info_,
|
|||
* Read the given memory at return_buffer into the output mix buffer, and update return_info_ if
|
||||
* update_count is set, to notify the game that an update happened.
|
||||
*
|
||||
* @param memory - Core memory for reading.
|
||||
* @param memory - Core memory for writing.
|
||||
* @param return_info_ - Meta information for where to read the mix buffer.
|
||||
* @param return_buffer - Memory address to read the samples from.
|
||||
* @param count_max - Maximum number of samples in the receiving buffer.
|
||||
|
|
@ -145,21 +112,16 @@ static u32 WriteAuxBufferDsp(Core::Memory::Memory& memory, CpuAddr send_info_,
|
|||
* @param update_count - If non-zero, send_info_ will be updated.
|
||||
* @return Number of samples read.
|
||||
*/
|
||||
static u32 ReadAuxBufferDsp(Core::Memory::Memory& memory, CpuAddr return_info_,
|
||||
CpuAddr return_buffer, u32 count_max, std::span<s32> output,
|
||||
u32 read_count_, u32 read_offset, u32 update_count) {
|
||||
static u32 ReadAuxBufferDsp(Core::Memory::Memory& memory, const CpuAddr return_info_,
|
||||
const CpuAddr return_buffer, const u32 count_max, std::span<s32> output,
|
||||
const u32 count_, const u32 read_offset, const u32 update_count) {
|
||||
if (count_max == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (read_count_ > count_max) {
|
||||
if (count_ > count_max) {
|
||||
LOG_ERROR(Service_Audio, "count must be smaller than count_max! count {}, count_max {}",
|
||||
read_count_, count_max);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (return_info_ == 0) {
|
||||
LOG_ERROR(Service_Audio, "return_info_ is 0!");
|
||||
count_, count_max);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -174,49 +136,35 @@ static u32 ReadAuxBufferDsp(Core::Memory::Memory& memory, CpuAddr return_info_,
|
|||
}
|
||||
|
||||
AuxInfo::AuxInfoDsp return_info{};
|
||||
auto return_ptr = &return_info;
|
||||
bool host_safe = (return_info_ & Core::Memory::YUZU_PAGEMASK) <=
|
||||
(Core::Memory::YUZU_PAGESIZE - sizeof(AuxInfo::AuxInfoDsp));
|
||||
memory.ReadBlockUnsafe(return_info_, &return_info, sizeof(AuxInfo::AuxInfoDsp));
|
||||
|
||||
if (host_safe) [[likely]] {
|
||||
return_ptr = memory.GetPointer<AuxInfo::AuxInfoDsp>(return_info_);
|
||||
} else {
|
||||
memory.ReadBlockUnsafe(return_info_, return_ptr, sizeof(AuxInfo::AuxInfoDsp));
|
||||
}
|
||||
|
||||
u32 target_read_offset{return_ptr->read_offset + read_offset};
|
||||
u32 target_read_offset{return_info.read_offset + read_offset};
|
||||
if (target_read_offset > count_max) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
u32 read_count{read_count_};
|
||||
u32 write_pos{0};
|
||||
u32 read_count{count_};
|
||||
u32 read_pos{0};
|
||||
while (read_count > 0) {
|
||||
u32 to_read{std::min(count_max - target_read_offset, read_count)};
|
||||
const auto read_addr = return_buffer + target_read_offset * sizeof(s32);
|
||||
bool read_safe{(read_addr & Core::Memory::YUZU_PAGEMASK) <=
|
||||
(Core::Memory::YUZU_PAGESIZE - (read_addr + to_read * sizeof(s32)))};
|
||||
if (read_safe) [[likely]] {
|
||||
auto ptr = memory.GetPointer(read_addr);
|
||||
std::memcpy(&output[write_pos], ptr, to_read * sizeof(s32));
|
||||
} else {
|
||||
|
||||
if (to_read > 0) {
|
||||
memory.ReadBlockUnsafe(return_buffer + target_read_offset * sizeof(s32),
|
||||
&output[write_pos], to_read * sizeof(s32));
|
||||
&output[read_pos], to_read * sizeof(s32));
|
||||
}
|
||||
|
||||
target_read_offset = (target_read_offset + to_read) % count_max;
|
||||
read_count -= to_read;
|
||||
write_pos += to_read;
|
||||
read_pos += to_read;
|
||||
}
|
||||
|
||||
if (update_count) {
|
||||
return_ptr->read_offset = (return_ptr->read_offset + update_count) % count_max;
|
||||
return_info.read_offset = (return_info.read_offset + update_count) % count_max;
|
||||
}
|
||||
|
||||
if (!host_safe) [[unlikely]] {
|
||||
memory.WriteBlockUnsafe(return_info_, return_ptr, sizeof(AuxInfo::AuxInfoDsp));
|
||||
}
|
||||
memory.WriteBlockUnsafe(return_info_, &return_info, sizeof(AuxInfo::AuxInfoDsp));
|
||||
|
||||
return read_count_;
|
||||
return count_;
|
||||
}
|
||||
|
||||
void AuxCommand::Dump([[maybe_unused]] const ADSP::CommandListProcessor& processor,
|
||||
|
|
@ -241,7 +189,7 @@ void AuxCommand::Process(const ADSP::CommandListProcessor& processor) {
|
|||
update_count)};
|
||||
|
||||
if (read != processor.sample_count) {
|
||||
std::memset(&output_buffer[read], 0, (processor.sample_count - read) * sizeof(s32));
|
||||
std::memset(&output_buffer[read], 0, processor.sample_count - read);
|
||||
}
|
||||
} else {
|
||||
ResetAuxBufferDsp(*processor.memory, send_buffer_info);
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@
|
|||
#include "audio_core/renderer/adsp/command_list_processor.h"
|
||||
#include "audio_core/renderer/command/effect/biquad_filter.h"
|
||||
#include "audio_core/renderer/voice/voice_state.h"
|
||||
#include "common/bit_cast.h"
|
||||
|
||||
namespace AudioCore::AudioRenderer {
|
||||
/**
|
||||
|
|
@ -20,21 +19,21 @@ namespace AudioCore::AudioRenderer {
|
|||
void ApplyBiquadFilterFloat(std::span<s32> output, std::span<const s32> input,
|
||||
std::array<s16, 3>& b_, std::array<s16, 2>& a_,
|
||||
VoiceState::BiquadFilterState& state, const u32 sample_count) {
|
||||
constexpr f64 min{std::numeric_limits<s32>::min()};
|
||||
constexpr f64 max{std::numeric_limits<s32>::max()};
|
||||
constexpr s64 min{std::numeric_limits<s32>::min()};
|
||||
constexpr s64 max{std::numeric_limits<s32>::max()};
|
||||
std::array<f64, 3> b{Common::FixedPoint<50, 14>::from_base(b_[0]).to_double(),
|
||||
Common::FixedPoint<50, 14>::from_base(b_[1]).to_double(),
|
||||
Common::FixedPoint<50, 14>::from_base(b_[2]).to_double()};
|
||||
std::array<f64, 2> a{Common::FixedPoint<50, 14>::from_base(a_[0]).to_double(),
|
||||
Common::FixedPoint<50, 14>::from_base(a_[1]).to_double()};
|
||||
std::array<f64, 4> s{Common::BitCast<f64>(state.s0), Common::BitCast<f64>(state.s1),
|
||||
Common::BitCast<f64>(state.s2), Common::BitCast<f64>(state.s3)};
|
||||
std::array<f64, 4> s{state.s0.to_double(), state.s1.to_double(), state.s2.to_double(),
|
||||
state.s3.to_double()};
|
||||
|
||||
for (u32 i = 0; i < sample_count; i++) {
|
||||
f64 in_sample{static_cast<f64>(input[i])};
|
||||
auto sample{in_sample * b[0] + s[0] * b[1] + s[1] * b[2] + s[2] * a[0] + s[3] * a[1]};
|
||||
|
||||
output[i] = static_cast<s32>(std::clamp(sample, min, max));
|
||||
output[i] = static_cast<s32>(std::clamp(static_cast<s64>(sample), min, max));
|
||||
|
||||
s[1] = s[0];
|
||||
s[0] = in_sample;
|
||||
|
|
@ -42,10 +41,10 @@ void ApplyBiquadFilterFloat(std::span<s32> output, std::span<const s32> input,
|
|||
s[2] = sample;
|
||||
}
|
||||
|
||||
state.s0 = Common::BitCast<s64>(s[0]);
|
||||
state.s1 = Common::BitCast<s64>(s[1]);
|
||||
state.s2 = Common::BitCast<s64>(s[2]);
|
||||
state.s3 = Common::BitCast<s64>(s[3]);
|
||||
state.s0 = s[0];
|
||||
state.s1 = s[1];
|
||||
state.s2 = s[2];
|
||||
state.s3 = s[3];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -59,20 +58,29 @@ void ApplyBiquadFilterFloat(std::span<s32> output, std::span<const s32> input,
|
|||
* @param sample_count - Number of samples to process.
|
||||
*/
|
||||
static void ApplyBiquadFilterInt(std::span<s32> output, std::span<const s32> input,
|
||||
std::array<s16, 3>& b, std::array<s16, 2>& a,
|
||||
std::array<s16, 3>& b_, std::array<s16, 2>& a_,
|
||||
VoiceState::BiquadFilterState& state, const u32 sample_count) {
|
||||
constexpr s64 min{std::numeric_limits<s32>::min()};
|
||||
constexpr s64 max{std::numeric_limits<s32>::max()};
|
||||
std::array<Common::FixedPoint<50, 14>, 3> b{
|
||||
Common::FixedPoint<50, 14>::from_base(b_[0]),
|
||||
Common::FixedPoint<50, 14>::from_base(b_[1]),
|
||||
Common::FixedPoint<50, 14>::from_base(b_[2]),
|
||||
};
|
||||
std::array<Common::FixedPoint<50, 14>, 3> a{
|
||||
Common::FixedPoint<50, 14>::from_base(a_[0]),
|
||||
Common::FixedPoint<50, 14>::from_base(a_[1]),
|
||||
};
|
||||
|
||||
for (u32 i = 0; i < sample_count; i++) {
|
||||
const s64 in_sample{input[i]};
|
||||
const s64 sample{in_sample * b[0] + state.s0};
|
||||
const s64 out_sample{std::clamp<s64>((sample + (1 << 13)) >> 14, min, max)};
|
||||
s64 in_sample{input[i]};
|
||||
auto sample{in_sample * b[0] + state.s0};
|
||||
const auto out_sample{std::clamp(sample.to_long(), min, max)};
|
||||
|
||||
output[i] = static_cast<s32>(out_sample);
|
||||
|
||||
state.s0 = state.s1 + b[1] * in_sample + a[0] * out_sample;
|
||||
state.s1 = b[2] * in_sample + a[1] * out_sample;
|
||||
state.s1 = 0 + b[2] * in_sample + a[1] * out_sample;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -244,16 +244,16 @@ template <size_t NumChannels>
|
|||
static void ApplyI3dl2ReverbEffect(I3dl2ReverbInfo::State& state,
|
||||
std::span<std::span<const s32>> inputs,
|
||||
std::span<std::span<s32>> outputs, const u32 sample_count) {
|
||||
static constexpr std::array<u8, I3dl2ReverbInfo::MaxDelayTaps> OutTapIndexes1Ch{
|
||||
constexpr std::array<u8, I3dl2ReverbInfo::MaxDelayTaps> OutTapIndexes1Ch{
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
};
|
||||
static constexpr std::array<u8, I3dl2ReverbInfo::MaxDelayTaps> OutTapIndexes2Ch{
|
||||
constexpr std::array<u8, I3dl2ReverbInfo::MaxDelayTaps> OutTapIndexes2Ch{
|
||||
0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1,
|
||||
};
|
||||
static constexpr std::array<u8, I3dl2ReverbInfo::MaxDelayTaps> OutTapIndexes4Ch{
|
||||
constexpr std::array<u8, I3dl2ReverbInfo::MaxDelayTaps> OutTapIndexes4Ch{
|
||||
0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 1, 1, 1, 0, 0, 0, 0, 3, 3, 3,
|
||||
};
|
||||
static constexpr std::array<u8, I3dl2ReverbInfo::MaxDelayTaps> OutTapIndexes6Ch{
|
||||
constexpr std::array<u8, I3dl2ReverbInfo::MaxDelayTaps> OutTapIndexes6Ch{
|
||||
2, 0, 0, 1, 1, 1, 1, 4, 4, 4, 1, 1, 1, 0, 0, 0, 0, 5, 5, 5,
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -252,16 +252,16 @@ template <size_t NumChannels>
|
|||
static void ApplyReverbEffect(const ReverbInfo::ParameterVersion2& params, ReverbInfo::State& state,
|
||||
std::vector<std::span<const s32>>& inputs,
|
||||
std::vector<std::span<s32>>& outputs, const u32 sample_count) {
|
||||
static constexpr std::array<u8, ReverbInfo::MaxDelayTaps> OutTapIndexes1Ch{
|
||||
constexpr std::array<u8, ReverbInfo::MaxDelayTaps> OutTapIndexes1Ch{
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
};
|
||||
static constexpr std::array<u8, ReverbInfo::MaxDelayTaps> OutTapIndexes2Ch{
|
||||
constexpr std::array<u8, ReverbInfo::MaxDelayTaps> OutTapIndexes2Ch{
|
||||
0, 0, 1, 1, 0, 1, 0, 0, 1, 1,
|
||||
};
|
||||
static constexpr std::array<u8, ReverbInfo::MaxDelayTaps> OutTapIndexes4Ch{
|
||||
constexpr std::array<u8, ReverbInfo::MaxDelayTaps> OutTapIndexes4Ch{
|
||||
0, 0, 1, 1, 0, 1, 2, 2, 3, 3,
|
||||
};
|
||||
static constexpr std::array<u8, ReverbInfo::MaxDelayTaps> OutTapIndexes6Ch{
|
||||
constexpr std::array<u8, ReverbInfo::MaxDelayTaps> OutTapIndexes6Ch{
|
||||
0, 0, 1, 1, 2, 2, 4, 4, 5, 5,
|
||||
};
|
||||
|
||||
|
|
@ -308,8 +308,7 @@ static void ApplyReverbEffect(const ReverbInfo::ParameterVersion2& params, Rever
|
|||
}
|
||||
|
||||
Common::FixedPoint<50, 14> pre_delay_sample{
|
||||
state.pre_delay_line.TapOut(state.pre_delay_time) *
|
||||
Common::FixedPoint<50, 14>::from_base(params.late_gain)};
|
||||
state.pre_delay_line.Read() * Common::FixedPoint<50, 14>::from_base(params.late_gain)};
|
||||
|
||||
std::array<Common::FixedPoint<50, 14>, ReverbInfo::MaxDelayLines> mix_matrix{
|
||||
state.prev_feedback_output[2] + state.prev_feedback_output[1] + pre_delay_sample,
|
||||
|
|
|
|||
|
|
@ -19,24 +19,24 @@ namespace AudioCore::AudioRenderer {
|
|||
static void SrcProcessFrame(std::span<s32> output, std::span<const s32> input,
|
||||
const u32 target_sample_count, const u32 source_sample_count,
|
||||
UpsamplerState* state) {
|
||||
static constexpr u32 WindowSize = 10;
|
||||
static constexpr std::array<Common::FixedPoint<17, 15>, WindowSize> WindowedSinc1{
|
||||
constexpr u32 WindowSize = 10;
|
||||
constexpr std::array<Common::FixedPoint<17, 15>, WindowSize> WindowedSinc1{
|
||||
0.95376587f, -0.12872314f, 0.060028076f, -0.032470703f, 0.017669678f,
|
||||
-0.009124756f, 0.004272461f, -0.001739502f, 0.000579834f, -0.000091552734f,
|
||||
};
|
||||
static constexpr std::array<Common::FixedPoint<17, 15>, WindowSize> WindowedSinc2{
|
||||
constexpr std::array<Common::FixedPoint<17, 15>, WindowSize> WindowedSinc2{
|
||||
0.8230896f, -0.19161987f, 0.093444824f, -0.05090332f, 0.027557373f,
|
||||
-0.014038086f, 0.0064697266f, -0.002532959f, 0.00079345703f, -0.00012207031f,
|
||||
};
|
||||
static constexpr std::array<Common::FixedPoint<17, 15>, WindowSize> WindowedSinc3{
|
||||
constexpr std::array<Common::FixedPoint<17, 15>, WindowSize> WindowedSinc3{
|
||||
0.6298828f, -0.19274902f, 0.09725952f, -0.05319214f, 0.028625488f,
|
||||
-0.014373779f, 0.006500244f, -0.0024719238f, 0.0007324219f, -0.000091552734f,
|
||||
};
|
||||
static constexpr std::array<Common::FixedPoint<17, 15>, WindowSize> WindowedSinc4{
|
||||
constexpr std::array<Common::FixedPoint<17, 15>, WindowSize> WindowedSinc4{
|
||||
0.4057312f, -0.1468811f, 0.07601929f, -0.041656494f, 0.022216797f,
|
||||
-0.011016846f, 0.004852295f, -0.0017700195f, 0.00048828125f, -0.000030517578f,
|
||||
};
|
||||
static constexpr std::array<Common::FixedPoint<17, 15>, WindowSize> WindowedSinc5{
|
||||
constexpr std::array<Common::FixedPoint<17, 15>, WindowSize> WindowedSinc5{
|
||||
0.1854248f, -0.075164795f, 0.03967285f, -0.021728516f, 0.011474609f,
|
||||
-0.005584717f, 0.0024108887f, -0.0008239746f, 0.00021362305f, 0.0f,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -192,7 +192,7 @@ public:
|
|||
/**
|
||||
* Get this effect's parameter data.
|
||||
*
|
||||
* @return Pointer to the parameter, must be cast to the correct type.
|
||||
* @return Pointer to the parametter, must be cast to the correct type.
|
||||
*/
|
||||
u8* GetParameter() {
|
||||
return parameter.data();
|
||||
|
|
@ -201,7 +201,7 @@ public:
|
|||
/**
|
||||
* Get this effect's parameter data.
|
||||
*
|
||||
* @return Pointer to the parameter, must be cast to the correct type.
|
||||
* @return Pointer to the parametter, must be cast to the correct type.
|
||||
*/
|
||||
u8* GetStateBuffer() {
|
||||
return state.data();
|
||||
|
|
|
|||
|
|
@ -104,8 +104,7 @@ public:
|
|||
}
|
||||
|
||||
void Write(const Common::FixedPoint<50, 14> sample) {
|
||||
*input = sample;
|
||||
input++;
|
||||
*(input++) = sample;
|
||||
if (input >= buffer_end) {
|
||||
input = buffer.data();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -79,10 +79,12 @@ public:
|
|||
return;
|
||||
}
|
||||
sample_count = delay_time;
|
||||
input = &buffer[0];
|
||||
input = &buffer[(output - buffer.data() + sample_count) % (sample_count_max + 1)];
|
||||
}
|
||||
|
||||
Common::FixedPoint<50, 14> Tick(const Common::FixedPoint<50, 14> sample) {
|
||||
Write(sample);
|
||||
|
||||
auto out_sample{Read()};
|
||||
|
||||
output++;
|
||||
|
|
@ -90,7 +92,6 @@ public:
|
|||
output = buffer.data();
|
||||
}
|
||||
|
||||
Write(sample);
|
||||
return out_sample;
|
||||
}
|
||||
|
||||
|
|
@ -99,8 +100,7 @@ public:
|
|||
}
|
||||
|
||||
void Write(const Common::FixedPoint<50, 14> sample) {
|
||||
*input = sample;
|
||||
input++;
|
||||
*(input++) = sample;
|
||||
if (input >= buffer_end) {
|
||||
input = buffer.data();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ public:
|
|||
*/
|
||||
enum class State {
|
||||
Invalid,
|
||||
Acquired,
|
||||
Aquired,
|
||||
RequestDetach,
|
||||
Detached,
|
||||
RequestAttach,
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ bool PoolMapper::TryAttachBuffer(BehaviorInfo::ErrorInfo& error_info, AddressInf
|
|||
address_info.Setup(address, size);
|
||||
|
||||
if (!FillDspAddr(address_info)) {
|
||||
error_info.error_code = Service::Audio::ResultInvalidAddressInfo;
|
||||
error_info.error_code = Service::Audio::ERR_POOL_MAPPING_FAILED;
|
||||
error_info.address = address;
|
||||
return force_map;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ public:
|
|||
* Splitter sort, traverse the splitter node graph and sort the sorted mixes from results.
|
||||
*
|
||||
* @param splitter_context - Splitter context for the sort.
|
||||
* @return True if the sort was successful, otherwise false.
|
||||
* @return True if the sort was successful, othewise false.
|
||||
*/
|
||||
bool TSortInfo(const SplitterContext& splitter_context);
|
||||
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ struct PerformanceDetailVersion1 {
|
|||
/* 0x0D */ PerformanceEntryType entry_type;
|
||||
};
|
||||
static_assert(sizeof(PerformanceDetailVersion1) == 0x10,
|
||||
"PerformanceDetailVersion1 has the wrong size!");
|
||||
"PerformanceDetailVersion1 has the worng size!");
|
||||
|
||||
struct PerformanceDetailVersion2 {
|
||||
/* 0x00 */ u32 node_id;
|
||||
|
|
@ -45,6 +45,6 @@ struct PerformanceDetailVersion2 {
|
|||
/* 0x14 */ char unk14[0x4];
|
||||
};
|
||||
static_assert(sizeof(PerformanceDetailVersion2) == 0x18,
|
||||
"PerformanceDetailVersion2 has the wrong size!");
|
||||
"PerformanceDetailVersion2 has the worng size!");
|
||||
|
||||
} // namespace AudioCore::AudioRenderer
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ struct PerformanceEntryVersion1 {
|
|||
/* 0x0C */ PerformanceEntryType entry_type;
|
||||
};
|
||||
static_assert(sizeof(PerformanceEntryVersion1) == 0x10,
|
||||
"PerformanceEntryVersion1 has the wrong size!");
|
||||
"PerformanceEntryVersion1 has the worng size!");
|
||||
|
||||
struct PerformanceEntryVersion2 {
|
||||
/* 0x00 */ u32 node_id;
|
||||
|
|
@ -32,6 +32,6 @@ struct PerformanceEntryVersion2 {
|
|||
/* 0x0D */ char unk0D[0xB];
|
||||
};
|
||||
static_assert(sizeof(PerformanceEntryVersion2) == 0x18,
|
||||
"PerformanceEntryVersion2 has the wrong size!");
|
||||
"PerformanceEntryVersion2 has the worng size!");
|
||||
|
||||
} // namespace AudioCore::AudioRenderer
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ struct PerformanceFrameHeaderVersion1 {
|
|||
/* 0x14 */ u32 frame_index;
|
||||
};
|
||||
static_assert(sizeof(PerformanceFrameHeaderVersion1) == 0x18,
|
||||
"PerformanceFrameHeaderVersion1 has the wrong size!");
|
||||
"PerformanceFrameHeaderVersion1 has the worng size!");
|
||||
|
||||
struct PerformanceFrameHeaderVersion2 {
|
||||
/* 0x00 */ u32 magic; // "PERF"
|
||||
|
|
@ -31,6 +31,6 @@ struct PerformanceFrameHeaderVersion2 {
|
|||
/* 0x25 */ char unk25[0xB];
|
||||
};
|
||||
static_assert(sizeof(PerformanceFrameHeaderVersion2) == 0x30,
|
||||
"PerformanceFrameHeaderVersion2 has the wrong size!");
|
||||
"PerformanceFrameHeaderVersion2 has the worng size!");
|
||||
|
||||
} // namespace AudioCore::AudioRenderer
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ public:
|
|||
/**
|
||||
* Get the total number of splitter destinations.
|
||||
*
|
||||
* @return Number of destinations.
|
||||
* @return Number of destiantions.
|
||||
*/
|
||||
u32 GetDataCount() const;
|
||||
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ public:
|
|||
/**
|
||||
* Update this destination.
|
||||
*
|
||||
* @param params - Input parameters to update the destination.
|
||||
* @param params - Inpout parameters to update the destination.
|
||||
*/
|
||||
void Update(const InParameter& params);
|
||||
|
||||
|
|
@ -126,9 +126,9 @@ private:
|
|||
std::array<f32, MaxMixBuffers> prev_mix_volumes{0.0f};
|
||||
/// Next destination in the mix chain
|
||||
SplitterDestinationData* next{};
|
||||
/// Is this destination in use?
|
||||
/// Is this destiantion in use?
|
||||
bool in_use{};
|
||||
/// Does this destination need its volumes updated?
|
||||
/// Does this destiantion need its volumes updated?
|
||||
bool need_update{};
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -49,14 +49,14 @@ public:
|
|||
/**
|
||||
* Get the number of destinations in this splitter.
|
||||
*
|
||||
* @return The number of destinations.
|
||||
* @return The number of destiantions.
|
||||
*/
|
||||
u32 GetDestinationCount() const;
|
||||
|
||||
/**
|
||||
* Set the number of destinations in this splitter.
|
||||
*
|
||||
* @param count - The new number of destinations.
|
||||
* @param count - The new number of destiantions.
|
||||
*/
|
||||
void SetDestinationCount(u32 count);
|
||||
|
||||
|
|
|
|||
|
|
@ -101,15 +101,15 @@ Result System::Initialize(const AudioRendererParameterInternal& params,
|
|||
Kernel::KTransferMemory* transfer_memory, u64 transfer_memory_size,
|
||||
u32 process_handle_, u64 applet_resource_user_id_, s32 session_id_) {
|
||||
if (!CheckValidRevision(params.revision)) {
|
||||
return Service::Audio::ResultInvalidRevision;
|
||||
return Service::Audio::ERR_INVALID_REVISION;
|
||||
}
|
||||
|
||||
if (GetWorkBufferSize(params) > transfer_memory_size) {
|
||||
return Service::Audio::ResultInsufficientBuffer;
|
||||
return Service::Audio::ERR_INSUFFICIENT_BUFFER_SIZE;
|
||||
}
|
||||
|
||||
if (process_handle_ == 0) {
|
||||
return Service::Audio::ResultInvalidHandle;
|
||||
return Service::Audio::ERR_INVALID_PROCESS_HANDLE;
|
||||
}
|
||||
|
||||
behavior.SetUserLibRevision(params.revision);
|
||||
|
|
@ -127,7 +127,8 @@ Result System::Initialize(const AudioRendererParameterInternal& params,
|
|||
render_device = params.rendering_device;
|
||||
execution_mode = params.execution_mode;
|
||||
|
||||
core.ApplicationMemory().ZeroBlock(transfer_memory->GetSourceAddress(), transfer_memory_size);
|
||||
core.Memory().ZeroBlock(*core.Kernel().CurrentProcess(), transfer_memory->GetSourceAddress(),
|
||||
transfer_memory_size);
|
||||
|
||||
// Note: We're not actually using the transfer memory because it's a pain to code for.
|
||||
// Allocate the memory normally instead and hope the game doesn't try to read anything back
|
||||
|
|
@ -142,19 +143,19 @@ Result System::Initialize(const AudioRendererParameterInternal& params,
|
|||
samples_workbuffer =
|
||||
allocator.Allocate<s32>((voice_channels + mix_buffer_count) * sample_count, 0x10);
|
||||
if (samples_workbuffer.empty()) {
|
||||
return Service::Audio::ResultInsufficientBuffer;
|
||||
return Service::Audio::ERR_INSUFFICIENT_BUFFER_SIZE;
|
||||
}
|
||||
|
||||
auto upsampler_workbuffer{allocator.Allocate<s32>(
|
||||
(voice_channels + mix_buffer_count) * TargetSampleCount * upsampler_count, 0x10)};
|
||||
if (upsampler_workbuffer.empty()) {
|
||||
return Service::Audio::ResultInsufficientBuffer;
|
||||
return Service::Audio::ERR_INSUFFICIENT_BUFFER_SIZE;
|
||||
}
|
||||
|
||||
depop_buffer =
|
||||
allocator.Allocate<s32>(Common::AlignUp(static_cast<u32>(mix_buffer_count), 0x40), 0x40);
|
||||
if (depop_buffer.empty()) {
|
||||
return Service::Audio::ResultInsufficientBuffer;
|
||||
return Service::Audio::ERR_INSUFFICIENT_BUFFER_SIZE;
|
||||
}
|
||||
|
||||
// invalidate samples_workbuffer DSP cache
|
||||
|
|
@ -165,12 +166,12 @@ Result System::Initialize(const AudioRendererParameterInternal& params,
|
|||
}
|
||||
|
||||
if (voice_infos.empty()) {
|
||||
return Service::Audio::ResultInsufficientBuffer;
|
||||
return Service::Audio::ERR_INSUFFICIENT_BUFFER_SIZE;
|
||||
}
|
||||
|
||||
auto sorted_voice_infos{allocator.Allocate<VoiceInfo*>(params.voices, 0x10)};
|
||||
if (sorted_voice_infos.empty()) {
|
||||
return Service::Audio::ResultInsufficientBuffer;
|
||||
return Service::Audio::ERR_INSUFFICIENT_BUFFER_SIZE;
|
||||
}
|
||||
|
||||
std::memset(sorted_voice_infos.data(), 0, sorted_voice_infos.size_bytes());
|
||||
|
|
@ -182,12 +183,12 @@ Result System::Initialize(const AudioRendererParameterInternal& params,
|
|||
}
|
||||
|
||||
if (voice_channel_resources.empty()) {
|
||||
return Service::Audio::ResultInsufficientBuffer;
|
||||
return Service::Audio::ERR_INSUFFICIENT_BUFFER_SIZE;
|
||||
}
|
||||
|
||||
auto voice_cpu_states{allocator.Allocate<VoiceState>(params.voices, 0x10)};
|
||||
if (voice_cpu_states.empty()) {
|
||||
return Service::Audio::ResultInsufficientBuffer;
|
||||
return Service::Audio::ERR_INSUFFICIENT_BUFFER_SIZE;
|
||||
}
|
||||
|
||||
for (auto& voice_state : voice_cpu_states) {
|
||||
|
|
@ -197,7 +198,7 @@ Result System::Initialize(const AudioRendererParameterInternal& params,
|
|||
auto mix_infos{allocator.Allocate<MixInfo>(params.sub_mixes + 1, 0x10)};
|
||||
|
||||
if (mix_infos.empty()) {
|
||||
return Service::Audio::ResultInsufficientBuffer;
|
||||
return Service::Audio::ERR_INSUFFICIENT_BUFFER_SIZE;
|
||||
}
|
||||
|
||||
u32 effect_process_order_count{0};
|
||||
|
|
@ -207,7 +208,7 @@ Result System::Initialize(const AudioRendererParameterInternal& params,
|
|||
effect_process_order_count = params.effects * (params.sub_mixes + 1);
|
||||
effect_process_order_buffer = allocator.Allocate<s32>(effect_process_order_count, 0x10);
|
||||
if (effect_process_order_buffer.empty()) {
|
||||
return Service::Audio::ResultInsufficientBuffer;
|
||||
return Service::Audio::ERR_INSUFFICIENT_BUFFER_SIZE;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -221,7 +222,7 @@ Result System::Initialize(const AudioRendererParameterInternal& params,
|
|||
|
||||
auto sorted_mix_infos{allocator.Allocate<MixInfo*>(params.sub_mixes + 1, 0x10)};
|
||||
if (sorted_mix_infos.empty()) {
|
||||
return Service::Audio::ResultInsufficientBuffer;
|
||||
return Service::Audio::ERR_INSUFFICIENT_BUFFER_SIZE;
|
||||
}
|
||||
|
||||
std::memset(sorted_mix_infos.data(), 0, sorted_mix_infos.size_bytes());
|
||||
|
|
@ -234,7 +235,7 @@ Result System::Initialize(const AudioRendererParameterInternal& params,
|
|||
auto edge_matrix_workbuffer{allocator.Allocate<u8>(edge_matrix_size, 1)};
|
||||
|
||||
if (node_states_workbuffer.empty() || edge_matrix_workbuffer.size() == 0) {
|
||||
return Service::Audio::ResultInsufficientBuffer;
|
||||
return Service::Audio::ERR_INSUFFICIENT_BUFFER_SIZE;
|
||||
}
|
||||
|
||||
mix_context.Initialize(sorted_mix_infos, mix_infos, params.sub_mixes + 1,
|
||||
|
|
@ -249,7 +250,7 @@ Result System::Initialize(const AudioRendererParameterInternal& params,
|
|||
|
||||
upsampler_manager = allocator.Allocate<UpsamplerManager>(1, 0x10).data();
|
||||
if (upsampler_manager == nullptr) {
|
||||
return Service::Audio::ResultInsufficientBuffer;
|
||||
return Service::Audio::ERR_INSUFFICIENT_BUFFER_SIZE;
|
||||
}
|
||||
|
||||
memory_pool_workbuffer = allocator.Allocate<MemoryPoolInfo>(memory_pool_count, 0x10);
|
||||
|
|
@ -258,18 +259,18 @@ Result System::Initialize(const AudioRendererParameterInternal& params,
|
|||
}
|
||||
|
||||
if (memory_pool_workbuffer.empty() && memory_pool_count > 0) {
|
||||
return Service::Audio::ResultInsufficientBuffer;
|
||||
return Service::Audio::ERR_INSUFFICIENT_BUFFER_SIZE;
|
||||
}
|
||||
|
||||
if (!splitter_context.Initialize(behavior, params, allocator)) {
|
||||
return Service::Audio::ResultInsufficientBuffer;
|
||||
return Service::Audio::ERR_INSUFFICIENT_BUFFER_SIZE;
|
||||
}
|
||||
|
||||
std::span<EffectResultState> effect_result_states_cpu{};
|
||||
if (behavior.IsEffectInfoVersion2Supported() && params.effects > 0) {
|
||||
effect_result_states_cpu = allocator.Allocate<EffectResultState>(params.effects, 0x10);
|
||||
if (effect_result_states_cpu.empty()) {
|
||||
return Service::Audio::ResultInsufficientBuffer;
|
||||
return Service::Audio::ERR_INSUFFICIENT_BUFFER_SIZE;
|
||||
}
|
||||
std::memset(effect_result_states_cpu.data(), 0, effect_result_states_cpu.size_bytes());
|
||||
}
|
||||
|
|
@ -288,7 +289,7 @@ Result System::Initialize(const AudioRendererParameterInternal& params,
|
|||
upsampler_workbuffer);
|
||||
|
||||
if (upsampler_infos.empty()) {
|
||||
return Service::Audio::ResultInsufficientBuffer;
|
||||
return Service::Audio::ERR_INSUFFICIENT_BUFFER_SIZE;
|
||||
}
|
||||
|
||||
auto effect_infos{allocator.Allocate<EffectInfoBase>(params.effects, 0x40)};
|
||||
|
|
@ -297,14 +298,14 @@ Result System::Initialize(const AudioRendererParameterInternal& params,
|
|||
}
|
||||
|
||||
if (effect_infos.empty() && params.effects > 0) {
|
||||
return Service::Audio::ResultInsufficientBuffer;
|
||||
return Service::Audio::ERR_INSUFFICIENT_BUFFER_SIZE;
|
||||
}
|
||||
|
||||
std::span<EffectResultState> effect_result_states_dsp{};
|
||||
if (behavior.IsEffectInfoVersion2Supported() && params.effects > 0) {
|
||||
effect_result_states_dsp = allocator.Allocate<EffectResultState>(params.effects, 0x40);
|
||||
if (effect_result_states_dsp.empty()) {
|
||||
return Service::Audio::ResultInsufficientBuffer;
|
||||
return Service::Audio::ERR_INSUFFICIENT_BUFFER_SIZE;
|
||||
}
|
||||
std::memset(effect_result_states_dsp.data(), 0, effect_result_states_dsp.size_bytes());
|
||||
}
|
||||
|
|
@ -318,14 +319,14 @@ Result System::Initialize(const AudioRendererParameterInternal& params,
|
|||
}
|
||||
|
||||
if (sinks.empty()) {
|
||||
return Service::Audio::ResultInsufficientBuffer;
|
||||
return Service::Audio::ERR_INSUFFICIENT_BUFFER_SIZE;
|
||||
}
|
||||
|
||||
sink_context.Initialize(sinks, params.sinks);
|
||||
|
||||
auto voice_dsp_states{allocator.Allocate<VoiceState>(params.voices, 0x40)};
|
||||
if (voice_dsp_states.empty()) {
|
||||
return Service::Audio::ResultInsufficientBuffer;
|
||||
return Service::Audio::ERR_INSUFFICIENT_BUFFER_SIZE;
|
||||
}
|
||||
|
||||
for (auto& voice_state : voice_dsp_states) {
|
||||
|
|
@ -343,7 +344,7 @@ Result System::Initialize(const AudioRendererParameterInternal& params,
|
|||
0xC};
|
||||
performance_workbuffer = allocator.Allocate<u8>(perf_workbuffer_size, 0x40);
|
||||
if (performance_workbuffer.empty()) {
|
||||
return Service::Audio::ResultInsufficientBuffer;
|
||||
return Service::Audio::ERR_INSUFFICIENT_BUFFER_SIZE;
|
||||
}
|
||||
std::memset(performance_workbuffer.data(), 0, performance_workbuffer.size_bytes());
|
||||
performance_manager.Initialize(performance_workbuffer, performance_workbuffer.size_bytes(),
|
||||
|
|
@ -359,7 +360,7 @@ Result System::Initialize(const AudioRendererParameterInternal& params,
|
|||
command_workbuffer_size = allocator.GetRemainingSize();
|
||||
command_workbuffer = allocator.Allocate<u8>(command_workbuffer_size, 0x40);
|
||||
if (command_workbuffer.empty()) {
|
||||
return Service::Audio::ResultInsufficientBuffer;
|
||||
return Service::Audio::ERR_INSUFFICIENT_BUFFER_SIZE;
|
||||
}
|
||||
|
||||
command_buffer_size = 0;
|
||||
|
|
@ -436,7 +437,10 @@ void System::Stop() {
|
|||
}
|
||||
|
||||
if (execution_mode == ExecutionMode::Auto) {
|
||||
terminate_event.Wait();
|
||||
// Should wait for the system to terminate here, but core timing (should have) already
|
||||
// stopped, so this isn't needed. Find a way to make this definite.
|
||||
|
||||
// terminate_event.Wait();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -154,7 +154,7 @@ public:
|
|||
ExecutionMode GetExecutionMode() const;
|
||||
|
||||
/**
|
||||
* Get the rendering device for this system.
|
||||
* Get the rendering deivce for this system.
|
||||
* This is unused.
|
||||
*
|
||||
* @return Rendering device for this system.
|
||||
|
|
@ -241,7 +241,7 @@ private:
|
|||
std::span<u8> command_workbuffer{};
|
||||
/// Size of command workbuffer
|
||||
u64 command_workbuffer_size{};
|
||||
/// Number of commands in the workbuffer
|
||||
/// Numebr of commands in the workbuffer
|
||||
u64 command_buffer_size{};
|
||||
/// Manager for upsamplers
|
||||
UpsamplerManager* upsampler_manager{};
|
||||
|
|
|
|||
|
|
@ -15,9 +15,14 @@ MICROPROFILE_DEFINE(Audio_RenderSystemManager, "Audio", "Render System Manager",
|
|||
MP_RGB(60, 19, 97));
|
||||
|
||||
namespace AudioCore::AudioRenderer {
|
||||
constexpr std::chrono::nanoseconds RENDER_TIME{5'000'000UL};
|
||||
|
||||
SystemManager::SystemManager(Core::System& core_)
|
||||
: core{core_}, adsp{core.AudioCore().GetADSP()}, mailbox{adsp.GetRenderMailbox()} {}
|
||||
: core{core_}, adsp{core.AudioCore().GetADSP()}, mailbox{adsp.GetRenderMailbox()},
|
||||
thread_event{Core::Timing::CreateEvent(
|
||||
"AudioRendererSystemManager", [this](std::uintptr_t, s64 time, std::chrono::nanoseconds) {
|
||||
return ThreadFunc2(time);
|
||||
})} {}
|
||||
|
||||
SystemManager::~SystemManager() {
|
||||
Stop();
|
||||
|
|
@ -27,7 +32,9 @@ bool SystemManager::InitializeUnsafe() {
|
|||
if (!active) {
|
||||
if (adsp.Start()) {
|
||||
active = true;
|
||||
thread = std::jthread([this](std::stop_token stop_token) { ThreadFunc(stop_token); });
|
||||
thread = std::jthread([this](std::stop_token stop_token) { ThreadFunc(); });
|
||||
core.CoreTiming().ScheduleLoopingEvent(std::chrono::nanoseconds(0), RENDER_TIME,
|
||||
thread_event);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -38,8 +45,10 @@ void SystemManager::Stop() {
|
|||
if (!active) {
|
||||
return;
|
||||
}
|
||||
core.CoreTiming().UnscheduleEvent(thread_event, {});
|
||||
active = false;
|
||||
thread.request_stop();
|
||||
update.store(true);
|
||||
update.notify_all();
|
||||
thread.join();
|
||||
adsp.Stop();
|
||||
}
|
||||
|
|
@ -84,12 +93,12 @@ bool SystemManager::Remove(System& system_) {
|
|||
return true;
|
||||
}
|
||||
|
||||
void SystemManager::ThreadFunc(std::stop_token stop_token) {
|
||||
static constexpr char name[]{"AudioRenderSystemManager"};
|
||||
void SystemManager::ThreadFunc() {
|
||||
constexpr char name[]{"AudioRenderSystemManager"};
|
||||
MicroProfileOnThreadCreate(name);
|
||||
Common::SetCurrentThreadName(name);
|
||||
Common::SetCurrentThreadPriority(Common::ThreadPriority::High);
|
||||
while (active && !stop_token.stop_requested()) {
|
||||
while (active) {
|
||||
{
|
||||
std::scoped_lock l{mutex1};
|
||||
|
||||
|
|
@ -102,7 +111,16 @@ void SystemManager::ThreadFunc(std::stop_token stop_token) {
|
|||
|
||||
adsp.Signal();
|
||||
adsp.Wait();
|
||||
|
||||
update.wait(false);
|
||||
update.store(false);
|
||||
}
|
||||
}
|
||||
|
||||
std::optional<std::chrono::nanoseconds> SystemManager::ThreadFunc2(s64 time) {
|
||||
update.store(true);
|
||||
update.notify_all();
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
} // namespace AudioCore::AudioRenderer
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ public:
|
|||
/**
|
||||
* Initialize the system manager, called when any system is registered.
|
||||
*
|
||||
* @return True if successfully initialized, otherwise false.
|
||||
* @return True if sucessfully initialized, otherwise false.
|
||||
*/
|
||||
bool InitializeUnsafe();
|
||||
|
||||
|
|
@ -50,7 +50,7 @@ public:
|
|||
* The manager does not own the system, so do not free it without calling Remove.
|
||||
*
|
||||
* @param system - The system to add.
|
||||
* @return True if successfully added, otherwise false.
|
||||
* @return True if succesfully added, otherwise false.
|
||||
*/
|
||||
bool Add(System& system);
|
||||
|
||||
|
|
@ -58,7 +58,7 @@ public:
|
|||
* Remove an audio render system from the manager.
|
||||
*
|
||||
* @param system - The system to remove.
|
||||
* @return True if successfully removed, otherwise false.
|
||||
* @return True if succesfully removed, otherwise false.
|
||||
*/
|
||||
bool Remove(System& system);
|
||||
|
||||
|
|
@ -66,7 +66,18 @@ private:
|
|||
/**
|
||||
* Main thread responsible for command generation.
|
||||
*/
|
||||
void ThreadFunc(std::stop_token stop_token);
|
||||
void ThreadFunc();
|
||||
|
||||
/**
|
||||
* Signalling core timing thread to run ThreadFunc.
|
||||
*/
|
||||
std::optional<std::chrono::nanoseconds> ThreadFunc2(s64 time);
|
||||
|
||||
enum class StreamState {
|
||||
Filling,
|
||||
Steady,
|
||||
Draining,
|
||||
};
|
||||
|
||||
/// Core system
|
||||
Core::System& core;
|
||||
|
|
@ -84,6 +95,10 @@ private:
|
|||
ADSP::ADSP& adsp;
|
||||
/// AudioRenderer mailbox for communication
|
||||
ADSP::AudioRenderer_Mailbox* mailbox{};
|
||||
/// Core timing event to signal main thread
|
||||
std::shared_ptr<Core::Timing::EventType> thread_event;
|
||||
/// Atomic for main thread to wait on
|
||||
std::atomic<bool> update{};
|
||||
};
|
||||
|
||||
} // namespace AudioCore::AudioRenderer
|
||||
|
|
|
|||
|
|
@ -181,7 +181,7 @@ void VoiceInfo::UpdateWaveBuffer(std::span<BehaviorInfo::ErrorInfo> error_info,
|
|||
if (wave_buffer_internal.start_offset * byte_size > wave_buffer_internal.size ||
|
||||
wave_buffer_internal.end_offset * byte_size > wave_buffer_internal.size) {
|
||||
LOG_ERROR(Service_Audio, "Invalid PCM16 start/end wavebuffer sizes!");
|
||||
error_info[0].error_code = Service::Audio::ResultInvalidUpdateInfo;
|
||||
error_info[0].error_code = Service::Audio::ERR_INVALID_UPDATE_DATA;
|
||||
error_info[0].address = wave_buffer_internal.address;
|
||||
return;
|
||||
}
|
||||
|
|
@ -192,7 +192,7 @@ void VoiceInfo::UpdateWaveBuffer(std::span<BehaviorInfo::ErrorInfo> error_info,
|
|||
if (wave_buffer_internal.start_offset * byte_size > wave_buffer_internal.size ||
|
||||
wave_buffer_internal.end_offset * byte_size > wave_buffer_internal.size) {
|
||||
LOG_ERROR(Service_Audio, "Invalid PCMFloat start/end wavebuffer sizes!");
|
||||
error_info[0].error_code = Service::Audio::ResultInvalidUpdateInfo;
|
||||
error_info[0].error_code = Service::Audio::ERR_INVALID_UPDATE_DATA;
|
||||
error_info[0].address = wave_buffer_internal.address;
|
||||
return;
|
||||
}
|
||||
|
|
@ -216,7 +216,7 @@ void VoiceInfo::UpdateWaveBuffer(std::span<BehaviorInfo::ErrorInfo> error_info,
|
|||
if (start > static_cast<s64>(wave_buffer_internal.size) ||
|
||||
end > static_cast<s64>(wave_buffer_internal.size)) {
|
||||
LOG_ERROR(Service_Audio, "Invalid ADPCM start/end wavebuffer sizes!");
|
||||
error_info[0].error_code = Service::Audio::ResultInvalidUpdateInfo;
|
||||
error_info[0].error_code = Service::Audio::ERR_INVALID_UPDATE_DATA;
|
||||
error_info[0].address = wave_buffer_internal.address;
|
||||
return;
|
||||
}
|
||||
|
|
@ -228,7 +228,7 @@ void VoiceInfo::UpdateWaveBuffer(std::span<BehaviorInfo::ErrorInfo> error_info,
|
|||
|
||||
if (wave_buffer_internal.start_offset < 0 || wave_buffer_internal.end_offset < 0) {
|
||||
LOG_ERROR(Service_Audio, "Invalid input start/end wavebuffer sizes!");
|
||||
error_info[0].error_code = Service::Audio::ResultInvalidUpdateInfo;
|
||||
error_info[0].error_code = Service::Audio::ERR_INVALID_UPDATE_DATA;
|
||||
error_info[0].address = wave_buffer_internal.address;
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -183,7 +183,7 @@ public:
|
|||
void Initialize();
|
||||
|
||||
/**
|
||||
* Does this voice need an update?
|
||||
* Does this voice ned an update?
|
||||
*
|
||||
* @param params - Input parameters to check matching.
|
||||
*
|
||||
|
|
@ -236,7 +236,7 @@ public:
|
|||
*
|
||||
* @param error_info - Output array of errors.
|
||||
* @param wave_buffer - The wavebuffer to be updated.
|
||||
* @param wave_buffer_internal - Input parameters to be used for the update.
|
||||
* @param wave_buffer_internal - Input parametters to be used for the update.
|
||||
* @param sample_format - Sample format of the wavebuffer.
|
||||
* @param valid - Is this wavebuffer valid?
|
||||
* @param pool_mapper - Used to map the wavebuffers.
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue