early-access version 3428

This commit is contained in:
pineappleEA 2023-03-01 16:26:39 +01:00
parent 9495ebb1c2
commit 4475cfff27
59 changed files with 9658 additions and 8374 deletions

View file

@ -56,6 +56,8 @@ option(YUZU_USE_BUNDLED_VCPKG "Use vcpkg for yuzu dependencies" "${MSVC}")
option(YUZU_CHECK_SUBMODULES "Check if submodules are present" ON) 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) CMAKE_DEPENDENT_OPTION(YUZU_USE_FASTER_LD "Check if a faster linker is available" ON "NOT WIN32" OFF)
if (YUZU_USE_BUNDLED_VCPKG) if (YUZU_USE_BUNDLED_VCPKG)
@ -65,6 +67,9 @@ if (YUZU_USE_BUNDLED_VCPKG)
if (YUZU_CRASH_DUMPS) if (YUZU_CRASH_DUMPS)
list(APPEND VCPKG_MANIFEST_FEATURES "dbghelp") list(APPEND VCPKG_MANIFEST_FEATURES "dbghelp")
endif() endif()
if (ENABLE_WEB_SERVICE)
list(APPEND VCPKG_MANIFEST_FEATURES "web-service")
endif()
include(${CMAKE_SOURCE_DIR}/externals/vcpkg/scripts/buildsystems/vcpkg.cmake) include(${CMAKE_SOURCE_DIR}/externals/vcpkg/scripts/buildsystems/vcpkg.cmake)
elseif(NOT "$ENV{VCPKG_TOOLCHAIN_FILE}" STREQUAL "") elseif(NOT "$ENV{VCPKG_TOOLCHAIN_FILE}" STREQUAL "")
@ -205,10 +210,11 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin)
# ======================================================================= # =======================================================================
# Enforce the search mode of non-required packages for better and shorter failure messages # Enforce the search mode of non-required packages for better and shorter failure messages
find_package(Boost 1.73.0 REQUIRED context)
find_package(enet 1.3 MODULE) find_package(enet 1.3 MODULE)
find_package(fmt 9 REQUIRED) find_package(fmt 9 REQUIRED)
find_package(inih MODULE) find_package(inih 52 MODULE COMPONENTS INIReader)
find_package(LLVM MODULE) find_package(LLVM MODULE COMPONENTS Demangle)
find_package(lz4 REQUIRED) find_package(lz4 REQUIRED)
find_package(nlohmann_json 3.8 REQUIRED) find_package(nlohmann_json 3.8 REQUIRED)
find_package(Opus 1.3 MODULE) find_package(Opus 1.3 MODULE)
@ -241,29 +247,13 @@ endif()
if (ENABLE_WEB_SERVICE) if (ENABLE_WEB_SERVICE)
find_package(cpp-jwt 1.4 CONFIG) find_package(cpp-jwt 1.4 CONFIG)
find_package(httplib 0.12 MODULE) find_package(httplib 0.12 MODULE COMPONENTS OpenSSL)
if (NOT cpp-jwt_FOUND OR NOT httplib_FOUND)
find_package(OpenSSL 1.1 MODULE COMPONENTS Crypto SSL)
endif()
endif() endif()
if (YUZU_TESTS) if (YUZU_TESTS)
find_package(Catch2 3.0.1 REQUIRED) find_package(Catch2 3.0.1 REQUIRED)
endif() 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 # boost:asio has functions that require AcceptEx et al
if (MINGW) if (MINGW)
find_library(MSWSOCK_LIBRARY mswsock REQUIRED) find_library(MSWSOCK_LIBRARY mswsock REQUIRED)
@ -460,14 +450,6 @@ if (ENABLE_SDL2)
endif() endif()
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 # List of all FFmpeg components required
set(FFmpeg_COMPONENTS set(FFmpeg_COMPONENTS
avcodec avcodec
@ -583,11 +565,7 @@ function(create_target_directory_groups target_name)
endfunction() endfunction()
# Prevent boost from linking against libs when building # Prevent boost from linking against libs when building
add_definitions(-DBOOST_ERROR_CODE_HEADER_ONLY target_link_libraries(Boost::headers INTERFACE Boost::disable_autolinking)
-DBOOST_SYSTEM_NO_LIB
-DBOOST_DATE_TIME_NO_LIB
-DBOOST_REGEX_NO_LIB
)
# Adjustments for MSVC + Ninja # Adjustments for MSVC + Ninja
if (MSVC AND CMAKE_GENERATOR STREQUAL "Ninja") if (MSVC AND CMAKE_GENERATOR STREQUAL "Ninja")
add_compile_options( add_compile_options(

View file

@ -2,15 +2,25 @@
# #
# SPDX-License-Identifier: GPL-3.0-or-later # SPDX-License-Identifier: GPL-3.0-or-later
find_package(LLVM QUIET CONFIG) 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()
include(FindPackageHandleStandardArgs) include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(LLVM CONFIG_MODE) find_package_handle_standard_args(LLVM HANDLE_COMPONENTS CONFIG_MODE)
if (LLVM_FOUND AND NOT TARGET LLVM::Demangle) if (LLVM_FOUND AND LLVM_Demangle_FOUND AND NOT TARGET LLVM::Demangle)
add_library(LLVM::Demangle INTERFACE IMPORTED) add_library(LLVM::Demangle INTERFACE IMPORTED)
llvm_map_components_to_libnames(LLVM_LIBRARIES demangle)
target_compile_definitions(LLVM::Demangle INTERFACE ${LLVM_DEFINITIONS}) target_compile_definitions(LLVM::Demangle INTERFACE ${LLVM_DEFINITIONS})
target_include_directories(LLVM::Demangle INTERFACE ${LLVM_INCLUDE_DIRS}) 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}) target_link_libraries(LLVM::Demangle INTERFACE ${LLVM_LIBRARIES})
endif() endif()

View file

@ -6,13 +6,23 @@ include(FindPackageHandleStandardArgs)
find_package(httplib QUIET CONFIG) find_package(httplib QUIET CONFIG)
if (httplib_CONSIDERED_CONFIGS) if (httplib_CONSIDERED_CONFIGS)
find_package_handle_standard_args(httplib CONFIG_MODE) find_package_handle_standard_args(httplib HANDLE_COMPONENTS CONFIG_MODE)
else() else()
find_package(PkgConfig QUIET) find_package(PkgConfig QUIET)
pkg_search_module(HTTPLIB QUIET IMPORTED_TARGET cpp-httplib) 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 find_package_handle_standard_args(httplib
REQUIRED_VARS HTTPLIB_INCLUDEDIR REQUIRED_VARS HTTPLIB_INCLUDEDIR
VERSION_VAR HTTPLIB_VERSION VERSION_VAR HTTPLIB_VERSION
HANDLE_COMPONENTS
) )
endif() endif()

View file

@ -3,14 +3,25 @@
# SPDX-License-Identifier: GPL-3.0-or-later # SPDX-License-Identifier: GPL-3.0-or-later
find_package(PkgConfig QUIET) find_package(PkgConfig QUIET)
pkg_search_module(INIREADER QUIET IMPORTED_TARGET INIReader) 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()
include(FindPackageHandleStandardArgs) include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(inih find_package_handle_standard_args(inih
REQUIRED_VARS INIREADER_LINK_LIBRARIES REQUIRED_VARS INIH_LINK_LIBRARIES
VERSION_VAR INIREADER_VERSION VERSION_VAR INIH_VERSION
HANDLE_COMPONENTS
) )
if (inih_FOUND AND NOT TARGET inih::INIReader) 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)
add_library(inih::INIReader ALIAS PkgConfig::INIREADER) add_library(inih::INIReader ALIAS PkgConfig::INIREADER)
endif() endif()

