early-access version 4017

This commit is contained in:
pineappleEA 2023-12-12 23:52:27 +01:00
parent 29cac37e95
commit 76fa9cc8e2
10 changed files with 45 additions and 34 deletions

View File

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

View File

@ -354,18 +354,36 @@ std::string_view RemoveTrailingSlash(std::string_view path) {
return path; return path;
} }
std::vector<std::string> SplitPathComponents(std::string_view filename) { template <typename F>
std::string copy(filename); static void ForEachPathComponent(std::string_view filename, F&& cb) {
std::replace(copy.begin(), copy.end(), '\\', '/'); const char* component_begin = filename.data();
std::vector<std::string> out; const char* const end = component_begin + filename.size();
for (const char* it = component_begin; it != end; ++it) {
std::stringstream stream(copy); const char c = *it;
std::string item; if (c == '\\' || c == '/') {
while (std::getline(stream, item, '/')) { if (component_begin != it) {
out.push_back(std::move(item)); cb(std::string_view{component_begin, it});
}
component_begin = it + 1;
}
} }
if (component_begin != end) {
cb(std::string_view{component_begin, end});
}
}
return out; std::vector<std::string_view> SplitPathComponents(std::string_view filename) {
std::vector<std::string_view> components;
ForEachPathComponent(filename, [&](auto component) { components.emplace_back(component); });
return components;
}
std::vector<std::string> SplitPathComponentsCopy(std::string_view filename) {
std::vector<std::string> components;
ForEachPathComponent(filename, [&](auto component) { components.emplace_back(component); });
return components;
} }
std::string SanitizePath(std::string_view path_, DirectorySeparator directory_separator) { std::string SanitizePath(std::string_view path_, DirectorySeparator directory_separator) {

View File

@ -289,7 +289,11 @@ enum class DirectorySeparator {
// Splits the path on '/' or '\' and put the components into a vector // Splits the path on '/' or '\' and put the components into a vector
// i.e. "C:\Users\Yuzu\Documents\save.bin" becomes {"C:", "Users", "Yuzu", "Documents", "save.bin" } // i.e. "C:\Users\Yuzu\Documents\save.bin" becomes {"C:", "Users", "Yuzu", "Documents", "save.bin" }
[[nodiscard]] std::vector<std::string> SplitPathComponents(std::string_view filename); [[nodiscard]] std::vector<std::string_view> SplitPathComponents(std::string_view filename);
// Splits the path on '/' or '\' and put the components into a vector
// i.e. "C:\Users\Yuzu\Documents\save.bin" becomes {"C:", "Users", "Yuzu", "Documents", "save.bin" }
[[nodiscard]] std::vector<std::string> SplitPathComponentsCopy(std::string_view filename);
// Removes trailing slash, makes all '\\' into '/', and removes duplicate '/'. Makes '/' into '\\' // Removes trailing slash, makes all '\\' into '/', and removes duplicate '/'. Makes '/' into '\\'
// depending if directory_separator is BackwardSlash or PlatformDefault and running on windows // depending if directory_separator is BackwardSlash or PlatformDefault and running on windows

View File

@ -201,8 +201,6 @@ std::string VfsFile::GetFullPath() const {
VirtualFile VfsDirectory::GetFileRelative(std::string_view path) const { VirtualFile VfsDirectory::GetFileRelative(std::string_view path) const {
auto vec = Common::FS::SplitPathComponents(path); auto vec = Common::FS::SplitPathComponents(path);
vec.erase(std::remove_if(vec.begin(), vec.end(), [](const auto& str) { return str.empty(); }),
vec.end());
if (vec.empty()) { if (vec.empty()) {
return nullptr; return nullptr;
} }
@ -237,8 +235,6 @@ VirtualFile VfsDirectory::GetFileAbsolute(std::string_view path) const {
VirtualDir VfsDirectory::GetDirectoryRelative(std::string_view path) const { VirtualDir VfsDirectory::GetDirectoryRelative(std::string_view path) const {
auto vec = Common::FS::SplitPathComponents(path); auto vec = Common::FS::SplitPathComponents(path);
vec.erase(std::remove_if(vec.begin(), vec.end(), [](const auto& str) { return str.empty(); }),
vec.end());
if (vec.empty()) { if (vec.empty()) {
// TODO(DarkLordZach): Return this directory if path is '/' or similar. Can't currently // TODO(DarkLordZach): Return this directory if path is '/' or similar. Can't currently
// because of const-ness // because of const-ness
@ -303,8 +299,6 @@ std::size_t VfsDirectory::GetSize() const {
VirtualFile VfsDirectory::CreateFileRelative(std::string_view path) { VirtualFile VfsDirectory::CreateFileRelative(std::string_view path) {
auto vec = Common::FS::SplitPathComponents(path); auto vec = Common::FS::SplitPathComponents(path);
vec.erase(std::remove_if(vec.begin(), vec.end(), [](const auto& str) { return str.empty(); }),
vec.end());
if (vec.empty()) { if (vec.empty()) {
return nullptr; return nullptr;
} }
@ -334,8 +328,6 @@ VirtualFile VfsDirectory::CreateFileAbsolute(std::string_view path) {
VirtualDir VfsDirectory::CreateDirectoryRelative(std::string_view path) { VirtualDir VfsDirectory::CreateDirectoryRelative(std::string_view path) {
auto vec = Common::FS::SplitPathComponents(path); auto vec = Common::FS::SplitPathComponents(path);
vec.erase(std::remove_if(vec.begin(), vec.end(), [](const auto& str) { return str.empty(); }),
vec.end());
if (vec.empty()) { if (vec.empty()) {
return nullptr; return nullptr;
} }

View File

@ -268,7 +268,7 @@ void RealVfsFilesystem::RemoveReferenceFromListLocked(FileReference& reference)
RealVfsFile::RealVfsFile(RealVfsFilesystem& base_, std::unique_ptr<FileReference> reference_, RealVfsFile::RealVfsFile(RealVfsFilesystem& base_, std::unique_ptr<FileReference> reference_,
const std::string& path_, Mode perms_, std::optional<u64> size_) const std::string& path_, Mode perms_, std::optional<u64> size_)
: base(base_), reference(std::move(reference_)), path(path_), : base(base_), reference(std::move(reference_)), path(path_),
parent_path(FS::GetParentPath(path_)), path_components(FS::SplitPathComponents(path_)), parent_path(FS::GetParentPath(path_)), path_components(FS::SplitPathComponentsCopy(path_)),
size(size_), perms(perms_) {} size(size_), perms(perms_) {}
RealVfsFile::~RealVfsFile() { RealVfsFile::~RealVfsFile() {
@ -276,7 +276,7 @@ RealVfsFile::~RealVfsFile() {
} }
std::string RealVfsFile::GetName() const { std::string RealVfsFile::GetName() const {
return path_components.back(); return path_components.empty() ? "" : std::string(path_components.back());
} }
std::size_t RealVfsFile::GetSize() const { std::size_t RealVfsFile::GetSize() const {
@ -375,7 +375,7 @@ std::vector<VirtualDir> RealVfsDirectory::IterateEntries<RealVfsDirectory, VfsDi
RealVfsDirectory::RealVfsDirectory(RealVfsFilesystem& base_, const std::string& path_, Mode perms_) RealVfsDirectory::RealVfsDirectory(RealVfsFilesystem& base_, const std::string& path_, Mode perms_)
: base(base_), path(FS::RemoveTrailingSlash(path_)), parent_path(FS::GetParentPath(path)), : base(base_), path(FS::RemoveTrailingSlash(path_)), parent_path(FS::GetParentPath(path)),
path_components(FS::SplitPathComponents(path)), perms(perms_) { path_components(FS::SplitPathComponentsCopy(path)), perms(perms_) {
if (!FS::Exists(path) && True(perms & Mode::Write)) { if (!FS::Exists(path) && True(perms & Mode::Write)) {
void(FS::CreateDirs(path)); void(FS::CreateDirs(path));
} }
@ -464,7 +464,7 @@ bool RealVfsDirectory::IsReadable() const {
} }
std::string RealVfsDirectory::GetName() const { std::string RealVfsDirectory::GetName() const {
return path_components.back(); return path_components.empty() ? "" : std::string(path_components.back());
} }
VirtualDir RealVfsDirectory::GetParentDirectory() const { VirtualDir RealVfsDirectory::GetParentDirectory() const {

View File

@ -104,11 +104,7 @@ Result VfsDirectoryServiceWrapper::CreateDirectory(const std::string& path_) con
const auto components = Common::FS::SplitPathComponents(path); const auto components = Common::FS::SplitPathComponents(path);
std::string relative_path; std::string relative_path;
for (const auto& component : components) { for (const auto& component : components) {
// Skip empty path components relative_path = Common::FS::SanitizePath(fmt::format("{}/{}", relative_path, component));
if (component.empty()) {
continue;
}
relative_path = Common::FS::SanitizePath(relative_path + '/' + component);
auto new_dir = backing->CreateSubdirectory(relative_path); auto new_dir = backing->CreateSubdirectory(relative_path);
if (new_dir == nullptr) { if (new_dir == nullptr) {
// TODO(DarkLordZach): Find a better error code for this // TODO(DarkLordZach): Find a better error code for this

View File

@ -204,8 +204,9 @@ Result FbShareBufferManager::Initialize(u64* out_buffer_id, u64* out_layer_id, u
// Record the display id. // Record the display id.
m_display_id = display_id; m_display_id = display_id;
// Create a layer for the display. // Create and open a layer for the display.
m_layer_id = m_flinger.CreateLayer(m_display_id).value(); m_layer_id = m_flinger.CreateLayer(m_display_id).value();
m_flinger.OpenLayer(m_layer_id);
// Set up the buffer. // Set up the buffer.
m_buffer_id = m_next_buffer_id++; m_buffer_id = m_next_buffer_id++;

View File

@ -66,7 +66,7 @@ public:
/// Whether or not this display has any layers added to it. /// Whether or not this display has any layers added to it.
bool HasLayers() const { bool HasLayers() const {
return !layers.empty(); return GetNumLayers() > 0;
} }
/// Gets a layer for this display based off an index. /// Gets a layer for this display based off an index.

View File

@ -381,7 +381,7 @@
<item row="5" column="0"> <item row="5" column="0">
<widget class="QCheckBox" name="disable_buffer_reorder"> <widget class="QCheckBox" name="disable_buffer_reorder">
<property name="toolTip"> <property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;When checked, disables reording of mapped memory uploads which allows to associate uploads with specific draws. May reduce performance in some cases.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string> <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;When checked, disables reordering of mapped memory uploads which allows to associate uploads with specific draws. May reduce performance in some cases.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property> </property>
<property name="text"> <property name="text">
<string>Disable Buffer Reorder</string> <string>Disable Buffer Reorder</string>

View File

@ -1,7 +1,7 @@
{ {
"$schema": "https://raw.githubusercontent.com/microsoft/vcpkg-tool/main/docs/vcpkg.schema.json", "$schema": "https://raw.githubusercontent.com/microsoft/vcpkg-tool/main/docs/vcpkg.schema.json",
"name": "yuzu", "name": "yuzu",
"builtin-baseline": "cbf56573a987527b39272e88cbdd11389b78c6e4", "builtin-baseline": "a42af01b72c28a8e1d7b48107b33e4f286a55ef6",
"version": "1.0", "version": "1.0",
"dependencies": [ "dependencies": [
"boost-algorithm", "boost-algorithm",
@ -50,7 +50,7 @@
}, },
{ {
"name": "fmt", "name": "fmt",
"version": "10.0.0" "version": "10.1.1"
} }
] ]
} }