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
=============
This is the source code for early-access 1694.
This is the source code for early-access 1695.
## Legal Notice

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -41,22 +41,23 @@ Config::Config() {
Config::~Config() = default;
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 (retry) {
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::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);
}
LOG_ERROR(Config, "Failed.");
return false;
}
LOG_INFO(Config, "Successfully loaded {}", FS::PathToUTF8String(sdl2_config_loc));
LOG_INFO(Config, "Successfully loaded {}", config_loc_str);
return true;
}