View file

@ -1,7 +1,7 @@
yuzu emulator early access yuzu emulator early access
============= =============
This is the source code for early-access 3419. This is the source code for early-access 3428.
## Legal Notice ## Legal Notice

741
dist/languages/ca.ts vendored

File diff suppressed because it is too large Load diff

743
dist/languages/cs.ts vendored

File diff suppressed because it is too large Load diff

739
dist/languages/da.ts vendored

File diff suppressed because it is too large Load diff

741
dist/languages/de.ts vendored

File diff suppressed because it is too large Load diff

741
dist/languages/el.ts vendored

File diff suppressed because it is too large Load diff

741
dist/languages/es.ts vendored

File diff suppressed because it is too large Load diff

849
dist/languages/fr.ts vendored

File diff suppressed because it is too large Load diff

739
dist/languages/id.ts vendored

File diff suppressed because it is too large Load diff

815
dist/languages/it.ts vendored

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

741
dist/languages/nb.ts vendored

File diff suppressed because it is too large Load diff

743
dist/languages/nl.ts vendored

File diff suppressed because it is too large Load diff

741
dist/languages/pl.ts vendored

File diff suppressed because it is too large Load diff

1171
dist/languages/pt_BR.ts vendored

File diff suppressed because it is too large Load diff

1171
dist/languages/pt_PT.ts vendored

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

745
dist/languages/sv.ts vendored

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

805
dist/languages/uk.ts vendored

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -100,41 +100,18 @@ endif()
# Sirit # Sirit
add_subdirectory(sirit EXCLUDE_FROM_ALL) add_subdirectory(sirit EXCLUDE_FROM_ALL)
# LibreSSL
if (ENABLE_WEB_SERVICE AND DEFINED OPENSSL_FOUND)
if (WIN32 OR NOT OPENSSL_FOUND)
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)
else()
set(OPENSSL_LIBRARIES OpenSSL::SSL OpenSSL::Crypto)
endif()
endif()
# httplib # httplib
if (ENABLE_WEB_SERVICE AND NOT TARGET httplib::httplib) if (ENABLE_WEB_SERVICE AND NOT TARGET httplib::httplib)
add_library(httplib INTERFACE) set(HTTPLIB_REQUIRE_OPENSSL ON)
target_include_directories(httplib INTERFACE ./cpp-httplib) add_subdirectory(cpp-httplib EXCLUDE_FROM_ALL)
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() endif()
# cpp-jwt # cpp-jwt
if (ENABLE_WEB_SERVICE AND NOT TARGET cpp-jwt::cpp-jwt) if (ENABLE_WEB_SERVICE AND NOT TARGET cpp-jwt::cpp-jwt)
add_library(cpp-jwt INTERFACE) set(CPP_JWT_BUILD_EXAMPLES OFF)
target_include_directories(cpp-jwt INTERFACE ./cpp-jwt/include) set(CPP_JWT_BUILD_TESTS OFF)
target_compile_definitions(cpp-jwt INTERFACE CPP_JWT_USE_VENDORED_NLOHMANN_JSON) set(CPP_JWT_USE_VENDORED_NLOHMANN_JSON OFF)
target_link_libraries(cpp-jwt INTERFACE ${OPENSSL_LIBRARIES}) add_subdirectory(cpp-jwt EXCLUDE_FROM_ALL)
add_library(cpp-jwt::cpp-jwt ALIAS cpp-jwt)
endif() endif()
# Opus # Opus

View file

@ -176,7 +176,7 @@ endif()
create_target_directory_groups(common) create_target_directory_groups(common)
target_link_libraries(common PUBLIC ${Boost_LIBRARIES} fmt::fmt microprofile Threads::Threads) target_link_libraries(common PUBLIC Boost::context Boost::headers fmt::fmt microprofile Threads::Threads)
target_link_libraries(common PRIVATE lz4::lz4 zstd::zstd LLVM::Demangle) target_link_libraries(common PRIVATE lz4::lz4 zstd::zstd LLVM::Demangle)
if (YUZU_USE_PRECOMPILED_HEADERS) if (YUZU_USE_PRECOMPILED_HEADERS)

View file

@ -834,7 +834,7 @@ endif()
create_target_directory_groups(core) create_target_directory_groups(core)
target_link_libraries(core PUBLIC common PRIVATE audio_core network video_core) target_link_libraries(core PUBLIC common PRIVATE audio_core network video_core)
target_link_libraries(core PUBLIC Boost::boost PRIVATE fmt::fmt nlohmann_json::nlohmann_json mbedtls Opus::opus) target_link_libraries(core PUBLIC Boost::headers PRIVATE fmt::fmt nlohmann_json::nlohmann_json mbedtls Opus::opus)
if (MINGW) if (MINGW)
target_link_libraries(core PRIVATE ${MSWSOCK_LIBRARY}) target_link_libraries(core PRIVATE ${MSWSOCK_LIBRARY})
endif() endif()
@ -863,3 +863,7 @@ endif()
if (YUZU_USE_PRECOMPILED_HEADERS) if (YUZU_USE_PRECOMPILED_HEADERS)
target_precompile_headers(core PRIVATE precompiled_headers.h) target_precompile_headers(core PRIVATE precompiled_headers.h)
endif() endif()
if (YUZU_ENABLE_LTO)
set_property(TARGET core PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
endif()

View file

@ -1265,9 +1265,8 @@ void ILibraryAppletCreator::CreateTransferMemoryStorage(Kernel::HLERequestContex
return; return;
} }
const u8* const mem_begin = system.Memory().GetPointer(transfer_mem->GetSourceAddress()); std::vector<u8> memory(transfer_mem->GetSize());
const u8* const mem_end = mem_begin + transfer_mem->GetSize(); system.Memory().ReadBlock(transfer_mem->GetSourceAddress(), memory.data(), memory.size());
std::vector<u8> memory{mem_begin, mem_end};
IPC::ResponseBuilder rb{ctx, 2, 0, 1}; IPC::ResponseBuilder rb{ctx, 2, 0, 1};
rb.Push(ResultSuccess); rb.Push(ResultSuccess);
@ -1299,9 +1298,8 @@ void ILibraryAppletCreator::CreateHandleStorage(Kernel::HLERequestContext& ctx)
return; return;
} }
const u8* const mem_begin = system.Memory().GetPointer(transfer_mem->GetSourceAddress()); std::vector<u8> memory(transfer_mem->GetSize());
const u8* const mem_end = mem_begin + transfer_mem->GetSize(); system.Memory().ReadBlock(transfer_mem->GetSourceAddress(), memory.data(), memory.size());
std::vector<u8> memory{mem_begin, mem_end};
IPC::ResponseBuilder rb{ctx, 2, 0, 1}; IPC::ResponseBuilder rb{ctx, 2, 0, 1};
rb.Push(ResultSuccess); rb.Push(ResultSuccess);

View file

