mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-07-28 04:54:30 +00:00
Merge branch 'shadps4-emu:main' into memory-fixes-again
This commit is contained in:
commit
62092753f6
@ -19,8 +19,6 @@ enum class MemoryPermission : u32 {
|
|||||||
};
|
};
|
||||||
DECLARE_ENUM_FLAG_OPERATORS(MemoryPermission)
|
DECLARE_ENUM_FLAG_OPERATORS(MemoryPermission)
|
||||||
|
|
||||||
constexpr VAddr CODE_BASE_OFFSET = 0x100000000ULL;
|
|
||||||
|
|
||||||
constexpr VAddr SYSTEM_MANAGED_MIN = 0x00000400000ULL;
|
constexpr VAddr SYSTEM_MANAGED_MIN = 0x00000400000ULL;
|
||||||
constexpr VAddr SYSTEM_MANAGED_MAX = 0x07FFFFBFFFULL;
|
constexpr VAddr SYSTEM_MANAGED_MAX = 0x07FFFFBFFFULL;
|
||||||
constexpr VAddr SYSTEM_RESERVED_MIN = 0x07FFFFC000ULL;
|
constexpr VAddr SYSTEM_RESERVED_MIN = 0x07FFFFC000ULL;
|
||||||
|
@ -181,10 +181,6 @@ s32 PS4_SYSV_ABI open(const char* raw_path, s32 flags, u16 mode) {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Start by opening as read-write so we can truncate regardless of flags.
|
|
||||||
// Since open starts by closing the file, this won't interfere with later open calls.
|
|
||||||
e = file->f.Open(file->m_host_name, Common::FS::FileAccessMode::ReadWrite);
|
|
||||||
|
|
||||||
file->type = Core::FileSys::FileType::Regular;
|
file->type = Core::FileSys::FileType::Regular;
|
||||||
|
|
||||||
if (truncate && read_only) {
|
if (truncate && read_only) {
|
||||||
@ -192,10 +188,15 @@ s32 PS4_SYSV_ABI open(const char* raw_path, s32 flags, u16 mode) {
|
|||||||
h->DeleteHandle(handle);
|
h->DeleteHandle(handle);
|
||||||
*__Error() = POSIX_EROFS;
|
*__Error() = POSIX_EROFS;
|
||||||
return -1;
|
return -1;
|
||||||
} else if (truncate && e == 0) {
|
} else if (truncate) {
|
||||||
// If the file was opened successfully and truncate was enabled, reduce size to 0
|
// Open the file as read-write so we can truncate regardless of flags.
|
||||||
|
// Since open starts by closing the file, this won't interfere with later open calls.
|
||||||
|
e = file->f.Open(file->m_host_name, Common::FS::FileAccessMode::ReadWrite);
|
||||||
|
if (e == 0) {
|
||||||
|
// If the file was opened successfully, reduce size to 0
|
||||||
file->f.SetSize(0);
|
file->f.SetSize(0);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (read) {
|
if (read) {
|
||||||
// Read only
|
// Read only
|
||||||
|
@ -49,14 +49,12 @@ void SaveDialogResult::CopyTo(OrbisSaveDataDialogResult& result) const {
|
|||||||
result.mode = this->mode;
|
result.mode = this->mode;
|
||||||
result.result = this->result;
|
result.result = this->result;
|
||||||
result.buttonId = this->button_id;
|
result.buttonId = this->button_id;
|
||||||
if (mode == SaveDataDialogMode::LIST || ElfInfo::Instance().FirmwareVer() >= ElfInfo::FW_45) {
|
|
||||||
if (result.dirName != nullptr) {
|
if (result.dirName != nullptr) {
|
||||||
result.dirName->data.FromString(this->dir_name);
|
result.dirName->data.FromString(this->dir_name);
|
||||||
}
|
}
|
||||||
if (result.param != nullptr && this->param.GetString(SaveParams::MAINTITLE).has_value()) {
|
if (result.param != nullptr && this->param.GetString(SaveParams::MAINTITLE).has_value()) {
|
||||||
result.param->FromSFO(this->param);
|
result.param->FromSFO(this->param);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
result.userData = this->user_data;
|
result.userData = this->user_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -345,12 +343,15 @@ SaveDialogUi::SaveDialogUi(SaveDialogUi&& other) noexcept
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SaveDialogUi& SaveDialogUi::operator=(SaveDialogUi other) {
|
SaveDialogUi& SaveDialogUi::operator=(SaveDialogUi&& other) noexcept {
|
||||||
std::scoped_lock lock(draw_mutex, other.draw_mutex);
|
std::scoped_lock lock(draw_mutex, other.draw_mutex);
|
||||||
using std::swap;
|
using std::swap;
|
||||||
swap(state, other.state);
|
state = other.state;
|
||||||
swap(status, other.status);
|
other.state = nullptr;
|
||||||
swap(result, other.result);
|
status = other.status;
|
||||||
|
other.status = nullptr;
|
||||||
|
result = other.result;
|
||||||
|
other.result = nullptr;
|
||||||
if (status && *status == Status::RUNNING) {
|
if (status && *status == Status::RUNNING) {
|
||||||
first_render = true;
|
first_render = true;
|
||||||
AddLayer(this);
|
AddLayer(this);
|
||||||
|
@ -300,7 +300,8 @@ public:
|
|||||||
~SaveDialogUi() override;
|
~SaveDialogUi() override;
|
||||||
SaveDialogUi(const SaveDialogUi& other) = delete;
|
SaveDialogUi(const SaveDialogUi& other) = delete;
|
||||||
SaveDialogUi(SaveDialogUi&& other) noexcept;
|
SaveDialogUi(SaveDialogUi&& other) noexcept;
|
||||||
SaveDialogUi& operator=(SaveDialogUi other);
|
SaveDialogUi& operator=(SaveDialogUi& other) = delete;
|
||||||
|
SaveDialogUi& operator=(SaveDialogUi&& other) noexcept;
|
||||||
|
|
||||||
void Finish(ButtonId buttonId, CommonDialog::Result r = CommonDialog::Result::OK);
|
void Finish(ButtonId buttonId, CommonDialog::Result r = CommonDialog::Result::OK);
|
||||||
|
|
||||||
|
@ -19,8 +19,7 @@ namespace Core {
|
|||||||
|
|
||||||
using EntryFunc = PS4_SYSV_ABI int (*)(size_t args, const void* argp, void* param);
|
using EntryFunc = PS4_SYSV_ABI int (*)(size_t args, const void* argp, void* param);
|
||||||
|
|
||||||
static u64 LoadOffset = CODE_BASE_OFFSET;
|
static constexpr u64 ModuleLoadBase = 0x800000000;
|
||||||
static constexpr u64 CODE_BASE_INCR = 0x010000000u;
|
|
||||||
|
|
||||||
static u64 GetAlignedSize(const elf_program_header& phdr) {
|
static u64 GetAlignedSize(const elf_program_header& phdr) {
|
||||||
return (phdr.p_align != 0 ? (phdr.p_memsz + (phdr.p_align - 1)) & ~(phdr.p_align - 1)
|
return (phdr.p_align != 0 ? (phdr.p_memsz + (phdr.p_align - 1)) & ~(phdr.p_align - 1)
|
||||||
@ -84,7 +83,7 @@ static std::string StringToNid(std::string_view symbol) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Module::Module(Core::MemoryManager* memory_, const std::filesystem::path& file_, u32& max_tls_index)
|
Module::Module(Core::MemoryManager* memory_, const std::filesystem::path& file_, u32& max_tls_index)
|
||||||
: memory{memory_}, file{file_}, name{file.stem().string()} {
|
: memory{memory_}, file{file_}, name{file.filename().string()} {
|
||||||
elf.Open(file);
|
elf.Open(file);
|
||||||
if (elf.IsElfFile()) {
|
if (elf.IsElfFile()) {
|
||||||
LoadModuleToMemory(max_tls_index);
|
LoadModuleToMemory(max_tls_index);
|
||||||
@ -113,10 +112,8 @@ void Module::LoadModuleToMemory(u32& max_tls_index) {
|
|||||||
|
|
||||||
// Map module segments (and possible TLS trampolines)
|
// Map module segments (and possible TLS trampolines)
|
||||||
void** out_addr = reinterpret_cast<void**>(&base_virtual_addr);
|
void** out_addr = reinterpret_cast<void**>(&base_virtual_addr);
|
||||||
memory->MapMemory(out_addr, memory->SystemReservedVirtualBase() + LoadOffset,
|
memory->MapMemory(out_addr, ModuleLoadBase, aligned_base_size + TrampolineSize,
|
||||||
aligned_base_size + TrampolineSize, MemoryProt::CpuReadWrite,
|
MemoryProt::CpuReadWrite, MemoryMapFlags::NoFlags, VMAType::Code, name, true);
|
||||||
MemoryMapFlags::Fixed, VMAType::Code, name, true);
|
|
||||||
LoadOffset += CODE_BASE_INCR * (1 + aligned_base_size / CODE_BASE_INCR);
|
|
||||||
LOG_INFO(Core_Linker, "Loading module {} to {}", name, fmt::ptr(*out_addr));
|
LOG_INFO(Core_Linker, "Loading module {} to {}", name, fmt::ptr(*out_addr));
|
||||||
|
|
||||||
#ifdef ARCH_X86_64
|
#ifdef ARCH_X86_64
|
||||||
@ -229,7 +226,7 @@ void Module::LoadModuleToMemory(u32& max_tls_index) {
|
|||||||
LOG_INFO(Core_Linker, "program entry addr ..........: {:#018x}", entry_addr);
|
LOG_INFO(Core_Linker, "program entry addr ..........: {:#018x}", entry_addr);
|
||||||
|
|
||||||
if (MemoryPatcher::g_eboot_address == 0) {
|
if (MemoryPatcher::g_eboot_address == 0) {
|
||||||
if (name == "eboot") {
|
if (name == "eboot.bin") {
|
||||||
MemoryPatcher::g_eboot_address = base_virtual_addr;
|
MemoryPatcher::g_eboot_address = base_virtual_addr;
|
||||||
MemoryPatcher::g_eboot_image_size = base_size;
|
MemoryPatcher::g_eboot_image_size = base_size;
|
||||||
MemoryPatcher::OnGameLoaded();
|
MemoryPatcher::OnGameLoaded();
|
||||||
|
148
src/emulator.cpp
148
src/emulator.cpp
@ -10,7 +10,6 @@
|
|||||||
#include "common/logging/log.h"
|
#include "common/logging/log.h"
|
||||||
#ifdef ENABLE_QT_GUI
|
#ifdef ENABLE_QT_GUI
|
||||||
#include <QtCore>
|
#include <QtCore>
|
||||||
#include "common/memory_patcher.h"
|
|
||||||
#endif
|
#endif
|
||||||
#include "common/assert.h"
|
#include "common/assert.h"
|
||||||
#ifdef ENABLE_DISCORD_RPC
|
#ifdef ENABLE_DISCORD_RPC
|
||||||
@ -20,6 +19,7 @@
|
|||||||
#include <WinSock2.h>
|
#include <WinSock2.h>
|
||||||
#endif
|
#endif
|
||||||
#include "common/elf_info.h"
|
#include "common/elf_info.h"
|
||||||
|
#include "common/memory_patcher.h"
|
||||||
#include "common/ntapi.h"
|
#include "common/ntapi.h"
|
||||||
#include "common/path_util.h"
|
#include "common/path_util.h"
|
||||||
#include "common/polyfill_thread.h"
|
#include "common/polyfill_thread.h"
|
||||||
@ -54,27 +54,6 @@ Emulator::Emulator() {
|
|||||||
WSADATA wsaData;
|
WSADATA wsaData;
|
||||||
WSAStartup(versionWanted, &wsaData);
|
WSAStartup(versionWanted, &wsaData);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Create stdin/stdout/stderr
|
|
||||||
Common::Singleton<FileSys::HandleTable>::Instance()->CreateStdHandles();
|
|
||||||
|
|
||||||
// Defer until after logging is initialized.
|
|
||||||
memory = Core::Memory::Instance();
|
|
||||||
controller = Common::Singleton<Input::GameController>::Instance();
|
|
||||||
linker = Common::Singleton<Core::Linker>::Instance();
|
|
||||||
|
|
||||||
// Load renderdoc module.
|
|
||||||
VideoCore::LoadRenderDoc();
|
|
||||||
|
|
||||||
// Start the timer (Play Time)
|
|
||||||
#ifdef ENABLE_QT_GUI
|
|
||||||
start_time = std::chrono::steady_clock::now();
|
|
||||||
const auto user_dir = Common::FS::GetUserPath(Common::FS::PathType::UserDir);
|
|
||||||
QString filePath = QString::fromStdString((user_dir / "play_time.txt").string());
|
|
||||||
QFile file(filePath);
|
|
||||||
ASSERT_MSG(file.open(QIODevice::ReadWrite | QIODevice::Text),
|
|
||||||
"Error opening or creating play_time.txt");
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Emulator::~Emulator() {
|
Emulator::~Emulator() {
|
||||||
@ -102,33 +81,39 @@ void Emulator::Run(const std::filesystem::path& file, const std::vector<std::str
|
|||||||
// Certain games may use /hostapp as well such as CUSA001100
|
// Certain games may use /hostapp as well such as CUSA001100
|
||||||
mnt->Mount(game_folder, "/hostapp", true);
|
mnt->Mount(game_folder, "/hostapp", true);
|
||||||
|
|
||||||
auto& game_info = Common::ElfInfo::Instance();
|
const auto param_sfo_path = mnt->GetHostPath("/app0/sce_sys/param.sfo");
|
||||||
|
const auto param_sfo_exists = std::filesystem::exists(param_sfo_path);
|
||||||
|
|
||||||
// Loading param.sfo file if exists
|
// Load param.sfo details if it exists
|
||||||
std::string id;
|
std::string id;
|
||||||
std::string title;
|
std::string title;
|
||||||
std::string app_version;
|
std::string app_version;
|
||||||
u32 fw_version;
|
u32 fw_version;
|
||||||
Common::PSFAttributes psf_attributes{};
|
Common::PSFAttributes psf_attributes{};
|
||||||
|
if (param_sfo_exists) {
|
||||||
const auto param_sfo_path = mnt->GetHostPath("/app0/sce_sys/param.sfo");
|
|
||||||
if (!std::filesystem::exists(param_sfo_path) || !Config::getSeparateLogFilesEnabled()) {
|
|
||||||
Common::Log::Initialize();
|
|
||||||
Common::Log::Start();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (std::filesystem::exists(param_sfo_path)) {
|
|
||||||
auto* param_sfo = Common::Singleton<PSF>::Instance();
|
auto* param_sfo = Common::Singleton<PSF>::Instance();
|
||||||
const bool success = param_sfo->Open(param_sfo_path);
|
ASSERT_MSG(param_sfo->Open(param_sfo_path), "Failed to open param.sfo");
|
||||||
ASSERT_MSG(success, "Failed to open param.sfo");
|
|
||||||
const auto content_id = param_sfo->GetString("CONTENT_ID");
|
const auto content_id = param_sfo->GetString("CONTENT_ID");
|
||||||
ASSERT_MSG(content_id.has_value(), "Failed to get CONTENT_ID");
|
ASSERT_MSG(content_id.has_value(), "Failed to get CONTENT_ID");
|
||||||
id = std::string(*content_id, 7, 9);
|
|
||||||
|
|
||||||
if (Config::getSeparateLogFilesEnabled()) {
|
id = std::string(*content_id, 7, 9);
|
||||||
Common::Log::Initialize(id + ".log");
|
title = param_sfo->GetString("TITLE").value_or("Unknown title");
|
||||||
Common::Log::Start();
|
fw_version = param_sfo->GetInteger("SYSTEM_VER").value_or(0x4700000);
|
||||||
|
app_version = param_sfo->GetString("APP_VER").value_or("Unknown version");
|
||||||
|
if (const auto raw_attributes = param_sfo->GetInteger("ATTRIBUTE")) {
|
||||||
|
psf_attributes.raw = *raw_attributes;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Initialize logging as soon as possible
|
||||||
|
if (!id.empty() && Config::getSeparateLogFilesEnabled()) {
|
||||||
|
Common::Log::Initialize(id + ".log");
|
||||||
|
} else {
|
||||||
|
Common::Log::Initialize();
|
||||||
|
}
|
||||||
|
Common::Log::Start();
|
||||||
|
|
||||||
LOG_INFO(Loader, "Starting shadps4 emulator v{} ", Common::g_version);
|
LOG_INFO(Loader, "Starting shadps4 emulator v{} ", Common::g_version);
|
||||||
LOG_INFO(Loader, "Revision {}", Common::g_scm_rev);
|
LOG_INFO(Loader, "Revision {}", Common::g_scm_rev);
|
||||||
LOG_INFO(Loader, "Branch {}", Common::g_scm_branch);
|
LOG_INFO(Loader, "Branch {}", Common::g_scm_branch);
|
||||||
@ -149,7 +134,36 @@ void Emulator::Run(const std::filesystem::path& file, const std::vector<std::str
|
|||||||
LOG_INFO(Config, "Vulkan guestMarkers: {}", Config::getVkGuestMarkersEnabled());
|
LOG_INFO(Config, "Vulkan guestMarkers: {}", Config::getVkGuestMarkersEnabled());
|
||||||
LOG_INFO(Config, "Vulkan rdocEnable: {}", Config::isRdocEnabled());
|
LOG_INFO(Config, "Vulkan rdocEnable: {}", Config::isRdocEnabled());
|
||||||
|
|
||||||
|
if (param_sfo_exists) {
|
||||||
|
LOG_INFO(Loader, "Game id: {} Title: {}", id, title);
|
||||||
|
LOG_INFO(Loader, "Fw: {:#x} App Version: {}", fw_version, app_version);
|
||||||
|
}
|
||||||
|
if (!args.empty()) {
|
||||||
|
const auto argc = std::min<size_t>(args.size(), 32);
|
||||||
|
for (auto i = 0; i < argc; i++) {
|
||||||
|
LOG_INFO(Loader, "Game argument {}: {}", i, args[i]);
|
||||||
|
}
|
||||||
|
if (args.size() > 32) {
|
||||||
|
LOG_ERROR(Loader, "Too many game arguments, only passing the first 32");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create stdin/stdout/stderr
|
||||||
|
Common::Singleton<FileSys::HandleTable>::Instance()->CreateStdHandles();
|
||||||
|
|
||||||
|
// Initialize components
|
||||||
|
memory = Core::Memory::Instance();
|
||||||
|
controller = Common::Singleton<Input::GameController>::Instance();
|
||||||
|
linker = Common::Singleton<Core::Linker>::Instance();
|
||||||
|
|
||||||
|
// Load renderdoc module
|
||||||
|
VideoCore::LoadRenderDoc();
|
||||||
|
|
||||||
|
// Initialize patcher and trophies
|
||||||
|
if (!id.empty()) {
|
||||||
|
MemoryPatcher::g_game_serial = id;
|
||||||
Libraries::NpTrophy::game_serial = id;
|
Libraries::NpTrophy::game_serial = id;
|
||||||
|
|
||||||
const auto trophyDir =
|
const auto trophyDir =
|
||||||
Common::FS::GetUserPath(Common::FS::PathType::MetaDataDir) / id / "TrophyFiles";
|
Common::FS::GetUserPath(Common::FS::PathType::MetaDataDir) / id / "TrophyFiles";
|
||||||
if (!std::filesystem::exists(trophyDir)) {
|
if (!std::filesystem::exists(trophyDir)) {
|
||||||
@ -158,41 +172,9 @@ void Emulator::Run(const std::filesystem::path& file, const std::vector<std::str
|
|||||||
LOG_ERROR(Loader, "Couldn't extract trophies");
|
LOG_ERROR(Loader, "Couldn't extract trophies");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifdef ENABLE_QT_GUI
|
|
||||||
MemoryPatcher::g_game_serial = id;
|
|
||||||
|
|
||||||
// Timer for 'Play Time'
|
|
||||||
QTimer* timer = new QTimer();
|
|
||||||
QObject::connect(timer, &QTimer::timeout, [this, id]() {
|
|
||||||
UpdatePlayTime(id);
|
|
||||||
start_time = std::chrono::steady_clock::now();
|
|
||||||
});
|
|
||||||
timer->start(60000); // 60000 ms = 1 minute
|
|
||||||
#endif
|
|
||||||
title = param_sfo->GetString("TITLE").value_or("Unknown title");
|
|
||||||
LOG_INFO(Loader, "Game id: {} Title: {}", id, title);
|
|
||||||
fw_version = param_sfo->GetInteger("SYSTEM_VER").value_or(0x4700000);
|
|
||||||
app_version = param_sfo->GetString("APP_VER").value_or("Unknown version");
|
|
||||||
LOG_INFO(Loader, "Fw: {:#x} App Version: {}", fw_version, app_version);
|
|
||||||
if (const auto raw_attributes = param_sfo->GetInteger("ATTRIBUTE")) {
|
|
||||||
psf_attributes.raw = *raw_attributes;
|
|
||||||
}
|
|
||||||
if (!args.empty()) {
|
|
||||||
int argc = std::min<int>(args.size(), 32);
|
|
||||||
for (int i = 0; i < argc; i++) {
|
|
||||||
LOG_INFO(Loader, "Game argument {}: {}", i, args[i]);
|
|
||||||
}
|
|
||||||
if (args.size() > 32) {
|
|
||||||
LOG_ERROR(Loader, "Too many game arguments, only passing the first 32");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const auto pic1_path = mnt->GetHostPath("/app0/sce_sys/pic1.png");
|
|
||||||
if (std::filesystem::exists(pic1_path)) {
|
|
||||||
game_info.splash_path = pic1_path;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto& game_info = Common::ElfInfo::Instance();
|
||||||
game_info.initialized = true;
|
game_info.initialized = true;
|
||||||
game_info.game_serial = id;
|
game_info.game_serial = id;
|
||||||
game_info.title = title;
|
game_info.title = title;
|
||||||
@ -201,6 +183,11 @@ void Emulator::Run(const std::filesystem::path& file, const std::vector<std::str
|
|||||||
game_info.raw_firmware_ver = fw_version;
|
game_info.raw_firmware_ver = fw_version;
|
||||||
game_info.psf_attributes = psf_attributes;
|
game_info.psf_attributes = psf_attributes;
|
||||||
|
|
||||||
|
const auto pic1_path = mnt->GetHostPath("/app0/sce_sys/pic1.png");
|
||||||
|
if (std::filesystem::exists(pic1_path)) {
|
||||||
|
game_info.splash_path = pic1_path;
|
||||||
|
}
|
||||||
|
|
||||||
std::string game_title = fmt::format("{} - {} <{}>", id, title, app_version);
|
std::string game_title = fmt::format("{} - {} <{}>", id, title, app_version);
|
||||||
std::string window_title = "";
|
std::string window_title = "";
|
||||||
if (Common::g_is_release) {
|
if (Common::g_is_release) {
|
||||||
@ -284,6 +271,25 @@ void Emulator::Run(const std::filesystem::path& file, const std::vector<std::str
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Start the timer (Play Time)
|
||||||
|
#ifdef ENABLE_QT_GUI
|
||||||
|
if (!id.empty()) {
|
||||||
|
auto* timer = new QTimer();
|
||||||
|
QObject::connect(timer, &QTimer::timeout, [this, id]() {
|
||||||
|
UpdatePlayTime(id);
|
||||||
|
start_time = std::chrono::steady_clock::now();
|
||||||
|
});
|
||||||
|
timer->start(60000); // 60000 ms = 1 minute
|
||||||
|
|
||||||
|
start_time = std::chrono::steady_clock::now();
|
||||||
|
const auto user_dir = Common::FS::GetUserPath(Common::FS::PathType::UserDir);
|
||||||
|
QString filePath = QString::fromStdString((user_dir / "play_time.txt").string());
|
||||||
|
QFile file(filePath);
|
||||||
|
ASSERT_MSG(file.open(QIODevice::ReadWrite | QIODevice::Text),
|
||||||
|
"Error opening or creating play_time.txt");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
linker->Execute(args);
|
linker->Execute(args);
|
||||||
|
|
||||||
window->InitTimers();
|
window->InitTimers();
|
||||||
|
@ -177,7 +177,7 @@ void BufferCache::BindVertexBuffers(const Vulkan::GraphicsPipeline& pipeline) {
|
|||||||
if (instance.IsVertexInputDynamicState()) {
|
if (instance.IsVertexInputDynamicState()) {
|
||||||
cmdbuf.bindVertexBuffers(0, num_buffers, host_buffers.data(), host_offsets.data());
|
cmdbuf.bindVertexBuffers(0, num_buffers, host_buffers.data(), host_offsets.data());
|
||||||
} else {
|
} else {
|
||||||
cmdbuf.bindVertexBuffers2EXT(0, num_buffers, host_buffers.data(), host_offsets.data(),
|
cmdbuf.bindVertexBuffers2(0, num_buffers, host_buffers.data(), host_offsets.data(),
|
||||||
host_sizes.data(), host_strides.data());
|
host_sizes.data(), host_strides.data());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -270,7 +270,25 @@ Frame* Presenter::PrepareLastFrame() {
|
|||||||
return frame;
|
return frame;
|
||||||
}
|
}
|
||||||
|
|
||||||
Frame* Presenter::PrepareFrameInternal(VideoCore::ImageId image_id, bool is_eop) {
|
static vk::Format GetFrameViewFormat(const Libraries::VideoOut::PixelFormat format) {
|
||||||
|
switch (format) {
|
||||||
|
case Libraries::VideoOut::PixelFormat::A8B8G8R8Srgb:
|
||||||
|
return vk::Format::eR8G8B8A8Srgb;
|
||||||
|
case Libraries::VideoOut::PixelFormat::A8R8G8B8Srgb:
|
||||||
|
return vk::Format::eB8G8R8A8Srgb;
|
||||||
|
case Libraries::VideoOut::PixelFormat::A2R10G10B10:
|
||||||
|
case Libraries::VideoOut::PixelFormat::A2R10G10B10Srgb:
|
||||||
|
case Libraries::VideoOut::PixelFormat::A2R10G10B10Bt2020Pq:
|
||||||
|
return vk::Format::eA2R10G10B10UnormPack32;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
UNREACHABLE_MSG("Unknown format={}", static_cast<u32>(format));
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
Frame* Presenter::PrepareFrameInternal(VideoCore::ImageId image_id,
|
||||||
|
const Libraries::VideoOut::PixelFormat format, bool is_eop) {
|
||||||
// Request a free presentation frame.
|
// Request a free presentation frame.
|
||||||
Frame* frame = GetRenderFrame();
|
Frame* frame = GetRenderFrame();
|
||||||
|
|
||||||
@ -324,7 +342,7 @@ Frame* Presenter::PrepareFrameInternal(VideoCore::ImageId image_id, bool is_eop)
|
|||||||
cmdbuf);
|
cmdbuf);
|
||||||
|
|
||||||
VideoCore::ImageViewInfo info{};
|
VideoCore::ImageViewInfo info{};
|
||||||
info.format = image.info.pixel_format;
|
info.format = GetFrameViewFormat(format);
|
||||||
// Exclude alpha from output frame to avoid blending with UI.
|
// Exclude alpha from output frame to avoid blending with UI.
|
||||||
info.mapping = vk::ComponentMapping{
|
info.mapping = vk::ComponentMapping{
|
||||||
.r = vk::ComponentSwizzle::eIdentity,
|
.r = vk::ComponentSwizzle::eIdentity,
|
||||||
|
@ -70,11 +70,12 @@ public:
|
|||||||
auto desc = VideoCore::TextureCache::VideoOutDesc{attribute, cpu_address};
|
auto desc = VideoCore::TextureCache::VideoOutDesc{attribute, cpu_address};
|
||||||
const auto image_id = texture_cache.FindImage(desc);
|
const auto image_id = texture_cache.FindImage(desc);
|
||||||
texture_cache.UpdateImage(image_id, is_eop ? nullptr : &flip_scheduler);
|
texture_cache.UpdateImage(image_id, is_eop ? nullptr : &flip_scheduler);
|
||||||
return PrepareFrameInternal(image_id, is_eop);
|
return PrepareFrameInternal(image_id, attribute.attrib.pixel_format, is_eop);
|
||||||
}
|
}
|
||||||
|
|
||||||
Frame* PrepareBlankFrame(bool is_eop) {
|
Frame* PrepareBlankFrame(bool is_eop) {
|
||||||
return PrepareFrameInternal(VideoCore::NULL_IMAGE_ID, is_eop);
|
return PrepareFrameInternal(VideoCore::NULL_IMAGE_ID,
|
||||||
|
Libraries::VideoOut::PixelFormat::Unknown, is_eop);
|
||||||
}
|
}
|
||||||
|
|
||||||
VideoCore::Image& RegisterVideoOutSurface(
|
VideoCore::Image& RegisterVideoOutSurface(
|
||||||
@ -119,7 +120,8 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Frame* PrepareFrameInternal(VideoCore::ImageId image_id, bool is_eop = true);
|
Frame* PrepareFrameInternal(VideoCore::ImageId image_id,
|
||||||
|
Libraries::VideoOut::PixelFormat format, bool is_eop = true);
|
||||||
Frame* GetRenderFrame();
|
Frame* GetRenderFrame();
|
||||||
|
|
||||||
void SetExpectedGameSize(s32 width, s32 height);
|
void SetExpectedGameSize(s32 width, s32 height);
|
||||||
|
@ -16,14 +16,15 @@ using VideoOutFormat = Libraries::VideoOut::PixelFormat;
|
|||||||
|
|
||||||
static vk::Format ConvertPixelFormat(const VideoOutFormat format) {
|
static vk::Format ConvertPixelFormat(const VideoOutFormat format) {
|
||||||
switch (format) {
|
switch (format) {
|
||||||
case VideoOutFormat::A8R8G8B8Srgb:
|
|
||||||
return vk::Format::eB8G8R8A8Srgb;
|
|
||||||
case VideoOutFormat::A8B8G8R8Srgb:
|
case VideoOutFormat::A8B8G8R8Srgb:
|
||||||
|
// Remaining formats are mapped to RGBA for internal consistency and changed to BGRA in the
|
||||||
|
// frame image view.
|
||||||
|
case VideoOutFormat::A8R8G8B8Srgb:
|
||||||
return vk::Format::eR8G8B8A8Srgb;
|
return vk::Format::eR8G8B8A8Srgb;
|
||||||
case VideoOutFormat::A2R10G10B10:
|
case VideoOutFormat::A2R10G10B10:
|
||||||
case VideoOutFormat::A2R10G10B10Srgb:
|
case VideoOutFormat::A2R10G10B10Srgb:
|
||||||
case VideoOutFormat::A2R10G10B10Bt2020Pq:
|
case VideoOutFormat::A2R10G10B10Bt2020Pq:
|
||||||
return vk::Format::eA2R10G10B10UnormPack32;
|
return vk::Format::eA2B10G10R10UnormPack32;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user