Merge branch 'main' into user_and_settings

This commit is contained in:
georgemoralis 2026-03-22 09:57:08 +02:00 committed by GitHub
commit 140af241a0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
32 changed files with 110 additions and 69 deletions

View File

@ -130,6 +130,7 @@ static auto UserPaths = [] {
create_path(PathType::HomeDir, user_dir / HOME_DIR);
create_path(PathType::CacheDir, user_dir / CACHE_DIR);
create_path(PathType::FontsDir, user_dir / FONTS_DIR);
create_path(PathType::HomeDir, user_dir / HOME_DIR);
std::ofstream notice_file(user_dir / CUSTOM_TROPHY / "Notice.txt");
if (notice_file.is_open()) {

View File

@ -27,6 +27,7 @@ enum class PathType {
HomeDir, // PS4 home directory
CacheDir, // Where pipeline and shader cache is stored.
FontsDir, // Where dumped system fonts are stored.
HomeDir, // PS4 home directory
};
constexpr auto PORTABLE_DIR = "user";
@ -48,6 +49,7 @@ constexpr auto CUSTOM_CONFIGS = "custom_configs";
constexpr auto HOME_DIR = "home";
constexpr auto CACHE_DIR = "cache";
constexpr auto FONTS_DIR = "fonts";
constexpr auto HOME_DIR = "home";
// Filenames
constexpr auto LOG_FILE = "shad_log.txt";

View File

@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: Copyright 2025 shadPS4 Emulator Project
// SPDX-FileCopyrightText: Copyright 2025-2026 shadPS4 Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once

View File

@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: Copyright 2026 shadPS4 Emulator Project
// SPDX-FileCopyrightText: Copyright 2024-2026 shadPS4 Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#include <map>

View File

@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: Copyright 2025 shadPS4 Emulator Project
// SPDX-FileCopyrightText: Copyright 2025-2026 shadPS4 Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#include "frame_graph.h"

View File

@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: Copyright 2026 shadPS4 Emulator Project
// SPDX-FileCopyrightText: Copyright 2024-2026 shadPS4 Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once

View File

@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: Copyright 2025-2026 shadPS4 Emulator Project
// SPDX-FileCopyrightText: Copyright 2024-2026 shadPS4 Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#include <fstream>
@ -245,7 +245,7 @@ void ShaderList::Draw() {
}
if (!EmulatorSettings.IsShaderCollect()) {
DrawCenteredText("Enable 'shader_dump' in config to see shaders");
DrawCenteredText("Enable 'shader_collect' in config to see shaders");
End();
return;
}

View File

@ -584,27 +584,48 @@ bool EmulatorSettingsImpl::TransferSettings() {
const toml::value& gui = og_data.at("GUI");
auto& s = m_general;
// TODO
// Transfer install directories
try {
const auto install_dir_array =
toml::find_or<std::vector<std::string>>(gui, "installDirs", {});
std::vector<bool> install_dirs_enabled;
// const auto install_dir_array =
// toml::find_or<std::vector<std::u8string>>(gui, "installDirs", {});
// try {
// install_dirs_enabled = toml::find<std::vector<bool>>(gui, "installDirsEnabled");
// } catch (...) {
// // If it does not exist, assume that all are enabled.
// install_dirs_enabled.resize(install_dir_array.size(), true);
// }
// if (install_dirs_enabled.size() < install_dir_array.size()) {
// install_dirs_enabled.resize(install_dir_array.size(), true);
// }
// settings_install_dirs.clear();
// for (size_t i = 0; i < install_dir_array.size(); i++) {
// settings_install_dirs.push_back(
// {std::filesystem::path{install_dir_array[i]}, install_dirs_enabled[i]});
// }
// save_data_path = toml::find_fs_path_or(gui, "saveDataPath", save_data_path);
// settings_addon_install_dir =
// toml::find_fs_path_or(gui, "addonInstallDir", settings_addon_install_dir);
try {
install_dirs_enabled = toml::find<std::vector<bool>>(gui, "installDirsEnabled");
} catch (...) {
// If it does not exist, assume that all are enabled.
install_dirs_enabled.resize(install_dir_array.size(), true);
}
if (install_dirs_enabled.size() < install_dir_array.size()) {
install_dirs_enabled.resize(install_dir_array.size(), true);
}
std::vector<GameInstallDir> settings_install_dirs;
for (size_t i = 0; i < install_dir_array.size(); i++) {
settings_install_dirs.push_back(
{std::filesystem::path{install_dir_array[i]}, install_dirs_enabled[i]});
}
s.install_dirs.value = settings_install_dirs;
} catch (const std::exception& e) {
LOG_WARNING(EmuSettings, "Failed to transfer install directories: {}", e.what());
}
// Transfer addon install directory
try {
std::string addon_install_dir_str;
if (gui.contains("addonInstallDir")) {
const auto& addon_value = gui.at("addonInstallDir");
if (addon_value.is_string()) {
addon_install_dir_str = toml::get<std::string>(addon_value);
if (!addon_install_dir_str.empty()) {
s.addon_install_dir.value = std::filesystem::path{addon_install_dir_str};
}
}
}
} catch (const std::exception& e) {
LOG_WARNING(EmuSettings, "Failed to transfer addon install directory: {}", e.what());
}
}
return true;

View File

@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
// SPDX-FileCopyrightText: Copyright 2024-2026 shadPS4 Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once

View File

@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: Copyright 2025 shadPS4 Emulator Project
// SPDX-FileCopyrightText: Copyright 2025-2026 shadPS4 Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#include <algorithm>

View File

@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: Copyright 2026 shadPS4 Emulator Project
// SPDX-FileCopyrightText: Copyright 2024-2026 shadPS4 Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#include <algorithm>

View File

@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: Copyright 2026 shadPS4 Emulator Project
// SPDX-FileCopyrightText: Copyright 2024-2026 shadPS4 Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#ifdef WIN32

View File

@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: Copyright 2026 shadPS4 Emulator Project
// SPDX-FileCopyrightText: Copyright 2025-2026 shadPS4 Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#include <mutex>

View File

@ -5,6 +5,7 @@
#include <mutex>
#include "common/logging/log.h"
#include "common/config.h"
#include "core/emulator_settings.h"
#include "core/libraries/error_codes.h"
#include "core/libraries/libs.h"

View File

@ -115,10 +115,10 @@ s32 PS4_SYSV_ABI sceNpWebApi2IntInitialize2(const OrbisNpWebApi2IntInitialize2Ar
if (args == nullptr || args->struct_size != sizeof(OrbisNpWebApi2IntInitialize2Args)) {
return ORBIS_NP_WEBAPI2_ERROR_INVALID_ARGUMENT;
}
LOG_ERROR(
Lib_NpWebApi2,
"(STUBBED) called, lib_http_ctx_id = {:#x}, pool_size = {:#x}, name = '{}', group = {:#x}",
args->lib_http_ctx_id, args->pool_size, args->name, args->push_config_group);
LOG_ERROR(Lib_NpWebApi2,
"(STUBBED) called, lib_http_ctx_id = {:#x}, pool_size = {:#x}, name = '{}', "
"group = {:#x}",
args->lib_http_ctx_id, args->pool_size, args->name, args->push_config_group);
return ORBIS_OK;
}

View File

@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: Copyright 2026 shadPS4 Emulator Project
// SPDX-FileCopyrightText: Copyright 2025-2026 shadPS4 Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#include <chrono>

View File

@ -1,8 +1,8 @@
// SPDX-FileCopyrightText: Copyright 2026 shadPS4 Emulator Project
// SPDX-FileCopyrightText: Copyright 2024-2026 shadPS4 Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#include <cstdlib>
#include "common/logging/log.h"
#include "common/config.h"
#include "common/singleton.h"
#include "core/emulator_settings.h"
#include "core/file_sys/fs.h"

View File

@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
// SPDX-FileCopyrightText: Copyright 2024-2026 shadPS4 Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#include "common/logging/log.h"
@ -10,6 +10,8 @@
#include <fmt/format.h>
#include <libusb.h>
#include "core/emulator_settings.h"
namespace Libraries::Usbd {
s32 libusb_to_orbis_error(int retVal) {

View File

@ -1223,13 +1223,16 @@ s32 MemoryManager::SetDirectMemoryType(VAddr addr, u64 size, s32 memory_type) {
// Increment phys_handle
phys_handle++;
}
// Check if VMA can be merged with adjacent areas after physical area modifications.
vma_handle = MergeAdjacent(vma_map, vma_handle);
}
current_addr += size_in_vma;
remaining_size -= size_in_vma;
vma_handle++;
// Check if VMA can be merged with adjacent areas after modifications.
vma_handle = MergeAdjacent(vma_map, vma_handle);
if (vma_handle->second.base + vma_handle->second.size <= current_addr) {
// If we're now in the next VMA, then go to the next handle.
vma_handle++;
}
}
return ORBIS_OK;
@ -1262,10 +1265,15 @@ void MemoryManager::NameVirtualRange(VAddr virtual_addr, u64 size, std::string_v
vma.name = name;
}
}
it = MergeAdjacent(vma_map, it);
remaining_size -= size_in_vma;
current_addr += size_in_vma;
it++;
// Check if VMA can be merged with adjacent areas after modifications.
it = MergeAdjacent(vma_map, it);
if (it->second.base + it->second.size <= current_addr) {
// If we're now in the next VMA, then go to the next handle.
it++;
}
}
}

