early-access version 1695

This commit is contained in:
pineappleEA 2021-05-18 20:58:12 +02:00
parent 3b4efdc459
commit 5ce5fce2e7
10 changed files with 27 additions and 68 deletions

View File

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

View File

@ -252,18 +252,14 @@ void IOFile::Open(const fs::path& path, FileAccessMode mode, FileType type, File
errno = 0; errno = 0;
#ifdef _WIN32 #ifdef _WIN32
if (flag != FileShareFlag::ShareNone) { if (flag != FileShareFlag::ShareNone) {
file = _wfsopen(path.wstring().c_str(), AccessModeToWStr(mode, type), file = _wfsopen(path.wstring().c_str(), AccessModeToWStr(mode, type),
ToWindowsFileShareFlag(flag)); ToWindowsFileShareFlag(flag));
} else { } else {
_wfopen_s(&file, path.wstring().c_str(), AccessModeToWStr(mode, type)); _wfopen_s(&file, path.wstring().c_str(), AccessModeToWStr(mode, type));
} }
#else #else
file = std::fopen(PathToUTF8String(path).c_str(), AccessModeToStr(mode, type)); file = std::fopen(PathToUTF8String(path).c_str(), AccessModeToStr(mode, type));
#endif #endif
if (!IsOpen()) { if (!IsOpen()) {
@ -334,13 +330,9 @@ bool IOFile::SetSize(u64 size) const {
errno = 0; errno = 0;
#ifdef _WIN32 #ifdef _WIN32
const auto set_size_result = _chsize_s(fileno(file), static_cast<s64>(size)) == 0; const auto set_size_result = _chsize_s(fileno(file), static_cast<s64>(size)) == 0;
#else #else
const auto set_size_result = ftruncate(fileno(file), static_cast<s64>(size)) == 0; const auto set_size_result = ftruncate(fileno(file), static_cast<s64>(size)) == 0;
#endif #endif
if (!set_size_result) { if (!set_size_result) {

View File

@ -83,7 +83,6 @@ public:
private: private:
PathManagerImpl() { PathManagerImpl() {
#ifdef _WIN32 #ifdef _WIN32
auto yuzu_path = GetExeDirectory() / PORTABLE_DIR; auto yuzu_path = GetExeDirectory() / PORTABLE_DIR;
if (!IsDir(yuzu_path)) { if (!IsDir(yuzu_path)) {
@ -93,9 +92,7 @@ private:
GenerateYuzuPath(YuzuPath::YuzuDir, yuzu_path); GenerateYuzuPath(YuzuPath::YuzuDir, yuzu_path);
GenerateYuzuPath(YuzuPath::CacheDir, yuzu_path / CACHE_DIR); GenerateYuzuPath(YuzuPath::CacheDir, yuzu_path / CACHE_DIR);
GenerateYuzuPath(YuzuPath::ConfigDir, yuzu_path / CONFIG_DIR); GenerateYuzuPath(YuzuPath::ConfigDir, yuzu_path / CONFIG_DIR);
#else #else
auto yuzu_path = GetCurrentDir() / PORTABLE_DIR; auto yuzu_path = GetCurrentDir() / PORTABLE_DIR;
if (Exists(yuzu_path) && IsDir(yuzu_path)) { if (Exists(yuzu_path) && IsDir(yuzu_path)) {
@ -109,7 +106,6 @@ private:
GenerateYuzuPath(YuzuPath::CacheDir, GetDataDirectory("XDG_CACHE_HOME") / YUZU_DIR); GenerateYuzuPath(YuzuPath::CacheDir, GetDataDirectory("XDG_CACHE_HOME") / YUZU_DIR);
GenerateYuzuPath(YuzuPath::ConfigDir, GetDataDirectory("XDG_CONFIG_HOME") / YUZU_DIR); GenerateYuzuPath(YuzuPath::ConfigDir, GetDataDirectory("XDG_CONFIG_HOME") / YUZU_DIR);
} }
#endif #endif
GenerateYuzuPath(YuzuPath::DumpDir, yuzu_path / DUMP_DIR); GenerateYuzuPath(YuzuPath::DumpDir, yuzu_path / DUMP_DIR);
@ -146,19 +142,15 @@ bool ValidatePath(const fs::path& path) {
} }
#ifdef _WIN32 #ifdef _WIN32
if (path.u16string().size() >= MAX_PATH) { if (path.u16string().size() >= MAX_PATH) {
LOG_ERROR(Common_Filesystem, "Input path is too long, path={}", PathToUTF8String(path)); LOG_ERROR(Common_Filesystem, "Input path is too long, path={}", PathToUTF8String(path));
return false; return false;
} }
#else #else
if (path.u8string().size() >= MAX_PATH) { if (path.u8string().size() >= MAX_PATH) {
LOG_ERROR(Common_Filesystem, "Input path is too long, path={}", PathToUTF8String(path)); LOG_ERROR(Common_Filesystem, "Input path is too long, path={}", PathToUTF8String(path));
return false; return false;
} }
#endif #endif
return true; return true;

View File

@ -52,7 +52,7 @@ public:
} }
size_t GetSize() const { size_t GetSize() const {
return is_initialized ? size * PageSize : 0; return is_initialized ? size : 0;
} }
private: private:

View File

@ -728,14 +728,17 @@ void FileSystemController::CreateFactories(FileSys::VfsFilesystem& vfs, bool ove
sdmc_factory = nullptr; sdmc_factory = nullptr;
} }
auto nand_directory = vfs.OpenDirectory( using YuzuPath = Common::FS::YuzuPath;
Common::FS::GetYuzuPathString(Common::FS::YuzuPath::NANDDir), FileSys::Mode::ReadWrite); const auto rw_mode = FileSys::Mode::ReadWrite;
auto sd_directory = vfs.OpenDirectory(
Common::FS::GetYuzuPathString(Common::FS::YuzuPath::SDMCDir), FileSys::Mode::ReadWrite); auto nand_directory =
auto load_directory = vfs.OpenDirectory( vfs.OpenDirectory(Common::FS::GetYuzuPathString(YuzuPath::NANDDir), rw_mode);
Common::FS::GetYuzuPathString(Common::FS::YuzuPath::LoadDir), FileSys::Mode::ReadWrite); auto sd_directory =
auto dump_directory = vfs.OpenDirectory( vfs.OpenDirectory(Common::FS::GetYuzuPathString(YuzuPath::SDMCDir), rw_mode);
Common::FS::GetYuzuPathString(Common::FS::YuzuPath::DumpDir), FileSys::Mode::ReadWrite); auto load_directory =
vfs.OpenDirectory(Common::FS::GetYuzuPathString(YuzuPath::LoadDir), rw_mode);
auto dump_directory =
vfs.OpenDirectory(Common::FS::GetYuzuPathString(YuzuPath::DumpDir), rw_mode);
if (bis_factory == nullptr) { if (bis_factory == nullptr) {
bis_factory = bis_factory =

View File

@ -76,21 +76,16 @@ bool ShaderDiskCacheEntry::Load(Common::FS::IOFile& file) {
if (!file.ReadObject(type)) { if (!file.ReadObject(type)) {
return false; return false;
} }
u32 code_size; u32 code_size;
u32 code_size_b; u32 code_size_b;
if (!file.ReadObject(code_size) || !file.ReadObject(code_size_b)) { if (!file.ReadObject(code_size) || !file.ReadObject(code_size_b)) {
return false; return false;
} }
code.resize(code_size); code.resize(code_size);
code_b.resize(code_size_b); code_b.resize(code_size_b);
if (file.Read(code) != code_size) { if (file.Read(code) != code_size) {
return false; return false;
} }
if (HasProgramA() && file.Read(code_b) != code_size_b) { if (HasProgramA() && file.Read(code_b) != code_size_b) {
return false; return false;
} }
@ -101,7 +96,6 @@ bool ShaderDiskCacheEntry::Load(Common::FS::IOFile& file) {
u32 num_bound_samplers; u32 num_bound_samplers;
u32 num_separate_samplers; u32 num_separate_samplers;
u32 num_bindless_samplers; u32 num_bindless_samplers;
if (!file.ReadObject(unique_identifier) || !file.ReadObject(bound_buffer) || if (!file.ReadObject(unique_identifier) || !file.ReadObject(bound_buffer) ||
!file.ReadObject(is_texture_handler_size_known) || !file.ReadObject(is_texture_handler_size_known) ||
!file.ReadObject(texture_handler_size_value) || !file.ReadObject(graphics_info) || !file.ReadObject(texture_handler_size_value) || !file.ReadObject(graphics_info) ||
@ -110,7 +104,6 @@ bool ShaderDiskCacheEntry::Load(Common::FS::IOFile& file) {
!file.ReadObject(num_bindless_samplers)) { !file.ReadObject(num_bindless_samplers)) {
return false; return false;
} }
if (is_texture_handler_size_known) { if (is_texture_handler_size_known) {
texture_handler_size = texture_handler_size_value; texture_handler_size = texture_handler_size_value;
} }
@ -119,29 +112,24 @@ bool ShaderDiskCacheEntry::Load(Common::FS::IOFile& file) {
std::vector<BoundSamplerEntry> flat_bound_samplers(num_bound_samplers); std::vector<BoundSamplerEntry> flat_bound_samplers(num_bound_samplers);
std::vector<SeparateSamplerEntry> flat_separate_samplers(num_separate_samplers); std::vector<SeparateSamplerEntry> flat_separate_samplers(num_separate_samplers);
std::vector<BindlessSamplerEntry> flat_bindless_samplers(num_bindless_samplers); std::vector<BindlessSamplerEntry> flat_bindless_samplers(num_bindless_samplers);
if (file.Read(flat_keys) != flat_keys.size() || if (file.Read(flat_keys) != flat_keys.size() ||
file.Read(flat_bound_samplers) != flat_bound_samplers.size() || file.Read(flat_bound_samplers) != flat_bound_samplers.size() ||
file.Read(flat_separate_samplers) != flat_separate_samplers.size() || file.Read(flat_separate_samplers) != flat_separate_samplers.size() ||
file.Read(flat_bindless_samplers) != flat_bindless_samplers.size()) { file.Read(flat_bindless_samplers) != flat_bindless_samplers.size()) {
return false; return false;
} }
for (const auto& entry : flat_keys) { for (const auto& entry : flat_keys) {
keys.insert({{entry.cbuf, entry.offset}, entry.value}); keys.insert({{entry.cbuf, entry.offset}, entry.value});
} }
for (const auto& entry : flat_bound_samplers) { for (const auto& entry : flat_bound_samplers) {
bound_samplers.emplace(entry.offset, entry.sampler); bound_samplers.emplace(entry.offset, entry.sampler);
} }
for (const auto& entry : flat_separate_samplers) { for (const auto& entry : flat_separate_samplers) {
SeparateSamplerKey key; SeparateSamplerKey key;
key.buffers = {entry.cbuf1, entry.cbuf2}; key.buffers = {entry.cbuf1, entry.cbuf2};
key.offsets = {entry.offset1, entry.offset2}; key.offsets = {entry.offset1, entry.offset2};
separate_samplers.emplace(key, entry.sampler); separate_samplers.emplace(key, entry.sampler);
} }
for (const auto& entry : flat_bindless_samplers) { for (const auto& entry : flat_bindless_samplers) {
bindless_samplers.insert({{entry.cbuf, entry.offset}, entry.sampler}); bindless_samplers.insert({{entry.cbuf, entry.offset}, entry.sampler});
} }
@ -155,11 +143,9 @@ bool ShaderDiskCacheEntry::Save(Common::FS::IOFile& file) const {
!file.WriteObject(static_cast<u32>(code_b.size()))) { !file.WriteObject(static_cast<u32>(code_b.size()))) {
return false; return false;
} }
if (file.Write(code) != code.size()) { if (file.Write(code) != code.size()) {
return false; return false;
} }
if (HasProgramA() && file.Write(code_b) != code_b.size()) { if (HasProgramA() && file.Write(code_b) != code_b.size()) {
return false; return false;
} }
@ -226,7 +212,6 @@ std::optional<std::vector<ShaderDiskCacheEntry>> ShaderDiskCacheOpenGL::LoadTran
Common::FS::IOFile file{GetTransferablePath(), Common::FS::FileAccessMode::Read, Common::FS::IOFile file{GetTransferablePath(), Common::FS::FileAccessMode::Read,
Common::FS::FileType::BinaryFile}; Common::FS::FileType::BinaryFile};
if (!file.IsOpen()) { if (!file.IsOpen()) {
LOG_INFO(Render_OpenGL, "No transferable shader cache found"); LOG_INFO(Render_OpenGL, "No transferable shader cache found");
is_usable = true; is_usable = true;
@ -234,7 +219,6 @@ std::optional<std::vector<ShaderDiskCacheEntry>> ShaderDiskCacheOpenGL::LoadTran
} }
u32 version{}; u32 version{};
if (!file.ReadObject(version)) { if (!file.ReadObject(version)) {
LOG_ERROR(Render_OpenGL, "Failed to get transferable cache version, skipping it"); LOG_ERROR(Render_OpenGL, "Failed to get transferable cache version, skipping it");
return std::nullopt; return std::nullopt;
@ -274,7 +258,6 @@ std::vector<ShaderDiskCachePrecompiled> ShaderDiskCacheOpenGL::LoadPrecompiled()
Common::FS::IOFile file{GetPrecompiledPath(), Common::FS::FileAccessMode::Read, Common::FS::IOFile file{GetPrecompiledPath(), Common::FS::FileAccessMode::Read,
Common::FS::FileType::BinaryFile}; Common::FS::FileType::BinaryFile};
if (!file.IsOpen()) { if (!file.IsOpen()) {
LOG_INFO(Render_OpenGL, "No precompiled shader cache found"); LOG_INFO(Render_OpenGL, "No precompiled shader cache found");
return {}; return {};
@ -294,11 +277,9 @@ std::optional<std::vector<ShaderDiskCachePrecompiled>> ShaderDiskCacheOpenGL::Lo
Common::FS::IOFile& file) { Common::FS::IOFile& file) {
// Read compressed file from disk and decompress to virtual precompiled cache file // Read compressed file from disk and decompress to virtual precompiled cache file
std::vector<u8> compressed(file.GetSize()); std::vector<u8> compressed(file.GetSize());
if (file.Read(compressed) != file.GetSize()) { if (file.Read(compressed) != file.GetSize()) {
return std::nullopt; return std::nullopt;
} }
const std::vector<u8> decompressed = Common::Compression::DecompressDataZSTD(compressed); const std::vector<u8> decompressed = Common::Compression::DecompressDataZSTD(compressed);
SaveArrayToPrecompiled(decompressed.data(), decompressed.size()); SaveArrayToPrecompiled(decompressed.data(), decompressed.size());
precompiled_cache_virtual_file_offset = 0; precompiled_cache_virtual_file_offset = 0;
@ -337,7 +318,6 @@ void ShaderDiskCacheOpenGL::InvalidateTransferable() {
LOG_ERROR(Render_OpenGL, "Failed to invalidate transferable file={}", LOG_ERROR(Render_OpenGL, "Failed to invalidate transferable file={}",
Common::FS::PathToUTF8String(GetTransferablePath())); Common::FS::PathToUTF8String(GetTransferablePath()));
} }
InvalidatePrecompiled(); InvalidatePrecompiled();
} }
@ -363,11 +343,9 @@ void ShaderDiskCacheOpenGL::SaveEntry(const ShaderDiskCacheEntry& entry) {
} }
Common::FS::IOFile file = AppendTransferableFile(); Common::FS::IOFile file = AppendTransferableFile();
if (!file.IsOpen()) { if (!file.IsOpen()) {
return; return;
} }
if (!entry.Save(file)) { if (!entry.Save(file)) {
LOG_ERROR(Render_OpenGL, "Failed to save raw transferable cache entry, removing"); LOG_ERROR(Render_OpenGL, "Failed to save raw transferable cache entry, removing");
file.Close(); file.Close();
@ -411,18 +389,16 @@ Common::FS::IOFile ShaderDiskCacheOpenGL::AppendTransferableFile() const {
return {}; return {};
} }
const auto transferable_path = GetTransferablePath(); const auto transferable_path{GetTransferablePath()};
const bool existed = Common::FS::Exists(transferable_path); const bool existed = Common::FS::Exists(transferable_path);
Common::FS::IOFile file{transferable_path, Common::FS::FileAccessMode::Append, Common::FS::IOFile file{transferable_path, Common::FS::FileAccessMode::Append,
Common::FS::FileType::BinaryFile}; Common::FS::FileType::BinaryFile};
if (!file.IsOpen()) { if (!file.IsOpen()) {
LOG_ERROR(Render_OpenGL, "Failed to open transferable cache in path={}", LOG_ERROR(Render_OpenGL, "Failed to open transferable cache in path={}",
Common::FS::PathToUTF8String(transferable_path)); Common::FS::PathToUTF8String(transferable_path));
return {}; return {};
} }
if (!existed || file.GetSize() == 0) { if (!existed || file.GetSize() == 0) {
// If the file didn't exist, write its version // If the file didn't exist, write its version
if (!file.WriteObject(NativeVersion)) { if (!file.WriteObject(NativeVersion)) {
@ -431,7 +407,6 @@ Common::FS::IOFile ShaderDiskCacheOpenGL::AppendTransferableFile() const {
return {}; return {};
} }
} }
return file; return file;
} }
@ -459,7 +434,6 @@ void ShaderDiskCacheOpenGL::SaveVirtualPrecompiledFile() {
Common::FS::PathToUTF8String(precompiled_path)); Common::FS::PathToUTF8String(precompiled_path));
return; return;
} }
if (file.Write(compressed) != compressed.size()) { if (file.Write(compressed) != compressed.size()) {
LOG_ERROR(Render_OpenGL, "Failed to write precompiled cache version in path={}", LOG_ERROR(Render_OpenGL, "Failed to write precompiled cache version in path={}",
Common::FS::PathToUTF8String(precompiled_path)); Common::FS::PathToUTF8String(precompiled_path));

View File

@ -244,26 +244,25 @@ const std::array<UISettings::Shortcut, 17> Config::default_hotkeys{{
void Config::Initialize(const std::string& config_name) { void Config::Initialize(const std::string& config_name) {
const auto fs_config_loc = FS::GetYuzuPath(FS::YuzuPath::ConfigDir); const auto fs_config_loc = FS::GetYuzuPath(FS::YuzuPath::ConfigDir);
const auto config_file = fmt::format("{}.ini", config_name);
switch (type) { switch (type) {
case ConfigType::GlobalConfig: case ConfigType::GlobalConfig:
qt_config_loc = FS::PathToUTF8String(fs_config_loc / fmt::format("{}.ini", config_name)); qt_config_loc = FS::PathToUTF8String(fs_config_loc / config_file);
void(FS::CreateParentDir(qt_config_loc)); void(FS::CreateParentDir(qt_config_loc));
qt_config = std::make_unique<QSettings>(QString::fromStdString(qt_config_loc), qt_config = std::make_unique<QSettings>(QString::fromStdString(qt_config_loc),
QSettings::IniFormat); QSettings::IniFormat);
Reload(); Reload();
break; break;
case ConfigType::PerGameConfig: case ConfigType::PerGameConfig:
qt_config_loc = qt_config_loc = FS::PathToUTF8String(fs_config_loc / "custom" / config_file);
FS::PathToUTF8String(fs_config_loc / "custom" / fmt::format("{}.ini", config_name));
void(FS::CreateParentDir(qt_config_loc)); void(FS::CreateParentDir(qt_config_loc));
qt_config = std::make_unique<QSettings>(QString::fromStdString(qt_config_loc), qt_config = std::make_unique<QSettings>(QString::fromStdString(qt_config_loc),
QSettings::IniFormat); QSettings::IniFormat);
Reload(); Reload();
break; break;
case ConfigType::InputProfile: case ConfigType::InputProfile:
qt_config_loc = qt_config_loc = FS::PathToUTF8String(fs_config_loc / "input" / config_file);
FS::PathToUTF8String(fs_config_loc / "input" / fmt::format("{}.ini", config_name));
void(FS::CreateParentDir(qt_config_loc)); void(FS::CreateParentDir(qt_config_loc));
qt_config = std::make_unique<QSettings>(QString::fromStdString(qt_config_loc), qt_config = std::make_unique<QSettings>(QString::fromStdString(qt_config_loc),
QSettings::IniFormat); QSettings::IniFormat);

View File

@ -297,7 +297,6 @@ void GameListWorker::ScanFileSystem(ScanTarget target, const std::string& dir_pa
} }
const auto physical_name = Common::FS::PathToUTF8String(path); const auto physical_name = Common::FS::PathToUTF8String(path);
const auto is_dir = Common::FS::IsDir(path); const auto is_dir = Common::FS::IsDir(path);
if (!is_dir && if (!is_dir &&

View File

@ -2953,12 +2953,11 @@ void GMainWindow::OnReinitializeKeys(ReinitializeKeyBehavior behavior) {
if (res == QMessageBox::Cancel) if (res == QMessageBox::Cancel)
return; return;
void(Common::FS::RemoveFile(Common::FS::GetYuzuPath(Common::FS::YuzuPath::KeysDir) / const auto keys_dir = Common::FS::GetYuzuPath(Common::FS::YuzuPath::KeysDir);
"prod.keys_autogenerated"));
void(Common::FS::RemoveFile(Common::FS::GetYuzuPath(Common::FS::YuzuPath::KeysDir) / void(Common::FS::RemoveFile(keys_dir / "prod.keys_autogenerated"));
"console.keys_autogenerated")); void(Common::FS::RemoveFile(keys_dir / "console.keys_autogenerated"));
void(Common::FS::RemoveFile(Common::FS::GetYuzuPath(Common::FS::YuzuPath::KeysDir) / void(Common::FS::RemoveFile(keys_dir / "title.keys_autogenerated"));
"title.keys_autogenerated"));
} }
Core::Crypto::KeyManager& keys = Core::Crypto::KeyManager::Instance(); Core::Crypto::KeyManager& keys = Core::Crypto::KeyManager::Instance();

View File

@ -41,22 +41,23 @@ Config::Config() {
Config::~Config() = default; Config::~Config() = default;
bool Config::LoadINI(const std::string& default_contents, bool retry) { bool Config::LoadINI(const std::string& default_contents, bool retry) {
const auto config_loc_str = FS::PathToUTF8String(sdl2_config_loc);
if (sdl2_config->ParseError() < 0) { if (sdl2_config->ParseError() < 0) {
if (retry) { if (retry) {
LOG_WARNING(Config, "Failed to load {}. Creating file from defaults...", LOG_WARNING(Config, "Failed to load {}. Creating file from defaults...",
FS::PathToUTF8String(sdl2_config_loc)); config_loc_str);
void(FS::CreateParentDir(sdl2_config_loc)); void(FS::CreateParentDir(sdl2_config_loc));
void(FS::WriteStringToFile(sdl2_config_loc, FS::FileType::TextFile, default_contents)); void(FS::WriteStringToFile(sdl2_config_loc, FS::FileType::TextFile, default_contents));
sdl2_config = std::make_unique<INIReader>(FS::PathToUTF8String(sdl2_config_loc)); sdl2_config = std::make_unique<INIReader>(config_loc_str);
return LoadINI(default_contents, false); return LoadINI(default_contents, false);
} }
LOG_ERROR(Config, "Failed."); LOG_ERROR(Config, "Failed.");
return false; return false;
} }
LOG_INFO(Config, "Successfully loaded {}", FS::PathToUTF8String(sdl2_config_loc)); LOG_INFO(Config, "Successfully loaded {}", config_loc_str);
return true; return true;
} }