@ -73,32 +73,36 @@ private:
void AcquireBleScanEvent(Kernel::HLERequestContext& ctx) { void AcquireBleScanEvent(Kernel::HLERequestContext& ctx) {
LOG_WARNING(Service_BTM, "(STUBBED) called"); LOG_WARNING(Service_BTM, "(STUBBED) called");
IPC::ResponseBuilder rb{ctx, 2, 1}; IPC::ResponseBuilder rb{ctx, 3, 1};
rb.Push(ResultSuccess); rb.Push(ResultSuccess);
rb.Push(true);
rb.PushCopyObjects(scan_event->GetReadableEvent()); rb.PushCopyObjects(scan_event->GetReadableEvent());
} }
void AcquireBleConnectionEvent(Kernel::HLERequestContext& ctx) { void AcquireBleConnectionEvent(Kernel::HLERequestContext& ctx) {
LOG_WARNING(Service_BTM, "(STUBBED) called"); LOG_WARNING(Service_BTM, "(STUBBED) called");
IPC::ResponseBuilder rb{ctx, 2, 1}; IPC::ResponseBuilder rb{ctx, 3, 1};
rb.Push(ResultSuccess); rb.Push(ResultSuccess);
rb.Push(true);
rb.PushCopyObjects(connection_event->GetReadableEvent()); rb.PushCopyObjects(connection_event->GetReadableEvent());
} }
void AcquireBleServiceDiscoveryEvent(Kernel::HLERequestContext& ctx) { void AcquireBleServiceDiscoveryEvent(Kernel::HLERequestContext& ctx) {
LOG_WARNING(Service_BTM, "(STUBBED) called"); LOG_WARNING(Service_BTM, "(STUBBED) called");
IPC::ResponseBuilder rb{ctx, 2, 1}; IPC::ResponseBuilder rb{ctx, 3, 1};
rb.Push(ResultSuccess); rb.Push(ResultSuccess);
rb.Push(true);
rb.PushCopyObjects(service_discovery_event->GetReadableEvent()); rb.PushCopyObjects(service_discovery_event->GetReadableEvent());
} }
void AcquireBleMtuConfigEvent(Kernel::HLERequestContext& ctx) { void AcquireBleMtuConfigEvent(Kernel::HLERequestContext& ctx) {
LOG_WARNING(Service_BTM, "(STUBBED) called"); LOG_WARNING(Service_BTM, "(STUBBED) called");
IPC::ResponseBuilder rb{ctx, 2, 1}; IPC::ResponseBuilder rb{ctx, 3, 1};
rb.Push(ResultSuccess); rb.Push(ResultSuccess);
rb.Push(true);
rb.PushCopyObjects(config_event->GetReadableEvent()); rb.PushCopyObjects(config_event->GetReadableEvent());
} }

View file