View File

@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
// SPDX-FileCopyrightText: Copyright 2024-2026 shadPS4 Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once

View File

@ -18,12 +18,11 @@ struct User {
};
struct Users {
int default_user_id = 1;
std::vector<User> user{};
std::string commit_hash{};
};
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(User, user_id, user_color, user_name, player_index)
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Users, default_user_id, user, commit_hash)
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Users, user, commit_hash)
using LoggedInUsers = std::array<User*, 4>;

View File

@ -14,6 +14,7 @@
#include "common/logging/backend.h"
#include "common/logging/log.h"
#include "common/thread.h"
#include "core/emulator_settings.h"
#include "core/ipc/ipc.h"
#ifdef ENABLE_DISCORD_RPC
#include "common/discord_rpc_handler.h"

View File

@ -218,6 +218,7 @@ void Render(const vk::CommandBuffer& cmdbuf, const vk::ImageView& image_view,
if (draw_data->CmdListsCount == 0) {
return;
}
if (EmulatorSettings.IsVkHostMarkersEnabled()) {
cmdbuf.beginDebugUtilsLabelEXT(vk::DebugUtilsLabelEXT{
.pLabelName = "ImGui Render",

View File

@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: Copyright 2026 shadPS4 Emulator Project
// SPDX-FileCopyrightText: Copyright 2024-2026 shadPS4 Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
// Based on imgui_impl_sdl3.cpp from Dear ImGui repository

View File

@ -9,6 +9,7 @@
#include <CLI/CLI.hpp>
#include <SDL3/SDL_messagebox.h>
#include <core/emulator_settings.h>
#include <core/emulator_state.h>
#include "common/key_manager.h"
#include "common/logging/backend.h"
@ -18,7 +19,6 @@
#include "core/file_sys/fs.h"
#include "core/ipc/ipc.h"
#include "emulator.h"
#ifdef _WIN32
#include <windows.h>
#endif
@ -43,6 +43,11 @@ int main(int argc, char* argv[]) {
auto key_manager = KeyManager::GetInstance();
key_manager->LoadFromFile();
// Load configurations
std::shared_ptr<EmulatorSettingsImpl> emu_settings = std::make_shared<EmulatorSettingsImpl>();
EmulatorSettingsImpl::SetInstance(emu_settings);
emu_settings->Load();
CLI::App app{"shadPS4 Emulator CLI"};
// ---- CLI state ----

View File

@ -5,6 +5,7 @@
#include "common/div_ceil.h"
#include "common/logging/log.h"
#include "core/emulator_settings.h"
#ifdef __linux__
#include "common/adaptive_mutex.h"

View File

@ -5,6 +5,7 @@
#include "common/io_file.h"
#include "common/polyfill_thread.h"
#include "common/thread.h"
#include "core/emulator_settings.h"
#include "core/emulator_settings.h"
#include "video_core/cache_storage.h"

View File

@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: Copyright 2025-2026 shadPS4 Emulator Project
// SPDX-FileCopyrightText: Copyright 2024-2026 shadPS4 Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#include <ranges>

View File

@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: Copyright 2026 shadPS4 Emulator Project
// SPDX-FileCopyrightText: Copyright 2024-2026 shadPS4 Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#include "common/debug.h"
@ -596,7 +596,6 @@ void Presenter::Present(Frame* frame, bool is_reusing_frame) {
TracyVkCollect(profiler_ctx, cmdbuf);
}
}
if (EmulatorSettings.IsVkHostMarkersEnabled()) {
cmdbuf.endDebugUtilsLabelEXT();
}

View File

@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: Copyright 2026 shadPS4 Emulator Project
// SPDX-FileCopyrightText: Copyright 2024-2026 shadPS4 Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#include "common/debug.h"

View File

@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: Copyright 2025-2026 shadPS4 Emulator Project
// SPDX-FileCopyrightText: Copyright 2024-2026 shadPS4 Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#include <algorithm>

View File

@ -247,13 +247,11 @@ Image::Barriers Image::GetBarriers(vk::ImageLayout dst_layout, vk::AccessFlags2
ASSERT(subres_idx < subresource_states.size());
auto& state = subresource_states[subres_idx];
if (state.layout != dst_layout || state.access_mask != dst_mask ||
static_cast<bool>(dst_mask &
(vk::AccessFlagBits2::eTransferWrite |
vk::AccessFlagBits2::eShaderWrite |
vk::AccessFlagBits2::eColorAttachmentWrite |
vk::AccessFlagBits2::eDepthStencilAttachmentWrite |
vk::AccessFlagBits2::eMemoryWrite))) {
constexpr auto write_flags = vk::AccessFlagBits2::eTransferWrite |
vk::AccessFlagBits2::eShaderWrite |
vk::AccessFlagBits2::eMemoryWrite;
const bool is_write = static_cast<bool>(state.access_mask & write_flags);
if (state.layout != dst_layout || state.access_mask != dst_mask || is_write) {
barriers.emplace_back(vk::ImageMemoryBarrier2{
.srcStageMask = state.pl_stage,
.srcAccessMask = state.access_mask,
@ -283,11 +281,10 @@ Image::Barriers Image::GetBarriers(vk::ImageLayout dst_layout, vk::AccessFlags2
subresource_states.clear();
}
} else { // Full resource transition
constexpr auto write_flags =
vk::AccessFlagBits2::eTransferWrite | vk::AccessFlagBits2::eShaderWrite |
vk::AccessFlagBits2::eColorAttachmentWrite |
vk::AccessFlagBits2::eDepthStencilAttachmentWrite | vk::AccessFlagBits2::eMemoryWrite;
const bool is_write = static_cast<bool>(dst_mask & write_flags);
constexpr auto write_flags = vk::AccessFlagBits2::eTransferWrite |
vk::AccessFlagBits2::eShaderWrite |
vk::AccessFlagBits2::eMemoryWrite;
const bool is_write = static_cast<bool>(last_state.access_mask & write_flags);
if (last_state.layout == dst_layout && last_state.access_mask == dst_mask && !is_write) {
return {};
}
@ -385,6 +382,8 @@ void Image::Upload(std::span<const vk::BufferImageCopy> upload_copies, vk::Buffe
.bufferMemoryBarrierCount = 1,
.pBufferMemoryBarriers = &post_barrier,
});
Transit(vk::ImageLayout::eGeneral,
vk::AccessFlagBits2::eShaderRead | vk::AccessFlagBits2::eTransferRead, {});
flags &= ~ImageFlagBits::Dirty;
}
@ -655,8 +654,6 @@ void Image::CopyImageWithBuffer(Image& src_image, vk::Buffer buffer, u64 offset)
cmdbuf.copyBufferToImage(buffer, GetImage(), vk::ImageLayout::eTransferDstOptimal,
buffer_copies);
// Match CopyImage: transition to general so shaders can sample the result.
Transit(vk::ImageLayout::eGeneral,
vk::AccessFlagBits2::eShaderRead | vk::AccessFlagBits2::eTransferRead, {});
}
@ -698,6 +695,8 @@ void Image::CopyMip(Image& src_image, u32 mip, u32 slice) {
const auto cmdbuf = scheduler->CommandBuffer();
cmdbuf.copyImage(src_image.GetImage(), src_image.backing->state.layout, GetImage(),
backing->state.layout, image_copy);
Transit(vk::ImageLayout::eGeneral,
vk::AccessFlagBits2::eShaderRead | vk::AccessFlagBits2::eTransferRead, {});
}
void Image::Resolve(Image& src_image, const VideoCore::SubresourceRange& mrt0_range,