possibly the biggest clang-format commit in shadPS4 so far

This commit is contained in:
kalaposfos13 2026-03-02 20:36:59 +01:00
parent 111f893f97
commit d92d55923b
26 changed files with 54 additions and 88 deletions

View File

@ -185,8 +185,7 @@ public:
void PushEntry(Class log_class, Level log_level, const char* filename, unsigned int line_num,
const char* function, const char* format, const fmt::format_args& args) {
if (!filter.CheckMessage(log_class, log_level) ||
!EmulatorSettings.IsLogEnabled()) {
if (!filter.CheckMessage(log_class, log_level) || !EmulatorSettings.IsLogEnabled()) {
return;
}

View File

@ -88,8 +88,8 @@
#if defined(_MSC_VER) || defined(_UCRT)
#pragma warning(push)
#pragma warning( \
disable : 4996) // warning C4996: 'sprintf': This function or variable may be unsafe.
#pragma warning(disable \
: 4996) // warning C4996: 'sprintf': This function or variable may be unsafe.
#endif
struct MemoryEditor {

View File

@ -99,7 +99,8 @@ void EmulatorSettingsImpl::RemoveGameInstallDir(const std::filesystem::path& dir
}
}
void EmulatorSettingsImpl::SetGameInstallDirEnabled(const std::filesystem::path& dir, bool enabled) {
void EmulatorSettingsImpl::SetGameInstallDirEnabled(const std::filesystem::path& dir,
bool enabled) {
auto iterator =
std::find_if(m_general.install_dirs.value.begin(), m_general.install_dirs.value.end(),
[&dir](const GameInstallDir& install_dir) { return install_dir.path == dir; });
@ -108,7 +109,8 @@ void EmulatorSettingsImpl::SetGameInstallDirEnabled(const std::filesystem::path&
}
}
void EmulatorSettingsImpl::SetGameInstallDirs(const std::vector<std::filesystem::path>& dirs_config) {
void EmulatorSettingsImpl::SetGameInstallDirs(
const std::vector<std::filesystem::path>& dirs_config) {
m_general.install_dirs.value.clear();
for (const auto& dir : dirs_config) {
m_general.install_dirs.value.push_back({dir, true});

View File

@ -3,8 +3,8 @@
#pragma once
#include <mutex>
#include <memory>
#include <mutex>
#include <core/libraries/system/userservice.h>
#include "common/types.h"

View File

@ -110,8 +110,7 @@ public:
max_channel_gain = std::max(max_channel_gain, channel_gain);
}
const float slider_gain =
EmulatorSettings.GetVolumeSlider() * 0.01f; // Faster than /100.0f
const float slider_gain = EmulatorSettings.GetVolumeSlider() * 0.01f; // Faster than /100.0f
const float total_gain = max_channel_gain * slider_gain;
const float current = current_gain.load(std::memory_order_acquire);
@ -157,8 +156,7 @@ private:
}
// Initialize current gain
current_gain.store(EmulatorSettings.GetVolumeSlider() * 0.01f,
std::memory_order_relaxed);
current_gain.store(EmulatorSettings.GetVolumeSlider() * 0.01f, std::memory_order_relaxed);
if (!SelectConverter()) {
FreeAlignedBuffer();

View File

@ -180,9 +180,8 @@ int PS4_SYSV_ABI sceNetCtlGetInfo(int code, OrbisNetCtlInfo* info) {
info->mtu = 1500; // default value
break;
case ORBIS_NET_CTL_INFO_LINK:
info->link = EmulatorSettings.IsConnectedToNetwork()
? ORBIS_NET_CTL_LINK_CONNECTED
: ORBIS_NET_CTL_LINK_DISCONNECTED;
info->link = EmulatorSettings.IsConnectedToNetwork() ? ORBIS_NET_CTL_LINK_CONNECTED
: ORBIS_NET_CTL_LINK_DISCONNECTED;
break;
case ORBIS_NET_CTL_INFO_IP_ADDRESS: {
strcpy(info->ip_address,

View File

@ -631,8 +631,7 @@ s32 PS4_SYSV_ABI sceNpGetNpId(Libraries::UserService::OrbisUserServiceUserId use
return ORBIS_NP_ERROR_SIGNED_OUT;
}
memset(np_id, 0, sizeof(OrbisNpId));
strncpy(np_id->handle.data,
UserManagement.GetDefaultUser().user_name.c_str(),
strncpy(np_id->handle.data, UserManagement.GetDefaultUser().user_name.c_str(),
sizeof(np_id->handle.data));
return ORBIS_OK;
}
@ -647,8 +646,7 @@ s32 PS4_SYSV_ABI sceNpGetOnlineId(Libraries::UserService::OrbisUserServiceUserId
return ORBIS_NP_ERROR_SIGNED_OUT;
}
memset(online_id, 0, sizeof(OrbisNpOnlineId));
strncpy(online_id->data,
UserManagement.GetDefaultUser().user_name.c_str(),
strncpy(online_id->data, UserManagement.GetDefaultUser().user_name.c_str(),
sizeof(online_id->data));
return ORBIS_OK;
}

View File

@ -376,8 +376,7 @@ int PS4_SYSV_ABI sceNpMatching2ContextStart(OrbisNpMatching2ContextId ctxId, u64
}
std::scoped_lock lk{g_events_mutex};
if (EmulatorSettings.IsConnectedToNetwork() &&
EmulatorSettings.IsPSNSignedIn()) {
if (EmulatorSettings.IsConnectedToNetwork() && EmulatorSettings.IsPSNSignedIn()) {
g_ctx_events.emplace_back(ctxId, ORBIS_NP_MATCHING2_CONTEXT_EVENT_STARTED,
ORBIS_NP_MATCHING2_EVENT_CAUSE_CONTEXT_ACTION, 0);
} else {

View File

@ -93,8 +93,7 @@ TrophyUI::TrophyUI(const std::filesystem::path& trophyIconPath, const std::strin
return;
}
MIX_SetMasterGain(
mixer, static_cast<float>(EmulatorSettings.GetVolumeSlider() / 100.f));
MIX_SetMasterGain(mixer, static_cast<float>(EmulatorSettings.GetVolumeSlider() / 100.f));
auto musicPathMp3 = CustomTrophy_Dir / "trophy.mp3";
auto musicPathWav = CustomTrophy_Dir / "trophy.wav";

View File

@ -32,8 +32,7 @@ int PS4_SYSV_ABI scePadDeviceClassGetExtendedInformation(
LOG_ERROR(Lib_Pad, "(STUBBED) called");
std::memset(pExtInfo, 0, sizeof(OrbisPadDeviceClassExtendedInformation));
if (EmulatorSettings.IsUsingSpecialPad()) {
pExtInfo->deviceClass =
(OrbisPadDeviceClass)EmulatorSettings.GetSpecialPadClass();
pExtInfo->deviceClass = (OrbisPadDeviceClass)EmulatorSettings.GetSpecialPadClass();
}
return ORBIS_OK;
}
@ -111,8 +110,7 @@ int PS4_SYSV_ABI scePadGetControllerInformation(s32 handle, OrbisPadControllerIn
pInfo->connected = true;
if (EmulatorSettings.IsUsingSpecialPad()) {
pInfo->connectionType = ORBIS_PAD_PORT_TYPE_SPECIAL;
pInfo->deviceClass =
(OrbisPadDeviceClass)EmulatorSettings.GetSpecialPadClass();
pInfo->deviceClass = (OrbisPadDeviceClass)EmulatorSettings.GetSpecialPadClass();
}
return ORBIS_OK;
}

View File

@ -48,14 +48,13 @@ namespace Libraries::SaveData {
fs::path SaveInstance::MakeTitleSavePath(Libraries::UserService::OrbisUserServiceUserId user_id,
std::string_view game_serial) {
return EmulatorSettings.GetHomeDir() / std::to_string(user_id) / "savedata" /
game_serial;
return EmulatorSettings.GetHomeDir() / std::to_string(user_id) / "savedata" / game_serial;
}
fs::path SaveInstance::MakeDirSavePath(OrbisUserServiceUserId user_id, std::string_view game_serial,
std::string_view dir_name) {
return EmulatorSettings.GetHomeDir() / std::to_string(user_id) / "savedata" /
game_serial / dir_name;
return EmulatorSettings.GetHomeDir() / std::to_string(user_id) / "savedata" / game_serial /
dir_name;
}
uint64_t SaveInstance::GetMaxBlockFromSFO(const PSF& psf) {

View File

@ -439,8 +439,8 @@ static Error saveDataMount(const OrbisSaveDataMount2* mount_info,
LOG_INFO(Lib_SaveData, "called with invalid block size");
}
const auto root_save = EmulatorSettings.GetHomeDir() /
std::to_string(mount_info->userId) / "savedata";
const auto root_save =
EmulatorSettings.GetHomeDir() / std::to_string(mount_info->userId) / "savedata";
fs::create_directories(root_save);
const auto available = fs::space(root_save).available;

View File

@ -1084,10 +1084,7 @@ s32 PS4_SYSV_ABI sceUserServiceGetUserColor(int user_id, OrbisUserServiceUserCol
LOG_ERROR(Lib_UserService, "color is null");
return ORBIS_USER_SERVICE_ERROR_INVALID_ARGUMENT;
}
*color = (OrbisUserServiceUserColor)EmulatorSettingsImpl::GetInstance()
->GetUserManager()
.GetUserByID(user_id)
->user_color;
*color = (OrbisUserServiceUserColor)UserManagement.GetUserByID(user_id)->user_color;
return ORBIS_OK;
}

View File

@ -10,7 +10,6 @@
#include <fmt/format.h>
#include <libusb.h>
namespace Libraries::Usbd {
s32 libusb_to_orbis_error(int retVal) {

View File

@ -268,8 +268,8 @@ void VideoOutDriver::SubmitFlipInternal(VideoOutPort* port, s32 index, s64 flip_
}
void VideoOutDriver::PresentThread(std::stop_token token) {
const std::chrono::nanoseconds vblank_period(
1000000000 / EmulatorSettings.GetVblankFrequency());
const std::chrono::nanoseconds vblank_period(1000000000 /
EmulatorSettings.GetVblankFrequency());
Common::SetCurrentThreadName("shadPS4:PresentThread");
Common::SetCurrentThreadRealtime(vblank_period);

View File

@ -455,9 +455,8 @@ s32 PS4_SYSV_ABI sceVideoOutSetWindowModeMargins(s32 handle, s32 top, s32 bottom
}
void RegisterLib(Core::Loader::SymbolsResolver* sym) {
driver = std::make_unique<VideoOutDriver>(
EmulatorSettings.GetInternalScreenWidth(),
EmulatorSettings.GetInternalScreenHeight());
driver = std::make_unique<VideoOutDriver>(EmulatorSettings.GetInternalScreenWidth(),
EmulatorSettings.GetInternalScreenHeight());
LIB_FUNCTION("SbU3dwp80lQ", "libSceVideoOut", 1, "libSceVideoOut", sceVideoOutGetFlipStatus);
LIB_FUNCTION("U46NwOiJpys", "libSceVideoOut", 1, "libSceVideoOut", sceVideoOutSubmitFlip);

View File

@ -16,8 +16,7 @@ bool UserManager::AddUser(const User& user) {
m_users.user.push_back(user);
// Create user home directory and subfolders
const auto user_dir =
EmulatorSettings.GetHomeDir() / std::to_string(user.user_id);
const auto user_dir = EmulatorSettings.GetHomeDir() / std::to_string(user.user_id);
std::error_code ec;
if (!std::filesystem::exists(user_dir)) {
@ -80,8 +79,7 @@ std::vector<User> UserManager::CreateDefaultUser() {
default_user.user_name = "shadPS4";
default_user.controller_port = 1;
const auto user_dir =
EmulatorSettings.GetHomeDir() / std::to_string(default_user.user_id);
const auto user_dir = EmulatorSettings.GetHomeDir() / std::to_string(default_user.user_id);
if (!std::filesystem::exists(user_dir)) {
std::filesystem::create_directory(user_dir);

View File

@ -665,8 +665,7 @@ static void UpdateMouseCursor() {
} else if (cursorState == HideCursorState::Idle &&
bd->time - bd->lastCursorMoveTime >=
EmulatorSettings.GetCursorHideTimeout() *
SDL_GetPerformanceFrequency()) {
EmulatorSettings.GetCursorHideTimeout() * SDL_GetPerformanceFrequency()) {
bool wasCursorVisible = SDL_CursorVisible();
SDL_HideCursor();

View File

@ -117,10 +117,8 @@ WindowSDL::WindowSDL(s32 width_, s32 height_, Input::GameControllers* controller
error = true;
}
if (!error) {
SDL_SetWindowFullscreenMode(window, EmulatorSettings.GetFullScreenMode() ==
"Fullscreen"
? displayMode
: NULL);
SDL_SetWindowFullscreenMode(
window, EmulatorSettings.GetFullScreenMode() == "Fullscreen" ? displayMode : NULL);
}
SDL_SetWindowFullscreen(window, EmulatorSettings.IsFullScreen());

View File

@ -229,10 +229,8 @@ Liverpool::Task Liverpool::ProcessGraphics(std::span<const u32> dcb, std::span<c
ce_task = ProcessCeUpdate(ccb);
RESUME_GFX(ce_task);
}
const bool host_markers_enabled =
rasterizer && EmulatorSettings.IsVkHostMarkersEnabled();
const bool guest_markers_enabled =
rasterizer && EmulatorSettings.IsVkGuestMarkersEnabled();
const bool host_markers_enabled = rasterizer && EmulatorSettings.IsVkHostMarkersEnabled();
const bool guest_markers_enabled = rasterizer && EmulatorSettings.IsVkGuestMarkersEnabled();
const auto base_addr = reinterpret_cast<uintptr_t>(dcb.data());
while (!dcb.empty()) {
@ -901,8 +899,7 @@ template <bool is_indirect>
Liverpool::Task Liverpool::ProcessCompute(std::span<const u32> acb, u32 vqid) {
FIBER_ENTER(acb_task_name[vqid]);
auto& queue = asc_queues[{vqid}];
const bool host_markers_enabled =
rasterizer && EmulatorSettings.IsVkHostMarkersEnabled();
const bool host_markers_enabled = rasterizer && EmulatorSettings.IsVkHostMarkersEnabled();
struct IndirectPatch {
const PM4Header* header;

View File

@ -74,8 +74,7 @@ public:
// modified. If we need to flush the flush function is going to perform CPU
// state change.
std::scoped_lock lk{manager->lock};
if (EmulatorSettings.GetReadbacksMode() !=
GpuReadbacksMode::Disabled &&
if (EmulatorSettings.GetReadbacksMode() != GpuReadbacksMode::Disabled &&
manager->template IsRegionModified<Type::GPU>(offset, size)) {
return true;
}

View File

@ -95,8 +95,7 @@ public:
}
if constexpr (type == Type::CPU) {
UpdateProtection<!enable, false>();
} else if (EmulatorSettings.GetReadbacksMode() ==
GpuReadbacksMode::Precise) {
} else if (EmulatorSettings.GetReadbacksMode() == GpuReadbacksMode::Precise) {
UpdateProtection<enable, true>();
}
}
@ -127,8 +126,7 @@ public:
bits.UnsetRange(start_page, end_page);
if constexpr (type == Type::CPU) {
UpdateProtection<true, false>();
} else if (EmulatorSettings.GetReadbacksMode() !=
GpuReadbacksMode::Disabled) {
} else if (EmulatorSettings.GetReadbacksMode() != GpuReadbacksMode::Disabled) {
UpdateProtection<false, true>();
}
}

View File

@ -192,9 +192,8 @@ bool DataBase::Save(BlobType type, const std::string& name, std::vector<u8>&& da
return false;
}
auto path = EmulatorSettings.IsPipelineCacheArchived()
? std::filesystem::path{name}
: cache_path / name;
auto path = EmulatorSettings.IsPipelineCacheArchived() ? std::filesystem::path{name}
: cache_path / name;
return WriteVector(type, std::move(path), std::move(data));
}
@ -203,9 +202,8 @@ bool DataBase::Save(BlobType type, const std::string& name, std::vector<u32>&& d
return false;
}
auto path = EmulatorSettings.IsPipelineCacheArchived()
? std::filesystem::path{name}
: cache_path / name;
auto path = EmulatorSettings.IsPipelineCacheArchived() ? std::filesystem::path{name}
: cache_path / name;
return WriteVector(type, std::move(path), std::move(data));
}
@ -214,9 +212,8 @@ void DataBase::Load(BlobType type, const std::string& name, std::vector<u8>& dat
return;
}
auto path = EmulatorSettings.IsPipelineCacheArchived()
? std::filesystem::path{name}
: cache_path / name;
auto path = EmulatorSettings.IsPipelineCacheArchived() ? std::filesystem::path{name}
: cache_path / name;
return LoadVector(type, path, data);
}
@ -225,9 +222,8 @@ void DataBase::Load(BlobType type, const std::string& name, std::vector<u32>& da
return;
}
auto path = EmulatorSettings.IsPipelineCacheArchived()
? std::filesystem::path{name}
: cache_path / name;
auto path = EmulatorSettings.IsPipelineCacheArchived() ? std::filesystem::path{name}
: cache_path / name;
return LoadVector(type, path, data);
}

View File

@ -306,12 +306,9 @@ vk::UniqueInstance CreateInstance(Frontend::WindowSystemType window_type, bool e
LOG_INFO(Render_Vulkan, "Enabled instance layers: {}", layers_string);
// Validation settings
vk::Bool32 enable_core =
EmulatorSettings.IsVkValidationCoreEnabled() ? vk::True : vk::False;
vk::Bool32 enable_sync =
EmulatorSettings.IsVkValidationSyncEnabled() ? vk::True : vk::False;
vk::Bool32 enable_gpuav =
EmulatorSettings.IsVkValidationGpuEnabled() ? vk::True : vk::False;
vk::Bool32 enable_core = EmulatorSettings.IsVkValidationCoreEnabled() ? vk::True : vk::False;
vk::Bool32 enable_sync = EmulatorSettings.IsVkValidationSyncEnabled() ? vk::True : vk::False;
vk::Bool32 enable_gpuav = EmulatorSettings.IsVkValidationGpuEnabled() ? vk::True : vk::False;
// Crash diagnostics settings
static const auto crash_diagnostic_path =

View File

@ -104,8 +104,7 @@ static vk::Rect2D FitImage(s32 frame_width, s32 frame_height, s32 swapchain_widt
Presenter::Presenter(Frontend::WindowSDL& window_, AmdGpu::Liverpool* liverpool_)
: window{window_}, liverpool{liverpool_},
instance{window, EmulatorSettings.GetGpuId(),
EmulatorSettings.IsVkValidationEnabled(),
instance{window, EmulatorSettings.GetGpuId(), EmulatorSettings.IsVkValidationEnabled(),
EmulatorSettings.IsVkCrashDiagnosticEnabled()},
draw_scheduler{instance}, present_scheduler{instance}, flip_scheduler{instance},
swapchain{instance, window},

View File

@ -649,8 +649,8 @@ ImageView& TextureCache::FindTexture(ImageId image_id, const ImageDesc& desc) {
Image& image = slot_images[image_id];
if (desc.type == BindingType::Storage) {
image.flags |= ImageFlagBits::GpuModified;
if (EmulatorSettings.IsReadbackLinearImagesEnabled() &&
!image.info.props.is_tiled && image.info.guest_address != 0) {
if (EmulatorSettings.IsReadbackLinearImagesEnabled() && !image.info.props.is_tiled &&
image.info.guest_address != 0) {
download_images.emplace(image_id);
}
}
@ -661,8 +661,7 @@ ImageView& TextureCache::FindTexture(ImageId image_id, const ImageDesc& desc) {
ImageView& TextureCache::FindRenderTarget(ImageId image_id, const ImageDesc& desc) {
Image& image = slot_images[image_id];
image.flags |= ImageFlagBits::GpuModified;
if (EmulatorSettings.IsReadbackLinearImagesEnabled() &&
!image.info.props.is_tiled) {
if (EmulatorSettings.IsReadbackLinearImagesEnabled() && !image.info.props.is_tiled) {
download_images.emplace(image_id);
}
image.usage.render_target = 1u;