summaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
Diffstat (limited to 'src/common')
-rw-r--r--src/common/fs/fs_util.cpp4
-rw-r--r--src/common/fs/fs_util.h11
-rw-r--r--src/common/host_memory.cpp9
-rw-r--r--src/common/settings.cpp8
-rw-r--r--src/common/settings.h15
-rw-r--r--src/common/uuid.cpp2
6 files changed, 37 insertions, 12 deletions
diff --git a/src/common/fs/fs_util.cpp b/src/common/fs/fs_util.cpp
index 357cf5855..9f8671982 100644
--- a/src/common/fs/fs_util.cpp
+++ b/src/common/fs/fs_util.cpp
@@ -20,6 +20,10 @@ std::string ToUTF8String(std::u8string_view u8_string) {
20 return std::string{u8_string.begin(), u8_string.end()}; 20 return std::string{u8_string.begin(), u8_string.end()};
21} 21}
22 22
23std::string BufferToUTF8String(std::span<const u8> buffer) {
24 return std::string{buffer.begin(), std::ranges::find(buffer, u8{0})};
25}
26
23std::string PathToUTF8String(const std::filesystem::path& path) { 27std::string PathToUTF8String(const std::filesystem::path& path) {
24 return ToUTF8String(path.u8string()); 28 return ToUTF8String(path.u8string());
25} 29}
diff --git a/src/common/fs/fs_util.h b/src/common/fs/fs_util.h
index ec9950ee7..1ec82eb35 100644
--- a/src/common/fs/fs_util.h
+++ b/src/common/fs/fs_util.h
@@ -47,6 +47,17 @@ concept IsChar = std::same_as<T, char>;
47[[nodiscard]] std::string ToUTF8String(std::u8string_view u8_string); 47[[nodiscard]] std::string ToUTF8String(std::u8string_view u8_string);
48 48
49/** 49/**
50 * Converts a buffer of bytes to a UTF8-encoded std::string.
51 * This converts from the start of the buffer until the first encountered null-terminator.
52 * If no null-terminator is found, this converts the entire buffer instead.
53 *
54 * @param buffer Buffer of bytes
55 *
56 * @returns UTF-8 encoded std::string.
57 */
58[[nodiscard]] std::string BufferToUTF8String(std::span<const u8> buffer);
59
60/**
50 * Converts a filesystem path to a UTF-8 encoded std::string. 61 * Converts a filesystem path to a UTF-8 encoded std::string.
51 * 62 *
52 * @param path Filesystem path 63 * @param path Filesystem path
diff --git a/src/common/host_memory.cpp b/src/common/host_memory.cpp
index 2a5a7596c..6661244cf 100644
--- a/src/common/host_memory.cpp
+++ b/src/common/host_memory.cpp
@@ -6,7 +6,7 @@
6#include <windows.h> 6#include <windows.h>
7#include "common/dynamic_library.h" 7#include "common/dynamic_library.h"
8 8
9#elif defined(__linux__) // ^^^ Windows ^^^ vvv Linux vvv 9#elif defined(__linux__) || defined(__FreeBSD__) // ^^^ Windows ^^^ vvv Linux vvv
10 10
11#ifndef _GNU_SOURCE 11#ifndef _GNU_SOURCE
12#define _GNU_SOURCE 12#define _GNU_SOURCE
@@ -343,7 +343,7 @@ private:
343 std::unordered_map<size_t, size_t> placeholder_host_pointers; ///< Placeholder backing offset 343 std::unordered_map<size_t, size_t> placeholder_host_pointers; ///< Placeholder backing offset
344}; 344};
345 345
346#elif defined(__linux__) // ^^^ Windows ^^^ vvv Linux vvv 346#elif defined(__linux__) || defined(__FreeBSD__) // ^^^ Windows ^^^ vvv Linux vvv
347 347
348class HostMemory::Impl { 348class HostMemory::Impl {
349public: 349public:
@@ -357,7 +357,12 @@ public:
357 }); 357 });
358 358
359 // Backing memory initialization 359 // Backing memory initialization
360#if defined(__FreeBSD__) && __FreeBSD__ < 13
361 // XXX Drop after FreeBSD 12.* reaches EOL on 2024-06-30
362 fd = shm_open(SHM_ANON, O_RDWR, 0600);
363#else
360 fd = memfd_create("HostMemory", 0); 364 fd = memfd_create("HostMemory", 0);
365#endif
361 if (fd == -1) { 366 if (fd == -1) {
362 LOG_CRITICAL(HW_Memory, "memfd_create failed: {}", strerror(errno)); 367 LOG_CRITICAL(HW_Memory, "memfd_create failed: {}", strerror(errno));
363 throw std::bad_alloc{}; 368 throw std::bad_alloc{};
diff --git a/src/common/settings.cpp b/src/common/settings.cpp
index 66268ea0f..996315999 100644
--- a/src/common/settings.cpp
+++ b/src/common/settings.cpp
@@ -48,8 +48,8 @@ void LogSettings() {
48 log_setting("Core_UseMultiCore", values.use_multi_core.GetValue()); 48 log_setting("Core_UseMultiCore", values.use_multi_core.GetValue());
49 log_setting("CPU_Accuracy", values.cpu_accuracy.GetValue()); 49 log_setting("CPU_Accuracy", values.cpu_accuracy.GetValue());
50 log_setting("Renderer_UseResolutionFactor", values.resolution_factor.GetValue()); 50 log_setting("Renderer_UseResolutionFactor", values.resolution_factor.GetValue());
51 log_setting("Renderer_UseFrameLimit", values.use_frame_limit.GetValue()); 51 log_setting("Renderer_UseSpeedLimit", values.use_speed_limit.GetValue());
52 log_setting("Renderer_FrameLimit", values.frame_limit.GetValue()); 52 log_setting("Renderer_SpeedLimit", values.speed_limit.GetValue());
53 log_setting("Renderer_UseDiskShaderCache", values.use_disk_shader_cache.GetValue()); 53 log_setting("Renderer_UseDiskShaderCache", values.use_disk_shader_cache.GetValue());
54 log_setting("Renderer_GPUAccuracyLevel", values.gpu_accuracy.GetValue()); 54 log_setting("Renderer_GPUAccuracyLevel", values.gpu_accuracy.GetValue());
55 log_setting("Renderer_UseAsynchronousGpuEmulation", 55 log_setting("Renderer_UseAsynchronousGpuEmulation",
@@ -132,8 +132,8 @@ void RestoreGlobalState(bool is_powered_on) {
132 values.vulkan_device.SetGlobal(true); 132 values.vulkan_device.SetGlobal(true);
133 values.aspect_ratio.SetGlobal(true); 133 values.aspect_ratio.SetGlobal(true);
134 values.max_anisotropy.SetGlobal(true); 134 values.max_anisotropy.SetGlobal(true);
135 values.use_frame_limit.SetGlobal(true); 135 values.use_speed_limit.SetGlobal(true);
136 values.frame_limit.SetGlobal(true); 136 values.speed_limit.SetGlobal(true);
137 values.use_disk_shader_cache.SetGlobal(true); 137 values.use_disk_shader_cache.SetGlobal(true);
138 values.gpu_accuracy.SetGlobal(true); 138 values.gpu_accuracy.SetGlobal(true);
139 values.use_asynchronous_gpu_emulation.SetGlobal(true); 139 values.use_asynchronous_gpu_emulation.SetGlobal(true);
diff --git a/src/common/settings.h b/src/common/settings.h
index df1762d1b..cfc1ab46f 100644
--- a/src/common/settings.h
+++ b/src/common/settings.h
@@ -42,6 +42,11 @@ enum class CPUAccuracy : u32 {
42 Unsafe = 2, 42 Unsafe = 2,
43}; 43};
44 44
45enum class FullscreenMode : u32 {
46 Borderless = 0,
47 Exclusive = 1,
48};
49
45/** The BasicSetting class is a simple resource manager. It defines a label and default value 50/** The BasicSetting class is a simple resource manager. It defines a label and default value
46 * alongside the actual value of the setting for simpler and less-error prone use with frontend 51 * alongside the actual value of the setting for simpler and less-error prone use with frontend
47 * configurations. Setting a default value and label is required, though subclasses may deviate from 52 * configurations. Setting a default value and label is required, though subclasses may deviate from
@@ -322,17 +327,17 @@ struct Values {
322 Setting<u16> resolution_factor{1, "resolution_factor"}; 327 Setting<u16> resolution_factor{1, "resolution_factor"};
323 // *nix platforms may have issues with the borderless windowed fullscreen mode. 328 // *nix platforms may have issues with the borderless windowed fullscreen mode.
324 // Default to exclusive fullscreen on these platforms for now. 329 // Default to exclusive fullscreen on these platforms for now.
325 Setting<int> fullscreen_mode{ 330 Setting<FullscreenMode> fullscreen_mode{
326#ifdef _WIN32 331#ifdef _WIN32
327 0, 332 FullscreenMode::Borderless,
328#else 333#else
329 1, 334 FullscreenMode::Exclusive,
330#endif 335#endif
331 "fullscreen_mode"}; 336 "fullscreen_mode"};
332 Setting<int> aspect_ratio{0, "aspect_ratio"}; 337 Setting<int> aspect_ratio{0, "aspect_ratio"};
333 Setting<int> max_anisotropy{0, "max_anisotropy"}; 338 Setting<int> max_anisotropy{0, "max_anisotropy"};
334 Setting<bool> use_frame_limit{true, "use_frame_limit"}; 339 Setting<bool> use_speed_limit{true, "use_speed_limit"};
335 Setting<u16> frame_limit{100, "frame_limit"}; 340 Setting<u16> speed_limit{100, "speed_limit"};
336 Setting<bool> use_disk_shader_cache{true, "use_disk_shader_cache"}; 341 Setting<bool> use_disk_shader_cache{true, "use_disk_shader_cache"};
337 Setting<GPUAccuracy> gpu_accuracy{GPUAccuracy::High, "gpu_accuracy"}; 342 Setting<GPUAccuracy> gpu_accuracy{GPUAccuracy::High, "gpu_accuracy"};
338 Setting<bool> use_asynchronous_gpu_emulation{true, "use_asynchronous_gpu_emulation"}; 343 Setting<bool> use_asynchronous_gpu_emulation{true, "use_asynchronous_gpu_emulation"};
diff --git a/src/common/uuid.cpp b/src/common/uuid.cpp
index 26db03fba..18303a1e3 100644
--- a/src/common/uuid.cpp
+++ b/src/common/uuid.cpp
@@ -18,7 +18,7 @@ UUID UUID::Generate() {
18} 18}
19 19
20std::string UUID::Format() const { 20std::string UUID::Format() const {
21 return fmt::format("0x{:016X}{:016X}", uuid[1], uuid[0]); 21 return fmt::format("{:016x}{:016x}", uuid[1], uuid[0]);
22} 22}
23 23
24std::string UUID::FormatSwitch() const { 24std::string UUID::FormatSwitch() const {