mirror of
https://github.com/Vita3K/Vita3K.git
synced 2026-07-11 01:34:23 +02:00
util: Use contains instead of find for strings (#3961)
* Update BUILDING.md * util: Use contains instead of find for strings also removed custom 'bit_cast' Co-authored-by: 双子叶植物 <149964080+Dicot0721@users.noreply.github.com> --------- Co-authored-by: nishinji <nishinji@users.noreply.github.com> Co-authored-by: 双子叶植物 <149964080+Dicot0721@users.noreply.github.com>
This commit is contained in:
+16
-1
@@ -1 +1,16 @@
|
||||
Please see the [Wiki](https://github.com/Vita3K/Vita3K/wiki) for developer information.
|
||||
# Getting Started
|
||||
Before getting started using the emulator, read the [Quickstart Guide](https://vita3k.org/quickstart.html). After reading it, if you need support, check out our `help` channel in [discord server](https://discord.gg/MaWhJVH).
|
||||
|
||||
# Issue Reporting
|
||||
**The GitHub Issue Tracker is not the place to ask for support or to submit[Game Compatibility reports.** Requests for support or incorrect reports will be closed.
|
||||
|
||||
**Before reporting an issue:**
|
||||
- Check if your system matches all the minimum requirements listed in the [Quickstart Guide](https://vita3k.org/quickstart.html);
|
||||
- Search older issues threads to see if your issue was already submitted;
|
||||
- Use understandable English. It doesn't need to be perfect, but clear enough to understand your message;
|
||||
- While reporting issues, please follow the template for the type of issue you've selected (Bug Report or Feature Request), which is prefilled on the issue's textbox.
|
||||
|
||||
Submitting your test results for Commercial Games must be done on our [Compatibility](https://github.com/Vita3K/compatibility) repo.
|
||||
|
||||
# Contributing
|
||||
Check the [Coding Style Guidelines](https://github.com/Vita3K/Vita3K/wiki/Coding-style) and [Developer Information](https://github.com/Vita3K/Vita3K/wiki/Developer-Information). If you have any questions, hit us up on our [Discord Server](https://discord.gg/MaWhJVJ) in the **#development** channel.
|
||||
|
||||
+1
-1
@@ -21,7 +21,7 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||
set(CMAKE_OSX_DEPLOYMENT_TARGET 11.0)
|
||||
|
||||
# workaround for SDL due to cmake bug
|
||||
# workaround for SDL due to cmake bug
|
||||
# https://github.com/libsdl-org/SDL/issues/6454
|
||||
# https://gitlab.kitware.com/cmake/cmake/-/issues/24104
|
||||
if(APPLE)
|
||||
|
||||
@@ -50,7 +50,7 @@ You can download the latest builds from [here](https://github.com/Vita3K/Vita3K/
|
||||
* [vita3k-git](https://aur.archlinux.org/packages/vita3k-git)<sup><small>AUR</small></sup>
|
||||
* Requirements:
|
||||
* xdg-desktop-portal
|
||||
* [Android](https://github.com/Vita3K/Vita3K-Android/releases/)
|
||||
* Android
|
||||
* [Adreno drivers](https://github.com/K11MCH1/AdrenoToolsDrivers/releases/)
|
||||
* Others
|
||||
* [Download Artifact](https://github.com/Vita3K/Vita3K/actions?query=event%3Apush+is%3Asuccess+branch%3Amaster)
|
||||
|
||||
@@ -76,7 +76,7 @@ static bool parse_xml(CompatState &state, const uint8_t *data, size_t size) {
|
||||
const std::string title_id = app.attribute("title_id").as_string();
|
||||
const uint32_t issue_id = app.child("issue_id").text().as_uint();
|
||||
|
||||
if ((title_id.find("PCS") == std::string::npos) && (title_id != "NPXS10007")) {
|
||||
if (!title_id.contains("PCS") && (title_id != "NPXS10007")) {
|
||||
LOG_WARN_IF(state.log_compat_warn, "Title ID {} is invalid. Please check GitHub issue {} and verify it!", title_id, issue_id);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -398,7 +398,7 @@ std::vector<std::pair<std::string, bool>> get_modules_list(
|
||||
}
|
||||
|
||||
for (auto &m : modules)
|
||||
m.second = vector_utils::contains(lle_modules, m.first);
|
||||
m.second = std::ranges::contains(lle_modules, m.first);
|
||||
|
||||
std::sort(modules.begin(), modules.end(), [](const auto &a, const auto &b) {
|
||||
if (a.second == b.second)
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
#include "cpu/common.h"
|
||||
#include <cpu/impl/dynarmic_cpu.h>
|
||||
#include <cpu/state.h>
|
||||
#include <util/bit_cast.h>
|
||||
#include <util/log.h>
|
||||
|
||||
#include <mem/ptr.h>
|
||||
@@ -27,6 +26,7 @@
|
||||
#include <dynarmic/interface/A32/coprocessor.h>
|
||||
#include <dynarmic/interface/exclusive_monitor.h>
|
||||
|
||||
#include <bit>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
#include <emuenv/state.h>
|
||||
#include <util/bit_cast.h>
|
||||
#include <util/log.h>
|
||||
|
||||
#include <gdbstub/functions.h>
|
||||
|
||||
@@ -689,7 +689,7 @@ void LiveAreaWidget::mousePressEvent(QMouseEvent *e) {
|
||||
continue;
|
||||
|
||||
const auto &target = item_it->second.target;
|
||||
if (target.empty() || target.find("psts:") != std::string::npos)
|
||||
if (target.empty() || target.contains("psts:"))
|
||||
continue;
|
||||
|
||||
const auto &fl = fl_it->second;
|
||||
@@ -736,7 +736,7 @@ void LiveAreaWidget::mouseMoveEvent(QMouseEvent *e) {
|
||||
auto item_it = m_frame_items.find(frame.id);
|
||||
if (item_it == m_frame_items.end() || item_it->second.target.empty())
|
||||
continue;
|
||||
if (item_it->second.target.find("psts:") != std::string::npos)
|
||||
if (item_it->second.target.contains("psts:"))
|
||||
continue;
|
||||
|
||||
const auto &fl = fl_it->second;
|
||||
|
||||
@@ -118,7 +118,7 @@ static bool set_content_path(EmuEnvState &emuenv, const bool is_theme, fs::path
|
||||
dest_path /= fs::path("addcont") / emuenv.app_info.app_title_id / emuenv.app_info.app_content_id;
|
||||
emuenv.app_info.app_title += " (DLC)";
|
||||
}
|
||||
} else if (emuenv.app_info.app_category.find("gp") != std::string::npos) {
|
||||
} else if (emuenv.app_info.app_category.contains("gp")) {
|
||||
if (!fs::exists(app_path) || fs::is_empty(app_path)) {
|
||||
LOG_ERROR("Install app before patch");
|
||||
return false;
|
||||
@@ -209,7 +209,7 @@ static bool install_archive_content(EmuEnvState &emuenv, const ZipPtr &zip, cons
|
||||
continue;
|
||||
}
|
||||
const std::string m_filename = file_stat.m_filename;
|
||||
if (m_filename.find(content_path) != std::string::npos) {
|
||||
if (m_filename.contains(content_path)) {
|
||||
file_progress = static_cast<float>(i) / num_files * 100.0f;
|
||||
update_progress();
|
||||
|
||||
@@ -254,7 +254,7 @@ static std::vector<std::string> get_archive_contents_path(const ZipPtr &zip) {
|
||||
continue;
|
||||
|
||||
std::string m_filename = std::string(file_stat.m_filename);
|
||||
if (m_filename.find("sce_module/steroid.suprx") != std::string::npos) {
|
||||
if (m_filename.contains("sce_module/steroid.suprx")) {
|
||||
LOG_CRITICAL("A Vitamin dump was detected, aborting installation...");
|
||||
#ifdef __ANDROID__
|
||||
// SDL_ShowAndroidToast("Vitamin dumps are not supported!", 1, -1, 0, 0);
|
||||
@@ -263,9 +263,9 @@ static std::vector<std::string> get_archive_contents_path(const ZipPtr &zip) {
|
||||
break;
|
||||
}
|
||||
|
||||
const auto is_content = (m_filename.find(sfo_path) != std::string::npos) || (m_filename.find(theme_path) != std::string::npos);
|
||||
const auto is_content = m_filename.contains(sfo_path) || m_filename.contains(theme_path);
|
||||
if (is_content) {
|
||||
const auto content_type = (m_filename.find(sfo_path) != std::string::npos) ? sfo_path : theme_path;
|
||||
const auto content_type = m_filename.contains(sfo_path) ? sfo_path : theme_path;
|
||||
m_filename.erase(m_filename.find(content_type));
|
||||
vector_utils::push_if_not_exists(content_path, m_filename);
|
||||
}
|
||||
|
||||
@@ -287,7 +287,7 @@ std::string translate_path(const char *path, VitaIoDevice &device, const IOState
|
||||
return std::string{};
|
||||
}
|
||||
default: {
|
||||
LOG_CRITICAL_IF(relative_path.find(':') != std::string::npos, "Unknown device with path {} used. Report this to the developers!", relative_path);
|
||||
LOG_CRITICAL_IF(relative_path.contains(':'), "Unknown device with path {} used. Report this to the developers!", relative_path);
|
||||
return std::string{};
|
||||
}
|
||||
}
|
||||
@@ -783,7 +783,7 @@ SceUID read_dir(IOState &io, const SceUID fd, SceIoDirent *dent, const fs::path
|
||||
|
||||
bool copy_path(const fs::path &src_path, const fs::path &pref_path, const std::string &app_title_id, const std::string &app_category) {
|
||||
// Check if is path
|
||||
if (app_category.find("gp") != std::string::npos) {
|
||||
if (app_category.contains("gp")) {
|
||||
const auto app_path{ pref_path / "ux0/app" / app_title_id };
|
||||
const auto result = fs_utils::copy_directory_contents(src_path, app_path);
|
||||
|
||||
|
||||
@@ -632,7 +632,7 @@ SceUID load_self(KernelState &kernel, MemState &mem, const void *self, const std
|
||||
|
||||
for (auto &patch : patches) {
|
||||
// TODO patches should maybe be able to specify the path/file to patch?
|
||||
if (seg_index == patch.seg && self_path.find("eboot.bin") != std::string::npos) {
|
||||
if (seg_index == patch.seg && self_path.contains("eboot.bin")) {
|
||||
LOG_INFO("Patching segment {} at offset 0x{:X} with {} values", seg_index, patch.offset, patch.values.size());
|
||||
memcpy(seg_ptr.get(mem) + patch.offset, patch.values.data(), patch.values.size());
|
||||
}
|
||||
@@ -749,7 +749,7 @@ SceUID load_self(KernelState &kernel, MemState &mem, const void *self, const std
|
||||
sceKernelModuleInfo->state = module_info->type;
|
||||
|
||||
LOG_INFO("Linking SELF {}...", self_path);
|
||||
if (self_path.find("eboot.bin") != std::string::npos)
|
||||
if (self_path.contains("eboot.bin"))
|
||||
LOG_INFO("eboot.bin module NID: {}", log_hex(module_info->module_nid));
|
||||
|
||||
if (!load_exports(sceKernelModuleInfo, *module_info, module_info_segment_address, kernel, mem)) {
|
||||
|
||||
@@ -168,13 +168,13 @@ bool is_lle_module(SceSysmoduleModuleId module_id, EmuEnvState &emuenv) {
|
||||
|
||||
if (have_paths) {
|
||||
if (emuenv.cfg.current_config.modules_mode != ModulesMode::MANUAL) {
|
||||
if (vector_utils::contains(auto_lle_modules, module_id))
|
||||
if (std::ranges::contains(auto_lle_modules, module_id))
|
||||
return true;
|
||||
}
|
||||
|
||||
if (emuenv.cfg.current_config.modules_mode != ModulesMode::AUTOMATIC) {
|
||||
for (auto path : paths) {
|
||||
if (vector_utils::contains(emuenv.cfg.current_config.lle_modules, path))
|
||||
if (std::ranges::contains(emuenv.cfg.current_config.lle_modules, path))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -198,11 +198,11 @@ bool is_lle_module(const std::string &module_name, EmuEnvState &emuenv) {
|
||||
if (auto_lle_module_names.empty())
|
||||
auto_lle_module_names = init_auto_lle_module_names();
|
||||
if (emuenv.cfg.current_config.modules_mode != ModulesMode::AUTOMATIC) {
|
||||
if (vector_utils::contains(emuenv.cfg.current_config.lle_modules, module_name))
|
||||
if (std::ranges::contains(emuenv.cfg.current_config.lle_modules, module_name))
|
||||
return true;
|
||||
}
|
||||
if (emuenv.cfg.current_config.modules_mode != ModulesMode::MANUAL) {
|
||||
if (vector_utils::contains(auto_lle_module_names, module_name))
|
||||
if (std::ranges::contains(auto_lle_module_names, module_name))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -411,7 +411,7 @@ EXPORT(SceInt32, _sceAppMgrLoadExec, const char *appPath, Ptr<char> const argv[]
|
||||
|
||||
// Create exec path
|
||||
auto exec_path = static_cast<std::string>(appPath);
|
||||
if (exec_path.find("app0:/") != std::string::npos)
|
||||
if (exec_path.contains("app0:/"))
|
||||
exec_path.erase(0, 6);
|
||||
else
|
||||
exec_path.erase(0, 5);
|
||||
|
||||
@@ -838,7 +838,7 @@ EXPORT(SceInt, sceHttpParseStatusLine, const char *statusLine, SceSize lineLen,
|
||||
return RET_ERROR(SCE_HTTP_ERROR_PARSE_HTTP_INVALID_RESPONSE);
|
||||
|
||||
*httpMajorVer = string_utils::stoi_def(version.substr(0, version.find('.'))); // we know this wont fail because parseStatusLine returned true :)
|
||||
if (version.find('.') != std::string::npos) {
|
||||
if (version.contains('.')) {
|
||||
auto minorVer = version.substr(version.find('.') + 1);
|
||||
*httpMinorVer = string_utils::stoi_def(minorVer);
|
||||
} else {
|
||||
@@ -1098,15 +1098,15 @@ EXPORT(SceInt, sceHttpSendRequest, SceInt reqId, const char *postData, SceSize s
|
||||
}
|
||||
|
||||
totalReceived += bytes;
|
||||
} while (std::string_view(resHeaders).find("\r\n\r\n") == std::string::npos || totalReceived == resHeadersMaxSize); // receive headers until we start receiving body
|
||||
} while (!std::string_view(resHeaders).contains("\r\n\r\n") || totalReceived == resHeadersMaxSize); // receive headers until we start receiving body
|
||||
|
||||
if (totalReceived != resHeadersMaxSize && std::string_view(resHeaders).find("\r\n\r\n") == std::string::npos) {
|
||||
if (totalReceived != resHeadersMaxSize && !std::string_view(resHeaders).contains("\r\n\r\n")) {
|
||||
delete[] resHeaders;
|
||||
return RET_ERROR(SCE_HTTP_ERROR_TIMEOUT);
|
||||
}
|
||||
|
||||
// Headers are too big
|
||||
if (totalReceived == resHeadersMaxSize && std::string_view(resHeaders).find("\r\n\r\n") == std::string::npos) {
|
||||
if (totalReceived == resHeadersMaxSize && !std::string_view(resHeaders).contains("\r\n\r\n")) {
|
||||
delete[] resHeaders;
|
||||
return RET_ERROR(SCE_HTTP_ERROR_TOO_LARGE_RESPONSE_HEADER);
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ static int kernel_stop_module(EmuEnvState &emuenv, SceUID module_id, SceSize arg
|
||||
EXPORT(SceUID, _sceKernelLoadStartModule, const char *moduleFileName, SceSize args, Ptr<const void> argp, SceUInt32 flags, const SceKernelLMOption *pOpt, int *pRes) {
|
||||
TRACY_FUNC(_sceKernelLoadStartModule, moduleFileName, args, argp, flags, pOpt, pRes);
|
||||
// Is workaround for fix crash on loading "rgpluginsgm_psvita" module, relate issue #1095 on github, delete this after fix it.
|
||||
if (std::string_view(moduleFileName).find("rgpluginsgm_psvita") != std::string::npos) {
|
||||
if (std::string_view(moduleFileName).contains("rgpluginsgm_psvita")) {
|
||||
LOG_WARN("Bypass load this module: {}", moduleFileName);
|
||||
return SCE_KERNEL_ERROR_MODULEMGR_INVALID_TYPE;
|
||||
}
|
||||
|
||||
@@ -186,7 +186,7 @@ EXPORT(int, sceSysmoduleIsLoadedInternal, SceSysmoduleInternalModuleId module_id
|
||||
return RET_ERROR(SCE_SYSMODULE_ERROR_INVALID_VALUE);
|
||||
|
||||
std::lock_guard<std::mutex> guard(emuenv.kernel.mutex);
|
||||
if (vector_utils::contains(emuenv.kernel.loaded_internal_sysmodules, module_id))
|
||||
if (std::ranges::contains(emuenv.kernel.loaded_internal_sysmodules, module_id))
|
||||
return SCE_SYSMODULE_LOADED;
|
||||
else
|
||||
return RET_ERROR(SCE_SYSMODULE_ERROR_UNLOADED);
|
||||
|
||||
@@ -16,7 +16,8 @@
|
||||
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
#include <net/socket.h>
|
||||
#include <util/bit_cast.h>
|
||||
|
||||
#include <bit>
|
||||
|
||||
static SceNetSockaddr convertP2PToPosix(const SceNetSockaddr *addr) {
|
||||
if (!addr) {
|
||||
|
||||
@@ -219,7 +219,7 @@ bool Voice::remove_patch(const MemState &mem, const Ptr<Patch> patch) {
|
||||
const std::lock_guard<std::mutex> guard(*voice_mutex);
|
||||
bool found = false;
|
||||
for (auto &patches_1 : patches) {
|
||||
if (vector_utils::contains(patches_1, patch)) {
|
||||
if (std::ranges::contains(patches_1, patch)) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ bool deliver_data(const MemState &mem, const std::vector<Voice *> &voice_queue,
|
||||
continue;
|
||||
|
||||
Voice *dest = patch->dest.get(mem);
|
||||
if (!dest || !vector_utils::contains(voice_queue, dest))
|
||||
if (!dest || !std::ranges::contains(voice_queue, dest))
|
||||
continue;
|
||||
|
||||
const std::lock_guard<std::mutex> guard(*dest->voice_mutex);
|
||||
|
||||
@@ -67,7 +67,7 @@ bool decrypt_install_nonpdrm(EmuEnvState &emuenv, const fs::path &drmlicpath, co
|
||||
if ((execute(zRIF, title_id_src, title_id_dst, f00d_enc_type, f00d_arg) < 0) && (title_path.string().find("theme") == std::string::npos))
|
||||
return false;
|
||||
|
||||
if (emuenv.app_info.app_category.find("gp") == std::string::npos)
|
||||
if (!emuenv.app_info.app_category.contains("gp"))
|
||||
copy_license(emuenv, drmlicpath);
|
||||
|
||||
fs::remove_all(title_id_src);
|
||||
|
||||
@@ -32,9 +32,9 @@ std::vector<Patch> get_patches(fs::path &path, const std::string &titleid, const
|
||||
// Just in case users decide to use lowercase filenames
|
||||
std::transform(filename.begin(), filename.end(), filename.begin(), ::toupper);
|
||||
|
||||
bool is_patchlist = filename.find("PATCHLIST.TXT") != std::string::npos;
|
||||
bool is_patchlist = filename.contains("PATCHLIST.TXT");
|
||||
|
||||
if ((filename.find(titleid) != std::string::npos && filename.ends_with(".TXT")) || is_patchlist) {
|
||||
if ((filename.contains(titleid) && filename.ends_with(".TXT")) || is_patchlist) {
|
||||
// Read the file
|
||||
std::ifstream file(entry.path().c_str());
|
||||
PatchHeader patch_header = PatchHeader{
|
||||
@@ -56,7 +56,7 @@ std::vector<Patch> get_patches(fs::path &path, const std::string &titleid, const
|
||||
|
||||
// Ignore comments and patches for other binaries
|
||||
// And @ lines for now
|
||||
if (line.empty() || line[0] == '#' || line[0] == '@' || bin.find(patch_header.bin) == std::string::npos || (is_patchlist && patch_header.titleid != titleid))
|
||||
if (line.empty() || line[0] == '#' || line[0] == '@' || !bin.contains(patch_header.bin) || (is_patchlist && patch_header.titleid != titleid))
|
||||
continue;
|
||||
|
||||
try {
|
||||
|
||||
@@ -67,7 +67,7 @@ static void init_reg_template(RegMgrState ®mgr, const std::string ®) {
|
||||
continue;
|
||||
|
||||
// Found the base register
|
||||
if (line.find("[BASE") != std::string::npos) {
|
||||
if (line.contains("[BASE")) {
|
||||
// Register the names with their numbers
|
||||
while (std::getline(iss, line) && (line != "[REG-BAS")) {
|
||||
if (line.empty())
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
#include <gxm/functions.h>
|
||||
#include <mem/ptr.h>
|
||||
#include <util/align.h>
|
||||
#include <util/bit_cast.h>
|
||||
#include <util/log.h>
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
@@ -98,7 +98,7 @@ static void debug_log_message(std::string_view msg) {
|
||||
|
||||
bool log_error = true;
|
||||
for (auto ignored_error : ignored_errors) {
|
||||
if (msg.find(ignored_error) != std::string_view::npos) {
|
||||
if (msg.contains(ignored_error)) {
|
||||
log_error = false;
|
||||
break;
|
||||
}
|
||||
@@ -977,7 +977,7 @@ void VKState::late_init(const Config &cfg, const std::string_view game_id, MemSt
|
||||
|
||||
#if defined(__linux__) && !defined(__ANDROID__) // According to my tests (Macdu), mprotect on buffers (mapped with external memory host) only works with Nvidia drivers
|
||||
surface_cache.can_mprotect_mapped_memory = mapping_method == MappingMethod::DoubleBuffer
|
||||
|| std::string_view(physical_device_properties.deviceName).find("NVIDIA") != std::string_view::npos;
|
||||
|| std::string_view(physical_device_properties.deviceName).contains("NVIDIA");
|
||||
#endif
|
||||
|
||||
pipeline_cache.init(support_rasterized_order_access);
|
||||
|
||||
@@ -17,8 +17,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <util/bit_cast.h>
|
||||
|
||||
#include <bit>
|
||||
#include <cstdint>
|
||||
|
||||
namespace shader::usse {
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
#include <shader/usse_program_analyzer.h>
|
||||
#include <shader/usse_utilities.h>
|
||||
|
||||
#include <util/bit_cast.h>
|
||||
#include <util/float_to_half.h>
|
||||
#include <util/log.h>
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@ add_library(
|
||||
STATIC
|
||||
src/android_driver.cpp
|
||||
src/arm.cpp
|
||||
src/byte.cpp
|
||||
src/float_to_half.cpp
|
||||
src/fs_utils.cpp
|
||||
src/hash.cpp
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
// Vita3K emulator project
|
||||
// Copyright (C) 2026 Vita3K team
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation; either version 2 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License along
|
||||
// with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <bit>
|
||||
#include <cstring>
|
||||
#include <type_traits>
|
||||
|
||||
#ifndef __cpp_lib_bit_cast
|
||||
namespace std {
|
||||
// https://en.cppreference.com/w/cpp/numeric/bit_cast
|
||||
template <class To, class From>
|
||||
std::enable_if_t<sizeof(To) == sizeof(From), To> bit_cast(const From &src) noexcept {
|
||||
if constexpr (alignof(From) >= alignof(To)) {
|
||||
return *reinterpret_cast<const To *>(&src);
|
||||
} else {
|
||||
alignas(alignof(To)) char dst[sizeof(To)];
|
||||
std::memcpy(&dst, &src, sizeof(To));
|
||||
return *reinterpret_cast<To *>(&dst);
|
||||
}
|
||||
}
|
||||
} // namespace std
|
||||
#endif
|
||||
@@ -18,18 +18,20 @@
|
||||
#pragma once
|
||||
|
||||
#include <bit>
|
||||
#include <cstdint>
|
||||
#include <concepts>
|
||||
|
||||
template <typename T>
|
||||
T byte_swap(T val);
|
||||
template <std::integral T>
|
||||
T byte_swap(T val) {
|
||||
return std::byteswap(val);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
template <std::integral T>
|
||||
T network_to_host_order(T val) {
|
||||
static_assert(((std::endian::native == std::endian::big) || (std::endian::native == std::endian::little)), "Mixed endian is unsupported");
|
||||
if constexpr (std::endian::native == std::endian::big) {
|
||||
return val;
|
||||
} else {
|
||||
return byte_swap(val);
|
||||
return std::byteswap(val);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -20,9 +20,9 @@
|
||||
// original source:https://stackoverflow.com/questions/1659440/32-bit-to-16-bit-floating-point-conversion
|
||||
// public domain
|
||||
|
||||
#include "util/bit_cast.h"
|
||||
#include "util/warning.h"
|
||||
|
||||
#include <bit> // bit_cast
|
||||
#include <climits> // CHAR_BIT
|
||||
#include <cstdint> // uint32_t, uint64_t, etc.
|
||||
#include <limits> // numeric_limits
|
||||
|
||||
@@ -57,8 +57,7 @@ size_t find_index(const T &v, const V &value) {
|
||||
|
||||
template <typename T, typename V>
|
||||
bool push_if_not_exists(T &v, const V &value) {
|
||||
auto it = std::find(v.begin(), v.end(), value);
|
||||
if (it == v.end()) {
|
||||
if (!std::ranges::contains(v, value)) {
|
||||
v.push_back(value);
|
||||
return false;
|
||||
} else {
|
||||
@@ -66,11 +65,6 @@ bool push_if_not_exists(T &v, const V &value) {
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T, typename V>
|
||||
bool contains(const T &v, const V &value) {
|
||||
return std::find(v.begin(), v.end(), value) != v.end();
|
||||
}
|
||||
|
||||
template <typename T, typename V>
|
||||
bool erase_first(T &v, const V &value) {
|
||||
auto it = std::find(v.begin(), v.end(), value);
|
||||
|
||||
@@ -1,52 +0,0 @@
|
||||
// Vita3K emulator project
|
||||
// Copyright (C) 2026 Vita3K team
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation; either version 2 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License along
|
||||
// with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
#include <util/bytes.h>
|
||||
|
||||
template <>
|
||||
uint16_t byte_swap(uint16_t val) {
|
||||
return (val >> 8) | (val << 8);
|
||||
}
|
||||
|
||||
template <>
|
||||
uint32_t byte_swap(uint32_t val) {
|
||||
// AA BB00 CC0000 DD000000
|
||||
return (val >> 24) | ((val >> 8) & 0xFF00) | ((val << 8) & 0xFF0000) | ((val << 24) & 0xFF000000);
|
||||
}
|
||||
|
||||
template <>
|
||||
uint64_t byte_swap(uint64_t val) {
|
||||
val = ((val << 8) & 0xFF00FF00FF00FF00ULL) | ((val >> 8) & 0x00FF00FF00FF00FFULL);
|
||||
val = ((val << 16) & 0xFFFF0000FFFF0000ULL) | ((val >> 16) & 0x0000FFFF0000FFFFULL);
|
||||
|
||||
return (val << 32) | (val >> 32);
|
||||
}
|
||||
|
||||
template <>
|
||||
int16_t byte_swap(int16_t val) {
|
||||
return byte_swap(static_cast<uint16_t>(val));
|
||||
}
|
||||
|
||||
template <>
|
||||
int32_t byte_swap(int32_t val) {
|
||||
return byte_swap(static_cast<uint32_t>(val));
|
||||
}
|
||||
|
||||
template <>
|
||||
int64_t byte_swap(int64_t val) {
|
||||
return byte_swap(static_cast<uint64_t>(val));
|
||||
}
|
||||
@@ -83,7 +83,7 @@ void load_from(const std::vector<std::string> &active_modules_str) {
|
||||
void cleanup(std::vector<std::string> &active_modules_str) {
|
||||
// remove if not found in tracy_available_advanced_profiling_modules
|
||||
std::erase_if(active_modules_str, [](const std::string &module) {
|
||||
return !vector_utils::contains(get_tracy_available_advanced_profiling_modules(), module);
|
||||
return !std::ranges::contains(get_tracy_available_advanced_profiling_modules(), module);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -17,9 +17,10 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <util/bit_cast.h>
|
||||
#include <vkutil/vkutil.h>
|
||||
|
||||
#include <bit>
|
||||
|
||||
namespace vkutil {
|
||||
|
||||
void init(vma::Allocator vma_allocator);
|
||||
|
||||
Reference in New Issue
Block a user