Misc: Pass string_view by value

This commit is contained in:
Stenzek 2024-05-05 20:21:54 +10:00
parent e4d940a476
commit ca3cfbaa99
No known key found for this signature in database
111 changed files with 543 additions and 542 deletions

View file

@ -976,7 +976,7 @@ bool ByteStream::WriteS64(s64 dest)
return Write2(&dest, sizeof(s64)); return Write2(&dest, sizeof(s64));
} }
bool ByteStream::WriteSizePrefixedString(const std::string_view& str) bool ByteStream::WriteSizePrefixedString(std::string_view str)
{ {
const u32 size = static_cast<u32>(str.size()); const u32 size = static_cast<u32>(str.size());
return (Write2(&size, sizeof(size)) && (size == 0 || Write2(str.data(), size))); return (Write2(&size, sizeof(size)) && (size == 0 || Write2(str.data(), size)));
@ -1315,7 +1315,7 @@ std::string ByteStream::ReadStreamToString(ByteStream* stream, bool seek_to_star
return ret; return ret;
} }
bool ByteStream::WriteStreamToString(const std::string_view& sv, ByteStream* stream) bool ByteStream::WriteStreamToString(std::string_view sv, ByteStream* stream)
{ {
if (sv.size() > std::numeric_limits<u32>::max()) if (sv.size() > std::numeric_limits<u32>::max())
return false; return false;

View file

@ -102,7 +102,7 @@ public:
bool WriteS16(s16 dest); bool WriteS16(s16 dest);
bool WriteS32(s32 dest); bool WriteS32(s32 dest);
bool WriteS64(s64 dest); bool WriteS64(s64 dest);
bool WriteSizePrefixedString(const std::string_view& str); bool WriteSizePrefixedString(std::string_view str);
// base byte stream creation functions // base byte stream creation functions
// opens a local file-based stream. fills in error if passed, and returns false if the file cannot be opened. // opens a local file-based stream. fills in error if passed, and returns false if the file cannot be opened.
@ -139,7 +139,7 @@ public:
static u32 CopyBytes(ByteStream* pSourceStream, u32 byteCount, ByteStream* pDestinationStream); static u32 CopyBytes(ByteStream* pSourceStream, u32 byteCount, ByteStream* pDestinationStream);
static std::string ReadStreamToString(ByteStream* stream, bool seek_to_start = true); static std::string ReadStreamToString(ByteStream* stream, bool seek_to_start = true);
static bool WriteStreamToString(const std::string_view& sv, ByteStream* stream); static bool WriteStreamToString(std::string_view sv, ByteStream* stream);
static std::vector<u8> ReadBinaryStream(ByteStream* stream, bool seek_to_start = true); static std::vector<u8> ReadBinaryStream(ByteStream* stream, bool seek_to_start = true);
static bool WriteBinaryToStream(ByteStream* stream, const void* data, size_t data_length); static bool WriteBinaryToStream(ByteStream* stream, const void* data, size_t data_length);

View file

@ -13,7 +13,7 @@ class Error;
#import <Cocoa/Cocoa.h> #import <Cocoa/Cocoa.h>
namespace CocoaTools { namespace CocoaTools {
NSString* StringViewToNSString(const std::string_view& str); NSString* StringViewToNSString(std::string_view str);
/// Converts NSError to a human-readable string. /// Converts NSError to a human-readable string.
std::string NSErrorToString(NSError* error); std::string NSErrorToString(NSError* error);

View file

@ -15,7 +15,7 @@
#error ARC should not be enabled. #error ARC should not be enabled.
#endif #endif
NSString* CocoaTools::StringViewToNSString(const std::string_view& str) NSString* CocoaTools::StringViewToNSString(std::string_view str)
{ {
if (str.empty()) if (str.empty())
return nil; return nil;

View file

@ -176,7 +176,7 @@ bool CrashHandler::Install()
return (s_veh_handle != nullptr); return (s_veh_handle != nullptr);
} }
void CrashHandler::SetWriteDirectory(const std::string_view& dump_directory) void CrashHandler::SetWriteDirectory(std::string_view dump_directory)
{ {
if (!s_veh_handle) if (!s_veh_handle)
return; return;
@ -384,7 +384,7 @@ bool CrashHandler::Install()
return true; return true;
} }
void CrashHandler::SetWriteDirectory(const std::string_view& dump_directory) void CrashHandler::SetWriteDirectory(std::string_view dump_directory)
{ {
} }
@ -404,7 +404,7 @@ bool CrashHandler::Install()
return false; return false;
} }
void CrashHandler::SetWriteDirectory(const std::string_view& dump_directory) void CrashHandler::SetWriteDirectory(std::string_view dump_directory)
{ {
} }

View file

@ -6,7 +6,7 @@
namespace CrashHandler { namespace CrashHandler {
bool Install(); bool Install();
void SetWriteDirectory(const std::string_view& dump_directory); void SetWriteDirectory(std::string_view dump_directory);
void WriteDumpForCaller(); void WriteDumpForCaller();
void Uninstall(); void Uninstall();
} // namespace CrashHandler } // namespace CrashHandler

View file

@ -135,7 +135,7 @@ static inline void PathAppendString(std::string& dst, const T& src)
} }
} }
std::string Path::SanitizeFileName(const std::string_view& str, bool strip_slashes /* = true */) std::string Path::SanitizeFileName(std::string_view str, bool strip_slashes /* = true */)
{ {
std::string ret; std::string ret;
ret.reserve(str.length()); ret.reserve(str.length());
@ -283,7 +283,7 @@ std::wstring FileSystem::GetWin32Path(std::string_view str)
#endif #endif
bool Path::IsAbsolute(const std::string_view& path) bool Path::IsAbsolute(std::string_view path)
{ {
#ifdef _WIN32 #ifdef _WIN32
return (path.length() >= 3 && ((path[0] >= 'A' && path[0] <= 'Z') || (path[0] >= 'a' && path[0] <= 'z')) && return (path.length() >= 3 && ((path[0] >= 'A' && path[0] <= 'Z') || (path[0] >= 'a' && path[0] <= 'z')) &&
@ -294,7 +294,7 @@ bool Path::IsAbsolute(const std::string_view& path)
#endif #endif
} }
std::string Path::RealPath(const std::string_view& path) std::string Path::RealPath(std::string_view path)
{ {
// Resolve non-absolute paths first. // Resolve non-absolute paths first.
std::vector<std::string_view> components; std::vector<std::string_view> components;
@ -472,7 +472,7 @@ std::string Path::RealPath(const std::string_view& path)
return realpath; return realpath;
} }
std::string Path::ToNativePath(const std::string_view& path) std::string Path::ToNativePath(std::string_view path)
{ {
std::string ret; std::string ret;
PathAppendString(ret, path); PathAppendString(ret, path);
@ -492,7 +492,7 @@ void Path::ToNativePath(std::string* path)
*path = Path::ToNativePath(*path); *path = Path::ToNativePath(*path);
} }
std::string Path::Canonicalize(const std::string_view& path) std::string Path::Canonicalize(std::string_view path)
{ {
std::vector<std::string_view> components = Path::SplitNativePath(path); std::vector<std::string_view> components = Path::SplitNativePath(path);
std::vector<std::string_view> new_components; std::vector<std::string_view> new_components;
@ -528,7 +528,7 @@ void Path::Canonicalize(std::string* path)
*path = Canonicalize(*path); *path = Canonicalize(*path);
} }
std::string Path::MakeRelative(const std::string_view& path, const std::string_view& relative_to) std::string Path::MakeRelative(std::string_view path, std::string_view relative_to)
{ {
// simple algorithm, we just work on the components. could probably be better, but it'll do for now. // simple algorithm, we just work on the components. could probably be better, but it'll do for now.
std::vector<std::string_view> path_components(SplitNativePath(path)); std::vector<std::string_view> path_components(SplitNativePath(path));
@ -575,7 +575,7 @@ std::string Path::MakeRelative(const std::string_view& path, const std::string_v
return JoinNativePath(new_components); return JoinNativePath(new_components);
} }
std::string_view Path::GetExtension(const std::string_view& path) std::string_view Path::GetExtension(std::string_view path)
{ {
const std::string_view::size_type pos = path.rfind('.'); const std::string_view::size_type pos = path.rfind('.');
if (pos == std::string_view::npos) if (pos == std::string_view::npos)
@ -584,7 +584,7 @@ std::string_view Path::GetExtension(const std::string_view& path)
return path.substr(pos + 1); return path.substr(pos + 1);
} }
std::string_view Path::StripExtension(const std::string_view& path) std::string_view Path::StripExtension(std::string_view path)
{ {
const std::string_view::size_type pos = path.rfind('.'); const std::string_view::size_type pos = path.rfind('.');
if (pos == std::string_view::npos) if (pos == std::string_view::npos)
@ -593,7 +593,7 @@ std::string_view Path::StripExtension(const std::string_view& path)
return path.substr(0, pos); return path.substr(0, pos);
} }
std::string Path::ReplaceExtension(const std::string_view& path, const std::string_view& new_extension) std::string Path::ReplaceExtension(std::string_view path, std::string_view new_extension)
{ {
const std::string_view::size_type pos = path.rfind('.'); const std::string_view::size_type pos = path.rfind('.');
if (pos == std::string_view::npos) if (pos == std::string_view::npos)
@ -604,7 +604,7 @@ std::string Path::ReplaceExtension(const std::string_view& path, const std::stri
return ret; return ret;
} }
static std::string_view::size_type GetLastSeperatorPosition(const std::string_view& filename, bool include_separator) static std::string_view::size_type GetLastSeperatorPosition(std::string_view filename, bool include_separator)
{ {
std::string_view::size_type last_separator = filename.rfind('/'); std::string_view::size_type last_separator = filename.rfind('/');
if (include_separator && last_separator != std::string_view::npos) if (include_separator && last_separator != std::string_view::npos)
@ -624,12 +624,12 @@ static std::string_view::size_type GetLastSeperatorPosition(const std::string_vi
return last_separator; return last_separator;
} }
std::string FileSystem::GetDisplayNameFromPath(const std::string_view& path) std::string FileSystem::GetDisplayNameFromPath(std::string_view path)
{ {
return std::string(Path::GetFileName(path)); return std::string(Path::GetFileName(path));
} }
std::string_view Path::GetDirectory(const std::string_view& path) std::string_view Path::GetDirectory(std::string_view path)
{ {
const std::string::size_type pos = GetLastSeperatorPosition(path, false); const std::string::size_type pos = GetLastSeperatorPosition(path, false);
if (pos == std::string_view::npos) if (pos == std::string_view::npos)
@ -638,7 +638,7 @@ std::string_view Path::GetDirectory(const std::string_view& path)
return path.substr(0, pos); return path.substr(0, pos);
} }
std::string_view Path::GetFileName(const std::string_view& path) std::string_view Path::GetFileName(std::string_view path)
{ {
const std::string_view::size_type pos = GetLastSeperatorPosition(path, true); const std::string_view::size_type pos = GetLastSeperatorPosition(path, true);
if (pos == std::string_view::npos) if (pos == std::string_view::npos)
@ -647,7 +647,7 @@ std::string_view Path::GetFileName(const std::string_view& path)
return path.substr(pos); return path.substr(pos);
} }
std::string_view Path::GetFileTitle(const std::string_view& path) std::string_view Path::GetFileTitle(std::string_view path)
{ {
const std::string_view filename(GetFileName(path)); const std::string_view filename(GetFileName(path));
const std::string::size_type pos = filename.rfind('.'); const std::string::size_type pos = filename.rfind('.');
@ -657,7 +657,7 @@ std::string_view Path::GetFileTitle(const std::string_view& path)
return filename.substr(0, pos); return filename.substr(0, pos);
} }
std::string Path::ChangeFileName(const std::string_view& path, const std::string_view& new_filename) std::string Path::ChangeFileName(std::string_view path, std::string_view new_filename)
{ {
std::string ret; std::string ret;
PathAppendString(ret, path); PathAppendString(ret, path);
@ -684,12 +684,12 @@ std::string Path::ChangeFileName(const std::string_view& path, const std::string
return ret; return ret;
} }
void Path::ChangeFileName(std::string* path, const std::string_view& new_filename) void Path::ChangeFileName(std::string* path, std::string_view new_filename)
{ {
*path = ChangeFileName(*path, new_filename); *path = ChangeFileName(*path, new_filename);
} }
std::string Path::AppendDirectory(const std::string_view& path, const std::string_view& new_dir) std::string Path::AppendDirectory(std::string_view path, std::string_view new_dir)
{ {
std::string ret; std::string ret;
if (!new_dir.empty()) if (!new_dir.empty())
@ -731,12 +731,12 @@ std::string Path::AppendDirectory(const std::string_view& path, const std::strin
return ret; return ret;
} }
void Path::AppendDirectory(std::string* path, const std::string_view& new_dir) void Path::AppendDirectory(std::string* path, std::string_view new_dir)
{ {
*path = AppendDirectory(*path, new_dir); *path = AppendDirectory(*path, new_dir);
} }
std::vector<std::string_view> Path::SplitWindowsPath(const std::string_view& path) std::vector<std::string_view> Path::SplitWindowsPath(std::string_view path)
{ {
std::vector<std::string_view> parts; std::vector<std::string_view> parts;
@ -774,7 +774,7 @@ std::string Path::JoinWindowsPath(const std::vector<std::string_view>& component
return StringUtil::JoinString(components.begin(), components.end(), '\\'); return StringUtil::JoinString(components.begin(), components.end(), '\\');
} }
std::vector<std::string_view> Path::SplitNativePath(const std::string_view& path) std::vector<std::string_view> Path::SplitNativePath(std::string_view path)
{ {
#ifdef _WIN32 #ifdef _WIN32
return SplitWindowsPath(path); return SplitWindowsPath(path);
@ -841,7 +841,7 @@ std::vector<std::string> FileSystem::GetRootDirectoryList()
return results; return results;
} }
std::string Path::BuildRelativePath(const std::string_view& filename, const std::string_view& new_filename) std::string Path::BuildRelativePath(std::string_view filename, std::string_view new_filename)
{ {
std::string new_string; std::string new_string;
@ -852,7 +852,7 @@ std::string Path::BuildRelativePath(const std::string_view& filename, const std:
return new_string; return new_string;
} }
std::string Path::Combine(const std::string_view& base, const std::string_view& next) std::string Path::Combine(std::string_view base, std::string_view next)
{ {
std::string ret; std::string ret;
ret.reserve(base.length() + next.length() + 1); ret.reserve(base.length() + next.length() + 1);
@ -1193,7 +1193,7 @@ bool FileSystem::WriteBinaryFile(const char* filename, const void* data, size_t
return true; return true;
} }
bool FileSystem::WriteStringToFile(const char* filename, const std::string_view& sv) bool FileSystem::WriteStringToFile(const char* filename, std::string_view sv)
{ {
ManagedCFilePtr fp = OpenManagedCFile(filename, "wb"); ManagedCFilePtr fp = OpenManagedCFile(filename, "wb");
if (!fp) if (!fp)

View file

@ -61,7 +61,7 @@ namespace FileSystem {
using FindResultsArray = std::vector<FILESYSTEM_FIND_DATA>; using FindResultsArray = std::vector<FILESYSTEM_FIND_DATA>;
/// Returns the display name of a filename. Usually this is the same as the path. /// Returns the display name of a filename. Usually this is the same as the path.
std::string GetDisplayNameFromPath(const std::string_view& path); std::string GetDisplayNameFromPath(std::string_view path);
/// Returns a list of "root directories" (i.e. root/home directories on Linux, drive letters on Windows). /// Returns a list of "root directories" (i.e. root/home directories on Linux, drive letters on Windows).
std::vector<std::string> GetRootDirectoryList(); std::vector<std::string> GetRootDirectoryList();
@ -145,7 +145,7 @@ std::optional<std::vector<u8>> ReadBinaryFile(std::FILE* fp);
std::optional<std::string> ReadFileToString(const char* filename, Error* error = nullptr); std::optional<std::string> ReadFileToString(const char* filename, Error* error = nullptr);
std::optional<std::string> ReadFileToString(std::FILE* fp); std::optional<std::string> ReadFileToString(std::FILE* fp);
bool WriteBinaryFile(const char* filename, const void* data, size_t data_length); bool WriteBinaryFile(const char* filename, const void* data, size_t data_length);
bool WriteStringToFile(const char* filename, const std::string_view& sv); bool WriteStringToFile(const char* filename, std::string_view sv);
/// creates a directory in the local filesystem /// creates a directory in the local filesystem
/// if the directory already exists, the return value will be true. /// if the directory already exists, the return value will be true.

View file

@ -276,7 +276,7 @@ void Log::ConsoleOutputLogCallback(void* pUserParam, const char* channelName, co
}); });
#elif !defined(__ANDROID__) #elif !defined(__ANDROID__)
FormatLogMessageAndPrint(channelName, functionName, level, message, s_console_output_timestamps, true, true, FormatLogMessageAndPrint(channelName, functionName, level, message, s_console_output_timestamps, true, true,
[level](const std::string_view& message) { [level](std::string_view message) {
const int outputFd = (level <= LOGLEVEL_WARNING) ? STDERR_FILENO : STDOUT_FILENO; const int outputFd = (level <= LOGLEVEL_WARNING) ? STDERR_FILENO : STDOUT_FILENO;
write(outputFd, message.data(), message.length()); write(outputFd, message.data(), message.length());
}); });
@ -413,9 +413,9 @@ void Log::FileOutputLogCallback(void* pUserParam, const char* channelName, const
if (!s_file_output_enabled) if (!s_file_output_enabled)
return; return;
FormatLogMessageAndPrint( FormatLogMessageAndPrint(channelName, functionName, level, message, true, false, true, [](std::string_view message) {
channelName, functionName, level, message, true, false, true, std::fwrite(message.data(), 1, message.size(), s_file_handle.get());
[](const std::string_view& message) { std::fwrite(message.data(), 1, message.size(), s_file_handle.get()); }); });
} }
void Log::SetFileOutputParams(bool enabled, const char* filename, bool timestamps /* = true */) void Log::SetFileOutputParams(bool enabled, const char* filename, bool timestamps /* = true */)

View file

@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2019-2022 Connor McLaughlin <stenzek@gmail.com> // SPDX-FileCopyrightText: 2019-2024 Connor McLaughlin <stenzek@gmail.com>
// SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0)
#pragma once #pragma once
@ -11,21 +11,21 @@
namespace Path { namespace Path {
/// Converts any forward slashes to backslashes on Win32. /// Converts any forward slashes to backslashes on Win32.
std::string ToNativePath(const std::string_view& path); std::string ToNativePath(std::string_view path);
void ToNativePath(std::string* path); void ToNativePath(std::string* path);
/// Builds a path relative to the specified file /// Builds a path relative to the specified file
std::string BuildRelativePath(const std::string_view& filename, const std::string_view& new_filename); std::string BuildRelativePath(std::string_view filename, std::string_view new_filename);
/// Joins path components together, producing a new path. /// Joins path components together, producing a new path.
std::string Combine(const std::string_view& base, const std::string_view& next); std::string Combine(std::string_view base, std::string_view next);
/// Removes all .. and . components from a path. /// Removes all .. and . components from a path.
std::string Canonicalize(const std::string_view& path); std::string Canonicalize(std::string_view path);
void Canonicalize(std::string* path); void Canonicalize(std::string* path);
/// Sanitizes a filename for use in a filesystem. /// Sanitizes a filename for use in a filesystem.
std::string SanitizeFileName(const std::string_view& str, bool strip_slashes = true); std::string SanitizeFileName(std::string_view str, bool strip_slashes = true);
void SanitizeFileName(std::string* str, bool strip_slashes = true); void SanitizeFileName(std::string* str, bool strip_slashes = true);
/// Mutates the path to remove any MAX_PATH limits (for Windows). /// Mutates the path to remove any MAX_PATH limits (for Windows).
@ -33,47 +33,47 @@ std::string RemoveLengthLimits(std::string_view str);
void RemoveLengthLimits(std::string* path); void RemoveLengthLimits(std::string* path);
/// Returns true if the specified path is an absolute path (C:\Path on Windows or /path on Unix). /// Returns true if the specified path is an absolute path (C:\Path on Windows or /path on Unix).
bool IsAbsolute(const std::string_view& path); bool IsAbsolute(std::string_view path);
/// Resolves any symbolic links in the specified path. /// Resolves any symbolic links in the specified path.
std::string RealPath(const std::string_view& path); std::string RealPath(std::string_view path);
/// Makes the specified path relative to another (e.g. /a/b/c, /a/b -> ../c). /// Makes the specified path relative to another (e.g. /a/b/c, /a/b -> ../c).
/// Both paths must be relative, otherwise this function will just return the input path. /// Both paths must be relative, otherwise this function will just return the input path.
std::string MakeRelative(const std::string_view& path, const std::string_view& relative_to); std::string MakeRelative(std::string_view path, std::string_view relative_to);
/// Returns a view of the extension of a filename. /// Returns a view of the extension of a filename.
std::string_view GetExtension(const std::string_view& path); std::string_view GetExtension(std::string_view path);
/// Removes the extension of a filename. /// Removes the extension of a filename.
std::string_view StripExtension(const std::string_view& path); std::string_view StripExtension(std::string_view path);
/// Replaces the extension of a filename with another. /// Replaces the extension of a filename with another.
std::string ReplaceExtension(const std::string_view& path, const std::string_view& new_extension); std::string ReplaceExtension(std::string_view path, std::string_view new_extension);
/// Returns the directory component of a filename. /// Returns the directory component of a filename.
std::string_view GetDirectory(const std::string_view& path); std::string_view GetDirectory(std::string_view path);
/// Returns the filename component of a filename. /// Returns the filename component of a filename.
std::string_view GetFileName(const std::string_view& path); std::string_view GetFileName(std::string_view path);
/// Returns the file title (less the extension and path) from a filename. /// Returns the file title (less the extension and path) from a filename.
std::string_view GetFileTitle(const std::string_view& path); std::string_view GetFileTitle(std::string_view path);
/// Changes the filename in a path. /// Changes the filename in a path.
std::string ChangeFileName(const std::string_view& path, const std::string_view& new_filename); std::string ChangeFileName(std::string_view path, std::string_view new_filename);
void ChangeFileName(std::string* path, const std::string_view& new_filename); void ChangeFileName(std::string* path, std::string_view new_filename);
/// Appends a directory to a path. /// Appends a directory to a path.
std::string AppendDirectory(const std::string_view& path, const std::string_view& new_dir); std::string AppendDirectory(std::string_view path, std::string_view new_dir);
void AppendDirectory(std::string* path, const std::string_view& new_dir); void AppendDirectory(std::string* path, std::string_view new_dir);
/// Splits a path into its components, handling both Windows and Unix separators. /// Splits a path into its components, handling both Windows and Unix separators.
std::vector<std::string_view> SplitWindowsPath(const std::string_view& path); std::vector<std::string_view> SplitWindowsPath(std::string_view path);
std::string JoinWindowsPath(const std::vector<std::string_view>& components); std::string JoinWindowsPath(const std::vector<std::string_view>& components);
/// Splits a path into its components, only handling native separators. /// Splits a path into its components, only handling native separators.
std::vector<std::string_view> SplitNativePath(const std::string_view& path); std::vector<std::string_view> SplitNativePath(std::string_view path);
std::string JoinNativePath(const std::vector<std::string_view>& components); std::string JoinNativePath(const std::vector<std::string_view>& components);
/// URL encodes the specified string. /// URL encodes the specified string.

View file

@ -118,7 +118,7 @@ struct AchievementProgressIndicator
}; };
} // namespace } // namespace
static void ReportError(const std::string_view& sv); static void ReportError(std::string_view sv);
template<typename... T> template<typename... T>
static void ReportFmtError(fmt::format_string<T...> fmt, T&&... args); static void ReportFmtError(fmt::format_string<T...> fmt, T&&... args);
template<typename... T> template<typename... T>
@ -242,7 +242,7 @@ const rc_client_user_game_summary_t& Achievements::GetGameSummary()
return s_game_summary; return s_game_summary;
} }
void Achievements::ReportError(const std::string_view& sv) void Achievements::ReportError(std::string_view sv)
{ {
std::string error = fmt::format("Achievements error: {}", sv); std::string error = fmt::format("Achievements error: {}", sv);
Log_ErrorPrint(error.c_str()); Log_ErrorPrint(error.c_str());
@ -1576,7 +1576,7 @@ std::string Achievements::GetAchievementBadgePath(const rc_client_achievement_t*
return path; return path;
} }
std::string Achievements::GetUserBadgePath(const std::string_view& username) std::string Achievements::GetUserBadgePath(std::string_view username)
{ {
// definitely want to sanitize usernames... :) // definitely want to sanitize usernames... :)
std::string path; std::string path;

View file

@ -17,7 +17,7 @@ const std::string& GetGameIconPath();
std::string GetAchievementBadgePath(const rc_client_achievement_t* achievement, int state, std::string GetAchievementBadgePath(const rc_client_achievement_t* achievement, int state,
bool download_if_missing = true); bool download_if_missing = true);
std::string GetUserBadgePath(const std::string_view& username); std::string GetUserBadgePath(std::string_view username);
std::string GetLeaderboardUserBadgePath(const rc_client_leaderboard_entry_t* entry); std::string GetLeaderboardUserBadgePath(const rc_client_leaderboard_entry_t* entry);
void OpenLeaderboard(const rc_client_leaderboard_t* lboard); void OpenLeaderboard(const rc_client_leaderboard_t* lboard);

View file

@ -369,7 +369,7 @@ void Bus::AddTTYCharacter(char ch)
} }
} }
void Bus::AddTTYString(const std::string_view& str) void Bus::AddTTYString(std::string_view str)
{ {
for (char ch : str) for (char ch : str)
AddTTYCharacter(ch); AddTTYCharacter(ch);

View file

@ -209,6 +209,6 @@ std::optional<PhysicalMemoryAddress> SearchMemory(PhysicalMemoryAddress start_ad
// TTY Logging. // TTY Logging.
void AddTTYCharacter(char ch); void AddTTYCharacter(char ch);
void AddTTYString(const std::string_view& str); void AddTTYString(std::string_view str);
} // namespace Bus } // namespace Bus

View file

@ -296,7 +296,7 @@ static void ResampleXAADPCM(const s16* frames_in, u32 num_frames_in);
static TinyString LBAToMSFString(CDImage::LBA lba); static TinyString LBAToMSFString(CDImage::LBA lba);
static void CreateFileMap(); static void CreateFileMap();
static void CreateFileMap(IsoReader& iso, const std::string_view& dir); static void CreateFileMap(IsoReader& iso, std::string_view dir);
static const std::string* LookupFileMap(u32 lba, u32* start_lba, u32* end_lba); static const std::string* LookupFileMap(u32 lba, u32* start_lba, u32* end_lba);
static std::unique_ptr<TimingEvent> s_command_event; static std::unique_ptr<TimingEvent> s_command_event;
@ -3317,7 +3317,7 @@ void CDROM::CreateFileMap()
Log_DevFmt("Found {} files", s_file_map.size()); Log_DevFmt("Found {} files", s_file_map.size());
} }
void CDROM::CreateFileMap(IsoReader& iso, const std::string_view& dir) void CDROM::CreateFileMap(IsoReader& iso, std::string_view dir)
{ {
for (auto& [path, entry] : iso.GetEntriesInDirectory(dir)) for (auto& [path, entry] : iso.GetEntriesInDirectory(dir))
{ {

View file

@ -157,7 +157,7 @@ std::vector<std::pair<std::string, std::string>> Controller::GetControllerTypeNa
return ret; return ret;
} }
std::optional<u32> Controller::GetBindIndex(ControllerType type, const std::string_view& bind_name) std::optional<u32> Controller::GetBindIndex(ControllerType type, std::string_view bind_name)
{ {
const ControllerInfo* info = GetControllerInfo(type); const ControllerInfo* info = GetControllerInfo(type);
if (!info) if (!info)
@ -172,7 +172,7 @@ std::optional<u32> Controller::GetBindIndex(ControllerType type, const std::stri
return std::nullopt; return std::nullopt;
} }
Controller::VibrationCapabilities Controller::GetControllerVibrationCapabilities(const std::string_view& type) Controller::VibrationCapabilities Controller::GetControllerVibrationCapabilities(std::string_view type)
{ {
const ControllerInfo* info = GetControllerInfo(type); const ControllerInfo* info = GetControllerInfo(type);
return info ? info->vibration_caps : VibrationCapabilities::NoVibration; return info ? info->vibration_caps : VibrationCapabilities::NoVibration;

View file

@ -102,10 +102,10 @@ public:
static std::vector<std::pair<std::string, std::string>> GetControllerTypeNames(); static std::vector<std::pair<std::string, std::string>> GetControllerTypeNames();
/// Gets the integer code for an axis in the specified controller type. /// Gets the integer code for an axis in the specified controller type.
static std::optional<u32> GetBindIndex(ControllerType type, const std::string_view& bind_name); static std::optional<u32> GetBindIndex(ControllerType type, std::string_view bind_name);
/// Returns the vibration configuration for the specified controller type. /// Returns the vibration configuration for the specified controller type.
static VibrationCapabilities GetControllerVibrationCapabilities(const std::string_view& type); static VibrationCapabilities GetControllerVibrationCapabilities(std::string_view type);
/// Returns general information for the specified controller type. /// Returns general information for the specified controller type.
static const ControllerInfo* GetControllerInfo(ControllerType type); static const ControllerInfo* GetControllerInfo(ControllerType type);

View file

@ -229,8 +229,8 @@ static void DrawLandingWindow();
static void DrawStartGameWindow(); static void DrawStartGameWindow();
static void DrawExitWindow(); static void DrawExitWindow();
static void DrawPauseMenu(); static void DrawPauseMenu();
static void ExitFullscreenAndOpenURL(const std::string_view& url); static void ExitFullscreenAndOpenURL(std::string_view url);
static void CopyTextToClipboard(std::string title, const std::string_view& text); static void CopyTextToClipboard(std::string title, std::string_view text);
static void DrawAboutWindow(); static void DrawAboutWindow();
static void OpenAboutWindow(); static void OpenAboutWindow();
static void FixStateIfPaused(); static void FixStateIfPaused();
@ -293,7 +293,7 @@ static void SwitchToSettings();
static void SwitchToGameSettings(); static void SwitchToGameSettings();
static void SwitchToGameSettings(const GameList::Entry* entry); static void SwitchToGameSettings(const GameList::Entry* entry);
static void SwitchToGameSettingsForPath(const std::string& path); static void SwitchToGameSettingsForPath(const std::string& path);
static void SwitchToGameSettingsForSerial(const std::string_view& serial); static void SwitchToGameSettingsForSerial(std::string_view serial);
static void DrawSettingsWindow(); static void DrawSettingsWindow();
static void DrawSummarySettingsPage(); static void DrawSummarySettingsPage();
static void DrawInterfaceSettingsPage(); static void DrawInterfaceSettingsPage();
@ -391,8 +391,8 @@ static void DrawFolderSetting(SettingsInterface* bsi, const char* title, const c
static void PopulateGraphicsAdapterList(); static void PopulateGraphicsAdapterList();
static void PopulateGameListDirectoryCache(SettingsInterface* si); static void PopulateGameListDirectoryCache(SettingsInterface* si);
static void PopulatePostProcessingChain(SettingsInterface* si); static void PopulatePostProcessingChain(SettingsInterface* si);
static void BeginInputBinding(SettingsInterface* bsi, InputBindingInfo::Type type, const std::string_view& section, static void BeginInputBinding(SettingsInterface* bsi, InputBindingInfo::Type type, std::string_view section,
const std::string_view& key, const std::string_view& display_name); std::string_view key, std::string_view display_name);
static void DrawInputBindingWindow(); static void DrawInputBindingWindow();
static void DrawInputBindingButton(SettingsInterface* bsi, InputBindingInfo::Type type, const char* section, static void DrawInputBindingButton(SettingsInterface* bsi, InputBindingInfo::Type type, const char* section,
const char* name, const char* display_name, const char* icon_name, const char* name, const char* display_name, const char* icon_name,
@ -1754,9 +1754,8 @@ void FullscreenUI::ClearInputBindingVariables()
s_input_binding_value_ranges = {}; s_input_binding_value_ranges = {};
} }
void FullscreenUI::BeginInputBinding(SettingsInterface* bsi, InputBindingInfo::Type type, void FullscreenUI::BeginInputBinding(SettingsInterface* bsi, InputBindingInfo::Type type, std::string_view section,
const std::string_view& section, const std::string_view& key, std::string_view key, std::string_view display_name)
const std::string_view& display_name)
{ {
if (s_input_binding_type != InputBindingInfo::Type::Unknown) if (s_input_binding_type != InputBindingInfo::Type::Unknown)
{ {
@ -2738,7 +2737,7 @@ void FullscreenUI::SwitchToSettings()
s_settings_page = SettingsPage::Interface; s_settings_page = SettingsPage::Interface;
} }
void FullscreenUI::SwitchToGameSettingsForSerial(const std::string_view& serial) void FullscreenUI::SwitchToGameSettingsForSerial(std::string_view serial)
{ {
s_game_settings_entry.reset(); s_game_settings_entry.reset();
s_game_settings_interface = std::make_unique<INISettingsInterface>(System::GetGameSettingsPath(serial)); s_game_settings_interface = std::make_unique<INISettingsInterface>(System::GetGameSettingsPath(serial));
@ -6837,7 +6836,7 @@ void FullscreenUI::OpenAboutWindow()
s_about_window_open = true; s_about_window_open = true;
} }
void FullscreenUI::ExitFullscreenAndOpenURL(const std::string_view& url) void FullscreenUI::ExitFullscreenAndOpenURL(std::string_view url)
{ {
Host::RunOnCPUThread([url = std::string(url)]() { Host::RunOnCPUThread([url = std::string(url)]() {
if (Host::IsFullscreen()) if (Host::IsFullscreen())
@ -6847,7 +6846,7 @@ void FullscreenUI::ExitFullscreenAndOpenURL(const std::string_view& url)
}); });
} }
void FullscreenUI::CopyTextToClipboard(std::string title, const std::string_view& text) void FullscreenUI::CopyTextToClipboard(std::string title, std::string_view text)
{ {
if (Host::CopyTextToClipboard(text)) if (Host::CopyTextToClipboard(text))
ShowToast(std::string(), std::move(title)); ShowToast(std::string(), std::move(title));

View file

@ -37,8 +37,8 @@ enum : u32
GAME_DATABASE_CACHE_VERSION = 7, GAME_DATABASE_CACHE_VERSION = 7,
}; };
static Entry* GetMutableEntry(const std::string_view& serial); static Entry* GetMutableEntry(std::string_view serial);
static const Entry* GetEntryForId(const std::string_view& code); static const Entry* GetEntryForId(std::string_view code);
static bool LoadFromCache(); static bool LoadFromCache();
static bool SaveToCache(); static bool SaveToCache();
@ -110,7 +110,7 @@ ALWAYS_INLINE std::string_view to_stringview(const c4::substr& s)
return std::string_view(s.data(), s.size()); return std::string_view(s.data(), s.size());
} }
ALWAYS_INLINE c4::csubstr to_csubstr(const std::string_view& sv) ALWAYS_INLINE c4::csubstr to_csubstr(std::string_view sv)
{ {
return c4::csubstr(sv.data(), sv.length()); return c4::csubstr(sv.data(), sv.length());
} }
@ -239,7 +239,7 @@ void GameDatabase::Unload()
s_loaded = false; s_loaded = false;
} }
const GameDatabase::Entry* GameDatabase::GetEntryForId(const std::string_view& code) const GameDatabase::Entry* GameDatabase::GetEntryForId(std::string_view code)
{ {
if (code.empty()) if (code.empty())
return nullptr; return nullptr;
@ -307,14 +307,14 @@ const GameDatabase::Entry* GameDatabase::GetEntryForGameDetails(const std::strin
return nullptr; return nullptr;
} }
const GameDatabase::Entry* GameDatabase::GetEntryForSerial(const std::string_view& serial) const GameDatabase::Entry* GameDatabase::GetEntryForSerial(std::string_view serial)
{ {
EnsureLoaded(); EnsureLoaded();
return GetMutableEntry(serial); return GetMutableEntry(serial);
} }
GameDatabase::Entry* GameDatabase::GetMutableEntry(const std::string_view& serial) GameDatabase::Entry* GameDatabase::GetMutableEntry(std::string_view serial)
{ {
for (Entry& entry : s_entries) for (Entry& entry : s_entries)
{ {

View file

@ -96,7 +96,7 @@ void Unload();
const Entry* GetEntryForDisc(CDImage* image); const Entry* GetEntryForDisc(CDImage* image);
const Entry* GetEntryForGameDetails(const std::string& id, u64 hash); const Entry* GetEntryForGameDetails(const std::string& id, u64 hash);
const Entry* GetEntryForSerial(const std::string_view& serial); const Entry* GetEntryForSerial(std::string_view serial);
std::string GetSerialForDisc(CDImage* image); std::string GetSerialForDisc(CDImage* image);
std::string GetSerialForPath(const char* path); std::string GetSerialForPath(const char* path);

View file

@ -117,7 +117,7 @@ bool GameList::IsGameListLoaded()
return s_game_list_loaded; return s_game_list_loaded;
} }
bool GameList::IsScannableFilename(const std::string_view& path) bool GameList::IsScannableFilename(std::string_view path)
{ {
// we don't scan bin files because they'll duplicate // we don't scan bin files because they'll duplicate
if (StringUtil::EndsWithNoCase(path, ".bin")) if (StringUtil::EndsWithNoCase(path, ".bin"))
@ -707,7 +707,7 @@ std::string GameList::GetCoverImagePathForEntry(const Entry* entry)
return GetCoverImagePath(entry->path, entry->serial, entry->title); return GetCoverImagePath(entry->path, entry->serial, entry->title);
} }
static std::string GetFullCoverPath(const std::string_view& filename, const std::string_view& extension) static std::string GetFullCoverPath(std::string_view filename, std::string_view extension)
{ {
return fmt::format("{}" FS_OSPATH_SEPARATOR_STR "{}.{}", EmuFolders::Covers, filename, extension); return fmt::format("{}" FS_OSPATH_SEPARATOR_STR "{}.{}", EmuFolders::Covers, filename, extension);
} }

View file

@ -68,7 +68,7 @@ struct Entry
const char* GetEntryTypeName(EntryType type); const char* GetEntryTypeName(EntryType type);
const char* GetEntryTypeDisplayName(EntryType type); const char* GetEntryTypeDisplayName(EntryType type);
bool IsScannableFilename(const std::string_view& path); bool IsScannableFilename(std::string_view path);
/// Populates a game list entry struct with information from the iso/elf. /// Populates a game list entry struct with information from the iso/elf.
/// Do *not* call while the system is running, it will mess with CDVD state. /// Do *not* call while the system is running, it will mess with CDVD state.

View file

@ -3,8 +3,8 @@
#include "gdb_protocol.h" #include "gdb_protocol.h"
#include "bus.h" #include "bus.h"
#include "cpu_core_private.h"
#include "cpu_core.h" #include "cpu_core.h"
#include "cpu_core_private.h"
#include "system.h" #include "system.h"
#include "common/log.h" #include "common/log.h"
@ -20,15 +20,16 @@
Log_SetChannel(GDBProtocol); Log_SetChannel(GDBProtocol);
namespace GDBProtocol namespace GDBProtocol {
{
static u8* GetMemoryPointer(PhysicalMemoryAddress address, u32 length) static u8* GetMemoryPointer(PhysicalMemoryAddress address, u32 length)
{ {
auto region = Bus::GetMemoryRegionForAddress(address); auto region = Bus::GetMemoryRegionForAddress(address);
if (region) { if (region)
{
u8* data = GetMemoryRegionPointer(*region); u8* data = GetMemoryRegionPointer(*region);
if (data && (address + length <= GetMemoryRegionEnd(*region))) { if (data && (address + length <= GetMemoryRegionEnd(*region)))
{
return data + (address - GetMemoryRegionStart(*region)); return data + (address - GetMemoryRegionStart(*region));
} }
} }
@ -36,34 +37,38 @@ static u8* GetMemoryPointer(PhysicalMemoryAddress address, u32 length)
return nullptr; return nullptr;
} }
static u8 ComputeChecksum(const std::string_view& str) static u8 ComputeChecksum(std::string_view str)
{ {
u8 checksum = 0; u8 checksum = 0;
for (char c : str) { for (char c : str)
{
checksum = (checksum + c) % 256; checksum = (checksum + c) % 256;
} }
return checksum; return checksum;
} }
static std::optional<std::string_view> DeserializePacket(const std::string_view& in) static std::optional<std::string_view> DeserializePacket(std::string_view in)
{ {
if ((in.size() < 4) || (in[0] != '$') || (in[in.size()-3] != '#')) { if ((in.size() < 4) || (in[0] != '$') || (in[in.size() - 3] != '#'))
{
return std::nullopt; return std::nullopt;
} }
std::string_view data = in.substr(1, in.size()-4); std::string_view data = in.substr(1, in.size() - 4);
u8 packetChecksum = StringUtil::FromChars<u8>(in.substr(in.size()-2, 2), 16).value_or(0); u8 packetChecksum = StringUtil::FromChars<u8>(in.substr(in.size() - 2, 2), 16).value_or(0);
u8 computedChecksum = ComputeChecksum(data); u8 computedChecksum = ComputeChecksum(data);
if (packetChecksum == computedChecksum) { if (packetChecksum == computedChecksum)
return { data }; {
return {data};
} }
else { else
{
return std::nullopt; return std::nullopt;
} }
} }
static std::string SerializePacket(const std::string_view& in) static std::string SerializePacket(std::string_view in)
{ {
std::stringstream ss; std::stringstream ss;
ss << '$' << in << '#' << TinyString::from_format("{:02x}", ComputeChecksum(in)); ss << '$' << in << '#' << TinyString::from_format("{:02x}", ComputeChecksum(in));
@ -71,7 +76,7 @@ static std::string SerializePacket(const std::string_view& in)
} }
/// List of GDB remote protocol registers for MIPS III (excluding FP). /// List of GDB remote protocol registers for MIPS III (excluding FP).
static const std::array<u32*, 38> REGISTERS { static const std::array<u32*, 38> REGISTERS{
&CPU::g_state.regs.r[0], &CPU::g_state.regs.r[0],
&CPU::g_state.regs.r[1], &CPU::g_state.regs.r[1],
&CPU::g_state.regs.r[2], &CPU::g_state.regs.r[2],
@ -117,53 +122,59 @@ static const std::array<u32*, 38> REGISTERS {
constexpr int NUM_GDB_REGISTERS = 73; constexpr int NUM_GDB_REGISTERS = 73;
/// Get stop reason. /// Get stop reason.
static std::optional<std::string> Cmd$_questionMark(const std::string_view& data) static std::optional<std::string> Cmd$_questionMark(std::string_view data)
{ {
return { "S02" }; return {"S02"};
} }
/// Get general registers. /// Get general registers.
static std::optional<std::string> Cmd$g(const std::string_view& data) static std::optional<std::string> Cmd$g(std::string_view data)
{ {
std::stringstream ss; std::stringstream ss;
for (u32* reg : REGISTERS) { for (u32* reg : REGISTERS)
{
// Data is in host order (little endian). // Data is in host order (little endian).
ss << StringUtil::EncodeHex(reinterpret_cast<u8*>(reg), 4); ss << StringUtil::EncodeHex(reinterpret_cast<u8*>(reg), 4);
} }
// Pad with dummy data (FP registers stuff). // Pad with dummy data (FP registers stuff).
for (int i = 0; i < NUM_GDB_REGISTERS - static_cast<int>(REGISTERS.size()); i++) { for (int i = 0; i < NUM_GDB_REGISTERS - static_cast<int>(REGISTERS.size()); i++)
{
ss << "00000000"; ss << "00000000";
} }
return { ss.str() }; return {ss.str()};
} }
/// Set general registers. /// Set general registers.
static std::optional<std::string> Cmd$G(const std::string_view& data) static std::optional<std::string> Cmd$G(std::string_view data)
{ {
if (data.size() == NUM_GDB_REGISTERS*8) { if (data.size() == NUM_GDB_REGISTERS * 8)
{
int offset = 0; int offset = 0;
for (u32* reg : REGISTERS) { for (u32* reg : REGISTERS)
{
// Data is in host order (little endian). // Data is in host order (little endian).
auto value = StringUtil::DecodeHex({data.data()+offset, 8}); auto value = StringUtil::DecodeHex({data.data() + offset, 8});
if (value) { if (value)
{
*reg = *reinterpret_cast<u32*>(&(*value)[0]); *reg = *reinterpret_cast<u32*>(&(*value)[0]);
} }
offset += 8; offset += 8;
} }
} }
else { else
Log_ErrorPrintf("Wrong payload size for 'G' command, expected %d got %zu", NUM_GDB_REGISTERS*8, data.size()); {
Log_ErrorPrintf("Wrong payload size for 'G' command, expected %d got %zu", NUM_GDB_REGISTERS * 8, data.size());
} }
return { "" }; return {""};
} }
/// Get memory. /// Get memory.
static std::optional<std::string> Cmd$m(const std::string_view& data) static std::optional<std::string> Cmd$m(std::string_view data)
{ {
std::stringstream ss{std::string{data}}; std::stringstream ss{std::string{data}};
std::string dataAddress, dataLength; std::string dataAddress, dataLength;
@ -174,20 +185,22 @@ static std::optional<std::string> Cmd$m(const std::string_view& data)
auto address = StringUtil::FromChars<VirtualMemoryAddress>(dataAddress, 16); auto address = StringUtil::FromChars<VirtualMemoryAddress>(dataAddress, 16);
auto length = StringUtil::FromChars<u32>(dataLength, 16); auto length = StringUtil::FromChars<u32>(dataLength, 16);
if (address && length) { if (address && length)
{
PhysicalMemoryAddress phys_addr = *address & CPU::PHYSICAL_MEMORY_ADDRESS_MASK; PhysicalMemoryAddress phys_addr = *address & CPU::PHYSICAL_MEMORY_ADDRESS_MASK;
u32 phys_length = *length; u32 phys_length = *length;
u8* ptr_data = GetMemoryPointer(phys_addr, phys_length); u8* ptr_data = GetMemoryPointer(phys_addr, phys_length);
if (ptr_data) { if (ptr_data)
return { StringUtil::EncodeHex(ptr_data, phys_length) }; {
return {StringUtil::EncodeHex(ptr_data, phys_length)};
} }
} }
return { "E00" }; return {"E00"};
} }
/// Set memory. /// Set memory.
static std::optional<std::string> Cmd$M(const std::string_view& data) static std::optional<std::string> Cmd$M(std::string_view data)
{ {
std::stringstream ss{std::string{data}}; std::stringstream ss{std::string{data}};
std::string dataAddress, dataLength, dataPayload; std::string dataAddress, dataLength, dataPayload;
@ -200,95 +213,101 @@ static std::optional<std::string> Cmd$M(const std::string_view& data)
auto length = StringUtil::FromChars<u32>(dataLength, 16); auto length = StringUtil::FromChars<u32>(dataLength, 16);
auto payload = StringUtil::DecodeHex(dataPayload); auto payload = StringUtil::DecodeHex(dataPayload);
if (address && length && payload && (payload->size() == *length)) { if (address && length && payload && (payload->size() == *length))
{
u32 phys_addr = *address & CPU::PHYSICAL_MEMORY_ADDRESS_MASK; u32 phys_addr = *address & CPU::PHYSICAL_MEMORY_ADDRESS_MASK;
u32 phys_length = *length; u32 phys_length = *length;
u8* ptr_data = GetMemoryPointer(phys_addr, phys_length); u8* ptr_data = GetMemoryPointer(phys_addr, phys_length);
if (ptr_data) { if (ptr_data)
{
memcpy(ptr_data, payload->data(), phys_length); memcpy(ptr_data, payload->data(), phys_length);
return { "OK" }; return {"OK"};
} }
} }
return { "E00" }; return {"E00"};
} }
/// Remove hardware breakpoint. /// Remove hardware breakpoint.
static std::optional<std::string> Cmd$z1(const std::string_view& data) static std::optional<std::string> Cmd$z1(std::string_view data)
{ {
auto address = StringUtil::FromChars<VirtualMemoryAddress>(data, 16); auto address = StringUtil::FromChars<VirtualMemoryAddress>(data, 16);
if (address) { if (address)
{
CPU::RemoveBreakpoint(CPU::BreakpointType::Execute, *address); CPU::RemoveBreakpoint(CPU::BreakpointType::Execute, *address);
return { "OK" }; return {"OK"};
} }
else { else
{
return std::nullopt; return std::nullopt;
} }
} }
/// Insert hardware breakpoint. /// Insert hardware breakpoint.
static std::optional<std::string> Cmd$Z1(const std::string_view& data) static std::optional<std::string> Cmd$Z1(std::string_view data)
{ {
auto address = StringUtil::FromChars<VirtualMemoryAddress>(data, 16); auto address = StringUtil::FromChars<VirtualMemoryAddress>(data, 16);
if (address) { if (address)
{
CPU::AddBreakpoint(CPU::BreakpointType::Execute, *address, false); CPU::AddBreakpoint(CPU::BreakpointType::Execute, *address, false);
return { "OK" }; return {"OK"};
} }
else { else
{
return std::nullopt; return std::nullopt;
} }
} }
static std::optional<std::string> Cmd$vMustReplyEmpty(const std::string_view& data) static std::optional<std::string> Cmd$vMustReplyEmpty(std::string_view data)
{ {
return { "" }; return {""};
} }
static std::optional<std::string> Cmd$qSupported(const std::string_view& data) static std::optional<std::string> Cmd$qSupported(std::string_view data)
{ {
return { "" }; return {""};
} }
/// List of all GDB remote protocol packets supported by us. /// List of all GDB remote protocol packets supported by us.
static const std::map<const char*, std::function<std::optional<std::string>(const std::string_view&)>> COMMANDS static const std::map<const char*, std::function<std::optional<std::string>(std::string_view)>> COMMANDS{
{ {"?", Cmd$_questionMark},
{ "?", Cmd$_questionMark }, {"g", Cmd$g},
{ "g", Cmd$g }, {"G", Cmd$G},
{ "G", Cmd$G }, {"m", Cmd$m},
{ "m", Cmd$m }, {"M", Cmd$M},
{ "M", Cmd$M }, {"z0,", Cmd$z1},
{ "z0,", Cmd$z1 }, {"Z0,", Cmd$Z1},
{ "Z0,", Cmd$Z1 }, {"z1,", Cmd$z1},
{ "z1,", Cmd$z1 }, {"Z1,", Cmd$Z1},
{ "Z1,", Cmd$Z1 }, {"vMustReplyEmpty", Cmd$vMustReplyEmpty},
{ "vMustReplyEmpty", Cmd$vMustReplyEmpty }, {"qSupported", Cmd$qSupported},
{ "qSupported", Cmd$qSupported },
}; };
bool IsPacketInterrupt(const std::string_view& data) bool IsPacketInterrupt(std::string_view data)
{ {
return (data.size() >= 1) && (data[data.size()-1] == '\003'); return (data.size() >= 1) && (data[data.size() - 1] == '\003');
} }
bool IsPacketContinue(const std::string_view& data) bool IsPacketContinue(std::string_view data)
{ {
return (data.size() >= 5) && (data.substr(data.size()-5) == "$c#63"); return (data.size() >= 5) && (data.substr(data.size() - 5) == "$c#63");
} }
bool IsPacketComplete(const std::string_view& data) bool IsPacketComplete(std::string_view data)
{ {
return ((data.size() == 1) && (data[0] == '\003')) || return ((data.size() == 1) && (data[0] == '\003')) || ((data.size() > 3) && (*(data.end() - 3) == '#'));
((data.size() > 3) && (*(data.end()-3) == '#'));
} }
std::string ProcessPacket(const std::string_view& data) std::string ProcessPacket(std::string_view data)
{ {
std::string_view trimmedData = data; std::string_view trimmedData = data;
// Eat ACKs. // Eat ACKs.
while (!trimmedData.empty() && (trimmedData[0] == '+' || trimmedData[0] == '-')) { while (!trimmedData.empty() && (trimmedData[0] == '+' || trimmedData[0] == '-'))
if (trimmedData[0] == '-') { {
if (trimmedData[0] == '-')
{
Log_ErrorPrint("Received negative ack"); Log_ErrorPrint("Received negative ack");
} }
trimmedData = trimmedData.substr(1); trimmedData = trimmedData.substr(1);
@ -296,17 +315,20 @@ std::string ProcessPacket(const std::string_view& data)
// Validate packet. // Validate packet.
auto packet = DeserializePacket(trimmedData); auto packet = DeserializePacket(trimmedData);
if (!packet) { if (!packet)
{
Log_ErrorPrintf("Malformed packet '%*s'", static_cast<int>(trimmedData.size()), trimmedData.data()); Log_ErrorPrintf("Malformed packet '%*s'", static_cast<int>(trimmedData.size()), trimmedData.data());
return "-"; return "-";
} }
std::optional<std::string> reply = { "" }; std::optional<std::string> reply = {""};
// Try to invoke packet command. // Try to invoke packet command.
bool processed = false; bool processed = false;
for (const auto& command : COMMANDS) { for (const auto& command : COMMANDS)
if (packet->starts_with(command.first)) { {
if (packet->starts_with(command.first))
{
Log_DebugPrintf("Processing command '%s'", command.first); Log_DebugPrintf("Processing command '%s'", command.first);
// Invoke command, remove command name from payload. // Invoke command, remove command name from payload.
@ -316,10 +338,11 @@ std::string ProcessPacket(const std::string_view& data)
} }
} }
if (!processed) { if (!processed)
{
Log_WarningPrintf("Failed to process packet '%*s'", static_cast<int>(trimmedData.size()), trimmedData.data()); Log_WarningPrintf("Failed to process packet '%*s'", static_cast<int>(trimmedData.size()), trimmedData.data());
} }
return reply ? "+"+SerializePacket(*reply) : "+"; return reply ? "+" + SerializePacket(*reply) : "+";
} }
} // namespace GDBProtocol } // namespace GDBProtocol

View file

@ -4,13 +4,10 @@
#pragma once #pragma once
#include <string_view> #include <string_view>
namespace GDBProtocol namespace GDBProtocol {
{ bool IsPacketInterrupt(std::string_view data);
bool IsPacketContinue(std::string_view data);
bool IsPacketInterrupt(const std::string_view& data);
bool IsPacketContinue(const std::string_view& data);
bool IsPacketComplete(const std::string_view& data);
std::string ProcessPacket(const std::string_view& data);
bool IsPacketComplete(std::string_view data);
std::string ProcessPacket(std::string_view data);
} // namespace GDBProtocol } // namespace GDBProtocol

View file

@ -74,7 +74,7 @@ SettingsInterface* GetSettingsInterface();
SettingsInterface* GetSettingsInterfaceForBindings(); SettingsInterface* GetSettingsInterfaceForBindings();
/// Debugger feedback. /// Debugger feedback.
void ReportDebuggerMessage(const std::string_view& message); void ReportDebuggerMessage(std::string_view message);
void ReportFormattedDebuggerMessage(const char* format, ...); void ReportFormattedDebuggerMessage(const char* format, ...);
/// Returns a list of supported languages and codes (suffixes for translation files). /// Returns a list of supported languages and codes (suffixes for translation files).

View file

@ -329,8 +329,7 @@ bool MemoryCardImage::ReadFile(const DataArray& data, const FileInfo& fi, std::v
return true; return true;
} }
bool MemoryCardImage::WriteFile(DataArray* data, const std::string_view& filename, const std::vector<u8>& buffer, bool MemoryCardImage::WriteFile(DataArray* data, std::string_view filename, const std::vector<u8>& buffer, Error* error)
Error* error)
{ {
if (buffer.empty()) if (buffer.empty())
{ {

View file

@ -51,7 +51,7 @@ bool IsValid(const DataArray& data);
u32 GetFreeBlockCount(const DataArray& data); u32 GetFreeBlockCount(const DataArray& data);
std::vector<FileInfo> EnumerateFiles(const DataArray& data, bool include_deleted); std::vector<FileInfo> EnumerateFiles(const DataArray& data, bool include_deleted);
bool ReadFile(const DataArray& data, const FileInfo& fi, std::vector<u8>* buffer, Error* error); bool ReadFile(const DataArray& data, const FileInfo& fi, std::vector<u8>* buffer, Error* error);
bool WriteFile(DataArray* data, const std::string_view& filename, const std::vector<u8>& buffer, Error* error); bool WriteFile(DataArray* data, std::string_view filename, const std::vector<u8>& buffer, Error* error);
bool DeleteFile(DataArray* data, const FileInfo& fi, bool clear_sectors); bool DeleteFile(DataArray* data, const FileInfo& fi, bool clear_sectors);
bool UndeleteFile(DataArray* data, const FileInfo& fi); bool UndeleteFile(DataArray* data, const FileInfo& fi);
bool ImportCard(DataArray* data, const char* filename, Error* error); bool ImportCard(DataArray* data, const char* filename, Error* error);

View file

@ -1621,7 +1621,7 @@ std::string Settings::GetSharedMemoryCardPath(u32 slot) const
return ret; return ret;
} }
std::string Settings::GetGameMemoryCardPath(const std::string_view& serial, u32 slot) std::string Settings::GetGameMemoryCardPath(std::string_view serial, u32 slot)
{ {
return Path::Combine(EmuFolders::MemoryCards, fmt::format("{}_{}.mcd", serial, slot + 1)); return Path::Combine(EmuFolders::MemoryCards, fmt::format("{}_{}.mcd", serial, slot + 1));
} }

View file

@ -322,7 +322,7 @@ struct Settings
std::string GetSharedMemoryCardPath(u32 slot) const; std::string GetSharedMemoryCardPath(u32 slot) const;
/// Returns the default path to a memory card for a specific game. /// Returns the default path to a memory card for a specific game.
static std::string GetGameMemoryCardPath(const std::string_view& serial, u32 slot); static std::string GetGameMemoryCardPath(std::string_view serial, u32 slot);
static void CPUOverclockPercentToFraction(u32 percent, u32* numerator, u32* denominator); static void CPUOverclockPercentToFraction(u32 percent, u32* numerator, u32* denominator);
static u32 CPUOverclockFractionToPercent(u32 numerator, u32 denominator); static u32 CPUOverclockFractionToPercent(u32 numerator, u32 denominator);

View file

@ -540,18 +540,18 @@ u32 System::GetFrameTimeHistoryPos()
return s_frame_time_history_pos; return s_frame_time_history_pos;
} }
bool System::IsExeFileName(const std::string_view& path) bool System::IsExeFileName(std::string_view path)
{ {
return (StringUtil::EndsWithNoCase(path, ".exe") || StringUtil::EndsWithNoCase(path, ".psexe") || return (StringUtil::EndsWithNoCase(path, ".exe") || StringUtil::EndsWithNoCase(path, ".psexe") ||
StringUtil::EndsWithNoCase(path, ".ps-exe")); StringUtil::EndsWithNoCase(path, ".ps-exe"));
} }
bool System::IsPsfFileName(const std::string_view& path) bool System::IsPsfFileName(std::string_view path)
{ {
return (StringUtil::EndsWithNoCase(path, ".psf") || StringUtil::EndsWithNoCase(path, ".minipsf")); return (StringUtil::EndsWithNoCase(path, ".psf") || StringUtil::EndsWithNoCase(path, ".minipsf"));
} }
bool System::IsLoadableFilename(const std::string_view& path) bool System::IsLoadableFilename(std::string_view path)
{ {
static constexpr const std::array extensions = { static constexpr const std::array extensions = {
".bin", ".cue", ".img", ".iso", ".chd", ".ecm", ".mds", // discs ".bin", ".cue", ".img", ".iso", ".chd", ".ecm", ".mds", // discs
@ -570,7 +570,7 @@ bool System::IsLoadableFilename(const std::string_view& path)
return false; return false;
} }
bool System::IsSaveStateFilename(const std::string_view& path) bool System::IsSaveStateFilename(std::string_view path)
{ {
return StringUtil::EndsWithNoCase(path, ".sav"); return StringUtil::EndsWithNoCase(path, ".sav");
} }
@ -907,13 +907,13 @@ std::optional<DiscRegion> System::GetRegionForPath(const char* image_path)
return GetRegionForImage(cdi.get()); return GetRegionForImage(cdi.get());
} }
std::string System::GetGameSettingsPath(const std::string_view& game_serial) std::string System::GetGameSettingsPath(std::string_view game_serial)
{ {
const std::string sanitized_serial(Path::SanitizeFileName(game_serial)); const std::string sanitized_serial(Path::SanitizeFileName(game_serial));
return Path::Combine(EmuFolders::GameSettings, fmt::format("{}.ini", sanitized_serial)); return Path::Combine(EmuFolders::GameSettings, fmt::format("{}.ini", sanitized_serial));
} }
std::string System::GetInputProfilePath(const std::string_view& name) std::string System::GetInputProfilePath(std::string_view name)
{ {
return Path::Combine(EmuFolders::InputProfiles, fmt::format("{}.ini", name)); return Path::Combine(EmuFolders::InputProfiles, fmt::format("{}.ini", name));
} }
@ -3614,7 +3614,7 @@ u32 System::GetMediaSubImageIndex()
return cdi ? cdi->GetCurrentSubImage() : 0; return cdi ? cdi->GetCurrentSubImage() : 0;
} }
u32 System::GetMediaSubImageIndexForTitle(const std::string_view& title) u32 System::GetMediaSubImageIndexForTitle(std::string_view title)
{ {
const CDImage* cdi = CDROM::GetMedia(); const CDImage* cdi = CDROM::GetMedia();
if (!cdi) if (!cdi)
@ -4533,7 +4533,7 @@ bool System::SaveScreenshot(const char* filename, DisplayScreenshotMode mode, Di
return g_gpu->RenderScreenshotToFile(filename, mode, quality, compress_on_thread, true); return g_gpu->RenderScreenshotToFile(filename, mode, quality, compress_on_thread, true);
} }
std::string System::GetGameSaveStateFileName(const std::string_view& serial, s32 slot) std::string System::GetGameSaveStateFileName(std::string_view serial, s32 slot)
{ {
if (slot < 0) if (slot < 0)
return Path::Combine(EmuFolders::SaveStates, fmt::format("{}_resume.sav", serial)); return Path::Combine(EmuFolders::SaveStates, fmt::format("{}_resume.sav", serial));

View file

@ -112,16 +112,16 @@ using GameHash = u64;
extern TickCount g_ticks_per_second; extern TickCount g_ticks_per_second;
/// Returns true if the filename is a PlayStation executable we can inject. /// Returns true if the filename is a PlayStation executable we can inject.
bool IsExeFileName(const std::string_view& path); bool IsExeFileName(std::string_view path);
/// Returns true if the filename is a Portable Sound Format file we can uncompress/load. /// Returns true if the filename is a Portable Sound Format file we can uncompress/load.
bool IsPsfFileName(const std::string_view& path); bool IsPsfFileName(std::string_view path);
/// Returns true if the filename is one we can load. /// Returns true if the filename is one we can load.
bool IsLoadableFilename(const std::string_view& path); bool IsLoadableFilename(std::string_view path);
/// Returns true if the filename is a save state. /// Returns true if the filename is a save state.
bool IsSaveStateFilename(const std::string_view& path); bool IsSaveStateFilename(std::string_view path);
/// Returns the preferred console type for a disc. /// Returns the preferred console type for a disc.
ConsoleRegion GetConsoleRegionForDiscRegion(DiscRegion region); ConsoleRegion GetConsoleRegionForDiscRegion(DiscRegion region);
@ -139,10 +139,10 @@ DiscRegion GetRegionForPsf(const char* path);
std::optional<DiscRegion> GetRegionForPath(const char* image_path); std::optional<DiscRegion> GetRegionForPath(const char* image_path);
/// Returns the path for the game settings ini file for the specified serial. /// Returns the path for the game settings ini file for the specified serial.
std::string GetGameSettingsPath(const std::string_view& game_serial); std::string GetGameSettingsPath(std::string_view game_serial);
/// Returns the path for the input profile ini file with the specified name (may not exist). /// Returns the path for the input profile ini file with the specified name (may not exist).
std::string GetInputProfilePath(const std::string_view& name); std::string GetInputProfilePath(std::string_view name);
State GetState(); State GetState();
void SetState(State new_state); void SetState(State new_state);
@ -332,7 +332,7 @@ u32 GetMediaSubImageCount();
u32 GetMediaSubImageIndex(); u32 GetMediaSubImageIndex();
/// Returns the index of the specified path in the playlist, or UINT32_MAX if it does not exist. /// Returns the index of the specified path in the playlist, or UINT32_MAX if it does not exist.
u32 GetMediaSubImageIndexForTitle(const std::string_view& title); u32 GetMediaSubImageIndexForTitle(std::string_view title);
/// Returns the path to the specified playlist index. /// Returns the path to the specified playlist index.
std::string GetMediaSubImageTitle(u32 index); std::string GetMediaSubImageTitle(u32 index);
@ -374,7 +374,7 @@ void DoFrameStep();
void DoToggleCheats(); void DoToggleCheats();
/// Returns the path to a save state file. Specifying an index of -1 is the "resume" save state. /// Returns the path to a save state file. Specifying an index of -1 is the "resume" save state.
std::string GetGameSaveStateFileName(const std::string_view& serial, s32 slot); std::string GetGameSaveStateFileName(std::string_view serial, s32 slot);
/// Returns the path to a save state file. Specifying an index of -1 is the "resume" save state. /// Returns the path to a save state file. Specifying an index of -1 is the "resume" save state.
std::string GetGlobalSaveStateFileName(s32 slot); std::string GetGlobalSaveStateFileName(s32 slot);

View file

@ -45,7 +45,7 @@ std::string TextureReplacementHash::ToString() const
return StringUtil::StdStringFromFormat("%" PRIx64 "%" PRIx64, high, low); return StringUtil::StdStringFromFormat("%" PRIx64 "%" PRIx64, high, low);
} }
bool TextureReplacementHash::ParseString(const std::string_view& sv) bool TextureReplacementHash::ParseString(std::string_view sv)
{ {
if (sv.length() != 32) if (sv.length() != 32)
return false; return false;

View file

@ -20,7 +20,7 @@ struct TextureReplacementHash
u64 high; u64 high;
std::string ToString() const; std::string ToString() const;
bool ParseString(const std::string_view& sv); bool ParseString(std::string_view sv);
bool operator<(const TextureReplacementHash& rhs) const { return std::tie(low, high) < std::tie(rhs.low, rhs.high); } bool operator<(const TextureReplacementHash& rhs) const { return std::tie(low, high) < std::tie(rhs.low, rhs.high); }
bool operator==(const TextureReplacementHash& rhs) const { return low == rhs.low && high == rhs.high; } bool operator==(const TextureReplacementHash& rhs) const { return low == rhs.low && high == rhs.high; }

View file

@ -1699,7 +1699,7 @@ void EmuThread::wakeThread()
QMetaObject::invokeMethod(m_event_loop, "quit", Qt::QueuedConnection); QMetaObject::invokeMethod(m_event_loop, "quit", Qt::QueuedConnection);
} }
void Host::ReportFatalError(const std::string_view& title, const std::string_view& message) void Host::ReportFatalError(std::string_view title, std::string_view message)
{ {
auto cb = [title = QtUtils::StringViewToQString(title), message = QtUtils::StringViewToQString(message)]() { auto cb = [title = QtUtils::StringViewToQString(title), message = QtUtils::StringViewToQString(message)]() {
QMessageBox::critical(g_main_window && g_main_window->isVisible() ? g_main_window : nullptr, title, message); QMessageBox::critical(g_main_window && g_main_window->isVisible() ? g_main_window : nullptr, title, message);
@ -1727,7 +1727,7 @@ void Host::ReportFatalError(const std::string_view& title, const std::string_vie
} }
} }
void Host::ReportErrorAsync(const std::string_view& title, const std::string_view& message) void Host::ReportErrorAsync(std::string_view title, std::string_view message)
{ {
if (!title.empty() && !message.empty()) if (!title.empty() && !message.empty())
{ {
@ -1745,7 +1745,7 @@ void Host::ReportErrorAsync(const std::string_view& title, const std::string_vie
Q_ARG(const QString&, message.empty() ? QString() : QString::fromUtf8(message.data(), message.size()))); Q_ARG(const QString&, message.empty() ? QString() : QString::fromUtf8(message.data(), message.size())));
} }
bool Host::ConfirmMessage(const std::string_view& title, const std::string_view& message) bool Host::ConfirmMessage(std::string_view title, std::string_view message)
{ {
auto lock = g_emu_thread->pauseAndLockSystem(); auto lock = g_emu_thread->pauseAndLockSystem();
@ -1753,12 +1753,12 @@ bool Host::ConfirmMessage(const std::string_view& title, const std::string_view&
QString::fromUtf8(message.data(), message.size())); QString::fromUtf8(message.data(), message.size()));
} }
void Host::OpenURL(const std::string_view& url) void Host::OpenURL(std::string_view url)
{ {
QtHost::RunOnUIThread([url = QtUtils::StringViewToQString(url)]() { QtUtils::OpenURL(g_main_window, QUrl(url)); }); QtHost::RunOnUIThread([url = QtUtils::StringViewToQString(url)]() { QtUtils::OpenURL(g_main_window, QUrl(url)); });
} }
bool Host::CopyTextToClipboard(const std::string_view& text) bool Host::CopyTextToClipboard(std::string_view text)
{ {
QtHost::RunOnUIThread([text = QtUtils::StringViewToQString(text)]() { QtHost::RunOnUIThread([text = QtUtils::StringViewToQString(text)]() {
QClipboard* clipboard = QGuiApplication::clipboard(); QClipboard* clipboard = QGuiApplication::clipboard();
@ -1768,7 +1768,7 @@ bool Host::CopyTextToClipboard(const std::string_view& text)
return true; return true;
} }
void Host::ReportDebuggerMessage(const std::string_view& message) void Host::ReportDebuggerMessage(std::string_view message)
{ {
emit g_emu_thread->debuggerMessageReported(QString::fromUtf8(message)); emit g_emu_thread->debuggerMessageReported(QString::fromUtf8(message));
} }
@ -1777,14 +1777,14 @@ void Host::AddFixedInputBindings(SettingsInterface& si)
{ {
} }
void Host::OnInputDeviceConnected(const std::string_view& identifier, const std::string_view& device_name) void Host::OnInputDeviceConnected(std::string_view identifier, std::string_view device_name)
{ {
emit g_emu_thread->onInputDeviceConnected( emit g_emu_thread->onInputDeviceConnected(
identifier.empty() ? QString() : QString::fromUtf8(identifier.data(), identifier.size()), identifier.empty() ? QString() : QString::fromUtf8(identifier.data(), identifier.size()),
device_name.empty() ? QString() : QString::fromUtf8(device_name.data(), device_name.size())); device_name.empty() ? QString() : QString::fromUtf8(device_name.data(), device_name.size()));
} }
void Host::OnInputDeviceDisconnected(const std::string_view& identifier) void Host::OnInputDeviceDisconnected(std::string_view identifier)
{ {
emit g_emu_thread->onInputDeviceDisconnected( emit g_emu_thread->onInputDeviceDisconnected(
identifier.empty() ? QString() : QString::fromUtf8(identifier.data(), identifier.size())); identifier.empty() ? QString() : QString::fromUtf8(identifier.data(), identifier.size()));

View file

@ -458,7 +458,7 @@ static constexpr KeyCodeName s_qt_key_names[] = {{Qt::Key_Escape, "Escape", ICON
{Qt::Key_Camera, "Camera", nullptr}, {Qt::Key_Camera, "Camera", nullptr},
{Qt::Key_CameraFocus, "CameraFocus", nullptr}}; {Qt::Key_CameraFocus, "CameraFocus", nullptr}};
std::optional<u32> InputManager::ConvertHostKeyboardStringToCode(const std::string_view& str) std::optional<u32> InputManager::ConvertHostKeyboardStringToCode(std::string_view str)
{ {
std::string_view compare_name = str; std::string_view compare_name = str;
u32 modifier_bits = 0; u32 modifier_bits = 0;

View file

@ -55,10 +55,10 @@ struct GlyphInfo
}; };
static QString FixLanguageName(const QString& language); static QString FixLanguageName(const QString& language);
static void UpdateGlyphRangesAndClearCache(QWidget* dialog_parent, const std::string_view& language); static void UpdateGlyphRangesAndClearCache(QWidget* dialog_parent, std::string_view language);
static bool DownloadMissingFont(QWidget* dialog_parent, const char* font_name, const char* font_url, static bool DownloadMissingFont(QWidget* dialog_parent, const char* font_name, const char* font_url,
const std::string& path); const std::string& path);
static const GlyphInfo* GetGlyphInfo(const std::string_view& language); static const GlyphInfo* GetGlyphInfo(std::string_view language);
static constexpr const char* DEFAULT_IMGUI_FONT_NAME = "Roboto-Regular.ttf"; static constexpr const char* DEFAULT_IMGUI_FONT_NAME = "Roboto-Regular.ttf";
#define MAKE_FONT_DOWNLOAD_URL(name) "https://www.duckstation.org/runtime-resources/fonts/" name #define MAKE_FONT_DOWNLOAD_URL(name) "https://www.duckstation.org/runtime-resources/fonts/" name
@ -156,7 +156,7 @@ QString QtHost::FixLanguageName(const QString& language)
return language; return language;
} }
s32 Host::Internal::GetTranslatedStringImpl(const std::string_view& context, const std::string_view& msg, char* tbuf, s32 Host::Internal::GetTranslatedStringImpl(std::string_view context, std::string_view msg, char* tbuf,
size_t tbuf_space) size_t tbuf_space)
{ {
// This is really awful. Thankfully we're caching the results... // This is really awful. Thankfully we're caching the results...
@ -220,7 +220,7 @@ static constexpr const ImWchar s_central_european_ranges[] = {
0x0100, 0x017F, // Central European diacritics 0x0100, 0x017F, // Central European diacritics
}; };
void QtHost::UpdateGlyphRangesAndClearCache(QWidget* dialog_parent, const std::string_view& language) void QtHost::UpdateGlyphRangesAndClearCache(QWidget* dialog_parent, std::string_view language)
{ {
const GlyphInfo* gi = GetGlyphInfo(language); const GlyphInfo* gi = GetGlyphInfo(language);
@ -357,7 +357,7 @@ static constexpr const QtHost::GlyphInfo s_glyph_info[] = {
}; };
// clang-format on // clang-format on
const QtHost::GlyphInfo* QtHost::GetGlyphInfo(const std::string_view& language) const QtHost::GlyphInfo* QtHost::GetGlyphInfo(std::string_view language)
{ {
for (const GlyphInfo& it : s_glyph_info) for (const GlyphInfo& it : s_glyph_info)
{ {

View file

@ -205,7 +205,7 @@ std::optional<unsigned> PromptForAddress(QWidget* parent, const QString& title,
return address; return address;
} }
QString StringViewToQString(const std::string_view& str) QString StringViewToQString(std::string_view str)
{ {
return str.empty() ? QString() : QString::fromUtf8(str.data(), str.size()); return str.empty() ? QString() : QString::fromUtf8(str.data(), str.size());
} }

View file

@ -93,7 +93,7 @@ void OpenURL(QWidget* parent, const char* url);
std::optional<unsigned> PromptForAddress(QWidget* parent, const QString& title, const QString& label, bool code); std::optional<unsigned> PromptForAddress(QWidget* parent, const QString& title, const QString& label, bool code);
/// Converts a std::string_view to a QString safely. /// Converts a std::string_view to a QString safely.
QString StringViewToQString(const std::string_view& str); QString StringViewToQString(std::string_view str);
/// Sets a widget to italics if the setting value is inherited. /// Sets a widget to italics if the setting value is inherited.
void SetWidgetFontForInheritedSetting(QWidget* widget, bool inherited); void SetWidgetFontForInheritedSetting(QWidget* widget, bool inherited);

View file

@ -116,13 +116,13 @@ bool RegTestHost::InitializeConfig()
return true; return true;
} }
void Host::ReportFatalError(const std::string_view& title, const std::string_view& message) void Host::ReportFatalError(std::string_view title, std::string_view message)
{ {
Log_ErrorPrintf("ReportFatalError: %.*s", static_cast<int>(message.size()), message.data()); Log_ErrorPrintf("ReportFatalError: %.*s", static_cast<int>(message.size()), message.data());
abort(); abort();
} }
void Host::ReportErrorAsync(const std::string_view& title, const std::string_view& message) void Host::ReportErrorAsync(std::string_view title, std::string_view message)
{ {
if (!title.empty() && !message.empty()) if (!title.empty() && !message.empty())
{ {
@ -135,7 +135,7 @@ void Host::ReportErrorAsync(const std::string_view& title, const std::string_vie
} }
} }
bool Host::ConfirmMessage(const std::string_view& title, const std::string_view& message) bool Host::ConfirmMessage(std::string_view title, std::string_view message)
{ {
if (!title.empty() && !message.empty()) if (!title.empty() && !message.empty())
{ {
@ -150,7 +150,7 @@ bool Host::ConfirmMessage(const std::string_view& title, const std::string_view&
return true; return true;
} }
void Host::ReportDebuggerMessage(const std::string_view& message) void Host::ReportDebuggerMessage(std::string_view message)
{ {
Log_ErrorPrintf("ReportDebuggerMessage: %.*s", static_cast<int>(message.size()), message.data()); Log_ErrorPrintf("ReportDebuggerMessage: %.*s", static_cast<int>(message.size()), message.data());
} }
@ -165,7 +165,7 @@ bool Host::ChangeLanguage(const char* new_language)
return false; return false;
} }
s32 Host::Internal::GetTranslatedStringImpl(const std::string_view& context, const std::string_view& msg, char* tbuf, s32 Host::Internal::GetTranslatedStringImpl(std::string_view context, std::string_view msg, char* tbuf,
size_t tbuf_space) size_t tbuf_space)
{ {
if (msg.size() > tbuf_space) if (msg.size() > tbuf_space)
@ -347,12 +347,12 @@ void Host::BeginPresentFrame()
} }
} }
void Host::OpenURL(const std::string_view& url) void Host::OpenURL(std::string_view url)
{ {
// //
} }
bool Host::CopyTextToClipboard(const std::string_view& text) bool Host::CopyTextToClipboard(std::string_view text)
{ {
return false; return false;
} }
@ -387,7 +387,7 @@ void Host::OnCoverDownloaderOpenRequested()
// noop // noop
} }
std::optional<u32> InputManager::ConvertHostKeyboardStringToCode(const std::string_view& str) std::optional<u32> InputManager::ConvertHostKeyboardStringToCode(std::string_view str)
{ {
return std::nullopt; return std::nullopt;
} }
@ -407,12 +407,12 @@ void Host::AddFixedInputBindings(SettingsInterface& si)
// noop // noop
} }
void Host::OnInputDeviceConnected(const std::string_view& identifier, const std::string_view& device_name) void Host::OnInputDeviceConnected(std::string_view identifier, std::string_view device_name)
{ {
// noop // noop
} }
void Host::OnInputDeviceDisconnected(const std::string_view& identifier) void Host::OnInputDeviceDisconnected(std::string_view identifier)
{ {
// noop // noop
} }

View file

@ -346,7 +346,7 @@ bool CDImage::HasNonStandardSubchannel() const
return false; return false;
} }
std::string CDImage::GetMetadata(const std::string_view& type) const std::string CDImage::GetMetadata(std::string_view type) const
{ {
std::string result; std::string result;
if (type == "title") if (type == "title")
@ -378,7 +378,7 @@ bool CDImage::SwitchSubImage(u32 index, Error* error)
return false; return false;
} }
std::string CDImage::GetSubImageMetadata(u32 index, const std::string_view& type) const std::string CDImage::GetSubImageMetadata(u32 index, std::string_view type) const
{ {
return {}; return {};
} }

View file

@ -307,7 +307,7 @@ public:
virtual bool ReadSectorFromIndex(void* buffer, const Index& index, LBA lba_in_index) = 0; virtual bool ReadSectorFromIndex(void* buffer, const Index& index, LBA lba_in_index) = 0;
// Retrieve image metadata. // Retrieve image metadata.
virtual std::string GetMetadata(const std::string_view& type) const; virtual std::string GetMetadata(std::string_view type) const;
// Returns true if this image type has sub-images (e.g. m3u). // Returns true if this image type has sub-images (e.g. m3u).
virtual bool HasSubImages() const; virtual bool HasSubImages() const;
@ -322,7 +322,7 @@ public:
virtual bool SwitchSubImage(u32 index, Error* error); virtual bool SwitchSubImage(u32 index, Error* error);
// Retrieve sub-image metadata. // Retrieve sub-image metadata.
virtual std::string GetSubImageMetadata(u32 index, const std::string_view& type) const; virtual std::string GetSubImageMetadata(u32 index, std::string_view type) const;
// Returns true if the source supports precaching, which may be more optimal than an in-memory copy. // Returns true if the source supports precaching, which may be more optimal than an in-memory copy.
virtual PrecacheResult Precache(ProgressCallback* progress = ProgressCallback::NullProgressCallback); virtual PrecacheResult Precache(ProgressCallback* progress = ProgressCallback::NullProgressCallback);

View file

@ -95,7 +95,7 @@ std::string CDImageHasher::HashToString(const Hash& hash)
hash[11], hash[12], hash[13], hash[14], hash[15]); hash[11], hash[12], hash[13], hash[14], hash[15]);
} }
std::optional<CDImageHasher::Hash> CDImageHasher::HashFromString(const std::string_view& str) std::optional<CDImageHasher::Hash> CDImageHasher::HashFromString(std::string_view str)
{ {
auto decoded = StringUtil::DecodeHex(str); auto decoded = StringUtil::DecodeHex(str);
if (decoded && decoded->size() == std::tuple_size_v<Hash>) if (decoded && decoded->size() == std::tuple_size_v<Hash>)

View file

@ -14,7 +14,7 @@ namespace CDImageHasher {
using Hash = std::array<u8, 16>; using Hash = std::array<u8, 16>;
std::string HashToString(const Hash& hash); std::string HashToString(const Hash& hash);
std::optional<Hash> HashFromString(const std::string_view& str); std::optional<Hash> HashFromString(std::string_view str);
bool GetImageHash(CDImage* image, Hash* out_hash, bool GetImageHash(CDImage* image, Hash* out_hash,
ProgressCallback* progress_callback = ProgressCallback::NullProgressCallback); ProgressCallback* progress_callback = ProgressCallback::NullProgressCallback);

View file

@ -33,7 +33,7 @@ public:
bool HasSubImages() const override; bool HasSubImages() const override;
u32 GetSubImageCount() const override; u32 GetSubImageCount() const override;
u32 GetCurrentSubImage() const override; u32 GetCurrentSubImage() const override;
std::string GetSubImageMetadata(u32 index, const std::string_view& type) const override; std::string GetSubImageMetadata(u32 index, std::string_view type) const override;
bool SwitchSubImage(u32 index, Error* error) override; bool SwitchSubImage(u32 index, Error* error) override;
protected: protected:
@ -159,7 +159,7 @@ bool CDImageM3u::SwitchSubImage(u32 index, Error* error)
return true; return true;
} }
std::string CDImageM3u::GetSubImageMetadata(u32 index, const std::string_view& type) const std::string CDImageM3u::GetSubImageMetadata(u32 index, std::string_view type) const
{ {
if (index > m_entries.size()) if (index > m_entries.size())
return {}; return {};

View file

@ -141,8 +141,8 @@ public:
u32 GetSubImageCount() const override; u32 GetSubImageCount() const override;
u32 GetCurrentSubImage() const override; u32 GetCurrentSubImage() const override;
bool SwitchSubImage(u32 index, Error* error) override; bool SwitchSubImage(u32 index, Error* error) override;
std::string GetMetadata(const std::string_view& type) const override; std::string GetMetadata(std::string_view type) const override;
std::string GetSubImageMetadata(u32 index, const std::string_view& type) const override; std::string GetSubImageMetadata(u32 index, std::string_view type) const override;
protected: protected:
bool ReadSectorFromIndex(void* buffer, const Index& index, LBA lba_in_index) override; bool ReadSectorFromIndex(void* buffer, const Index& index, LBA lba_in_index) override;
@ -915,7 +915,7 @@ bool CDImagePBP::HasSubImages() const
return m_disc_offsets.size() > 1; return m_disc_offsets.size() > 1;
} }
std::string CDImagePBP::GetMetadata(const std::string_view& type) const std::string CDImagePBP::GetMetadata(std::string_view type) const
{ {
if (type == "title") if (type == "title")
{ {
@ -953,7 +953,7 @@ bool CDImagePBP::SwitchSubImage(u32 index, Error* error)
return true; return true;
} }
std::string CDImagePBP::GetSubImageMetadata(u32 index, const std::string_view& type) const std::string CDImagePBP::GetSubImageMetadata(u32 index, std::string_view type) const
{ {
if (type == "title") if (type == "title")
{ {

View file

@ -35,8 +35,8 @@ public:
bool HasNonStandardSubchannel() const override; bool HasNonStandardSubchannel() const override;
s64 GetSizeOnDisk() const override; s64 GetSizeOnDisk() const override;
std::string GetMetadata(const std::string_view& type) const override; std::string GetMetadata(std::string_view type) const override;
std::string GetSubImageMetadata(u32 index, const std::string_view& type) const override; std::string GetSubImageMetadata(u32 index, std::string_view type) const override;
PrecacheResult Precache(ProgressCallback* progress = ProgressCallback::NullProgressCallback) override; PrecacheResult Precache(ProgressCallback* progress = ProgressCallback::NullProgressCallback) override;
@ -416,12 +416,12 @@ bool CDImagePPF::HasNonStandardSubchannel() const
return m_parent_image->HasNonStandardSubchannel(); return m_parent_image->HasNonStandardSubchannel();
} }
std::string CDImagePPF::GetMetadata(const std::string_view& type) const std::string CDImagePPF::GetMetadata(std::string_view type) const
{ {
return m_parent_image->GetMetadata(type); return m_parent_image->GetMetadata(type);
} }
std::string CDImagePPF::GetSubImageMetadata(u32 index, const std::string_view& type) const std::string CDImagePPF::GetSubImageMetadata(u32 index, std::string_view type) const
{ {
// We only support a single sub-image for patched games. // We only support a single sub-image for patched games.
std::string ret; std::string ret;

View file

@ -12,10 +12,10 @@
Log_SetChannel(CueParser); Log_SetChannel(CueParser);
namespace CueParser { namespace CueParser {
static bool TokenMatch(const std::string_view& s1, const char* token); static bool TokenMatch(std::string_view s1, const char* token);
} }
bool CueParser::TokenMatch(const std::string_view& s1, const char* token) bool CueParser::TokenMatch(std::string_view s1, const char* token)
{ {
const size_t token_len = std::strlen(token); const size_t token_len = std::strlen(token);
if (s1.length() != token_len) if (s1.length() != token_len)
@ -124,7 +124,7 @@ std::string_view CueParser::File::GetToken(const char*& line)
return ret; return ret;
} }
std::optional<CueParser::MSF> CueParser::File::GetMSF(const std::string_view& token) std::optional<CueParser::MSF> CueParser::File::GetMSF(std::string_view token)
{ {
static const s32 max_values[] = {std::numeric_limits<s32>::max(), 60, 75}; static const s32 max_values[] = {std::numeric_limits<s32>::max(), 60, 75};

View file

@ -68,7 +68,7 @@ private:
void SetError(u32 line_number, Error* error, const char* format, ...); void SetError(u32 line_number, Error* error, const char* format, ...);
static std::string_view GetToken(const char*& line); static std::string_view GetToken(const char*& line);
static std::optional<MSF> GetMSF(const std::string_view& token); static std::optional<MSF> GetMSF(std::string_view token);
bool ParseLine(const char* line, u32 line_number, Error* error); bool ParseLine(const char* line, u32 line_number, Error* error);

View file

@ -31,7 +31,7 @@ static std::mutex s_instance_mutex;
static constexpr std::array<float, 4> s_clear_color = {}; static constexpr std::array<float, 4> s_clear_color = {};
static constexpr GPUTexture::Format s_swap_chain_format = GPUTexture::Format::RGBA8; static constexpr GPUTexture::Format s_swap_chain_format = GPUTexture::Format::RGBA8;
void SetD3DDebugObjectName(ID3D11DeviceChild* obj, const std::string_view& name) void SetD3DDebugObjectName(ID3D11DeviceChild* obj, std::string_view name)
{ {
#ifdef _DEBUG #ifdef _DEBUG
// WKPDID_D3DDebugObjectName // WKPDID_D3DDebugObjectName
@ -64,7 +64,7 @@ bool D3D11Device::HasSurface() const
return static_cast<bool>(m_swap_chain); return static_cast<bool>(m_swap_chain);
} }
bool D3D11Device::CreateDevice(const std::string_view& adapter, bool threaded_presentation, bool D3D11Device::CreateDevice(std::string_view adapter, bool threaded_presentation,
std::optional<bool> exclusive_fullscreen_control, FeatureMask disabled_features, std::optional<bool> exclusive_fullscreen_control, FeatureMask disabled_features,
Error* error) Error* error)
{ {
@ -943,7 +943,8 @@ void D3D11Device::UnmapUniformBuffer(u32 size)
} }
} }
void D3D11Device::SetRenderTargets(GPUTexture* const* rts, u32 num_rts, GPUTexture* ds, GPUPipeline::RenderPassFlag feedback_loop) void D3D11Device::SetRenderTargets(GPUTexture* const* rts, u32 num_rts, GPUTexture* ds,
GPUPipeline::RenderPassFlag feedback_loop)
{ {
ID3D11RenderTargetView* rtvs[MAX_RENDER_TARGETS]; ID3D11RenderTargetView* rtvs[MAX_RENDER_TARGETS];
DebugAssert(!feedback_loop); DebugAssert(!feedback_loop);

View file

@ -69,7 +69,7 @@ public:
void InvalidateRenderTarget(GPUTexture* t) override; void InvalidateRenderTarget(GPUTexture* t) override;
std::unique_ptr<GPUShader> CreateShaderFromBinary(GPUShaderStage stage, std::span<const u8> data) override; std::unique_ptr<GPUShader> CreateShaderFromBinary(GPUShaderStage stage, std::span<const u8> data) override;
std::unique_ptr<GPUShader> CreateShaderFromSource(GPUShaderStage stage, const std::string_view& source, std::unique_ptr<GPUShader> CreateShaderFromSource(GPUShaderStage stage, std::string_view source,
const char* entry_point, DynamicHeapArray<u8>* binary) override; const char* entry_point, DynamicHeapArray<u8>* binary) override;
std::unique_ptr<GPUPipeline> CreatePipeline(const GPUPipeline::GraphicsConfig& config) override; std::unique_ptr<GPUPipeline> CreatePipeline(const GPUPipeline::GraphicsConfig& config) override;
@ -111,7 +111,7 @@ public:
static AdapterAndModeList StaticGetAdapterAndModeList(); static AdapterAndModeList StaticGetAdapterAndModeList();
protected: protected:
bool CreateDevice(const std::string_view& adapter, bool threaded_presentation, bool CreateDevice(std::string_view adapter, bool threaded_presentation,
std::optional<bool> exclusive_fullscreen_control, FeatureMask disabled_features, std::optional<bool> exclusive_fullscreen_control, FeatureMask disabled_features,
Error* error) override; Error* error) override;
void DestroyDevice() override; void DestroyDevice() override;
@ -204,4 +204,4 @@ private:
float m_accumulated_gpu_time = 0.0f; float m_accumulated_gpu_time = 0.0f;
}; };
void SetD3DDebugObjectName(ID3D11DeviceChild* obj, const std::string_view& name); void SetD3DDebugObjectName(ID3D11DeviceChild* obj, std::string_view name);

View file

@ -46,7 +46,7 @@ ID3D11ComputeShader* D3D11Shader::GetComputeShader() const
return static_cast<ID3D11ComputeShader*>(m_shader.Get()); return static_cast<ID3D11ComputeShader*>(m_shader.Get());
} }
void D3D11Shader::SetDebugName(const std::string_view& name) void D3D11Shader::SetDebugName(std::string_view name)
{ {
SetD3DDebugObjectName(m_shader.Get(), name); SetD3DDebugObjectName(m_shader.Get(), name);
} }
@ -92,7 +92,7 @@ std::unique_ptr<GPUShader> D3D11Device::CreateShaderFromBinary(GPUShaderStage st
return std::unique_ptr<GPUShader>(new D3D11Shader(stage, std::move(shader), std::move(bytecode))); return std::unique_ptr<GPUShader>(new D3D11Shader(stage, std::move(shader), std::move(bytecode)));
} }
std::unique_ptr<GPUShader> D3D11Device::CreateShaderFromSource(GPUShaderStage stage, const std::string_view& source, std::unique_ptr<GPUShader> D3D11Device::CreateShaderFromSource(GPUShaderStage stage, std::string_view source,
const char* entry_point, const char* entry_point,
DynamicHeapArray<u8>* out_binary) DynamicHeapArray<u8>* out_binary)
{ {
@ -123,7 +123,7 @@ D3D11Pipeline::~D3D11Pipeline()
D3D11Device::GetInstance().UnbindPipeline(this); D3D11Device::GetInstance().UnbindPipeline(this);
} }
void D3D11Pipeline::SetDebugName(const std::string_view& name) void D3D11Pipeline::SetDebugName(std::string_view name)
{ {
// can't label this directly // can't label this directly
} }

View file

@ -30,7 +30,7 @@ public:
ALWAYS_INLINE const std::vector<u8>& GetBytecode() const { return m_bytecode; } ALWAYS_INLINE const std::vector<u8>& GetBytecode() const { return m_bytecode; }
void SetDebugName(const std::string_view& name) override; void SetDebugName(std::string_view name) override;
private: private:
D3D11Shader(GPUShaderStage stage, Microsoft::WRL::ComPtr<ID3D11DeviceChild> shader, std::vector<u8> bytecode); D3D11Shader(GPUShaderStage stage, Microsoft::WRL::ComPtr<ID3D11DeviceChild> shader, std::vector<u8> bytecode);
@ -49,7 +49,7 @@ class D3D11Pipeline final : public GPUPipeline
public: public:
~D3D11Pipeline() override; ~D3D11Pipeline() override;
void SetDebugName(const std::string_view& name) override; void SetDebugName(std::string_view name) override;
ALWAYS_INLINE ID3D11RasterizerState* GetRasterizerState() const { return m_rs.Get(); } ALWAYS_INLINE ID3D11RasterizerState* GetRasterizerState() const { return m_rs.Get(); }
ALWAYS_INLINE ID3D11DepthStencilState* GetDepthStencilState() const { return m_ds.Get(); } ALWAYS_INLINE ID3D11DepthStencilState* GetDepthStencilState() const { return m_ds.Get(); }

View file

@ -38,7 +38,7 @@ D3D11Sampler::D3D11Sampler(ComPtr<ID3D11SamplerState> ss) : m_ss(std::move(ss))
D3D11Sampler::~D3D11Sampler() = default; D3D11Sampler::~D3D11Sampler() = default;
void D3D11Sampler::SetDebugName(const std::string_view& name) void D3D11Sampler::SetDebugName(std::string_view name)
{ {
SetD3DDebugObjectName(m_ss.Get(), name); SetD3DDebugObjectName(m_ss.Get(), name);
} }
@ -209,7 +209,7 @@ void D3D11Texture::Unmap()
m_mapped_subresource = 0; m_mapped_subresource = 0;
} }
void D3D11Texture::SetDebugName(const std::string_view& name) void D3D11Texture::SetDebugName(std::string_view name)
{ {
SetD3DDebugObjectName(m_texture.Get(), name); SetD3DDebugObjectName(m_texture.Get(), name);
} }
@ -376,7 +376,7 @@ void D3D11TextureBuffer::Unmap(u32 used_elements)
m_buffer.Unmap(D3D11Device::GetD3DContext(), size); m_buffer.Unmap(D3D11Device::GetD3DContext(), size);
} }
void D3D11TextureBuffer::SetDebugName(const std::string_view& name) void D3D11TextureBuffer::SetDebugName(std::string_view name)
{ {
SetD3DDebugObjectName(m_buffer.GetD3DBuffer(), name); SetD3DDebugObjectName(m_buffer.GetD3DBuffer(), name);
} }

View file

@ -26,7 +26,7 @@ public:
ALWAYS_INLINE ID3D11SamplerState* GetSamplerState() const { return m_ss.Get(); } ALWAYS_INLINE ID3D11SamplerState* GetSamplerState() const { return m_ss.Get(); }
ALWAYS_INLINE ID3D11SamplerState* const* GetSamplerStateArray() const { return m_ss.GetAddressOf(); } ALWAYS_INLINE ID3D11SamplerState* const* GetSamplerStateArray() const { return m_ss.GetAddressOf(); }
void SetDebugName(const std::string_view& name) override; void SetDebugName(std::string_view name) override;
private: private:
D3D11Sampler(ComPtr<ID3D11SamplerState> ss); D3D11Sampler(ComPtr<ID3D11SamplerState> ss);
@ -85,7 +85,7 @@ public:
bool Map(void** map, u32* map_stride, u32 x, u32 y, u32 width, u32 height, u32 layer = 0, u32 level = 0) override; bool Map(void** map, u32* map_stride, u32 x, u32 y, u32 width, u32 height, u32 layer = 0, u32 level = 0) override;
void Unmap() override; void Unmap() override;
void SetDebugName(const std::string_view& name) override; void SetDebugName(std::string_view name) override;
private: private:
D3D11Texture(u32 width, u32 height, u32 layers, u32 levels, u32 samples, Type type, Format format, D3D11Texture(u32 width, u32 height, u32 layers, u32 levels, u32 samples, Type type, Format format,
@ -113,7 +113,7 @@ public:
void* Map(u32 required_elements) override; void* Map(u32 required_elements) override;
void Unmap(u32 used_elements) override; void Unmap(u32 used_elements) override;
void SetDebugName(const std::string_view& name) override; void SetDebugName(std::string_view name) override;
private: private:
D3D11StreamBuffer m_buffer; D3D11StreamBuffer m_buffer;

View file

@ -336,7 +336,7 @@ u32 D3D12::RootSignatureBuilder::AddDescriptorTable(D3D12_DESCRIPTOR_RANGE_TYPE
#ifdef _DEBUG #ifdef _DEBUG
void D3D12::SetObjectName(ID3D12Object* object, const std::string_view& name) void D3D12::SetObjectName(ID3D12Object* object, std::string_view name)
{ {
object->SetName(StringUtil::UTF8StringToWideString(name).c_str()); object->SetName(StringUtil::UTF8StringToWideString(name).c_str());
} }

View file

@ -126,10 +126,10 @@ private:
}; };
#ifdef _DEBUG #ifdef _DEBUG
void SetObjectName(ID3D12Object* object, const std::string_view& name); void SetObjectName(ID3D12Object* object, std::string_view name);
void SetObjectNameFormatted(ID3D12Object* object, const char* format, ...); void SetObjectNameFormatted(ID3D12Object* object, const char* format, ...);
#else #else
static inline void SetObjectName(ID3D12Object* object, const std::string_view& name) static inline void SetObjectName(ID3D12Object* object, std::string_view name)
{ {
} }
static inline void SetObjectNameFormatted(ID3D12Object* object, const char* format, ...) static inline void SetObjectNameFormatted(ID3D12Object* object, const char* format, ...)

View file

@ -117,7 +117,7 @@ D3D12Device::ComPtr<ID3D12RootSignature> D3D12Device::CreateRootSignature(const
return rs; return rs;
} }
bool D3D12Device::CreateDevice(const std::string_view& adapter, bool threaded_presentation, bool D3D12Device::CreateDevice(std::string_view adapter, bool threaded_presentation,
std::optional<bool> exclusive_fullscreen_control, FeatureMask disabled_features, std::optional<bool> exclusive_fullscreen_control, FeatureMask disabled_features,
Error* error) Error* error)
{ {

View file

@ -91,7 +91,7 @@ public:
void InvalidateRenderTarget(GPUTexture* t) override; void InvalidateRenderTarget(GPUTexture* t) override;
std::unique_ptr<GPUShader> CreateShaderFromBinary(GPUShaderStage stage, std::span<const u8> data) override; std::unique_ptr<GPUShader> CreateShaderFromBinary(GPUShaderStage stage, std::span<const u8> data) override;
std::unique_ptr<GPUShader> CreateShaderFromSource(GPUShaderStage stage, const std::string_view& source, std::unique_ptr<GPUShader> CreateShaderFromSource(GPUShaderStage stage, std::string_view source,
const char* entry_point, DynamicHeapArray<u8>* out_binary) override; const char* entry_point, DynamicHeapArray<u8>* out_binary) override;
std::unique_ptr<GPUPipeline> CreatePipeline(const GPUPipeline::GraphicsConfig& config) override; std::unique_ptr<GPUPipeline> CreatePipeline(const GPUPipeline::GraphicsConfig& config) override;
@ -180,7 +180,7 @@ public:
void UnbindTextureBuffer(D3D12TextureBuffer* buf); void UnbindTextureBuffer(D3D12TextureBuffer* buf);
protected: protected:
bool CreateDevice(const std::string_view& adapter, bool threaded_presentation, bool CreateDevice(std::string_view adapter, bool threaded_presentation,
std::optional<bool> exclusive_fullscreen_control, FeatureMask disabled_features, std::optional<bool> exclusive_fullscreen_control, FeatureMask disabled_features,
Error* error) override; Error* error) override;
void DestroyDevice() override; void DestroyDevice() override;

View file

@ -21,7 +21,7 @@ D3D12Shader::D3D12Shader(GPUShaderStage stage, Bytecode bytecode) : GPUShader(st
D3D12Shader::~D3D12Shader() = default; D3D12Shader::~D3D12Shader() = default;
void D3D12Shader::SetDebugName(const std::string_view& name) void D3D12Shader::SetDebugName(std::string_view name)
{ {
} }
@ -32,7 +32,7 @@ std::unique_ptr<GPUShader> D3D12Device::CreateShaderFromBinary(GPUShaderStage st
return std::unique_ptr<GPUShader>(new D3D12Shader(stage, std::move(bytecode))); return std::unique_ptr<GPUShader>(new D3D12Shader(stage, std::move(bytecode)));
} }
std::unique_ptr<GPUShader> D3D12Device::CreateShaderFromSource(GPUShaderStage stage, const std::string_view& source, std::unique_ptr<GPUShader> D3D12Device::CreateShaderFromSource(GPUShaderStage stage, std::string_view source,
const char* entry_point, const char* entry_point,
DynamicHeapArray<u8>* out_binary) DynamicHeapArray<u8>* out_binary)
{ {
@ -63,7 +63,7 @@ D3D12Pipeline::~D3D12Pipeline()
D3D12Device::GetInstance().DeferObjectDestruction(std::move(m_pipeline)); D3D12Device::GetInstance().DeferObjectDestruction(std::move(m_pipeline));
} }
void D3D12Pipeline::SetDebugName(const std::string_view& name) void D3D12Pipeline::SetDebugName(std::string_view name)
{ {
D3D12::SetObjectName(m_pipeline.Get(), name); D3D12::SetObjectName(m_pipeline.Get(), name);
} }

View file

@ -25,7 +25,7 @@ public:
ALWAYS_INLINE const u8* GetBytecodeData() const { return m_bytecode.data(); } ALWAYS_INLINE const u8* GetBytecodeData() const { return m_bytecode.data(); }
ALWAYS_INLINE u32 GetBytecodeSize() const { return static_cast<u32>(m_bytecode.size()); } ALWAYS_INLINE u32 GetBytecodeSize() const { return static_cast<u32>(m_bytecode.size()); }
void SetDebugName(const std::string_view& name) override; void SetDebugName(std::string_view name) override;
private: private:
D3D12Shader(GPUShaderStage stage, Bytecode bytecode); D3D12Shader(GPUShaderStage stage, Bytecode bytecode);
@ -48,7 +48,7 @@ public:
ALWAYS_INLINE const std::array<float, 4>& GetBlendConstantsF() const { return m_blend_constants_f; } ALWAYS_INLINE const std::array<float, 4>& GetBlendConstantsF() const { return m_blend_constants_f; }
ALWAYS_INLINE bool HasVertexStride() const { return (m_vertex_stride > 0); } ALWAYS_INLINE bool HasVertexStride() const { return (m_vertex_stride > 0); }
void SetDebugName(const std::string_view& name) override; void SetDebugName(std::string_view name) override;
static std::string GetPipelineName(const GraphicsConfig& config); static std::string GetPipelineName(const GraphicsConfig& config);

View file

@ -591,7 +591,7 @@ void D3D12Texture::ActuallyCommitClear(ID3D12GraphicsCommandList* cmdlist)
SetState(State::Dirty); SetState(State::Dirty);
} }
void D3D12Texture::SetDebugName(const std::string_view& name) void D3D12Texture::SetDebugName(std::string_view name)
{ {
D3D12::SetObjectName(m_resource.Get(), name); D3D12::SetObjectName(m_resource.Get(), name);
} }
@ -673,7 +673,7 @@ D3D12Sampler::~D3D12Sampler()
// Cleaned up by main class. // Cleaned up by main class.
} }
void D3D12Sampler::SetDebugName(const std::string_view& name) void D3D12Sampler::SetDebugName(std::string_view name)
{ {
} }
@ -813,7 +813,7 @@ void D3D12TextureBuffer::Unmap(u32 used_elements)
m_buffer.CommitMemory(size); m_buffer.CommitMemory(size);
} }
void D3D12TextureBuffer::SetDebugName(const std::string_view& name) void D3D12TextureBuffer::SetDebugName(std::string_view name)
{ {
D3D12::SetObjectName(m_buffer.GetBuffer(), name); D3D12::SetObjectName(m_buffer.GetBuffer(), name);
} }

View file

@ -42,7 +42,7 @@ public:
void Unmap() override; void Unmap() override;
void MakeReadyForSampling() override; void MakeReadyForSampling() override;
void SetDebugName(const std::string_view& name) override; void SetDebugName(std::string_view name) override;
void TransitionToState(D3D12_RESOURCE_STATES state); void TransitionToState(D3D12_RESOURCE_STATES state);
void CommitClear(); void CommitClear();
@ -115,7 +115,7 @@ public:
ALWAYS_INLINE const D3D12DescriptorHandle& GetDescriptor() const { return m_descriptor; } ALWAYS_INLINE const D3D12DescriptorHandle& GetDescriptor() const { return m_descriptor; }
void SetDebugName(const std::string_view& name) override; void SetDebugName(std::string_view name) override;
private: private:
D3D12Sampler(D3D12DescriptorHandle descriptor); D3D12Sampler(D3D12DescriptorHandle descriptor);
@ -140,7 +140,7 @@ public:
void* Map(u32 required_elements) override; void* Map(u32 required_elements) override;
void Unmap(u32 used_elements) override; void Unmap(u32 used_elements) override;
void SetDebugName(const std::string_view& name) override; void SetDebugName(std::string_view name) override;
private: private:
D3D12StreamBuffer m_buffer; D3D12StreamBuffer m_buffer;

View file

@ -134,7 +134,7 @@ std::vector<std::string> D3DCommon::GetAdapterNames(IDXGIFactory5* factory)
return adapter_names; return adapter_names;
} }
std::vector<std::string> D3DCommon::GetFullscreenModes(IDXGIFactory5* factory, const std::string_view& adapter_name) std::vector<std::string> D3DCommon::GetFullscreenModes(IDXGIFactory5* factory, std::string_view adapter_name)
{ {
std::vector<std::string> modes; std::vector<std::string> modes;
HRESULT hr; HRESULT hr;
@ -250,7 +250,7 @@ bool D3DCommon::GetRequestedExclusiveFullscreenModeDesc(IDXGIFactory5* factory,
return true; return true;
} }
Microsoft::WRL::ComPtr<IDXGIAdapter1> D3DCommon::GetAdapterByName(IDXGIFactory5* factory, const std::string_view& name) Microsoft::WRL::ComPtr<IDXGIAdapter1> D3DCommon::GetAdapterByName(IDXGIFactory5* factory, std::string_view name)
{ {
if (name.empty()) if (name.empty())
return {}; return {};
@ -296,8 +296,7 @@ Microsoft::WRL::ComPtr<IDXGIAdapter1> D3DCommon::GetFirstAdapter(IDXGIFactory5*
return adapter; return adapter;
} }
Microsoft::WRL::ComPtr<IDXGIAdapter1> D3DCommon::GetChosenOrFirstAdapter(IDXGIFactory5* factory, Microsoft::WRL::ComPtr<IDXGIAdapter1> D3DCommon::GetChosenOrFirstAdapter(IDXGIFactory5* factory, std::string_view name)
const std::string_view& name)
{ {
Microsoft::WRL::ComPtr<IDXGIAdapter1> adapter = GetAdapterByName(factory, name); Microsoft::WRL::ComPtr<IDXGIAdapter1> adapter = GetAdapterByName(factory, name);
if (!adapter) if (!adapter)
@ -374,7 +373,7 @@ std::string D3DCommon::GetDriverVersionFromLUID(const LUID& luid)
} }
std::optional<DynamicHeapArray<u8>> D3DCommon::CompileShader(D3D_FEATURE_LEVEL feature_level, bool debug_device, std::optional<DynamicHeapArray<u8>> D3DCommon::CompileShader(D3D_FEATURE_LEVEL feature_level, bool debug_device,
GPUShaderStage stage, const std::string_view& source, GPUShaderStage stage, std::string_view source,
const char* entry_point) const char* entry_point)
{ {
const char* target; const char* target;

View file

@ -38,7 +38,7 @@ Microsoft::WRL::ComPtr<IDXGIFactory5> CreateFactory(bool debug, Error* error);
std::vector<std::string> GetAdapterNames(IDXGIFactory5* factory); std::vector<std::string> GetAdapterNames(IDXGIFactory5* factory);
// returns a list of fullscreen modes for the specified adapter // returns a list of fullscreen modes for the specified adapter
std::vector<std::string> GetFullscreenModes(IDXGIFactory5* factory, const std::string_view& adapter_name); std::vector<std::string> GetFullscreenModes(IDXGIFactory5* factory, std::string_view adapter_name);
// returns the fullscreen mode to use for the specified dimensions // returns the fullscreen mode to use for the specified dimensions
bool GetRequestedExclusiveFullscreenModeDesc(IDXGIFactory5* factory, const RECT& window_rect, u32 width, u32 height, bool GetRequestedExclusiveFullscreenModeDesc(IDXGIFactory5* factory, const RECT& window_rect, u32 width, u32 height,
@ -46,13 +46,13 @@ bool GetRequestedExclusiveFullscreenModeDesc(IDXGIFactory5* factory, const RECT&
IDXGIOutput** output); IDXGIOutput** output);
// get an adapter based on name // get an adapter based on name
Microsoft::WRL::ComPtr<IDXGIAdapter1> GetAdapterByName(IDXGIFactory5* factory, const std::string_view& name); Microsoft::WRL::ComPtr<IDXGIAdapter1> GetAdapterByName(IDXGIFactory5* factory, std::string_view name);
// returns the first adapter in the system // returns the first adapter in the system
Microsoft::WRL::ComPtr<IDXGIAdapter1> GetFirstAdapter(IDXGIFactory5* factory); Microsoft::WRL::ComPtr<IDXGIAdapter1> GetFirstAdapter(IDXGIFactory5* factory);
// returns the adapter specified in the configuration, or the default // returns the adapter specified in the configuration, or the default
Microsoft::WRL::ComPtr<IDXGIAdapter1> GetChosenOrFirstAdapter(IDXGIFactory5* factory, const std::string_view& name); Microsoft::WRL::ComPtr<IDXGIAdapter1> GetChosenOrFirstAdapter(IDXGIFactory5* factory, std::string_view name);
// returns a utf-8 string of the specified adapter's name // returns a utf-8 string of the specified adapter's name
std::string GetAdapterName(IDXGIAdapter1* adapter); std::string GetAdapterName(IDXGIAdapter1* adapter);
@ -61,7 +61,7 @@ std::string GetAdapterName(IDXGIAdapter1* adapter);
std::string GetDriverVersionFromLUID(const LUID& luid); std::string GetDriverVersionFromLUID(const LUID& luid);
std::optional<DynamicHeapArray<u8>> CompileShader(D3D_FEATURE_LEVEL feature_level, bool debug_device, std::optional<DynamicHeapArray<u8>> CompileShader(D3D_FEATURE_LEVEL feature_level, bool debug_device,
GPUShaderStage stage, const std::string_view& source, GPUShaderStage stage, std::string_view source,
const char* entry_point); const char* entry_point);
struct DXGIFormatMapping struct DXGIFormatMapping

View file

@ -307,7 +307,7 @@ std::vector<InputBindingKey> DInputSource::EnumerateMotors()
return {}; return {};
} }
bool DInputSource::GetGenericBindingMapping(const std::string_view& device, GenericInputBindingMapping* mapping) bool DInputSource::GetGenericBindingMapping(std::string_view device, GenericInputBindingMapping* mapping)
{ {
return {}; return {};
} }
@ -323,8 +323,7 @@ void DInputSource::UpdateMotorState(InputBindingKey large_key, InputBindingKey s
// not supported // not supported
} }
std::optional<InputBindingKey> DInputSource::ParseKeyString(const std::string_view& device, std::optional<InputBindingKey> DInputSource::ParseKeyString(std::string_view device, std::string_view binding)
const std::string_view& binding)
{ {
if (!device.starts_with("DInput-") || binding.empty()) if (!device.starts_with("DInput-") || binding.empty())
return std::nullopt; return std::nullopt;

View file

@ -41,13 +41,12 @@ public:
void PollEvents() override; void PollEvents() override;
std::vector<std::pair<std::string, std::string>> EnumerateDevices() override; std::vector<std::pair<std::string, std::string>> EnumerateDevices() override;
std::vector<InputBindingKey> EnumerateMotors() override; std::vector<InputBindingKey> EnumerateMotors() override;
bool GetGenericBindingMapping(const std::string_view& device, GenericInputBindingMapping* mapping) override; bool GetGenericBindingMapping(std::string_view device, GenericInputBindingMapping* mapping) override;
void UpdateMotorState(InputBindingKey key, float intensity) override; void UpdateMotorState(InputBindingKey key, float intensity) override;
void UpdateMotorState(InputBindingKey large_key, InputBindingKey small_key, float large_intensity, void UpdateMotorState(InputBindingKey large_key, InputBindingKey small_key, float large_intensity,
float small_intensity) override; float small_intensity) override;
std::optional<InputBindingKey> ParseKeyString(const std::string_view& device, std::optional<InputBindingKey> ParseKeyString(std::string_view device, std::string_view binding) override;
const std::string_view& binding) override;
TinyString ConvertKeyToString(InputBindingKey key) override; TinyString ConvertKeyToString(InputBindingKey key) override;
TinyString ConvertKeyToIcon(InputBindingKey key) override; TinyString ConvertKeyToIcon(InputBindingKey key) override;

View file

@ -270,8 +270,8 @@ bool GPUDevice::IsSameRenderAPI(RenderAPI lhs, RenderAPI rhs)
(rhs == RenderAPI::OpenGL || rhs == RenderAPI::OpenGLES))); (rhs == RenderAPI::OpenGL || rhs == RenderAPI::OpenGLES)));
} }
bool GPUDevice::Create(const std::string_view& adapter, const std::string_view& shader_cache_path, bool GPUDevice::Create(std::string_view adapter, std::string_view shader_cache_path, u32 shader_cache_version,
u32 shader_cache_version, bool debug_device, bool vsync, bool threaded_presentation, bool debug_device, bool vsync, bool threaded_presentation,
std::optional<bool> exclusive_fullscreen_control, FeatureMask disabled_features, Error* error) std::optional<bool> exclusive_fullscreen_control, FeatureMask disabled_features, Error* error)
{ {
m_vsync_enabled = vsync; m_vsync_enabled = vsync;
@ -318,7 +318,7 @@ bool GPUDevice::SupportsExclusiveFullscreen() const
return false; return false;
} }
void GPUDevice::OpenShaderCache(const std::string_view& base_path, u32 version) void GPUDevice::OpenShaderCache(std::string_view base_path, u32 version)
{ {
if (m_features.shader_cache && !base_path.empty()) if (m_features.shader_cache && !base_path.empty())
{ {
@ -388,7 +388,7 @@ void GPUDevice::CloseShaderCache()
} }
} }
std::string GPUDevice::GetShaderCacheBaseName(const std::string_view& type) const std::string GPUDevice::GetShaderCacheBaseName(std::string_view type) const
{ {
const std::string_view debug_suffix = m_debug_device ? "_debug" : ""; const std::string_view debug_suffix = m_debug_device ? "_debug" : "";
@ -641,7 +641,7 @@ void GPUDevice::InvalidateRenderTarget(GPUTexture* t)
t->SetState(GPUTexture::State::Invalidated); t->SetState(GPUTexture::State::Invalidated);
} }
std::unique_ptr<GPUShader> GPUDevice::CreateShader(GPUShaderStage stage, const std::string_view& source, std::unique_ptr<GPUShader> GPUDevice::CreateShader(GPUShaderStage stage, std::string_view source,
const char* entry_point /* = "main" */) const char* entry_point /* = "main" */)
{ {
std::unique_ptr<GPUShader> shader; std::unique_ptr<GPUShader> shader;
@ -730,7 +730,7 @@ std::string GPUDevice::GetFullscreenModeString(u32 width, u32 height, float refr
return fmt::format("{} x {} @ {} hz", width, height, refresh_rate); return fmt::format("{} x {} @ {} hz", width, height, refresh_rate);
} }
std::string GPUDevice::GetShaderDumpPath(const std::string_view& name) std::string GPUDevice::GetShaderDumpPath(std::string_view name)
{ {
return Path::Combine(EmuFolders::Dumps, name); return Path::Combine(EmuFolders::Dumps, name);
} }

View file

@ -88,7 +88,7 @@ public:
GPUSampler(); GPUSampler();
virtual ~GPUSampler(); virtual ~GPUSampler();
virtual void SetDebugName(const std::string_view& name) = 0; virtual void SetDebugName(std::string_view name) = 0;
static Config GetNearestConfig(); static Config GetNearestConfig();
static Config GetLinearConfig(); static Config GetLinearConfig();
@ -114,7 +114,7 @@ public:
ALWAYS_INLINE GPUShaderStage GetStage() const { return m_stage; } ALWAYS_INLINE GPUShaderStage GetStage() const { return m_stage; }
virtual void SetDebugName(const std::string_view& name) = 0; virtual void SetDebugName(std::string_view name) = 0;
protected: protected:
GPUShaderStage m_stage; GPUShaderStage m_stage;
@ -397,7 +397,7 @@ public:
GPUPipeline(); GPUPipeline();
virtual ~GPUPipeline(); virtual ~GPUPipeline();
virtual void SetDebugName(const std::string_view& name) = 0; virtual void SetDebugName(std::string_view name) = 0;
}; };
class GPUTextureBuffer class GPUTextureBuffer
@ -423,7 +423,7 @@ public:
virtual void* Map(u32 required_elements) = 0; virtual void* Map(u32 required_elements) = 0;
virtual void Unmap(u32 used_elements) = 0; virtual void Unmap(u32 used_elements) = 0;
virtual void SetDebugName(const std::string_view& name) = 0; virtual void SetDebugName(std::string_view name) = 0;
protected: protected:
Format m_format; Format m_format;
@ -527,7 +527,7 @@ public:
static std::string GetFullscreenModeString(u32 width, u32 height, float refresh_rate); static std::string GetFullscreenModeString(u32 width, u32 height, float refresh_rate);
/// Returns the directory bad shaders are saved to. /// Returns the directory bad shaders are saved to.
static std::string GetShaderDumpPath(const std::string_view& name); static std::string GetShaderDumpPath(std::string_view name);
/// Dumps out a shader that failed compilation. /// Dumps out a shader that failed compilation.
static void DumpBadShader(std::string_view code, std::string_view errors); static void DumpBadShader(std::string_view code, std::string_view errors);
@ -572,9 +572,9 @@ public:
virtual RenderAPI GetRenderAPI() const = 0; virtual RenderAPI GetRenderAPI() const = 0;
bool Create(const std::string_view& adapter, const std::string_view& shader_cache_path, u32 shader_cache_version, bool Create(std::string_view adapter, std::string_view shader_cache_path, u32 shader_cache_version, bool debug_device,
bool debug_device, bool vsync, bool threaded_presentation, bool vsync, bool threaded_presentation, std::optional<bool> exclusive_fullscreen_control,
std::optional<bool> exclusive_fullscreen_control, FeatureMask disabled_features, Error* error); FeatureMask disabled_features, Error* error);
void Destroy(); void Destroy();
virtual bool HasSurface() const = 0; virtual bool HasSurface() const = 0;
@ -622,7 +622,7 @@ public:
virtual void InvalidateRenderTarget(GPUTexture* t); virtual void InvalidateRenderTarget(GPUTexture* t);
/// Shader abstraction. /// Shader abstraction.
std::unique_ptr<GPUShader> CreateShader(GPUShaderStage stage, const std::string_view& source, std::unique_ptr<GPUShader> CreateShader(GPUShaderStage stage, std::string_view source,
const char* entry_point = "main"); const char* entry_point = "main");
virtual std::unique_ptr<GPUPipeline> CreatePipeline(const GPUPipeline::GraphicsConfig& config) = 0; virtual std::unique_ptr<GPUPipeline> CreatePipeline(const GPUPipeline::GraphicsConfig& config) = 0;
@ -701,17 +701,17 @@ public:
static void ResetStatistics(); static void ResetStatistics();
protected: protected:
virtual bool CreateDevice(const std::string_view& adapter, bool threaded_presentation, virtual bool CreateDevice(std::string_view adapter, bool threaded_presentation,
std::optional<bool> exclusive_fullscreen_control, FeatureMask disabled_features, std::optional<bool> exclusive_fullscreen_control, FeatureMask disabled_features,
Error* error) = 0; Error* error) = 0;
virtual void DestroyDevice() = 0; virtual void DestroyDevice() = 0;
std::string GetShaderCacheBaseName(const std::string_view& type) const; std::string GetShaderCacheBaseName(std::string_view type) const;
virtual bool ReadPipelineCache(const std::string& filename); virtual bool ReadPipelineCache(const std::string& filename);
virtual bool GetPipelineCacheData(DynamicHeapArray<u8>* data); virtual bool GetPipelineCacheData(DynamicHeapArray<u8>* data);
virtual std::unique_ptr<GPUShader> CreateShaderFromBinary(GPUShaderStage stage, std::span<const u8> data) = 0; virtual std::unique_ptr<GPUShader> CreateShaderFromBinary(GPUShaderStage stage, std::span<const u8> data) = 0;
virtual std::unique_ptr<GPUShader> CreateShaderFromSource(GPUShaderStage stage, const std::string_view& source, virtual std::unique_ptr<GPUShader> CreateShaderFromSource(GPUShaderStage stage, std::string_view source,
const char* entry_point, const char* entry_point,
DynamicHeapArray<u8>* out_binary) = 0; DynamicHeapArray<u8>* out_binary) = 0;
@ -764,7 +764,7 @@ private:
using TexturePool = std::deque<TexturePoolEntry>; using TexturePool = std::deque<TexturePoolEntry>;
void OpenShaderCache(const std::string_view& base_path, u32 version); void OpenShaderCache(std::string_view base_path, u32 version);
void CloseShaderCache(); void CloseShaderCache();
bool CreateResources(); bool CreateResources();
void DestroyResources(); void DestroyResources();

View file

@ -56,7 +56,7 @@ std::size_t GPUShaderCache::CacheIndexEntryHash::operator()(const CacheIndexKey&
return h; return h;
} }
bool GPUShaderCache::Open(const std::string_view& base_filename, u32 version) bool GPUShaderCache::Open(std::string_view base_filename, u32 version)
{ {
m_base_filename = base_filename; m_base_filename = base_filename;
m_version = version; m_version = version;
@ -214,8 +214,8 @@ bool GPUShaderCache::ReadExisting(const std::string& index_filename, const std::
return true; return true;
} }
GPUShaderCache::CacheIndexKey GPUShaderCache::GetCacheKey(GPUShaderStage stage, const std::string_view& shader_code, GPUShaderCache::CacheIndexKey GPUShaderCache::GetCacheKey(GPUShaderStage stage, std::string_view shader_code,
const std::string_view& entry_point) std::string_view entry_point)
{ {
union union
{ {

View file

@ -46,12 +46,11 @@ public:
bool IsOpen() const { return (m_index_file != nullptr); } bool IsOpen() const { return (m_index_file != nullptr); }
bool Open(const std::string_view& base_filename, u32 version); bool Open(std::string_view base_filename, u32 version);
bool Create(); bool Create();
void Close(); void Close();
static CacheIndexKey GetCacheKey(GPUShaderStage stage, const std::string_view& shader_code, static CacheIndexKey GetCacheKey(GPUShaderStage stage, std::string_view shader_code, std::string_view entry_point);
const std::string_view& entry_point);
bool Lookup(const CacheIndexKey& key, ShaderBinary* binary); bool Lookup(const CacheIndexKey& key, ShaderBinary* binary);
bool Insert(const CacheIndexKey& key, const void* data, u32 data_size); bool Insert(const CacheIndexKey& key, const void* data, u32 data_size);

View file

@ -156,7 +156,7 @@ public:
// Instructs the backend that we're finished rendering to this texture. It may transition it to a new layout. // Instructs the backend that we're finished rendering to this texture. It may transition it to a new layout.
virtual void MakeReadyForSampling(); virtual void MakeReadyForSampling();
virtual void SetDebugName(const std::string_view& name) = 0; virtual void SetDebugName(std::string_view name) = 0;
protected: protected:
GPUTexture(u16 width, u16 height, u8 layers, u8 levels, u8 samples, Type type, Format format); GPUTexture(u16 width, u16 height, u8 layers, u8 levels, u8 samples, Type type, Format format);

View file

@ -14,8 +14,7 @@
Log_SetChannel(Host); Log_SetChannel(Host);
namespace Host { namespace Host {
static std::pair<const char*, u32> LookupTranslationString(const std::string_view& context, static std::pair<const char*, u32> LookupTranslationString(std::string_view context, std::string_view msg);
const std::string_view& msg);
static constexpr u32 TRANSLATION_STRING_CACHE_SIZE = 4 * 1024 * 1024; static constexpr u32 TRANSLATION_STRING_CACHE_SIZE = 4 * 1024 * 1024;
using TranslationStringMap = PreferUnorderedStringMap<std::pair<u32, u32>>; using TranslationStringMap = PreferUnorderedStringMap<std::pair<u32, u32>>;
@ -26,7 +25,7 @@ static std::vector<char> s_translation_string_cache;
static u32 s_translation_string_cache_pos; static u32 s_translation_string_cache_pos;
} // namespace Host } // namespace Host
std::pair<const char*, u32> Host::LookupTranslationString(const std::string_view& context, const std::string_view& msg) std::pair<const char*, u32> Host::LookupTranslationString(std::string_view context, std::string_view msg)
{ {
// TODO: TranslatableString, compile-time hashing. // TODO: TranslatableString, compile-time hashing.
@ -103,18 +102,18 @@ add_string:
return ret; return ret;
} }
const char* Host::TranslateToCString(const std::string_view& context, const std::string_view& msg) const char* Host::TranslateToCString(std::string_view context, std::string_view msg)
{ {
return LookupTranslationString(context, msg).first; return LookupTranslationString(context, msg).first;
} }
std::string_view Host::TranslateToStringView(const std::string_view& context, const std::string_view& msg) std::string_view Host::TranslateToStringView(std::string_view context, std::string_view msg)
{ {
const auto mp = LookupTranslationString(context, msg); const auto mp = LookupTranslationString(context, msg);
return std::string_view(mp.first, mp.second); return std::string_view(mp.first, mp.second);
} }
std::string Host::TranslateToString(const std::string_view& context, const std::string_view& msg) std::string Host::TranslateToString(std::string_view context, std::string_view msg)
{ {
return std::string(TranslateToStringView(context, msg)); return std::string(TranslateToStringView(context, msg));
} }
@ -127,7 +126,7 @@ void Host::ClearTranslationCache()
s_translation_string_mutex.unlock(); s_translation_string_mutex.unlock();
} }
void Host::ReportFormattedErrorAsync(const std::string_view& title, const char* format, ...) void Host::ReportFormattedErrorAsync(std::string_view title, const char* format, ...)
{ {
std::va_list ap; std::va_list ap;
va_start(ap, format); va_start(ap, format);
@ -136,7 +135,7 @@ void Host::ReportFormattedErrorAsync(const std::string_view& title, const char*
ReportErrorAsync(title, message); ReportErrorAsync(title, message);
} }
bool Host::ConfirmFormattedMessage(const std::string_view& title, const char* format, ...) bool Host::ConfirmFormattedMessage(std::string_view title, const char* format, ...)
{ {
std::va_list ap; std::va_list ap;
va_start(ap, format); va_start(ap, format);

View file

@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2019-2023 Connor McLaughlin <stenzek@gmail.com> // SPDX-FileCopyrightText: 2019-2024 Connor McLaughlin <stenzek@gmail.com>
// SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0)
#pragma once #pragma once
@ -27,45 +27,44 @@ std::optional<std::time_t> GetResourceFileTimestamp(std::string_view filename, b
/// Reports a fatal error on the main thread. This does not assume that the main window exists, /// Reports a fatal error on the main thread. This does not assume that the main window exists,
/// unlike ReportErrorAsync(), and will exit the application after the popup is closed. /// unlike ReportErrorAsync(), and will exit the application after the popup is closed.
void ReportFatalError(const std::string_view& title, const std::string_view& message); void ReportFatalError(std::string_view title, std::string_view message);
/// Displays an asynchronous error on the UI thread, i.e. doesn't block the caller. /// Displays an asynchronous error on the UI thread, i.e. doesn't block the caller.
void ReportErrorAsync(const std::string_view& title, const std::string_view& message); void ReportErrorAsync(std::string_view title, std::string_view message);
void ReportFormattedErrorAsync(const std::string_view& title, const char* format, ...); void ReportFormattedErrorAsync(std::string_view title, const char* format, ...);
/// Displays a synchronous confirmation on the UI thread, i.e. blocks the caller. /// Displays a synchronous confirmation on the UI thread, i.e. blocks the caller.
bool ConfirmMessage(const std::string_view& title, const std::string_view& message); bool ConfirmMessage(std::string_view title, std::string_view message);
bool ConfirmFormattedMessage(const std::string_view& title, const char* format, ...); bool ConfirmFormattedMessage(std::string_view title, const char* format, ...);
/// Returns the user agent to use for HTTP requests. /// Returns the user agent to use for HTTP requests.
std::string GetHTTPUserAgent(); std::string GetHTTPUserAgent();
/// Opens a URL, using the default application. /// Opens a URL, using the default application.
void OpenURL(const std::string_view& url); void OpenURL(std::string_view url);
/// Copies the provided text to the host's clipboard, if present. /// Copies the provided text to the host's clipboard, if present.
bool CopyTextToClipboard(const std::string_view& text); bool CopyTextToClipboard(std::string_view text);
/// Returns a localized version of the specified string within the specified context. /// Returns a localized version of the specified string within the specified context.
/// The pointer is guaranteed to be valid until the next language change. /// The pointer is guaranteed to be valid until the next language change.
const char* TranslateToCString(const std::string_view& context, const std::string_view& msg); const char* TranslateToCString(std::string_view context, std::string_view msg);
/// Returns a localized version of the specified string within the specified context. /// Returns a localized version of the specified string within the specified context.
/// The view is guaranteed to be valid until the next language change. /// The view is guaranteed to be valid until the next language change.
/// NOTE: When passing this to fmt, positional arguments should be used in the base string, as /// NOTE: When passing this to fmt, positional arguments should be used in the base string, as
/// not all locales follow the same word ordering. /// not all locales follow the same word ordering.
std::string_view TranslateToStringView(const std::string_view& context, const std::string_view& msg); std::string_view TranslateToStringView(std::string_view context, std::string_view msg);
/// Returns a localized version of the specified string within the specified context. /// Returns a localized version of the specified string within the specified context.
std::string TranslateToString(const std::string_view& context, const std::string_view& msg); std::string TranslateToString(std::string_view context, std::string_view msg);
/// Clears the translation cache. All previously used strings should be considered invalid. /// Clears the translation cache. All previously used strings should be considered invalid.
void ClearTranslationCache(); void ClearTranslationCache();
namespace Internal { namespace Internal {
/// Implementation to retrieve a translated string. /// Implementation to retrieve a translated string.
s32 GetTranslatedStringImpl(const std::string_view& context, const std::string_view& msg, char* tbuf, s32 GetTranslatedStringImpl(std::string_view context, std::string_view msg, char* tbuf, size_t tbuf_space);
size_t tbuf_space);
} // namespace Internal } // namespace Internal
} // namespace Host } // namespace Host

View file

@ -27,26 +27,26 @@ Log_SetChannel(Image);
static bool PNGBufferLoader(RGBA8Image* image, const void* buffer, size_t buffer_size); static bool PNGBufferLoader(RGBA8Image* image, const void* buffer, size_t buffer_size);
static bool PNGBufferSaver(const RGBA8Image& image, std::vector<u8>* buffer, u8 quality); static bool PNGBufferSaver(const RGBA8Image& image, std::vector<u8>* buffer, u8 quality);
static bool PNGFileLoader(RGBA8Image* image, const char* filename, std::FILE* fp); static bool PNGFileLoader(RGBA8Image* image, std::string_view filename, std::FILE* fp);
static bool PNGFileSaver(const RGBA8Image& image, const char* filename, std::FILE* fp, u8 quality); static bool PNGFileSaver(const RGBA8Image& image, std::string_view filename, std::FILE* fp, u8 quality);
static bool JPEGBufferLoader(RGBA8Image* image, const void* buffer, size_t buffer_size); static bool JPEGBufferLoader(RGBA8Image* image, const void* buffer, size_t buffer_size);
static bool JPEGBufferSaver(const RGBA8Image& image, std::vector<u8>* buffer, u8 quality); static bool JPEGBufferSaver(const RGBA8Image& image, std::vector<u8>* buffer, u8 quality);
static bool JPEGFileLoader(RGBA8Image* image, const char* filename, std::FILE* fp); static bool JPEGFileLoader(RGBA8Image* image, std::string_view filename, std::FILE* fp);
static bool JPEGFileSaver(const RGBA8Image& image, const char* filename, std::FILE* fp, u8 quality); static bool JPEGFileSaver(const RGBA8Image& image, std::string_view filename, std::FILE* fp, u8 quality);
static bool WebPBufferLoader(RGBA8Image* image, const void* buffer, size_t buffer_size); static bool WebPBufferLoader(RGBA8Image* image, const void* buffer, size_t buffer_size);
static bool WebPBufferSaver(const RGBA8Image& image, std::vector<u8>* buffer, u8 quality); static bool WebPBufferSaver(const RGBA8Image& image, std::vector<u8>* buffer, u8 quality);
static bool WebPFileLoader(RGBA8Image* image, const char* filename, std::FILE* fp); static bool WebPFileLoader(RGBA8Image* image, std::string_view filename, std::FILE* fp);
static bool WebPFileSaver(const RGBA8Image& image, const char* filename, std::FILE* fp, u8 quality); static bool WebPFileSaver(const RGBA8Image& image, std::string_view filename, std::FILE* fp, u8 quality);
struct FormatHandler struct FormatHandler
{ {
const char* extension; const char* extension;
bool (*buffer_loader)(RGBA8Image*, const void*, size_t); bool (*buffer_loader)(RGBA8Image*, const void*, size_t);
bool (*buffer_saver)(const RGBA8Image&, std::vector<u8>*, u8); bool (*buffer_saver)(const RGBA8Image&, std::vector<u8>*, u8);
bool (*file_loader)(RGBA8Image*, const char*, std::FILE*); bool (*file_loader)(RGBA8Image*, std::string_view, std::FILE*);
bool (*file_saver)(const RGBA8Image&, const char*, std::FILE*, u8); bool (*file_saver)(const RGBA8Image&, std::string_view, std::FILE*, u8);
}; };
static constexpr FormatHandler s_format_handlers[] = { static constexpr FormatHandler s_format_handlers[] = {
@ -56,7 +56,7 @@ static constexpr FormatHandler s_format_handlers[] = {
{"webp", WebPBufferLoader, WebPBufferSaver, WebPFileLoader, WebPFileSaver}, {"webp", WebPBufferLoader, WebPBufferSaver, WebPFileLoader, WebPFileSaver},
}; };
static const FormatHandler* GetFormatHandler(const std::string_view& extension) static const FormatHandler* GetFormatHandler(std::string_view extension)
{ {
for (const FormatHandler& handler : s_format_handlers) for (const FormatHandler& handler : s_format_handlers)
{ {
@ -125,39 +125,39 @@ bool RGBA8Image::SaveToFile(const char* filename, u8 quality) const
return false; return false;
} }
bool RGBA8Image::LoadFromFile(const char* filename, std::FILE* fp) bool RGBA8Image::LoadFromFile(std::string_view filename, std::FILE* fp)
{ {
const std::string_view extension(Path::GetExtension(filename)); const std::string_view extension(Path::GetExtension(filename));
const FormatHandler* handler = GetFormatHandler(extension); const FormatHandler* handler = GetFormatHandler(extension);
if (!handler || !handler->file_loader) if (!handler || !handler->file_loader)
{ {
Log_ErrorPrintf("Unknown extension '%.*s'", static_cast<int>(extension.size()), extension.data()); Log_ErrorFmt("Unknown extension '{}'", extension);
return false; return false;
} }
return handler->file_loader(this, filename, fp); return handler->file_loader(this, filename, fp);
} }
bool RGBA8Image::LoadFromBuffer(const char* filename, const void* buffer, size_t buffer_size) bool RGBA8Image::LoadFromBuffer(std::string_view filename, const void* buffer, size_t buffer_size)
{ {
const std::string_view extension(Path::GetExtension(filename)); const std::string_view extension(Path::GetExtension(filename));
const FormatHandler* handler = GetFormatHandler(extension); const FormatHandler* handler = GetFormatHandler(extension);
if (!handler || !handler->buffer_loader) if (!handler || !handler->buffer_loader)
{ {
Log_ErrorPrintf("Unknown extension '%.*s'", static_cast<int>(extension.size()), extension.data()); Log_ErrorFmt("Unknown extension '{}'", extension);
return false; return false;
} }
return handler->buffer_loader(this, buffer, buffer_size); return handler->buffer_loader(this, buffer, buffer_size);
} }
bool RGBA8Image::SaveToFile(const char* filename, std::FILE* fp, u8 quality) const bool RGBA8Image::SaveToFile(std::string_view filename, std::FILE* fp, u8 quality) const
{ {
const std::string_view extension(Path::GetExtension(filename)); const std::string_view extension(Path::GetExtension(filename));
const FormatHandler* handler = GetFormatHandler(extension); const FormatHandler* handler = GetFormatHandler(extension);
if (!handler || !handler->file_saver) if (!handler || !handler->file_saver)
{ {
Log_ErrorPrintf("Unknown extension '%.*s'", static_cast<int>(extension.size()), extension.data()); Log_ErrorFmt("Unknown extension '{}'", extension);
return false; return false;
} }
@ -167,7 +167,7 @@ bool RGBA8Image::SaveToFile(const char* filename, std::FILE* fp, u8 quality) con
return (std::fflush(fp) == 0); return (std::fflush(fp) == 0);
} }
std::optional<std::vector<u8>> RGBA8Image::SaveToBuffer(const char* filename, u8 quality) const std::optional<std::vector<u8>> RGBA8Image::SaveToBuffer(std::string_view filename, u8 quality) const
{ {
std::optional<std::vector<u8>> ret; std::optional<std::vector<u8>> ret;
@ -175,7 +175,7 @@ std::optional<std::vector<u8>> RGBA8Image::SaveToBuffer(const char* filename, u8
const FormatHandler* handler = GetFormatHandler(extension); const FormatHandler* handler = GetFormatHandler(extension);
if (!handler || !handler->file_saver) if (!handler || !handler->file_saver)
{ {
Log_ErrorPrintf("Unknown extension '%.*s'", static_cast<int>(extension.size()), extension.data()); Log_ErrorFmt("Unknown extension '{}'", extension);
return ret; return ret;
} }
@ -271,7 +271,7 @@ static bool PNGCommonLoader(RGBA8Image* image, png_structp png_ptr, png_infop in
return true; return true;
} }
bool PNGFileLoader(RGBA8Image* image, const char* filename, std::FILE* fp) bool PNGFileLoader(RGBA8Image* image, std::string_view filename, std::FILE* fp)
{ {
png_structp png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, nullptr, nullptr, nullptr); png_structp png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, nullptr, nullptr, nullptr);
if (!png_ptr) if (!png_ptr)
@ -356,7 +356,7 @@ static void PNGSaveCommon(const RGBA8Image& image, png_structp png_ptr, png_info
png_write_end(png_ptr, nullptr); png_write_end(png_ptr, nullptr);
} }
bool PNGFileSaver(const RGBA8Image& image, const char* filename, std::FILE* fp, u8 quality) bool PNGFileSaver(const RGBA8Image& image, std::string_view filename, std::FILE* fp, u8 quality)
{ {
png_structp png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, nullptr, nullptr, nullptr); png_structp png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, nullptr, nullptr, nullptr);
png_infop info_ptr = nullptr; png_infop info_ptr = nullptr;
@ -521,7 +521,7 @@ bool JPEGBufferLoader(RGBA8Image* image, const void* buffer, size_t buffer_size)
}); });
} }
bool JPEGFileLoader(RGBA8Image* image, const char* filename, std::FILE* fp) bool JPEGFileLoader(RGBA8Image* image, std::string_view filename, std::FILE* fp)
{ {
static constexpr u32 BUFFER_SIZE = 16384; static constexpr u32 BUFFER_SIZE = 16384;
@ -671,7 +671,7 @@ bool JPEGBufferSaver(const RGBA8Image& image, std::vector<u8>* buffer, u8 qualit
return WrapJPEGCompress(image, quality, [&cb](jpeg_compress_struct& info) { info.dest = &cb.mgr; }); return WrapJPEGCompress(image, quality, [&cb](jpeg_compress_struct& info) { info.dest = &cb.mgr; });
} }
bool JPEGFileSaver(const RGBA8Image& image, const char* filename, std::FILE* fp, u8 quality) bool JPEGFileSaver(const RGBA8Image& image, std::string_view filename, std::FILE* fp, u8 quality)
{ {
static constexpr u32 BUFFER_SIZE = 16384; static constexpr u32 BUFFER_SIZE = 16384;
@ -755,7 +755,7 @@ bool WebPBufferSaver(const RGBA8Image& image, std::vector<u8>* buffer, u8 qualit
return true; return true;
} }
bool WebPFileLoader(RGBA8Image* image, const char* filename, std::FILE* fp) bool WebPFileLoader(RGBA8Image* image, std::string_view filename, std::FILE* fp)
{ {
std::optional<std::vector<u8>> data = FileSystem::ReadBinaryFile(fp); std::optional<std::vector<u8>> data = FileSystem::ReadBinaryFile(fp);
if (!data.has_value()) if (!data.has_value())
@ -764,7 +764,7 @@ bool WebPFileLoader(RGBA8Image* image, const char* filename, std::FILE* fp)
return WebPBufferLoader(image, data->data(), data->size()); return WebPBufferLoader(image, data->data(), data->size());
} }
bool WebPFileSaver(const RGBA8Image& image, const char* filename, std::FILE* fp, u8 quality) bool WebPFileSaver(const RGBA8Image& image, std::string_view filename, std::FILE* fp, u8 quality)
{ {
std::vector<u8> buffer; std::vector<u8> buffer;
if (!WebPBufferSaver(image, &buffer, quality)) if (!WebPBufferSaver(image, &buffer, quality))

View file

@ -10,6 +10,7 @@
#include <cstdio> #include <cstdio>
#include <cstring> #include <cstring>
#include <optional> #include <optional>
#include <string_view>
#include <vector> #include <vector>
template<typename PixelType> template<typename PixelType>
@ -127,10 +128,10 @@ public:
RGBA8Image& operator=(RGBA8Image&& move); RGBA8Image& operator=(RGBA8Image&& move);
bool LoadFromFile(const char* filename); bool LoadFromFile(const char* filename);
bool LoadFromFile(const char* filename, std::FILE* fp); bool LoadFromFile(std::string_view filename, std::FILE* fp);
bool LoadFromBuffer(const char* filename, const void* buffer, size_t buffer_size); bool LoadFromBuffer(std::string_view filename, const void* buffer, size_t buffer_size);
bool SaveToFile(const char* filename, u8 quality = DEFAULT_SAVE_QUALITY) const; bool SaveToFile(const char* filename, u8 quality = DEFAULT_SAVE_QUALITY) const;
bool SaveToFile(const char* filename, std::FILE* fp, u8 quality = DEFAULT_SAVE_QUALITY) const; bool SaveToFile(std::string_view filename, std::FILE* fp, u8 quality = DEFAULT_SAVE_QUALITY) const;
std::optional<std::vector<u8>> SaveToBuffer(const char* filename, u8 quality = DEFAULT_SAVE_QUALITY) const; std::optional<std::vector<u8>> SaveToBuffer(std::string_view filename, u8 quality = DEFAULT_SAVE_QUALITY) const;
}; };

View file

@ -43,8 +43,8 @@ using MessageDialogCallbackVariant = std::variant<InfoMessageDialogCallback, Con
static constexpr float MENU_BACKGROUND_ANIMATION_TIME = 0.5f; static constexpr float MENU_BACKGROUND_ANIMATION_TIME = 0.5f;
static std::optional<RGBA8Image> LoadTextureImage(const char* path); static std::optional<RGBA8Image> LoadTextureImage(std::string_view path);
static std::shared_ptr<GPUTexture> UploadTexture(const char* path, const RGBA8Image& image); static std::shared_ptr<GPUTexture> UploadTexture(std::string_view path, const RGBA8Image& image);
static void TextureLoaderThread(); static void TextureLoaderThread();
static void DrawFileSelector(); static void DrawFileSelector();
@ -282,17 +282,18 @@ const std::shared_ptr<GPUTexture>& ImGuiFullscreen::GetPlaceholderTexture()
return s_placeholder_texture; return s_placeholder_texture;
} }
std::optional<RGBA8Image> ImGuiFullscreen::LoadTextureImage(const char* path) std::optional<RGBA8Image> ImGuiFullscreen::LoadTextureImage(std::string_view path)
{ {
std::optional<RGBA8Image> image; std::optional<RGBA8Image> image;
if (Path::IsAbsolute(path)) if (Path::IsAbsolute(path))
{ {
Error error; Error error;
auto fp = FileSystem::OpenManagedCFile(path, "rb", &error); std::string path_str(path);
auto fp = FileSystem::OpenManagedCFile(path_str.c_str(), "rb", &error);
if (fp) if (fp)
{ {
image = RGBA8Image(); image = RGBA8Image();
if (!image->LoadFromFile(path, fp.get())) if (!image->LoadFromFile(path_str.c_str(), fp.get()))
Log_ErrorFmt("Failed to read texture file '{}'", path); Log_ErrorFmt("Failed to read texture file '{}'", path);
} }
else else
@ -321,28 +322,27 @@ std::optional<RGBA8Image> ImGuiFullscreen::LoadTextureImage(const char* path)
return image; return image;
} }
std::shared_ptr<GPUTexture> ImGuiFullscreen::UploadTexture(const char* path, const RGBA8Image& image) std::shared_ptr<GPUTexture> ImGuiFullscreen::UploadTexture(std::string_view path, const RGBA8Image& image)
{ {
std::unique_ptr<GPUTexture> texture = std::unique_ptr<GPUTexture> texture =
g_gpu_device->FetchTexture(image.GetWidth(), image.GetHeight(), 1, 1, 1, GPUTexture::Type::Texture, g_gpu_device->FetchTexture(image.GetWidth(), image.GetHeight(), 1, 1, 1, GPUTexture::Type::Texture,
GPUTexture::Format::RGBA8, image.GetPixels(), image.GetPitch()); GPUTexture::Format::RGBA8, image.GetPixels(), image.GetPitch());
if (!texture) if (!texture)
{ {
Log_ErrorPrintf("failed to create %ux%u texture for resource", image.GetWidth(), image.GetHeight()); Log_ErrorFmt("failed to create {}x{} texture for resource", image.GetWidth(), image.GetHeight());
return {}; return {};
} }
Log_DevPrintf("Uploaded texture resource '%s' (%ux%u)", path, image.GetWidth(), image.GetHeight()); Log_DevFmt("Uploaded texture resource '{}' ({}x{})", path, image.GetWidth(), image.GetHeight());
return std::shared_ptr<GPUTexture>(texture.release(), GPUDevice::PooledTextureDeleter()); return std::shared_ptr<GPUTexture>(texture.release(), GPUDevice::PooledTextureDeleter());
} }
std::shared_ptr<GPUTexture> ImGuiFullscreen::LoadTexture(const std::string_view& path) std::shared_ptr<GPUTexture> ImGuiFullscreen::LoadTexture(std::string_view path)
{ {
std::string path_str(path); std::optional<RGBA8Image> image(LoadTextureImage(path));
std::optional<RGBA8Image> image(LoadTextureImage(path_str.c_str()));
if (image.has_value()) if (image.has_value())
{ {
std::shared_ptr<GPUTexture> ret(UploadTexture(path_str.c_str(), image.value())); std::shared_ptr<GPUTexture> ret(UploadTexture(path, image.value()));
if (ret) if (ret)
return ret; return ret;
} }
@ -350,7 +350,7 @@ std::shared_ptr<GPUTexture> ImGuiFullscreen::LoadTexture(const std::string_view&
return s_placeholder_texture; return s_placeholder_texture;
} }
GPUTexture* ImGuiFullscreen::GetCachedTexture(const std::string_view& name) GPUTexture* ImGuiFullscreen::GetCachedTexture(std::string_view name)
{ {
std::shared_ptr<GPUTexture>* tex_ptr = s_texture_cache.Lookup(name); std::shared_ptr<GPUTexture>* tex_ptr = s_texture_cache.Lookup(name);
if (!tex_ptr) if (!tex_ptr)
@ -362,7 +362,7 @@ GPUTexture* ImGuiFullscreen::GetCachedTexture(const std::string_view& name)
return tex_ptr->get(); return tex_ptr->get();
} }
GPUTexture* ImGuiFullscreen::GetCachedTextureAsync(const std::string_view& name) GPUTexture* ImGuiFullscreen::GetCachedTextureAsync(std::string_view name)
{ {
std::shared_ptr<GPUTexture>* tex_ptr = s_texture_cache.Lookup(name); std::shared_ptr<GPUTexture>* tex_ptr = s_texture_cache.Lookup(name);
if (!tex_ptr) if (!tex_ptr)

View file

@ -105,7 +105,7 @@ ALWAYS_INLINE static ImVec4 MulAlpha(const ImVec4& v, float a)
return ImVec4(v.x, v.y, v.z, v.w * a); return ImVec4(v.x, v.y, v.z, v.w * a);
} }
ALWAYS_INLINE static std::string_view RemoveHash(const std::string_view& s) ALWAYS_INLINE static std::string_view RemoveHash(std::string_view s)
{ {
const std::string_view::size_type pos = s.find('#'); const std::string_view::size_type pos = s.find('#');
return (pos != std::string_view::npos) ? s.substr(0, pos) : s; return (pos != std::string_view::npos) ? s.substr(0, pos) : s;
@ -127,9 +127,9 @@ void Shutdown();
/// Texture cache. /// Texture cache.
const std::shared_ptr<GPUTexture>& GetPlaceholderTexture(); const std::shared_ptr<GPUTexture>& GetPlaceholderTexture();
std::shared_ptr<GPUTexture> LoadTexture(const std::string_view& path); std::shared_ptr<GPUTexture> LoadTexture(std::string_view path);
GPUTexture* GetCachedTexture(const std::string_view& name); GPUTexture* GetCachedTexture(std::string_view name);
GPUTexture* GetCachedTextureAsync(const std::string_view& name); GPUTexture* GetCachedTextureAsync(std::string_view name);
bool InvalidateCachedTexture(const std::string& path); bool InvalidateCachedTexture(const std::string& path);
void UploadAsyncTextures(); void UploadAsyncTextures();

View file

@ -98,16 +98,13 @@ struct MacroButton
// Forward Declarations (for static qualifier) // Forward Declarations (for static qualifier)
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
namespace InputManager { namespace InputManager {
static std::optional<InputBindingKey> ParseHostKeyboardKey(const std::string_view& source, static std::optional<InputBindingKey> ParseHostKeyboardKey(std::string_view source, std::string_view sub_binding);
const std::string_view& sub_binding); static std::optional<InputBindingKey> ParsePointerKey(std::string_view source, std::string_view sub_binding);
static std::optional<InputBindingKey> ParsePointerKey(const std::string_view& source, static std::optional<InputBindingKey> ParseSensorKey(std::string_view source, std::string_view sub_binding);
const std::string_view& sub_binding);
static std::optional<InputBindingKey> ParseSensorKey(const std::string_view& source,
const std::string_view& sub_binding);
static std::vector<std::string_view> SplitChord(const std::string_view& binding); static std::vector<std::string_view> SplitChord(std::string_view binding);
static bool SplitBinding(const std::string_view& binding, std::string_view* source, std::string_view* sub_binding); static bool SplitBinding(std::string_view binding, std::string_view* source, std::string_view* sub_binding);
static void PrettifyInputBindingPart(const std::string_view binding, SmallString& ret, bool& changed); static void PrettifyInputBindingPart(std::string_view binding, SmallString& ret, bool& changed);
static void AddBindings(const std::vector<std::string>& bindings, const InputEventHandler& handler); static void AddBindings(const std::vector<std::string>& bindings, const InputEventHandler& handler);
static bool IsAxisHandler(const InputEventHandler& handler); static bool IsAxisHandler(const InputEventHandler& handler);
@ -189,7 +186,7 @@ static std::vector<std::pair<u32, PointerMoveCallback>> s_pointer_move_callbacks
// Binding Parsing // Binding Parsing
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
std::vector<std::string_view> InputManager::SplitChord(const std::string_view& binding) std::vector<std::string_view> InputManager::SplitChord(std::string_view binding)
{ {
std::vector<std::string_view> parts; std::vector<std::string_view> parts;
@ -219,8 +216,7 @@ std::vector<std::string_view> InputManager::SplitChord(const std::string_view& b
return parts; return parts;
} }
bool InputManager::SplitBinding(const std::string_view& binding, std::string_view* source, bool InputManager::SplitBinding(std::string_view binding, std::string_view* source, std::string_view* sub_binding)
std::string_view* sub_binding)
{ {
const std::string_view::size_type slash_pos = binding.find('/'); const std::string_view::size_type slash_pos = binding.find('/');
if (slash_pos == std::string_view::npos) if (slash_pos == std::string_view::npos)
@ -234,7 +230,7 @@ bool InputManager::SplitBinding(const std::string_view& binding, std::string_vie
return true; return true;
} }
std::optional<InputBindingKey> InputManager::ParseInputBindingKey(const std::string_view& binding) std::optional<InputBindingKey> InputManager::ParseInputBindingKey(std::string_view binding)
{ {
std::string_view source, sub_binding; std::string_view source, sub_binding;
if (!SplitBinding(binding, &source, &sub_binding)) if (!SplitBinding(binding, &source, &sub_binding))
@ -269,7 +265,7 @@ std::optional<InputBindingKey> InputManager::ParseInputBindingKey(const std::str
return std::nullopt; return std::nullopt;
} }
bool InputManager::ParseBindingAndGetSource(const std::string_view& binding, InputBindingKey* key, InputSource** source) bool InputManager::ParseBindingAndGetSource(std::string_view binding, InputBindingKey* key, InputSource** source)
{ {
std::string_view source_string, sub_binding; std::string_view source_string, sub_binding;
if (!SplitBinding(binding, &source_string, &sub_binding)) if (!SplitBinding(binding, &source_string, &sub_binding))
@ -486,7 +482,7 @@ void InputManager::AddBindings(const std::vector<std::string>& bindings, const I
AddBinding(binding, handler); AddBinding(binding, handler);
} }
void InputManager::AddBinding(const std::string_view& binding, const InputEventHandler& handler) void InputManager::AddBinding(std::string_view binding, const InputEventHandler& handler)
{ {
std::shared_ptr<InputBinding> ibinding; std::shared_ptr<InputBinding> ibinding;
const std::vector<std::string_view> chord_bindings(SplitChord(binding)); const std::vector<std::string_view> chord_bindings(SplitChord(binding));
@ -650,7 +646,7 @@ bool InputManager::GetInputSourceDefaultEnabled(InputSourceType type)
} }
} }
std::optional<InputSourceType> InputManager::ParseInputSourceString(const std::string_view& str) std::optional<InputSourceType> InputManager::ParseInputSourceString(std::string_view str)
{ {
for (u32 i = 0; i < static_cast<u32>(InputSourceType::Count); i++) for (u32 i = 0; i < static_cast<u32>(InputSourceType::Count); i++)
{ {
@ -661,8 +657,7 @@ std::optional<InputSourceType> InputManager::ParseInputSourceString(const std::s
return std::nullopt; return std::nullopt;
} }
std::optional<InputBindingKey> InputManager::ParseHostKeyboardKey(const std::string_view& source, std::optional<InputBindingKey> InputManager::ParseHostKeyboardKey(std::string_view source, std::string_view sub_binding)
const std::string_view& sub_binding)
{ {
if (source != "Keyboard") if (source != "Keyboard")
return std::nullopt; return std::nullopt;
@ -677,8 +672,7 @@ std::optional<InputBindingKey> InputManager::ParseHostKeyboardKey(const std::str
return key; return key;
} }
std::optional<InputBindingKey> InputManager::ParsePointerKey(const std::string_view& source, std::optional<InputBindingKey> InputManager::ParsePointerKey(std::string_view source, std::string_view sub_binding)
const std::string_view& sub_binding)
{ {
const std::optional<s32> pointer_index = StringUtil::FromChars<s32>(source.substr(8)); const std::optional<s32> pointer_index = StringUtil::FromChars<s32>(source.substr(8));
if (!pointer_index.has_value() || pointer_index.value() < 0) if (!pointer_index.has_value() || pointer_index.value() < 0)
@ -731,7 +725,7 @@ std::optional<InputBindingKey> InputManager::ParsePointerKey(const std::string_v
return std::nullopt; return std::nullopt;
} }
std::optional<u32> InputManager::GetIndexFromPointerBinding(const std::string_view& source) std::optional<u32> InputManager::GetIndexFromPointerBinding(std::string_view source)
{ {
if (!source.starts_with("Pointer-")) if (!source.starts_with("Pointer-"))
return std::nullopt; return std::nullopt;
@ -748,8 +742,7 @@ std::string InputManager::GetPointerDeviceName(u32 pointer_index)
return fmt::format("Pointer-{}", pointer_index); return fmt::format("Pointer-{}", pointer_index);
} }
std::optional<InputBindingKey> InputManager::ParseSensorKey(const std::string_view& source, std::optional<InputBindingKey> InputManager::ParseSensorKey(std::string_view source, std::string_view sub_binding)
const std::string_view& sub_binding)
{ {
if (source != "Sensor") if (source != "Sensor")
return std::nullopt; return std::nullopt;
@ -1442,12 +1435,12 @@ std::vector<std::string> InputManager::GetInputProfileNames()
return ret; return ret;
} }
void InputManager::OnInputDeviceConnected(const std::string_view& identifier, const std::string_view& device_name) void InputManager::OnInputDeviceConnected(std::string_view identifier, std::string_view device_name)
{ {
Host::OnInputDeviceConnected(identifier, device_name); Host::OnInputDeviceConnected(identifier, device_name);
} }
void InputManager::OnInputDeviceDisconnected(const std::string_view& identifier) void InputManager::OnInputDeviceDisconnected(std::string_view identifier)
{ {
Host::OnInputDeviceDisconnected(identifier); Host::OnInputDeviceDisconnected(identifier);
} }
@ -1873,7 +1866,7 @@ static void GetKeyboardGenericBindingMapping(std::vector<std::pair<GenericInputB
mapping->emplace_back(GenericInputBinding::R3, "Keyboard/4"); mapping->emplace_back(GenericInputBinding::R3, "Keyboard/4");
} }
static bool GetInternalGenericBindingMapping(const std::string_view& device, GenericInputBindingMapping* mapping) static bool GetInternalGenericBindingMapping(std::string_view device, GenericInputBindingMapping* mapping)
{ {
if (device == "Keyboard") if (device == "Keyboard")
{ {
@ -1884,7 +1877,7 @@ static bool GetInternalGenericBindingMapping(const std::string_view& device, Gen
return false; return false;
} }
GenericInputBindingMapping InputManager::GetGenericBindingMapping(const std::string_view& device) GenericInputBindingMapping InputManager::GetGenericBindingMapping(std::string_view device)
{ {
GenericInputBindingMapping mapping; GenericInputBindingMapping mapping;

View file

@ -194,16 +194,16 @@ const char* InputSourceToString(InputSourceType clazz);
bool GetInputSourceDefaultEnabled(InputSourceType type); bool GetInputSourceDefaultEnabled(InputSourceType type);
/// Parses an input class string. /// Parses an input class string.
std::optional<InputSourceType> ParseInputSourceString(const std::string_view& str); std::optional<InputSourceType> ParseInputSourceString(std::string_view str);
/// Parses a pointer device string, i.e. tells you which pointer is specified. /// Parses a pointer device string, i.e. tells you which pointer is specified.
std::optional<u32> GetIndexFromPointerBinding(const std::string_view& str); std::optional<u32> GetIndexFromPointerBinding(std::string_view str);
/// Returns the device name for a pointer index (e.g. Pointer-0). /// Returns the device name for a pointer index (e.g. Pointer-0).
std::string GetPointerDeviceName(u32 pointer_index); std::string GetPointerDeviceName(u32 pointer_index);
/// Converts a key code from a human-readable string to an identifier. /// Converts a key code from a human-readable string to an identifier.
std::optional<u32> ConvertHostKeyboardStringToCode(const std::string_view& str); std::optional<u32> ConvertHostKeyboardStringToCode(std::string_view str);
/// Converts a key code from an identifier to a human-readable string. /// Converts a key code from an identifier to a human-readable string.
std::optional<std::string> ConvertHostKeyboardCodeToString(u32 code); std::optional<std::string> ConvertHostKeyboardCodeToString(u32 code);
@ -225,7 +225,7 @@ InputBindingKey MakePointerAxisKey(u32 index, InputPointerAxis axis);
InputBindingKey MakeSensorAxisKey(InputSubclass sensor, u32 axis); InputBindingKey MakeSensorAxisKey(InputSubclass sensor, u32 axis);
/// Parses an input binding key string. /// Parses an input binding key string.
std::optional<InputBindingKey> ParseInputBindingKey(const std::string_view& binding); std::optional<InputBindingKey> ParseInputBindingKey(std::string_view binding);
/// Converts a input key to a string. /// Converts a input key to a string.
std::string ConvertInputBindingKeyToString(InputBindingInfo::Type binding_type, InputBindingKey key); std::string ConvertInputBindingKeyToString(InputBindingInfo::Type binding_type, InputBindingKey key);
@ -247,7 +247,7 @@ std::vector<std::pair<std::string, std::string>> EnumerateDevices();
std::vector<InputBindingKey> EnumerateMotors(); std::vector<InputBindingKey> EnumerateMotors();
/// Retrieves bindings that match the generic bindings for the specified device. /// Retrieves bindings that match the generic bindings for the specified device.
GenericInputBindingMapping GetGenericBindingMapping(const std::string_view& device); GenericInputBindingMapping GetGenericBindingMapping(std::string_view device);
/// Returns true if the specified input source is enabled. /// Returns true if the specified input source is enabled.
bool IsInputSourceEnabled(SettingsInterface& si, InputSourceType type); bool IsInputSourceEnabled(SettingsInterface& si, InputSourceType type);
@ -277,10 +277,10 @@ bool HasAnyBindingsForKey(InputBindingKey key);
bool HasAnyBindingsForSource(InputBindingKey key); bool HasAnyBindingsForSource(InputBindingKey key);
/// Parses a string binding into its components. Use with external AddBinding(). /// Parses a string binding into its components. Use with external AddBinding().
bool ParseBindingAndGetSource(const std::string_view& binding, InputBindingKey* key, InputSource** source); bool ParseBindingAndGetSource(std::string_view binding, InputBindingKey* key, InputSource** source);
/// Externally adds a fixed binding. Be sure to call *after* ReloadBindings() otherwise it will be lost. /// Externally adds a fixed binding. Be sure to call *after* ReloadBindings() otherwise it will be lost.
void AddBinding(const std::string_view& binding, const InputEventHandler& handler); void AddBinding(std::string_view binding, const InputEventHandler& handler);
/// Adds an external vibration binding. /// Adds an external vibration binding.
void AddVibrationBinding(u32 pad_index, const InputBindingKey* motor_0_binding, InputSource* motor_0_source, void AddVibrationBinding(u32 pad_index, const InputBindingKey* motor_0_binding, InputSource* motor_0_source,
@ -348,10 +348,10 @@ bool MapController(SettingsInterface& si, u32 controller,
std::vector<std::string> GetInputProfileNames(); std::vector<std::string> GetInputProfileNames();
/// Called when a new input device is connected. /// Called when a new input device is connected.
void OnInputDeviceConnected(const std::string_view& identifier, const std::string_view& device_name); void OnInputDeviceConnected(std::string_view identifier, std::string_view device_name);
/// Called when an input device is disconnected. /// Called when an input device is disconnected.
void OnInputDeviceDisconnected(const std::string_view& identifier); void OnInputDeviceDisconnected(std::string_view identifier);
} // namespace InputManager } // namespace InputManager
namespace Host { namespace Host {
@ -359,10 +359,10 @@ namespace Host {
void AddFixedInputBindings(SettingsInterface& si); void AddFixedInputBindings(SettingsInterface& si);
/// Called when a new input device is connected. /// Called when a new input device is connected.
void OnInputDeviceConnected(const std::string_view& identifier, const std::string_view& device_name); void OnInputDeviceConnected(std::string_view identifier, std::string_view device_name);
/// Called when an input device is disconnected. /// Called when an input device is disconnected.
void OnInputDeviceDisconnected(const std::string_view& identifier); void OnInputDeviceDisconnected(std::string_view identifier);
/// Enables "relative" mouse mode, locking the cursor position and returning relative coordinates. /// Enables "relative" mouse mode, locking the cursor position and returning relative coordinates.
void SetMouseMode(bool relative, bool hide_cursor); void SetMouseMode(bool relative, bool hide_cursor);

View file

@ -60,8 +60,8 @@ InputBindingKey InputSource::MakeGenericControllerMotorKey(InputSourceType clazz
} }
std::optional<InputBindingKey> InputSource::ParseGenericControllerKey(InputSourceType clazz, std::optional<InputBindingKey> InputSource::ParseGenericControllerKey(InputSourceType clazz,
const std::string_view& source, std::string_view source,
const std::string_view& sub_binding) std::string_view sub_binding)
{ {
// try to find the number, this function doesn't care about whether it's xinput or sdl or whatever // try to find the number, this function doesn't care about whether it's xinput or sdl or whatever
std::string_view::size_type pos = 0; std::string_view::size_type pos = 0;

View file

@ -29,8 +29,7 @@ public:
virtual void PollEvents() = 0; virtual void PollEvents() = 0;
virtual std::optional<InputBindingKey> ParseKeyString(const std::string_view& device, virtual std::optional<InputBindingKey> ParseKeyString(std::string_view device, std::string_view binding) = 0;
const std::string_view& binding) = 0;
virtual TinyString ConvertKeyToString(InputBindingKey key) = 0; virtual TinyString ConvertKeyToString(InputBindingKey key) = 0;
virtual TinyString ConvertKeyToIcon(InputBindingKey key) = 0; virtual TinyString ConvertKeyToIcon(InputBindingKey key) = 0;
@ -42,7 +41,7 @@ public:
/// Retrieves bindings that match the generic bindings for the specified device. /// Retrieves bindings that match the generic bindings for the specified device.
/// Returns false if it's not one of our devices. /// Returns false if it's not one of our devices.
virtual bool GetGenericBindingMapping(const std::string_view& device, GenericInputBindingMapping* mapping) = 0; virtual bool GetGenericBindingMapping(std::string_view device, GenericInputBindingMapping* mapping) = 0;
/// Informs the source of a new vibration motor state. Changes may not take effect until the next PollEvents() call. /// Informs the source of a new vibration motor state. Changes may not take effect until the next PollEvents() call.
virtual void UpdateMotorState(InputBindingKey key, float intensity) = 0; virtual void UpdateMotorState(InputBindingKey key, float intensity) = 0;
@ -65,8 +64,8 @@ public:
static InputBindingKey MakeGenericControllerMotorKey(InputSourceType clazz, u32 controller_index, s32 motor_index); static InputBindingKey MakeGenericControllerMotorKey(InputSourceType clazz, u32 controller_index, s32 motor_index);
/// Parses a generic controller key string. /// Parses a generic controller key string.
static std::optional<InputBindingKey> ParseGenericControllerKey(InputSourceType clazz, const std::string_view& source, static std::optional<InputBindingKey> ParseGenericControllerKey(InputSourceType clazz, std::string_view source,
const std::string_view& sub_binding); std::string_view sub_binding);
/// Converts a generic controller key to a string. /// Converts a generic controller key to a string.
static std::string ConvertGenericControllerKeyToString(InputBindingKey key); static std::string ConvertGenericControllerKeyToString(InputBindingKey key);

View file

@ -18,7 +18,7 @@ IsoReader::IsoReader() = default;
IsoReader::~IsoReader() = default; IsoReader::~IsoReader() = default;
std::string_view IsoReader::RemoveVersionIdentifierFromPath(const std::string_view& path) std::string_view IsoReader::RemoveVersionIdentifierFromPath(std::string_view path)
{ {
const std::string_view::size_type pos = path.find(';'); const std::string_view::size_type pos = path.find(';');
return (pos != std::string_view::npos) ? path.substr(0, pos) : path; return (pos != std::string_view::npos) ? path.substr(0, pos) : path;
@ -82,7 +82,7 @@ bool IsoReader::ReadPVD(Error* error)
return false; return false;
} }
std::optional<IsoReader::ISODirectoryEntry> IsoReader::LocateFile(const std::string_view& path, Error* error) std::optional<IsoReader::ISODirectoryEntry> IsoReader::LocateFile(std::string_view path, Error* error)
{ {
const ISODirectoryEntry* root_de = reinterpret_cast<const ISODirectoryEntry*>(m_pvd.root_directory_entry); const ISODirectoryEntry* root_de = reinterpret_cast<const ISODirectoryEntry*>(m_pvd.root_directory_entry);
if (path.empty() || path == "/" || path == "\\") if (path.empty() || path == "/" || path == "\\")
@ -125,7 +125,7 @@ std::string_view IsoReader::GetDirectoryEntryFileName(const u8* sector, u32 de_s
return std::string_view(str, length_without_version); return std::string_view(str, length_without_version);
} }
std::optional<IsoReader::ISODirectoryEntry> IsoReader::LocateFile(const std::string_view& path, u8* sector_buffer, std::optional<IsoReader::ISODirectoryEntry> IsoReader::LocateFile(std::string_view path, u8* sector_buffer,
u32 directory_record_lba, u32 directory_record_size, u32 directory_record_lba, u32 directory_record_size,
Error* error) Error* error)
{ {
@ -206,7 +206,7 @@ std::optional<IsoReader::ISODirectoryEntry> IsoReader::LocateFile(const std::str
return std::nullopt; return std::nullopt;
} }
std::vector<std::string> IsoReader::GetFilesInDirectory(const std::string_view& path, Error* error) std::vector<std::string> IsoReader::GetFilesInDirectory(std::string_view path, Error* error)
{ {
std::string base_path(path); std::string base_path(path);
u32 directory_record_lsn; u32 directory_record_lsn;
@ -268,7 +268,7 @@ std::vector<std::string> IsoReader::GetFilesInDirectory(const std::string_view&
} }
std::vector<std::pair<std::string, IsoReader::ISODirectoryEntry>> std::vector<std::pair<std::string, IsoReader::ISODirectoryEntry>>
IsoReader::GetEntriesInDirectory(const std::string_view& path, Error* error /*= nullptr*/) IsoReader::GetEntriesInDirectory(std::string_view path, Error* error /*= nullptr*/)
{ {
std::string base_path(path); std::string base_path(path);
u32 directory_record_lsn; u32 directory_record_lsn;
@ -329,7 +329,7 @@ IsoReader::GetEntriesInDirectory(const std::string_view& path, Error* error /*=
return files; return files;
} }
bool IsoReader::FileExists(const std::string_view& path, Error* error) bool IsoReader::FileExists(std::string_view path, Error* error)
{ {
auto de = LocateFile(path, error); auto de = LocateFile(path, error);
if (!de) if (!de)
@ -338,7 +338,7 @@ bool IsoReader::FileExists(const std::string_view& path, Error* error)
return (de->flags & ISODirectoryEntryFlag_Directory) == 0; return (de->flags & ISODirectoryEntryFlag_Directory) == 0;
} }
bool IsoReader::DirectoryExists(const std::string_view& path, Error* error) bool IsoReader::DirectoryExists(std::string_view path, Error* error)
{ {
auto de = LocateFile(path, error); auto de = LocateFile(path, error);
if (!de) if (!de)
@ -347,7 +347,7 @@ bool IsoReader::DirectoryExists(const std::string_view& path, Error* error)
return (de->flags & ISODirectoryEntryFlag_Directory) == ISODirectoryEntryFlag_Directory; return (de->flags & ISODirectoryEntryFlag_Directory) == ISODirectoryEntryFlag_Directory;
} }
bool IsoReader::ReadFile(const std::string_view& path, std::vector<u8>* data, Error* error) bool IsoReader::ReadFile(std::string_view path, std::vector<u8>* data, Error* error)
{ {
auto de = LocateFile(path, error); auto de = LocateFile(path, error);
if (!de) if (!de)

View file

@ -141,7 +141,7 @@ public:
IsoReader(); IsoReader();
~IsoReader(); ~IsoReader();
static std::string_view RemoveVersionIdentifierFromPath(const std::string_view& path); static std::string_view RemoveVersionIdentifierFromPath(std::string_view path);
ALWAYS_INLINE const CDImage* GetImage() const { return m_image; } ALWAYS_INLINE const CDImage* GetImage() const { return m_image; }
ALWAYS_INLINE u32 GetTrackNumber() const { return m_track_number; } ALWAYS_INLINE u32 GetTrackNumber() const { return m_track_number; }
@ -150,15 +150,15 @@ public:
bool Open(CDImage* image, u32 track_number, Error* error = nullptr); bool Open(CDImage* image, u32 track_number, Error* error = nullptr);
std::vector<std::string> GetFilesInDirectory(const std::string_view& path, Error* error = nullptr); std::vector<std::string> GetFilesInDirectory(std::string_view path, Error* error = nullptr);
std::vector<std::pair<std::string, ISODirectoryEntry>> GetEntriesInDirectory(const std::string_view& path, std::vector<std::pair<std::string, ISODirectoryEntry>> GetEntriesInDirectory(std::string_view path,
Error* error = nullptr); Error* error = nullptr);
std::optional<ISODirectoryEntry> LocateFile(const std::string_view& path, Error* error); std::optional<ISODirectoryEntry> LocateFile(std::string_view path, Error* error);
bool FileExists(const std::string_view& path, Error* error = nullptr); bool FileExists(std::string_view path, Error* error = nullptr);
bool DirectoryExists(const std::string_view& path, Error* error = nullptr); bool DirectoryExists(std::string_view path, Error* error = nullptr);
bool ReadFile(const std::string_view& path, std::vector<u8>* data, Error* error = nullptr); bool ReadFile(std::string_view path, std::vector<u8>* data, Error* error = nullptr);
bool ReadFile(const ISODirectoryEntry& de, std::vector<u8>* data, Error* error = nullptr); bool ReadFile(const ISODirectoryEntry& de, std::vector<u8>* data, Error* error = nullptr);
private: private:
@ -167,7 +167,7 @@ private:
bool ReadSector(u8* buf, u32 lsn, Error* error); bool ReadSector(u8* buf, u32 lsn, Error* error);
bool ReadPVD(Error* error); bool ReadPVD(Error* error);
std::optional<ISODirectoryEntry> LocateFile(const std::string_view& path, u8* sector_buffer, u32 directory_record_lba, std::optional<ISODirectoryEntry> LocateFile(std::string_view path, u8* sector_buffer, u32 directory_record_lba,
u32 directory_record_size, Error* error); u32 directory_record_size, Error* error);
CDImage* m_image; CDImage* m_image;

View file

@ -45,7 +45,7 @@ public:
ALWAYS_INLINE id<MTLSamplerState> GetSamplerState() const { return m_ss; } ALWAYS_INLINE id<MTLSamplerState> GetSamplerState() const { return m_ss; }
void SetDebugName(const std::string_view& name) override; void SetDebugName(std::string_view name) override;
private: private:
MetalSampler(id<MTLSamplerState> ss); MetalSampler(id<MTLSamplerState> ss);
@ -63,7 +63,7 @@ public:
ALWAYS_INLINE id<MTLLibrary> GetLibrary() const { return m_library; } ALWAYS_INLINE id<MTLLibrary> GetLibrary() const { return m_library; }
ALWAYS_INLINE id<MTLFunction> GetFunction() const { return m_function; } ALWAYS_INLINE id<MTLFunction> GetFunction() const { return m_function; }
void SetDebugName(const std::string_view& name) override; void SetDebugName(std::string_view name) override;
private: private:
MetalShader(GPUShaderStage stage, id<MTLLibrary> library, id<MTLFunction> function); MetalShader(GPUShaderStage stage, id<MTLLibrary> library, id<MTLFunction> function);
@ -84,7 +84,7 @@ public:
ALWAYS_INLINE MTLCullMode GetCullMode() const { return m_cull_mode; } ALWAYS_INLINE MTLCullMode GetCullMode() const { return m_cull_mode; }
ALWAYS_INLINE MTLPrimitiveType GetPrimitive() const { return m_primitive; } ALWAYS_INLINE MTLPrimitiveType GetPrimitive() const { return m_primitive; }
void SetDebugName(const std::string_view& name) override; void SetDebugName(std::string_view name) override;
private: private:
MetalPipeline(id<MTLRenderPipelineState> pipeline, id<MTLDepthStencilState> depth, MTLCullMode cull_mode, MetalPipeline(id<MTLRenderPipelineState> pipeline, id<MTLDepthStencilState> depth, MTLCullMode cull_mode,
@ -114,7 +114,7 @@ public:
void MakeReadyForSampling() override; void MakeReadyForSampling() override;
void SetDebugName(const std::string_view& name) override; void SetDebugName(std::string_view name) override;
// Call when the texture is bound to the pipeline, or read from in a copy. // Call when the texture is bound to the pipeline, or read from in a copy.
ALWAYS_INLINE void SetUseFenceCounter(u64 counter) { m_use_fence_counter = counter; } ALWAYS_INLINE void SetUseFenceCounter(u64 counter) { m_use_fence_counter = counter; }
@ -179,7 +179,7 @@ public:
void* Map(u32 required_elements) override; void* Map(u32 required_elements) override;
void Unmap(u32 used_elements) override; void Unmap(u32 used_elements) override;
void SetDebugName(const std::string_view& name) override; void SetDebugName(std::string_view name) override;
private: private:
MetalStreamBuffer m_buffer; MetalStreamBuffer m_buffer;
@ -232,7 +232,7 @@ public:
void InvalidateRenderTarget(GPUTexture* t) override; void InvalidateRenderTarget(GPUTexture* t) override;
std::unique_ptr<GPUShader> CreateShaderFromBinary(GPUShaderStage stage, std::span<const u8> data) override; std::unique_ptr<GPUShader> CreateShaderFromBinary(GPUShaderStage stage, std::span<const u8> data) override;
std::unique_ptr<GPUShader> CreateShaderFromSource(GPUShaderStage stage, const std::string_view& source, std::unique_ptr<GPUShader> CreateShaderFromSource(GPUShaderStage stage, std::string_view source,
const char* entry_point, const char* entry_point,
DynamicHeapArray<u8>* out_binary = nullptr) override; DynamicHeapArray<u8>* out_binary = nullptr) override;
std::unique_ptr<GPUPipeline> CreatePipeline(const GPUPipeline::GraphicsConfig& config) override; std::unique_ptr<GPUPipeline> CreatePipeline(const GPUPipeline::GraphicsConfig& config) override;
@ -291,7 +291,7 @@ public:
static AdapterAndModeList StaticGetAdapterAndModeList(); static AdapterAndModeList StaticGetAdapterAndModeList();
protected: protected:
bool CreateDevice(const std::string_view& adapter, bool threaded_presentation, bool CreateDevice(std::string_view adapter, bool threaded_presentation,
std::optional<bool> exclusive_fullscreen_control, FeatureMask disabled_features, std::optional<bool> exclusive_fullscreen_control, FeatureMask disabled_features,
Error* error) override; Error* error) override;
void DestroyDevice() override; void DestroyDevice() override;
@ -329,8 +329,8 @@ private:
ClearPipelineConfig GetCurrentClearPipelineConfig() const; ClearPipelineConfig GetCurrentClearPipelineConfig() const;
id<MTLRenderPipelineState> GetClearDepthPipeline(const ClearPipelineConfig& config); id<MTLRenderPipelineState> GetClearDepthPipeline(const ClearPipelineConfig& config);
std::unique_ptr<GPUShader> CreateShaderFromMSL(GPUShaderStage stage, const std::string_view& source, std::unique_ptr<GPUShader> CreateShaderFromMSL(GPUShaderStage stage, std::string_view source,
const std::string_view& entry_point); std::string_view entry_point);
id<MTLDepthStencilState> GetDepthState(const GPUPipeline::DepthState& ds); id<MTLDepthStencilState> GetDepthState(const GPUPipeline::DepthState& ds);

View file

@ -61,7 +61,7 @@ static constexpr std::array<MTLPixelFormat, static_cast<u32>(GPUTexture::Format:
static std::unique_ptr<shaderc::Compiler> s_shaderc_compiler; static std::unique_ptr<shaderc::Compiler> s_shaderc_compiler;
static NSString* StringViewToNSString(const std::string_view& str) static NSString* StringViewToNSString(std::string_view str)
{ {
if (str.empty()) if (str.empty())
return nil; return nil;
@ -137,7 +137,7 @@ void MetalDevice::SetVSyncEnabled(bool enabled)
[m_layer setDisplaySyncEnabled:enabled]; [m_layer setDisplaySyncEnabled:enabled];
} }
bool MetalDevice::CreateDevice(const std::string_view& adapter, bool threaded_presentation, bool MetalDevice::CreateDevice(std::string_view adapter, bool threaded_presentation,
std::optional<bool> exclusive_fullscreen_control, FeatureMask disabled_features, std::optional<bool> exclusive_fullscreen_control, FeatureMask disabled_features,
Error* error) Error* error)
{ {
@ -592,7 +592,7 @@ MetalShader::~MetalShader()
MetalDevice::DeferRelease(m_library); MetalDevice::DeferRelease(m_library);
} }
void MetalShader::SetDebugName(const std::string_view& name) void MetalShader::SetDebugName(std::string_view name)
{ {
@autoreleasepool @autoreleasepool
{ {
@ -604,7 +604,7 @@ void MetalShader::SetDebugName(const std::string_view& name)
namespace EmuFolders { namespace EmuFolders {
extern std::string DataRoot; extern std::string DataRoot;
} }
static void DumpShader(u32 n, const std::string_view& suffix, const std::string_view& data) static void DumpShader(u32 n, std::string_view suffix, std::string_view data)
{ {
if (data.empty()) if (data.empty())
return; return;
@ -617,8 +617,8 @@ static void DumpShader(u32 n, const std::string_view& suffix, const std::string_
std::fwrite(data.data(), data.length(), 1, fp.get()); std::fwrite(data.data(), data.length(), 1, fp.get());
} }
std::unique_ptr<GPUShader> MetalDevice::CreateShaderFromMSL(GPUShaderStage stage, const std::string_view& source, std::unique_ptr<GPUShader> MetalDevice::CreateShaderFromMSL(GPUShaderStage stage, std::string_view source,
const std::string_view& entry_point) std::string_view entry_point)
{ {
@autoreleasepool @autoreleasepool
{ {
@ -651,7 +651,7 @@ std::unique_ptr<GPUShader> MetalDevice::CreateShaderFromBinary(GPUShaderStage st
return CreateShaderFromMSL(stage, str_data, "main0"); return CreateShaderFromMSL(stage, str_data, "main0");
} }
std::unique_ptr<GPUShader> MetalDevice::CreateShaderFromSource(GPUShaderStage stage, const std::string_view& source, std::unique_ptr<GPUShader> MetalDevice::CreateShaderFromSource(GPUShaderStage stage, std::string_view source,
const char* entry_point, const char* entry_point,
DynamicHeapArray<u8>* out_binary /* = nullptr */) DynamicHeapArray<u8>* out_binary /* = nullptr */)
{ {
@ -839,7 +839,7 @@ MetalPipeline::~MetalPipeline()
MetalDevice::DeferRelease(m_pipeline); MetalDevice::DeferRelease(m_pipeline);
} }
void MetalPipeline::SetDebugName(const std::string_view& name) void MetalPipeline::SetDebugName(std::string_view name)
{ {
// readonly property :/ // readonly property :/
} }
@ -1188,7 +1188,7 @@ void MetalTexture::MakeReadyForSampling()
dev.EndRenderPass(); dev.EndRenderPass();
} }
void MetalTexture::SetDebugName(const std::string_view& name) void MetalTexture::SetDebugName(std::string_view name)
{ {
@autoreleasepool @autoreleasepool
{ {
@ -1434,7 +1434,7 @@ MetalSampler::MetalSampler(id<MTLSamplerState> ss) : m_ss(ss)
MetalSampler::~MetalSampler() = default; MetalSampler::~MetalSampler() = default;
void MetalSampler::SetDebugName(const std::string_view& name) void MetalSampler::SetDebugName(std::string_view name)
{ {
// lame.. have to put it on the descriptor :/ // lame.. have to put it on the descriptor :/
} }
@ -1831,7 +1831,7 @@ void MetalTextureBuffer::Unmap(u32 used_elements)
m_buffer.CommitMemory(size); m_buffer.CommitMemory(size);
} }
void MetalTextureBuffer::SetDebugName(const std::string_view& name) void MetalTextureBuffer::SetDebugName(std::string_view name)
{ {
@autoreleasepool @autoreleasepool
{ {

View file

@ -272,7 +272,7 @@ bool OpenGLDevice::HasSurface() const
return m_window_info.type != WindowInfo::Type::Surfaceless; return m_window_info.type != WindowInfo::Type::Surfaceless;
} }
bool OpenGLDevice::CreateDevice(const std::string_view& adapter, bool threaded_presentation, bool OpenGLDevice::CreateDevice(std::string_view adapter, bool threaded_presentation,
std::optional<bool> exclusive_fullscreen_control, FeatureMask disabled_features, std::optional<bool> exclusive_fullscreen_control, FeatureMask disabled_features,
Error* error) Error* error)
{ {

View file

@ -73,7 +73,7 @@ public:
void InvalidateRenderTarget(GPUTexture* t) override; void InvalidateRenderTarget(GPUTexture* t) override;
std::unique_ptr<GPUShader> CreateShaderFromBinary(GPUShaderStage stage, std::span<const u8> data) override; std::unique_ptr<GPUShader> CreateShaderFromBinary(GPUShaderStage stage, std::span<const u8> data) override;
std::unique_ptr<GPUShader> CreateShaderFromSource(GPUShaderStage stage, const std::string_view& source, std::unique_ptr<GPUShader> CreateShaderFromSource(GPUShaderStage stage, std::string_view source,
const char* entry_point, DynamicHeapArray<u8>* out_binary) override; const char* entry_point, DynamicHeapArray<u8>* out_binary) override;
std::unique_ptr<GPUPipeline> CreatePipeline(const GPUPipeline::GraphicsConfig& config) override; std::unique_ptr<GPUPipeline> CreatePipeline(const GPUPipeline::GraphicsConfig& config) override;
@ -130,7 +130,7 @@ public:
void UnbindPipeline(const OpenGLPipeline* pl); void UnbindPipeline(const OpenGLPipeline* pl);
protected: protected:
bool CreateDevice(const std::string_view& adapter, bool threaded_presentation, bool CreateDevice(std::string_view adapter, bool threaded_presentation,
std::optional<bool> exclusive_fullscreen_control, FeatureMask disabled_features, std::optional<bool> exclusive_fullscreen_control, FeatureMask disabled_features,
Error* error) override; Error* error) override;
void DestroyDevice() override; void DestroyDevice() override;

View file

@ -78,7 +78,7 @@ OpenGLShader::~OpenGLShader()
glDeleteShader(m_id.value()); glDeleteShader(m_id.value());
} }
void OpenGLShader::SetDebugName(const std::string_view& name) void OpenGLShader::SetDebugName(std::string_view name)
{ {
#ifdef _DEBUG #ifdef _DEBUG
if (glObjectLabel) if (glObjectLabel)
@ -163,7 +163,7 @@ std::unique_ptr<GPUShader> OpenGLDevice::CreateShaderFromBinary(GPUShaderStage s
return {}; return {};
} }
std::unique_ptr<GPUShader> OpenGLDevice::CreateShaderFromSource(GPUShaderStage stage, const std::string_view& source, std::unique_ptr<GPUShader> OpenGLDevice::CreateShaderFromSource(GPUShaderStage stage, std::string_view source,
const char* entry_point, const char* entry_point,
DynamicHeapArray<u8>* out_binary) DynamicHeapArray<u8>* out_binary)
{ {
@ -440,7 +440,8 @@ void OpenGLDevice::UnrefProgram(const OpenGLPipeline::ProgramCacheKey& key)
m_program_cache.erase(it); m_program_cache.erase(it);
} }
OpenGLPipeline::VertexArrayCache::const_iterator OpenGLDevice::LookupVAOCache(const OpenGLPipeline::VertexArrayCacheKey& key) OpenGLPipeline::VertexArrayCache::const_iterator
OpenGLDevice::LookupVAOCache(const OpenGLPipeline::VertexArrayCacheKey& key)
{ {
OpenGLPipeline::VertexArrayCache::iterator it = m_vao_cache.find(key); OpenGLPipeline::VertexArrayCache::iterator it = m_vao_cache.find(key);
if (it != m_vao_cache.end()) if (it != m_vao_cache.end())
@ -546,7 +547,7 @@ OpenGLPipeline::~OpenGLPipeline()
dev.UnrefVAO(m_key.va_key); dev.UnrefVAO(m_key.va_key);
} }
void OpenGLPipeline::SetDebugName(const std::string_view& name) void OpenGLPipeline::SetDebugName(std::string_view name)
{ {
#ifdef _DEBUG #ifdef _DEBUG
if (glObjectLabel) if (glObjectLabel)

View file

@ -16,7 +16,7 @@ class OpenGLShader final : public GPUShader
public: public:
~OpenGLShader() override; ~OpenGLShader() override;
void SetDebugName(const std::string_view& name) override; void SetDebugName(std::string_view name) override;
bool Compile(); bool Compile();
@ -103,7 +103,7 @@ public:
ALWAYS_INLINE const BlendState& GetBlendState() const { return m_blend_state; } ALWAYS_INLINE const BlendState& GetBlendState() const { return m_blend_state; }
ALWAYS_INLINE GLenum GetTopology() const { return m_topology; } ALWAYS_INLINE GLenum GetTopology() const { return m_topology; }
void SetDebugName(const std::string_view& name) override; void SetDebugName(std::string_view name) override;
private: private:
OpenGLPipeline(const ProgramCacheKey& key, GLuint program, VertexArrayCache::const_iterator vao, OpenGLPipeline(const ProgramCacheKey& key, GLuint program, VertexArrayCache::const_iterator vao,

View file

@ -29,7 +29,7 @@ void OpenGLStreamBuffer::Unbind()
glBindBuffer(m_target, 0); glBindBuffer(m_target, 0);
} }
void OpenGLStreamBuffer::SetDebugName(const std::string_view& name) void OpenGLStreamBuffer::SetDebugName(std::string_view name)
{ {
#ifdef _DEBUG #ifdef _DEBUG
if (glObjectLabel) if (glObjectLabel)

View file

@ -24,7 +24,7 @@ public:
void Bind(); void Bind();
void Unbind(); void Unbind();
void SetDebugName(const std::string_view& name); void SetDebugName(std::string_view name);
struct MappingResult struct MappingResult
{ {

View file

@ -350,7 +350,7 @@ void OpenGLTexture::Unmap()
sb->Unbind(); sb->Unbind();
} }
void OpenGLTexture::SetDebugName(const std::string_view& name) void OpenGLTexture::SetDebugName(std::string_view name)
{ {
#ifdef _DEBUG #ifdef _DEBUG
if (glObjectLabel) if (glObjectLabel)
@ -375,7 +375,7 @@ OpenGLSampler::~OpenGLSampler()
OpenGLDevice::GetInstance().UnbindSampler(m_id); OpenGLDevice::GetInstance().UnbindSampler(m_id);
} }
void OpenGLSampler::SetDebugName(const std::string_view& name) void OpenGLSampler::SetDebugName(std::string_view name)
{ {
#ifdef _DEBUG #ifdef _DEBUG
if (glObjectLabel) if (glObjectLabel)
@ -660,7 +660,7 @@ void OpenGLTextureBuffer::Unmap(u32 used_elements)
m_buffer->Unmap(size); m_buffer->Unmap(size);
} }
void OpenGLTextureBuffer::SetDebugName(const std::string_view& name) void OpenGLTextureBuffer::SetDebugName(std::string_view name)
{ {
#ifdef _DEBUG #ifdef _DEBUG
if (glObjectLabel) if (glObjectLabel)

View file

@ -27,7 +27,7 @@ public:
bool Map(void** map, u32* map_stride, u32 x, u32 y, u32 width, u32 height, u32 layer = 0, u32 level = 0) override; bool Map(void** map, u32* map_stride, u32 x, u32 y, u32 width, u32 height, u32 layer = 0, u32 level = 0) override;
void Unmap() override; void Unmap() override;
void SetDebugName(const std::string_view& name) override; void SetDebugName(std::string_view name) override;
static std::unique_ptr<OpenGLTexture> Create(u32 width, u32 height, u32 layers, u32 levels, u32 samples, Type type, static std::unique_ptr<OpenGLTexture> Create(u32 width, u32 height, u32 layers, u32 levels, u32 samples, Type type,
Format format, const void* data = nullptr, u32 data_pitch = 0); Format format, const void* data = nullptr, u32 data_pitch = 0);
@ -73,7 +73,7 @@ public:
void* Map(u32 required_elements) override; void* Map(u32 required_elements) override;
void Unmap(u32 used_elements) override; void Unmap(u32 used_elements) override;
void SetDebugName(const std::string_view& name) override; void SetDebugName(std::string_view name) override;
private: private:
OpenGLTextureBuffer(Format format, u32 size_in_elements, std::unique_ptr<OpenGLStreamBuffer> buffer, OpenGLTextureBuffer(Format format, u32 size_in_elements, std::unique_ptr<OpenGLStreamBuffer> buffer,
@ -92,7 +92,7 @@ public:
ALWAYS_INLINE GLuint GetID() const { return m_id; } ALWAYS_INLINE GLuint GetID() const { return m_id; }
void SetDebugName(const std::string_view& name) override; void SetDebugName(std::string_view name) override;
private: private:
OpenGLSampler(GLuint id); OpenGLSampler(GLuint id);

View file

@ -33,7 +33,7 @@ Log_SetChannel(PostProcessing);
namespace PostProcessing { namespace PostProcessing {
template<typename T> template<typename T>
static u32 ParseVector(const std::string_view& line, ShaderOption::ValueVector* values); static u32 ParseVector(std::string_view line, ShaderOption::ValueVector* values);
static TinyString ValueToString(ShaderOption::Type type, u32 vector_size, const ShaderOption::ValueVector& value); static TinyString ValueToString(ShaderOption::Type type, u32 vector_size, const ShaderOption::ValueVector& value);
@ -63,7 +63,7 @@ static std::unique_ptr<GPUTexture> s_dummy_texture;
} // namespace PostProcessing } // namespace PostProcessing
template<typename T> template<typename T>
u32 PostProcessing::ParseVector(const std::string_view& line, ShaderOption::ValueVector* values) u32 PostProcessing::ParseVector(std::string_view line, ShaderOption::ValueVector* values)
{ {
u32 index = 0; u32 index = 0;
size_t start = 0; size_t start = 0;
@ -102,12 +102,12 @@ u32 PostProcessing::ParseVector(const std::string_view& line, ShaderOption::Valu
return size; return size;
} }
u32 PostProcessing::ShaderOption::ParseFloatVector(const std::string_view& line, ValueVector* values) u32 PostProcessing::ShaderOption::ParseFloatVector(std::string_view line, ValueVector* values)
{ {
return ParseVector<float>(line, values); return ParseVector<float>(line, values);
} }
u32 PostProcessing::ShaderOption::ParseIntVector(const std::string_view& line, ValueVector* values) u32 PostProcessing::ShaderOption::ParseIntVector(std::string_view line, ValueVector* values)
{ {
return ParseVector<s32>(line, values); return ParseVector<s32>(line, values);
} }

View file

@ -63,8 +63,8 @@ struct ShaderOption
ValueVector value; ValueVector value;
std::vector<std::string> choice_options; std::vector<std::string> choice_options;
static u32 ParseIntVector(const std::string_view& line, ValueVector* values); static u32 ParseIntVector(std::string_view line, ValueVector* values);
static u32 ParseFloatVector(const std::string_view& line, ValueVector* values); static u32 ParseFloatVector(std::string_view line, ValueVector* values);
static constexpr ValueVector MakeIntVector(s32 x, s32 y = 0, s32 z = 0, s32 w = 0) static constexpr ValueVector MakeIntVector(s32 x, s32 y = 0, s32 z = 0, s32 w = 0)
{ {

View file

@ -13,7 +13,7 @@
Log_SetChannel(PostProcessing); Log_SetChannel(PostProcessing);
void PostProcessing::Shader::ParseKeyValue(const std::string_view& line, std::string_view* key, std::string_view* value) void PostProcessing::Shader::ParseKeyValue(std::string_view line, std::string_view* key, std::string_view* value)
{ {
size_t key_start = 0; size_t key_start = 0;
while (key_start < line.size() && std::isspace(line[key_start])) while (key_start < line.size() && std::isspace(line[key_start]))
@ -105,7 +105,7 @@ void PostProcessing::Shader::LoadOptions(const SettingsInterface& si, const char
} }
} }
const PostProcessing::ShaderOption* PostProcessing::Shader::GetOptionByName(const std::string_view& name) const const PostProcessing::ShaderOption* PostProcessing::Shader::GetOptionByName(std::string_view name) const
{ {
for (const ShaderOption& option : m_options) for (const ShaderOption& option : m_options)
{ {
@ -116,7 +116,7 @@ const PostProcessing::ShaderOption* PostProcessing::Shader::GetOptionByName(cons
return nullptr; return nullptr;
} }
PostProcessing::ShaderOption* PostProcessing::Shader::GetOptionByName(const std::string_view& name) PostProcessing::ShaderOption* PostProcessing::Shader::GetOptionByName(std::string_view name)
{ {
for (ShaderOption& option : m_options) for (ShaderOption& option : m_options)
{ {

View file

@ -41,8 +41,8 @@ public:
std::vector<ShaderOption> TakeOptions(); std::vector<ShaderOption> TakeOptions();
void LoadOptions(const SettingsInterface& si, const char* section); void LoadOptions(const SettingsInterface& si, const char* section);
const ShaderOption* GetOptionByName(const std::string_view& name) const; const ShaderOption* GetOptionByName(std::string_view name) const;
ShaderOption* GetOptionByName(const std::string_view& name); ShaderOption* GetOptionByName(std::string_view name);
virtual bool ResizeOutput(GPUTexture::Format format, u32 width, u32 height) = 0; virtual bool ResizeOutput(GPUTexture::Format format, u32 width, u32 height) = 0;
@ -52,7 +52,7 @@ public:
s32 final_height, s32 orig_width, s32 orig_height, u32 target_width, u32 target_height) = 0; s32 final_height, s32 orig_width, s32 orig_height, u32 target_width, u32 target_height) = 0;
protected: protected:
static void ParseKeyValue(const std::string_view& line, std::string_view* key, std::string_view* value); static void ParseKeyValue(std::string_view line, std::string_view* key, std::string_view* value);
virtual void OnOptionChanged(const ShaderOption& option); virtual void OnOptionChanged(const ShaderOption& option);

View file

@ -438,7 +438,7 @@ bool PostProcessing::ReShadeFXShader::CreateModule(s32 buffer_width, s32 buffer_
return true; return true;
} }
static bool HasAnnotationWithName(const reshadefx::uniform_info& uniform, const std::string_view& annotation_name) static bool HasAnnotationWithName(const reshadefx::uniform_info& uniform, const std::string_view annotation_name)
{ {
for (const reshadefx::annotation& an : uniform.annotations) for (const reshadefx::annotation& an : uniform.annotations)
{ {

View file

@ -243,7 +243,7 @@ u32 SDLInputSource::GetRGBForPlayerId(SettingsInterface& si, u32 player_id)
player_id); player_id);
} }
u32 SDLInputSource::ParseRGBForPlayerId(const std::string_view& str, u32 player_id) u32 SDLInputSource::ParseRGBForPlayerId(std::string_view str, u32 player_id)
{ {
if (player_id >= MAX_LED_COLORS) if (player_id >= MAX_LED_COLORS)
return 0; return 0;
@ -355,8 +355,7 @@ std::vector<std::pair<std::string, std::string>> SDLInputSource::EnumerateDevice
return ret; return ret;
} }
std::optional<InputBindingKey> SDLInputSource::ParseKeyString(const std::string_view& device, std::optional<InputBindingKey> SDLInputSource::ParseKeyString(std::string_view device, std::string_view binding)
const std::string_view& binding)
{ {
if (!device.starts_with("SDL-") || binding.empty()) if (!device.starts_with("SDL-") || binding.empty())
return std::nullopt; return std::nullopt;
@ -638,7 +637,7 @@ bool SDLInputSource::ProcessSDLEvent(const SDL_Event* event)
} }
} }
SDL_Joystick* SDLInputSource::GetJoystickForDevice(const std::string_view& device) SDL_Joystick* SDLInputSource::GetJoystickForDevice(std::string_view device)
{ {
if (!device.starts_with("SDL-")) if (!device.starts_with("SDL-"))
return nullptr; return nullptr;
@ -952,7 +951,7 @@ std::vector<InputBindingKey> SDLInputSource::EnumerateMotors()
return ret; return ret;
} }
bool SDLInputSource::GetGenericBindingMapping(const std::string_view& device, GenericInputBindingMapping* mapping) bool SDLInputSource::GetGenericBindingMapping(std::string_view device, GenericInputBindingMapping* mapping)
{ {
if (!device.starts_with("SDL-")) if (!device.starts_with("SDL-"))
return false; return false;

View file

@ -29,22 +29,21 @@ public:
void PollEvents() override; void PollEvents() override;
std::vector<std::pair<std::string, std::string>> EnumerateDevices() override; std::vector<std::pair<std::string, std::string>> EnumerateDevices() override;
std::vector<InputBindingKey> EnumerateMotors() override; std::vector<InputBindingKey> EnumerateMotors() override;
bool GetGenericBindingMapping(const std::string_view& device, GenericInputBindingMapping* mapping) override; bool GetGenericBindingMapping(std::string_view device, GenericInputBindingMapping* mapping) override;
void UpdateMotorState(InputBindingKey key, float intensity) override; void UpdateMotorState(InputBindingKey key, float intensity) override;
void UpdateMotorState(InputBindingKey large_key, InputBindingKey small_key, float large_intensity, void UpdateMotorState(InputBindingKey large_key, InputBindingKey small_key, float large_intensity,
float small_intensity) override; float small_intensity) override;
std::optional<InputBindingKey> ParseKeyString(const std::string_view& device, std::optional<InputBindingKey> ParseKeyString(std::string_view device, std::string_view binding) override;
const std::string_view& binding) override;
TinyString ConvertKeyToString(InputBindingKey key) override; TinyString ConvertKeyToString(InputBindingKey key) override;
TinyString ConvertKeyToIcon(InputBindingKey key) override; TinyString ConvertKeyToIcon(InputBindingKey key) override;
bool ProcessSDLEvent(const SDL_Event* event); bool ProcessSDLEvent(const SDL_Event* event);
SDL_Joystick* GetJoystickForDevice(const std::string_view& device); SDL_Joystick* GetJoystickForDevice(std::string_view device);
static u32 GetRGBForPlayerId(SettingsInterface& si, u32 player_id); static u32 GetRGBForPlayerId(SettingsInterface& si, u32 player_id);
static u32 ParseRGBForPlayerId(const std::string_view& str, u32 player_id); static u32 ParseRGBForPlayerId(std::string_view str, u32 player_id);
static bool IsHandledInputEvent(const SDL_Event* ev); static bool IsHandledInputEvent(const SDL_Event* ev);

Some files were not shown because too many files have changed in this diff Show more