@ -1,17 +1,18 @@
// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project // SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later // SPDX-License-Identifier: GPL-2.0-or-later
#include "core/core.h"
#include "core/core_timing.h" #include "core/core_timing.h"
#include "core/hid/emulated_console.h" #include "core/hid/emulated_console.h"
#include "core/hid/hid_core.h" #include "core/hid/hid_core.h"
#include "core/hle/service/hid/controllers/console_sixaxis.h" #include "core/hle/service/hid/controllers/console_sixaxis.h"
#include "core/memory.h"
namespace Service::HID { namespace Service::HID {
constexpr std::size_t SHARED_MEMORY_OFFSET = 0x3C200; constexpr std::size_t SHARED_MEMORY_OFFSET = 0x3C200;
Controller_ConsoleSixAxis::Controller_ConsoleSixAxis(Core::HID::HIDCore& hid_core_, Controller_ConsoleSixAxis::Controller_ConsoleSixAxis(Core::System& system_, u8* raw_shared_memory_)
u8* raw_shared_memory_) : ControllerBase{system_.HIDCore()}, system{system_} {
: ControllerBase{hid_core_} {
console = hid_core.GetEmulatedConsole(); console = hid_core.GetEmulatedConsole();
static_assert(SHARED_MEMORY_OFFSET + sizeof(ConsoleSharedMemory) < shared_memory_size, static_assert(SHARED_MEMORY_OFFSET + sizeof(ConsoleSharedMemory) < shared_memory_size,
"ConsoleSharedMemory is bigger than the shared memory"); "ConsoleSharedMemory is bigger than the shared memory");
@ -26,7 +27,7 @@ void Controller_ConsoleSixAxis::OnInit() {}
void Controller_ConsoleSixAxis::OnRelease() {} void Controller_ConsoleSixAxis::OnRelease() {}
void Controller_ConsoleSixAxis::OnUpdate(const Core::Timing::CoreTiming& core_timing) { void Controller_ConsoleSixAxis::OnUpdate(const Core::Timing::CoreTiming& core_timing) {
if (!IsControllerActivated() || !is_transfer_memory_set) { if (!IsControllerActivated() || transfer_memory == 0) {
seven_sixaxis_lifo.buffer_count = 0; seven_sixaxis_lifo.buffer_count = 0;
seven_sixaxis_lifo.buffer_tail = 0; seven_sixaxis_lifo.buffer_tail = 0;
return; return;
@ -59,11 +60,10 @@ void Controller_ConsoleSixAxis::OnUpdate(const Core::Timing::CoreTiming& core_ti
// Update seven six axis transfer memory // Update seven six axis transfer memory
seven_sixaxis_lifo.WriteNextEntry(next_seven_sixaxis_state); seven_sixaxis_lifo.WriteNextEntry(next_seven_sixaxis_state);
std::memcpy(transfer_memory, &seven_sixaxis_lifo, sizeof(seven_sixaxis_lifo)); system.Memory().WriteBlock(transfer_memory, &seven_sixaxis_lifo, sizeof(seven_sixaxis_lifo));
} }
void Controller_ConsoleSixAxis::SetTransferMemoryPointer(u8* t_mem) { void Controller_ConsoleSixAxis::SetTransferMemoryAddress(VAddr t_mem) {
is_transfer_memory_set = true;
transfer_memory = t_mem; transfer_memory = t_mem;
} }

View file

@ -10,6 +10,10 @@
#include "core/hle/service/hid/controllers/controller_base.h" #include "core/hle/service/hid/controllers/controller_base.h"
#include "core/hle/service/hid/ring_lifo.h" #include "core/hle/service/hid/ring_lifo.h"
namespace Core {
class System;
} // namespace Core
namespace Core::HID { namespace Core::HID {
class EmulatedConsole; class EmulatedConsole;
} // namespace Core::HID } // namespace Core::HID
@ -17,7 +21,7 @@ class EmulatedConsole;
namespace Service::HID { namespace Service::HID {
class Controller_ConsoleSixAxis final : public ControllerBase { class Controller_ConsoleSixAxis final : public ControllerBase {
public: public:
explicit Controller_ConsoleSixAxis(Core::HID::HIDCore& hid_core_, u8* raw_shared_memory_); explicit Controller_ConsoleSixAxis(Core::System& system_, u8* raw_shared_memory_);
~Controller_ConsoleSixAxis() override; ~Controller_ConsoleSixAxis() override;
// Called when the controller is initialized // Called when the controller is initialized
@ -30,7 +34,7 @@ public:
void OnUpdate(const Core::Timing::CoreTiming& core_timing) override; void OnUpdate(const Core::Timing::CoreTiming& core_timing) override;
// Called on InitializeSevenSixAxisSensor // Called on InitializeSevenSixAxisSensor
void SetTransferMemoryPointer(u8* t_mem); void SetTransferMemoryAddress(VAddr t_mem);
// Called on ResetSevenSixAxisSensorTimestamp // Called on ResetSevenSixAxisSensorTimestamp
void ResetTimestamp(); void ResetTimestamp();
@ -62,12 +66,13 @@ private:
static_assert(sizeof(seven_sixaxis_lifo) == 0xA70, "SevenSixAxisState is an invalid size"); static_assert(sizeof(seven_sixaxis_lifo) == 0xA70, "SevenSixAxisState is an invalid size");
SevenSixAxisState next_seven_sixaxis_state{}; SevenSixAxisState next_seven_sixaxis_state{};
u8* transfer_memory = nullptr; VAddr transfer_memory{};
ConsoleSharedMemory* shared_memory = nullptr; ConsoleSharedMemory* shared_memory = nullptr;
Core::HID::EmulatedConsole* console = nullptr; Core::HID::EmulatedConsole* console = nullptr;
bool is_transfer_memory_set = false;
u64 last_saved_timestamp{}; u64 last_saved_timestamp{};
u64 last_global_timestamp{}; u64 last_global_timestamp{};
Core::System& system;
}; };
} // namespace Service::HID } // namespace Service::HID

View file

@ -152,7 +152,7 @@ Result Controller_Palma::WritePalmaRgbLedPatternEntry(const PalmaConnectionHandl
} }
Result Controller_Palma::WritePalmaWaveEntry(const PalmaConnectionHandle& handle, PalmaWaveSet wave, Result Controller_Palma::WritePalmaWaveEntry(const PalmaConnectionHandle& handle, PalmaWaveSet wave,
u8* t_mem, u64 size) { VAddr t_mem, u64 size) {
if (handle.npad_id != active_handle.npad_id) { if (handle.npad_id != active_handle.npad_id) {
return InvalidPalmaHandle; return InvalidPalmaHandle;
} }

View file

@ -125,7 +125,7 @@ public:
Result ReadPalmaUniqueCode(const PalmaConnectionHandle& handle); Result ReadPalmaUniqueCode(const PalmaConnectionHandle& handle);
Result SetPalmaUniqueCodeInvalid(const PalmaConnectionHandle& handle); Result SetPalmaUniqueCodeInvalid(const PalmaConnectionHandle& handle);
Result WritePalmaRgbLedPatternEntry(const PalmaConnectionHandle& handle, u64 unknown); Result WritePalmaRgbLedPatternEntry(const PalmaConnectionHandle& handle, u64 unknown);
Result WritePalmaWaveEntry(const PalmaConnectionHandle& handle, PalmaWaveSet wave, u8* t_mem, Result WritePalmaWaveEntry(const PalmaConnectionHandle& handle, PalmaWaveSet wave, VAddr t_mem,
u64 size); u64 size);
Result SetPalmaDataBaseIdentificationVersion(const PalmaConnectionHandle& handle, Result SetPalmaDataBaseIdentificationVersion(const PalmaConnectionHandle& handle,
s32 database_id_version_); s32 database_id_version_);

View file

@ -1862,7 +1862,7 @@ void Hid::InitializeSevenSixAxisSensor(Kernel::HLERequestContext& ctx) {
.ActivateController(); .ActivateController();
applet_resource->GetController<Controller_ConsoleSixAxis>(HidController::ConsoleSixAxisSensor) applet_resource->GetController<Controller_ConsoleSixAxis>(HidController::ConsoleSixAxisSensor)
.SetTransferMemoryPointer(system.Memory().GetPointer(t_mem_1->GetSourceAddress())); .SetTransferMemoryAddress(t_mem_1->GetSourceAddress());
LOG_WARNING(Service_HID, LOG_WARNING(Service_HID,
"called, t_mem_1_handle=0x{:08X}, t_mem_2_handle=0x{:08X}, " "called, t_mem_1_handle=0x{:08X}, t_mem_2_handle=0x{:08X}, "
@ -2149,8 +2149,7 @@ void Hid::WritePalmaWaveEntry(Kernel::HLERequestContext& ctx) {
connection_handle.npad_id, wave_set, unknown, t_mem_handle, t_mem_size, size); connection_handle.npad_id, wave_set, unknown, t_mem_handle, t_mem_size, size);
applet_resource->GetController<Controller_Palma>(HidController::Palma) applet_resource->GetController<Controller_Palma>(HidController::Palma)
.WritePalmaWaveEntry(connection_handle, wave_set, .WritePalmaWaveEntry(connection_handle, wave_set, t_mem->GetSourceAddress(), t_mem_size);
system.Memory().GetPointer(t_mem->GetSourceAddress()), t_mem_size);
IPC::ResponseBuilder rb{ctx, 2}; IPC::ResponseBuilder rb{ctx, 2};
rb.Push(ResultSuccess); rb.Push(ResultSuccess);

View file

@ -61,9 +61,15 @@ public:
private: private:
template <typename T> template <typename T>
void MakeController(HidController controller, u8* shared_memory) { void MakeController(HidController controller, u8* shared_memory) {
controllers[static_cast<std::size_t>(controller)] = if constexpr (std::is_constructible_v<T, Core::System&, u8*>) {
std::make_unique<T>(system.HIDCore(), shared_memory); controllers[static_cast<std::size_t>(controller)] =
std::make_unique<T>(system, shared_memory);
} else {
controllers[static_cast<std::size_t>(controller)] =
std::make_unique<T>(system.HIDCore(), shared_memory);
}
} }
template <typename T> template <typename T>
void MakeControllerWithServiceContext(HidController controller, u8* shared_memory) { void MakeControllerWithServiceContext(HidController controller, u8* shared_memory) {
controllers[static_cast<std::size_t>(controller)] = controllers[static_cast<std::size_t>(controller)] =

View file

@ -472,7 +472,7 @@ void HidBus::EnableJoyPollingReceiveMode(Kernel::HLERequestContext& ctx) {
if (device_index) { if (device_index) {
auto& device = devices[device_index.value()].device; auto& device = devices[device_index.value()].device;
device->SetPollingMode(polling_mode_); device->SetPollingMode(polling_mode_);
device->SetTransferMemoryPointer(system.Memory().GetPointer(t_mem->GetSourceAddress())); device->SetTransferMemoryAddress(t_mem->GetSourceAddress());
IPC::ResponseBuilder rb{ctx, 2}; IPC::ResponseBuilder rb{ctx, 2};
rb.Push(ResultSuccess); rb.Push(ResultSuccess);

View file

@ -115,8 +115,7 @@ private:
void MakeDevice(BusHandle handle) { void MakeDevice(BusHandle handle) {
const auto device_index = GetDeviceIndexFromHandle(handle); const auto device_index = GetDeviceIndexFromHandle(handle);
if (device_index) { if (device_index) {
devices[device_index.value()].device = devices[device_index.value()].device = std::make_unique<T>(system, service_context);
std::make_unique<T>(system.HIDCore(), service_context);
} }
} }

View file

@ -9,8 +9,8 @@
namespace Service::HID { namespace Service::HID {
HidbusBase::HidbusBase(KernelHelpers::ServiceContext& service_context_) HidbusBase::HidbusBase(Core::System& system_, KernelHelpers::ServiceContext& service_context_)
: service_context(service_context_) { : system(system_), service_context(service_context_) {
send_command_async_event = service_context.CreateEvent("hidbus:SendCommandAsyncEvent"); send_command_async_event = service_context.CreateEvent("hidbus:SendCommandAsyncEvent");
} }
HidbusBase::~HidbusBase() = default; HidbusBase::~HidbusBase() = default;
@ -59,8 +59,7 @@ void HidbusBase::DisablePollingMode() {
polling_mode_enabled = false; polling_mode_enabled = false;
} }
void HidbusBase::SetTransferMemoryPointer(u8* t_mem) { void HidbusBase::SetTransferMemoryAddress(VAddr t_mem) {
is_transfer_memory_set = true;
transfer_memory = t_mem; transfer_memory = t_mem;
} }

View file

@ -8,6 +8,10 @@
#include "common/common_types.h" #include "common/common_types.h"
#include "core/hle/result.h" #include "core/hle/result.h"
namespace Core {
class System;
}
namespace Kernel { namespace Kernel {
class KEvent; class KEvent;
class KReadableEvent; class KReadableEvent;
@ -106,7 +110,7 @@ static_assert(sizeof(ButtonOnlyPollingDataAccessor) == 0x2F0,
class HidbusBase { class HidbusBase {
public: public:
explicit HidbusBase(KernelHelpers::ServiceContext& service_context_); explicit HidbusBase(Core::System& system_, KernelHelpers::ServiceContext& service_context_);
virtual ~HidbusBase(); virtual ~HidbusBase();
void ActivateDevice(); void ActivateDevice();
@ -134,7 +138,7 @@ public:
void DisablePollingMode(); void DisablePollingMode();
// Called on EnableJoyPollingReceiveMode // Called on EnableJoyPollingReceiveMode
void SetTransferMemoryPointer(u8* t_mem); void SetTransferMemoryAddress(VAddr t_mem);
Kernel::KReadableEvent& GetSendCommandAsycEvent() const; Kernel::KReadableEvent& GetSendCommandAsycEvent() const;
@ -170,9 +174,9 @@ protected:
JoyEnableSixAxisDataAccessor enable_sixaxis_data{}; JoyEnableSixAxisDataAccessor enable_sixaxis_data{};
ButtonOnlyPollingDataAccessor button_only_data{}; ButtonOnlyPollingDataAccessor button_only_data{};
u8* transfer_memory{nullptr}; VAddr transfer_memory{};
bool is_transfer_memory_set{};
Core::System& system;
Kernel::KEvent* send_command_async_event; Kernel::KEvent* send_command_async_event;
KernelHelpers::ServiceContext& service_context; KernelHelpers::ServiceContext& service_context;
}; };

View file

@ -1,18 +1,20 @@
// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project // SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later // SPDX-License-Identifier: GPL-2.0-or-later
#include "core/core.h"
#include "core/hid/emulated_controller.h" #include "core/hid/emulated_controller.h"
#include "core/hid/hid_core.h" #include "core/hid/hid_core.h"
#include "core/hle/kernel/k_event.h" #include "core/hle/kernel/k_event.h"
#include "core/hle/kernel/k_readable_event.h" #include "core/hle/kernel/k_readable_event.h"
#include "core/hle/service/hid/hidbus/ringcon.h" #include "core/hle/service/hid/hidbus/ringcon.h"
#include "core/memory.h"
namespace Service::HID { namespace Service::HID {
RingController::RingController(Core::HID::HIDCore& hid_core_, RingController::RingController(Core::System& system_,
KernelHelpers::ServiceContext& service_context_) KernelHelpers::ServiceContext& service_context_)
: HidbusBase(service_context_) { : HidbusBase(system_, service_context_) {
input = hid_core_.GetEmulatedController(Core::HID::NpadIdType::Player1); input = system.HIDCore().GetEmulatedController(Core::HID::NpadIdType::Player1);
} }
RingController::~RingController() = default; RingController::~RingController() = default;
@ -38,7 +40,7 @@ void RingController::OnUpdate() {
return; return;
} }
if (!polling_mode_enabled || !is_transfer_memory_set) { if (!polling_mode_enabled || transfer_memory == 0) {
return; return;
} }
@ -62,7 +64,8 @@ void RingController::OnUpdate() {
curr_entry.polling_data.out_size = sizeof(ringcon_value); curr_entry.polling_data.out_size = sizeof(ringcon_value);
std::memcpy(curr_entry.polling_data.data.data(), &ringcon_value, sizeof(ringcon_value)); std::memcpy(curr_entry.polling_data.data.data(), &ringcon_value, sizeof(ringcon_value));
std::memcpy(transfer_memory, &enable_sixaxis_data, sizeof(enable_sixaxis_data)); system.Memory().WriteBlock(transfer_memory, &enable_sixaxis_data,
sizeof(enable_sixaxis_data));
break; break;
} }
default: default:

View file

@ -17,8 +17,7 @@ namespace Service::HID {
class RingController final : public HidbusBase { class RingController final : public HidbusBase {
public: public:
explicit RingController(Core::HID::HIDCore& hid_core_, explicit RingController(Core::System& system_, KernelHelpers::ServiceContext& service_context_);
KernelHelpers::ServiceContext& service_context_);
~RingController() override; ~RingController() override;
void OnInit() override; void OnInit() override;

View file

@ -8,8 +8,8 @@
namespace Service::HID { namespace Service::HID {
constexpr u8 DEVICE_ID = 0x28; constexpr u8 DEVICE_ID = 0x28;
Starlink::Starlink(Core::HID::HIDCore& hid_core_, KernelHelpers::ServiceContext& service_context_) Starlink::Starlink(Core::System& system_, KernelHelpers::ServiceContext& service_context_)
: HidbusBase(service_context_) {} : HidbusBase(system_, service_context_) {}
Starlink::~Starlink() = default; Starlink::~Starlink() = default;
void Starlink::OnInit() { void Starlink::OnInit() {
@ -27,7 +27,7 @@ void Starlink::OnUpdate() {
if (!device_enabled) { if (!device_enabled) {
return; return;
} }
if (!polling_mode_enabled || !is_transfer_memory_set) { if (!polling_mode_enabled || transfer_memory == 0) {
return; return;
} }

View file

@ -14,8 +14,7 @@ namespace Service::HID {
class Starlink final : public HidbusBase { class Starlink final : public HidbusBase {
public: public:
explicit Starlink(Core::HID::HIDCore& hid_core_, explicit Starlink(Core::System& system_, KernelHelpers::ServiceContext& service_context_);
KernelHelpers::ServiceContext& service_context_);
~Starlink() override; ~Starlink() override;
void OnInit() override; void OnInit() override;

View file

@ -8,9 +8,8 @@
namespace Service::HID { namespace Service::HID {
constexpr u8 DEVICE_ID = 0xFF; constexpr u8 DEVICE_ID = 0xFF;
HidbusStubbed::HidbusStubbed(Core::HID::HIDCore& hid_core_, HidbusStubbed::HidbusStubbed(Core::System& system_, KernelHelpers::ServiceContext& service_context_)
KernelHelpers::ServiceContext& service_context_) : HidbusBase(system_, service_context_) {}
: HidbusBase(service_context_) {}
HidbusStubbed::~HidbusStubbed() = default; HidbusStubbed::~HidbusStubbed() = default;
void HidbusStubbed::OnInit() { void HidbusStubbed::OnInit() {
@ -28,7 +27,7 @@ void HidbusStubbed::OnUpdate() {
if (!device_enabled) { if (!device_enabled) {
return; return;
} }
if (!polling_mode_enabled || !is_transfer_memory_set) { if (!polling_mode_enabled || transfer_memory == 0) {
return; return;
} }

View file

@ -14,8 +14,7 @@ namespace Service::HID {
class HidbusStubbed final : public HidbusBase { class HidbusStubbed final : public HidbusBase {
public: public:
explicit HidbusStubbed(Core::HID::HIDCore& hid_core_, explicit HidbusStubbed(Core::System& system_, KernelHelpers::ServiceContext& service_context_);
KernelHelpers::ServiceContext& service_context_);
~HidbusStubbed() override; ~HidbusStubbed() override;
void OnInit() override; void OnInit() override;

View file

@ -208,8 +208,6 @@ void IRS::RunImageTransferProcessor(Kernel::HLERequestContext& ctx) {
ASSERT_MSG(t_mem->GetSize() == parameters.transfer_memory_size, "t_mem has incorrect size"); ASSERT_MSG(t_mem->GetSize() == parameters.transfer_memory_size, "t_mem has incorrect size");
u8* transfer_memory = system.Memory().GetPointer(t_mem->GetSourceAddress());
LOG_INFO(Service_IRS, LOG_INFO(Service_IRS,
"called, npad_type={}, npad_id={}, transfer_memory_size={}, transfer_memory_size={}, " "called, npad_type={}, npad_id={}, transfer_memory_size={}, transfer_memory_size={}, "
"applet_resource_user_id={}", "applet_resource_user_id={}",
@ -224,7 +222,7 @@ void IRS::RunImageTransferProcessor(Kernel::HLERequestContext& ctx) {
auto& image_transfer_processor = auto& image_transfer_processor =
GetProcessor<ImageTransferProcessor>(parameters.camera_handle); GetProcessor<ImageTransferProcessor>(parameters.camera_handle);
image_transfer_processor.SetConfig(parameters.processor_config); image_transfer_processor.SetConfig(parameters.processor_config);
image_transfer_processor.SetTransferMemoryPointer(transfer_memory); image_transfer_processor.SetTransferMemoryAddress(t_mem->GetSourceAddress());
npad_device->SetPollingMode(Core::HID::EmulatedDeviceIndex::RightIndex, npad_device->SetPollingMode(Core::HID::EmulatedDeviceIndex::RightIndex,
Common::Input::PollingMode::IR); Common::Input::PollingMode::IR);
} }
@ -448,8 +446,6 @@ void IRS::RunImageTransferExProcessor(Kernel::HLERequestContext& ctx) {
auto t_mem = system.ApplicationProcess()->GetHandleTable().GetObject<Kernel::KTransferMemory>( auto t_mem = system.ApplicationProcess()->GetHandleTable().GetObject<Kernel::KTransferMemory>(
t_mem_handle); t_mem_handle);
u8* transfer_memory = system.Memory().GetPointer(t_mem->GetSourceAddress());
LOG_INFO(Service_IRS, LOG_INFO(Service_IRS,
"called, npad_type={}, npad_id={}, transfer_memory_size={}, " "called, npad_type={}, npad_id={}, transfer_memory_size={}, "
"applet_resource_user_id={}", "applet_resource_user_id={}",
@ -464,7 +460,7 @@ void IRS::RunImageTransferExProcessor(Kernel::HLERequestContext& ctx) {
auto& image_transfer_processor = auto& image_transfer_processor =
GetProcessor<ImageTransferProcessor>(parameters.camera_handle); GetProcessor<ImageTransferProcessor>(parameters.camera_handle);
image_transfer_processor.SetConfig(parameters.processor_config); image_transfer_processor.SetConfig(parameters.processor_config);
image_transfer_processor.SetTransferMemoryPointer(transfer_memory); image_transfer_processor.SetTransferMemoryAddress(t_mem->GetSourceAddress());
npad_device->SetPollingMode(Core::HID::EmulatedDeviceIndex::RightIndex, npad_device->SetPollingMode(Core::HID::EmulatedDeviceIndex::RightIndex,
Common::Input::PollingMode::IR); Common::Input::PollingMode::IR);
} }

View file

@ -80,7 +80,13 @@ private:
LOG_CRITICAL(Service_IRS, "Invalid index {}", index); LOG_CRITICAL(Service_IRS, "Invalid index {}", index);
return; return;
} }
processors[index] = std::make_unique<T>(system.HIDCore(), device_state, index);
if constexpr (std::is_constructible_v<T, Core::System&, Core::IrSensor::DeviceFormat&,
std::size_t>) {
processors[index] = std::make_unique<T>(system, device_state, index);
} else {
processors[index] = std::make_unique<T>(system.HIDCore(), device_state, index);
}
} }
template <typename T> template <typename T>

View file

@ -1,16 +1,18 @@
// SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project // SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project
// SPDX-License-Identifier: GPL-3.0-or-later // SPDX-License-Identifier: GPL-3.0-or-later
#include "core/core.h"
#include "core/hid/emulated_controller.h" #include "core/hid/emulated_controller.h"
#include "core/hid/hid_core.h" #include "core/hid/hid_core.h"
#include "core/hle/service/hid/irsensor/image_transfer_processor.h" #include "core/hle/service/hid/irsensor/image_transfer_processor.h"
#include "core/memory.h"
namespace Service::IRS { namespace Service::IRS {
ImageTransferProcessor::ImageTransferProcessor(Core::HID::HIDCore& hid_core_, ImageTransferProcessor::ImageTransferProcessor(Core::System& system_,
Core::IrSensor::DeviceFormat& device_format, Core::IrSensor::DeviceFormat& device_format,
std::size_t npad_index) std::size_t npad_index)
: device{device_format} { : device{device_format}, system{system_} {
npad_device = hid_core_.GetEmulatedControllerByIndex(npad_index); npad_device = system.HIDCore().GetEmulatedControllerByIndex(npad_index);
Core::HID::ControllerUpdateCallback engine_callback{ Core::HID::ControllerUpdateCallback engine_callback{
.on_change = [this](Core::HID::ControllerTriggerType type) { OnControllerUpdate(type); }, .on_change = [this](Core::HID::ControllerTriggerType type) { OnControllerUpdate(type); },
@ -43,7 +45,7 @@ void ImageTransferProcessor::OnControllerUpdate(Core::HID::ControllerTriggerType
if (type != Core::HID::ControllerTriggerType::IrSensor) { if (type != Core::HID::ControllerTriggerType::IrSensor) {
return; return;
} }
if (!is_transfer_memory_set) { if (transfer_memory == 0) {
return; return;
} }
@ -56,14 +58,16 @@ void ImageTransferProcessor::OnControllerUpdate(Core::HID::ControllerTriggerType
if (camera_data.format != current_config.origin_format) { if (camera_data.format != current_config.origin_format) {
LOG_WARNING(Service_IRS, "Wrong Input format {} expected {}", camera_data.format, LOG_WARNING(Service_IRS, "Wrong Input format {} expected {}", camera_data.format,
current_config.origin_format); current_config.origin_format);
memset(transfer_memory, 0, GetDataSize(current_config.trimming_format)); system.Memory().ZeroBlock(*system.ApplicationProcess(), transfer_memory,
GetDataSize(current_config.trimming_format));
return; return;
} }
if (current_config.origin_format > current_config.trimming_format) { if (current_config.origin_format > current_config.trimming_format) {
LOG_WARNING(Service_IRS, "Origin format {} is smaller than trimming format {}", LOG_WARNING(Service_IRS, "Origin format {} is smaller than trimming format {}",
current_config.origin_format, current_config.trimming_format); current_config.origin_format, current_config.trimming_format);
memset(transfer_memory, 0, GetDataSize(current_config.trimming_format)); system.Memory().ZeroBlock(*system.ApplicationProcess(), transfer_memory,
GetDataSize(current_config.trimming_format));
return; return;
} }
@ -80,7 +84,8 @@ void ImageTransferProcessor::OnControllerUpdate(Core::HID::ControllerTriggerType
"Trimming area ({}, {}, {}, {}) is outside of origin area ({}, {})", "Trimming area ({}, {}, {}, {}) is outside of origin area ({}, {})",
current_config.trimming_start_x, current_config.trimming_start_y, current_config.trimming_start_x, current_config.trimming_start_y,
trimming_width, trimming_height, origin_width, origin_height); trimming_width, trimming_height, origin_width, origin_height);
memset(transfer_memory, 0, GetDataSize(current_config.trimming_format)); system.Memory().ZeroBlock(*system.ApplicationProcess(), transfer_memory,
GetDataSize(current_config.trimming_format));
return; return;
} }
@ -94,7 +99,8 @@ void ImageTransferProcessor::OnControllerUpdate(Core::HID::ControllerTriggerType
} }
} }
memcpy(transfer_memory, window_data.data(), GetDataSize(current_config.trimming_format)); system.Memory().WriteBlock(transfer_memory, window_data.data(),
GetDataSize(current_config.trimming_format));
if (!IsProcessorActive()) { if (!IsProcessorActive()) {
StartProcessor(); StartProcessor();
@ -134,8 +140,7 @@ void ImageTransferProcessor::SetConfig(
npad_device->SetCameraFormat(current_config.origin_format); npad_device->SetCameraFormat(current_config.origin_format);
} }
void ImageTransferProcessor::SetTransferMemoryPointer(u8* t_mem) { void ImageTransferProcessor::SetTransferMemoryAddress(VAddr t_mem) {
is_transfer_memory_set = true;
transfer_memory = t_mem; transfer_memory = t_mem;
} }
@ -143,7 +148,7 @@ Core::IrSensor::ImageTransferProcessorState ImageTransferProcessor::GetState(
std::vector<u8>& data) const { std::vector<u8>& data) const {
const auto size = GetDataSize(current_config.trimming_format); const auto size = GetDataSize(current_config.trimming_format);
data.resize(size); data.resize(size);
memcpy(data.data(), transfer_memory, size); system.Memory().ReadBlock(transfer_memory, data.data(), size);
return processor_state; return processor_state;
} }

View file

@ -7,6 +7,10 @@
#include "core/hid/irs_types.h" #include "core/hid/irs_types.h"
#include "core/hle/service/hid/irsensor/processor_base.h" #include "core/hle/service/hid/irsensor/processor_base.h"
namespace Core {
class System;
}
namespace Core::HID { namespace Core::HID {
class EmulatedController; class EmulatedController;
} // namespace Core::HID } // namespace Core::HID
@ -14,7 +18,7 @@ class EmulatedController;
namespace Service::IRS { namespace Service::IRS {
class ImageTransferProcessor final : public ProcessorBase { class ImageTransferProcessor final : public ProcessorBase {
public: public:
explicit ImageTransferProcessor(Core::HID::HIDCore& hid_core_, explicit ImageTransferProcessor(Core::System& system_,
Core::IrSensor::DeviceFormat& device_format, Core::IrSensor::DeviceFormat& device_format,
std::size_t npad_index); std::size_t npad_index);
~ImageTransferProcessor() override; ~ImageTransferProcessor() override;
@ -33,7 +37,7 @@ public:
void SetConfig(Core::IrSensor::PackedImageTransferProcessorExConfig config); void SetConfig(Core::IrSensor::PackedImageTransferProcessorExConfig config);
// Transfer memory where the image data will be stored // Transfer memory where the image data will be stored
void SetTransferMemoryPointer(u8* t_mem); void SetTransferMemoryAddress(VAddr t_mem);
Core::IrSensor::ImageTransferProcessorState GetState(std::vector<u8>& data) const; Core::IrSensor::ImageTransferProcessorState GetState(std::vector<u8>& data) const;
@ -67,7 +71,7 @@ private:
Core::HID::EmulatedController* npad_device; Core::HID::EmulatedController* npad_device;
int callback_key{}; int callback_key{};
u8* transfer_memory = nullptr; Core::System& system;
bool is_transfer_memory_set = false; VAddr transfer_memory{};
}; };
} // namespace Service::IRS } // namespace Service::IRS

View file

@ -89,7 +89,7 @@ if (ENABLE_LIBUSB)
endif() endif()
create_target_directory_groups(input_common) create_target_directory_groups(input_common)
target_link_libraries(input_common PUBLIC core PRIVATE common Boost::boost) target_link_libraries(input_common PUBLIC core PRIVATE common Boost::headers)
if (YUZU_USE_PRECOMPILED_HEADERS) if (YUZU_USE_PRECOMPILED_HEADERS)
target_precompile_headers(input_common PRIVATE precompiled_headers.h) target_precompile_headers(input_common PRIVATE precompiled_headers.h)

View file

@ -19,7 +19,7 @@ add_library(network STATIC
create_target_directory_groups(network) create_target_directory_groups(network)
target_link_libraries(network PRIVATE common enet::enet Boost::boost) target_link_libraries(network PRIVATE common enet::enet Boost::headers)
if (ENABLE_WEB_SERVICE) if (ENABLE_WEB_SERVICE)
target_compile_definitions(network PRIVATE -DENABLE_WEB_SERVICE) target_compile_definitions(network PRIVATE -DENABLE_WEB_SERVICE)
target_link_libraries(network PRIVATE web_service) target_link_libraries(network PRIVATE web_service)

View file

@ -35,6 +35,7 @@ struct Bias {
u32 index; u32 index;
u32 offset_begin; u32 offset_begin;
u32 offset_end; u32 offset_end;
u32 alignment;
}; };
using boost::container::flat_set; using boost::container::flat_set;
@ -349,7 +350,8 @@ std::optional<StorageBufferAddr> Track(const IR::Value& value, const Bias* bias)
.index = index.U32(), .index = index.U32(),
.offset = offset.U32(), .offset = offset.U32(),
}; };
if (!Common::IsAligned(storage_buffer.offset, 16)) { const u32 alignment{bias ? bias->alignment : 8U};
if (!Common::IsAligned(storage_buffer.offset, alignment)) {
// The SSBO pointer has to be aligned // The SSBO pointer has to be aligned
return std::nullopt; return std::nullopt;
} }
@ -371,6 +373,7 @@ void CollectStorageBuffers(IR::Block& block, IR::Inst& inst, StorageInfo& info)
.index = 0, .index = 0,
.offset_begin = 0x110, .offset_begin = 0x110,
.offset_end = 0x610, .offset_end = 0x610,
.alignment = 16,
}; };
// Track the low address of the instruction // Track the low address of the instruction
const std::optional<LowAddrInfo> low_addr_info{TrackLowAddress(&inst)}; const std::optional<LowAddrInfo> low_addr_info{TrackLowAddress(&inst)};
@ -386,8 +389,11 @@ void CollectStorageBuffers(IR::Block& block, IR::Inst& inst, StorageInfo& info)
storage_buffer = Track(low_addr, nullptr); storage_buffer = Track(low_addr, nullptr);
if (!storage_buffer) { if (!storage_buffer) {
// If that also fails, use NVN fallbacks // If that also fails, use NVN fallbacks
LOG_WARNING(Shader, "Storage buffer failed to track, using global memory fallbacks");
return; return;
} }
LOG_WARNING(Shader, "Storage buffer tracked without bias, index {} offset {}",
storage_buffer->index, storage_buffer->offset);
} }
// Collect storage buffer and the instruction // Collect storage buffer and the instruction
if (IsGlobalMemoryWrite(inst)) { if (IsGlobalMemoryWrite(inst)) {

View file

@ -330,3 +330,7 @@ endif()
if (YUZU_USE_PRECOMPILED_HEADERS) if (YUZU_USE_PRECOMPILED_HEADERS)
target_precompile_headers(video_core PRIVATE precompiled_headers.h) target_precompile_headers(video_core PRIVATE precompiled_headers.h)
endif() endif()
if (YUZU_ENABLE_LTO)
set_property(TARGET video_core PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
endif()

View file

@ -383,7 +383,8 @@ private:
void NotifyBufferDeletion(); void NotifyBufferDeletion();
[[nodiscard]] Binding StorageBufferBinding(GPUVAddr ssbo_addr, bool is_written = false) const; [[nodiscard]] Binding StorageBufferBinding(GPUVAddr ssbo_addr, u32 cbuf_index,
bool is_written = false) const;
[[nodiscard]] TextureBufferBinding GetTextureBufferBinding(GPUVAddr gpu_addr, u32 size, [[nodiscard]] TextureBufferBinding GetTextureBufferBinding(GPUVAddr gpu_addr, u32 size,
PixelFormat format); PixelFormat format);
@ -802,7 +803,7 @@ void BufferCache<P>::BindGraphicsStorageBuffer(size_t stage, size_t ssbo_index,
const auto& cbufs = maxwell3d->state.shader_stages[stage]; const auto& cbufs = maxwell3d->state.shader_stages[stage];
const GPUVAddr ssbo_addr = cbufs.const_buffers[cbuf_index].address + cbuf_offset; const GPUVAddr ssbo_addr = cbufs.const_buffers[cbuf_index].address + cbuf_offset;
storage_buffers[stage][ssbo_index] = StorageBufferBinding(ssbo_addr, is_written); storage_buffers[stage][ssbo_index] = StorageBufferBinding(ssbo_addr, cbuf_index, is_written);
} }
template <class P> template <class P>
@ -842,7 +843,7 @@ void BufferCache<P>::BindComputeStorageBuffer(size_t ssbo_index, u32 cbuf_index,
const auto& cbufs = launch_desc.const_buffer_config; const auto& cbufs = launch_desc.const_buffer_config;
const GPUVAddr ssbo_addr = cbufs[cbuf_index].Address() + cbuf_offset; const GPUVAddr ssbo_addr = cbufs[cbuf_index].Address() + cbuf_offset;
compute_storage_buffers[ssbo_index] = StorageBufferBinding(ssbo_addr, is_written); compute_storage_buffers[ssbo_index] = StorageBufferBinding(ssbo_addr, cbuf_index, is_written);
} }
template <class P> template <class P>
@ -1988,11 +1989,26 @@ void BufferCache<P>::NotifyBufferDeletion() {
template <class P> template <class P>
typename BufferCache<P>::Binding BufferCache<P>::StorageBufferBinding(GPUVAddr ssbo_addr, typename BufferCache<P>::Binding BufferCache<P>::StorageBufferBinding(GPUVAddr ssbo_addr,
u32 cbuf_index,
bool is_written) const { bool is_written) const {
const GPUVAddr gpu_addr = gpu_memory->Read<u64>(ssbo_addr); const GPUVAddr gpu_addr = gpu_memory->Read<u64>(ssbo_addr);
const u32 size = gpu_memory->Read<u32>(ssbo_addr + 8); const auto size = [&]() {
const bool is_nvn_cbuf = cbuf_index == 0;
// The NVN driver buffer (index 0) is known to pack the SSBO address followed by its size.
if (is_nvn_cbuf) {
return gpu_memory->Read<u32>(ssbo_addr + 8);
}
// Other titles (notably Doom Eternal) may use STG/LDG on buffer addresses in custom defined
// cbufs, which do not store the sizes adjacent to the addresses, so use the fully
// mapped buffer size for now.
const u32 memory_layout_size = static_cast<u32>(gpu_memory->GetMemoryLayoutSize(gpu_addr));
LOG_INFO(HW_GPU, "Binding storage buffer for cbuf index {}, MemoryLayoutSize 0x{:X}",
cbuf_index, memory_layout_size);
return memory_layout_size;
}();
const std::optional<VAddr> cpu_addr = gpu_memory->GpuToCpuAddress(gpu_addr); const std::optional<VAddr> cpu_addr = gpu_memory->GpuToCpuAddress(gpu_addr);
if (!cpu_addr || size == 0) { if (!cpu_addr || size == 0) {
LOG_WARNING(HW_GPU, "Failed to find storage buffer for cbuf index {}", cbuf_index);
return NULL_BINDING; return NULL_BINDING;
} }
const VAddr cpu_end = Common::AlignUp(*cpu_addr + size, Core::Memory::YUZU_PAGESIZE); const VAddr cpu_end = Common::AlignUp(*cpu_addr + size, Core::Memory::YUZU_PAGESIZE);

View file

@ -314,7 +314,7 @@ endif()
create_target_directory_groups(yuzu) create_target_directory_groups(yuzu)
target_link_libraries(yuzu PRIVATE common core input_common network video_core) target_link_libraries(yuzu PRIVATE common core input_common network video_core)
target_link_libraries(yuzu PRIVATE Boost::boost glad Qt${QT_MAJOR_VERSION}::Widgets) target_link_libraries(yuzu PRIVATE Boost::headers glad Qt${QT_MAJOR_VERSION}::Widgets)
target_link_libraries(yuzu PRIVATE ${PLATFORM_LIBRARIES} Threads::Threads) target_link_libraries(yuzu PRIVATE ${PLATFORM_LIBRARIES} Threads::Threads)
target_link_libraries(yuzu PRIVATE Vulkan::Headers) target_link_libraries(yuzu PRIVATE Vulkan::Headers)

View file

@ -1,5 +1,5 @@
{ {
"$schema": "https://raw.githubusercontent.com/microsoft/vcpkg/master/scripts/vcpkg.schema.json", "$schema": "https://raw.githubusercontent.com/microsoft/vcpkg-tool/main/docs/vcpkg.schema.json",
"name": "yuzu", "name": "yuzu",
"builtin-baseline": "9b22b40c6c61bf0da2d46346dd44a11e90972cc9", "builtin-baseline": "9b22b40c6c61bf0da2d46346dd44a11e90972cc9",
"version": "1.0", "version": "1.0",
@ -35,6 +35,15 @@
"dbghelp": { "dbghelp": {
"description": "Compile Windows crash dump (Minidump) support", "description": "Compile Windows crash dump (Minidump) support",
"dependencies": [ "dbghelp" ] "dependencies": [ "dbghelp" ]
},
"web-service": {
"description": "Enable web services (telemetry, etc.)",
"dependencies": [
{
"name": "openssl",
"platform": "windows"
}
]
} }
}, },
"overrides": [ "overrides": [