diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/CMakeLists.txt | 1 | ||||
| -rw-r--r-- | src/core/hle/kernel/k_handle_table.cpp | 8 | ||||
| -rw-r--r-- | src/core/hle/kernel/k_handle_table.h | 34 | ||||
| -rw-r--r-- | src/core/hle/kernel/k_page_buffer.cpp | 19 | ||||
| -rw-r--r-- | src/core/hle/kernel/k_page_buffer.h | 9 | ||||
| -rw-r--r-- | src/core/hle/kernel/k_thread_local_page.cpp | 1 | ||||
| -rw-r--r-- | src/core/hle/service/sockets/bsd.cpp | 4 | ||||
| -rw-r--r-- | src/video_core/fence_manager.h | 2 | ||||
| -rw-r--r-- | src/video_core/query_cache.h | 1 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_state_tracker.h | 1 | ||||
| -rw-r--r-- | src/video_core/renderer_vulkan/vk_state_tracker.h | 1 | ||||
| -rw-r--r-- | src/video_core/texture_cache/texture_cache.h | 18 | ||||
| -rw-r--r-- | src/yuzu_cmd/config.cpp | 10 | ||||
| -rw-r--r-- | src/yuzu_cmd/config.h | 5 | ||||
| -rw-r--r-- | src/yuzu_cmd/yuzu.cpp | 22 |
15 files changed, 67 insertions, 69 deletions
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 1f234c822..1d4e92edb 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt | |||
| @@ -209,6 +209,7 @@ add_library(core STATIC | |||
| 209 | hle/kernel/k_memory_region.h | 209 | hle/kernel/k_memory_region.h |
| 210 | hle/kernel/k_memory_region_type.h | 210 | hle/kernel/k_memory_region_type.h |
| 211 | hle/kernel/k_page_bitmap.h | 211 | hle/kernel/k_page_bitmap.h |
| 212 | hle/kernel/k_page_buffer.cpp | ||
| 212 | hle/kernel/k_page_buffer.h | 213 | hle/kernel/k_page_buffer.h |
| 213 | hle/kernel/k_page_heap.cpp | 214 | hle/kernel/k_page_heap.cpp |
| 214 | hle/kernel/k_page_heap.h | 215 | hle/kernel/k_page_heap.h |
diff --git a/src/core/hle/kernel/k_handle_table.cpp b/src/core/hle/kernel/k_handle_table.cpp index cf95f0852..db7512ee7 100644 --- a/src/core/hle/kernel/k_handle_table.cpp +++ b/src/core/hle/kernel/k_handle_table.cpp | |||
| @@ -63,7 +63,7 @@ bool KHandleTable::Remove(Handle handle) { | |||
| 63 | return true; | 63 | return true; |
| 64 | } | 64 | } |
| 65 | 65 | ||
| 66 | ResultCode KHandleTable::Add(Handle* out_handle, KAutoObject* obj, u16 type) { | 66 | ResultCode KHandleTable::Add(Handle* out_handle, KAutoObject* obj) { |
| 67 | KScopedDisableDispatch dd(kernel); | 67 | KScopedDisableDispatch dd(kernel); |
| 68 | KScopedSpinLock lk(m_lock); | 68 | KScopedSpinLock lk(m_lock); |
| 69 | 69 | ||
| @@ -75,7 +75,7 @@ ResultCode KHandleTable::Add(Handle* out_handle, KAutoObject* obj, u16 type) { | |||
| 75 | const auto linear_id = this->AllocateLinearId(); | 75 | const auto linear_id = this->AllocateLinearId(); |
| 76 | const auto index = this->AllocateEntry(); | 76 | const auto index = this->AllocateEntry(); |
| 77 | 77 | ||
| 78 | m_entry_infos[index].info = {.linear_id = linear_id, .type = type}; | 78 | m_entry_infos[index].linear_id = linear_id; |
| 79 | m_objects[index] = obj; | 79 | m_objects[index] = obj; |
| 80 | 80 | ||
| 81 | obj->Open(); | 81 | obj->Open(); |
| @@ -116,7 +116,7 @@ void KHandleTable::Unreserve(Handle handle) { | |||
| 116 | } | 116 | } |
| 117 | } | 117 | } |
| 118 | 118 | ||
| 119 | void KHandleTable::Register(Handle handle, KAutoObject* obj, u16 type) { | 119 | void KHandleTable::Register(Handle handle, KAutoObject* obj) { |
| 120 | KScopedDisableDispatch dd(kernel); | 120 | KScopedDisableDispatch dd(kernel); |
| 121 | KScopedSpinLock lk(m_lock); | 121 | KScopedSpinLock lk(m_lock); |
| 122 | 122 | ||
| @@ -132,7 +132,7 @@ void KHandleTable::Register(Handle handle, KAutoObject* obj, u16 type) { | |||
| 132 | // Set the entry. | 132 | // Set the entry. |
| 133 | ASSERT(m_objects[index] == nullptr); | 133 | ASSERT(m_objects[index] == nullptr); |
| 134 | 134 | ||
| 135 | m_entry_infos[index].info = {.linear_id = static_cast<u16>(linear_id), .type = type}; | 135 | m_entry_infos[index].linear_id = static_cast<u16>(linear_id); |
| 136 | m_objects[index] = obj; | 136 | m_objects[index] = obj; |
| 137 | 137 | ||
| 138 | obj->Open(); | 138 | obj->Open(); |
diff --git a/src/core/hle/kernel/k_handle_table.h b/src/core/hle/kernel/k_handle_table.h index 87004a0f9..dd27689b6 100644 --- a/src/core/hle/kernel/k_handle_table.h +++ b/src/core/hle/kernel/k_handle_table.h | |||
| @@ -42,7 +42,7 @@ public: | |||
| 42 | m_free_head_index = -1; | 42 | m_free_head_index = -1; |
| 43 | 43 | ||
| 44 | // Free all entries. | 44 | // Free all entries. |
| 45 | for (s32 i = 0; i < static_cast<s32>(m_table_size); ++i) { | 45 | for (s16 i = 0; i < static_cast<s16>(m_table_size); ++i) { |
| 46 | m_objects[i] = nullptr; | 46 | m_objects[i] = nullptr; |
| 47 | m_entry_infos[i].next_free_index = i - 1; | 47 | m_entry_infos[i].next_free_index = i - 1; |
| 48 | m_free_head_index = i; | 48 | m_free_head_index = i; |
| @@ -104,17 +104,8 @@ public: | |||
| 104 | ResultCode Reserve(Handle* out_handle); | 104 | ResultCode Reserve(Handle* out_handle); |
| 105 | void Unreserve(Handle handle); | 105 | void Unreserve(Handle handle); |
| 106 | 106 | ||
| 107 | template <typename T> | 107 | ResultCode Add(Handle* out_handle, KAutoObject* obj); |
| 108 | ResultCode Add(Handle* out_handle, T* obj) { | 108 | void Register(Handle handle, KAutoObject* obj); |
| 109 | static_assert(std::is_base_of_v<KAutoObject, T>); | ||
| 110 | return this->Add(out_handle, obj, obj->GetTypeObj().GetClassToken()); | ||
| 111 | } | ||
| 112 | |||
| 113 | template <typename T> | ||
| 114 | void Register(Handle handle, T* obj) { | ||
| 115 | static_assert(std::is_base_of_v<KAutoObject, T>); | ||
| 116 | return this->Register(handle, obj, obj->GetTypeObj().GetClassToken()); | ||
| 117 | } | ||
| 118 | 109 | ||
| 119 | template <typename T> | 110 | template <typename T> |
| 120 | bool GetMultipleObjects(T** out, const Handle* handles, size_t num_handles) const { | 111 | bool GetMultipleObjects(T** out, const Handle* handles, size_t num_handles) const { |
| @@ -160,9 +151,6 @@ public: | |||
| 160 | } | 151 | } |
| 161 | 152 | ||
| 162 | private: | 153 | private: |
| 163 | ResultCode Add(Handle* out_handle, KAutoObject* obj, u16 type); | ||
| 164 | void Register(Handle handle, KAutoObject* obj, u16 type); | ||
| 165 | |||
| 166 | s32 AllocateEntry() { | 154 | s32 AllocateEntry() { |
| 167 | ASSERT(m_count < m_table_size); | 155 | ASSERT(m_count < m_table_size); |
| 168 | 156 | ||
| @@ -179,7 +167,7 @@ private: | |||
| 179 | ASSERT(m_count > 0); | 167 | ASSERT(m_count > 0); |
| 180 | 168 | ||
| 181 | m_objects[index] = nullptr; | 169 | m_objects[index] = nullptr; |
| 182 | m_entry_infos[index].next_free_index = m_free_head_index; | 170 | m_entry_infos[index].next_free_index = static_cast<s16>(m_free_head_index); |
| 183 | 171 | ||
| 184 | m_free_head_index = index; | 172 | m_free_head_index = index; |
| 185 | 173 | ||
| @@ -278,19 +266,13 @@ private: | |||
| 278 | } | 266 | } |
| 279 | 267 | ||
| 280 | union EntryInfo { | 268 | union EntryInfo { |
| 281 | struct { | 269 | u16 linear_id; |
| 282 | u16 linear_id; | 270 | s16 next_free_index; |
| 283 | u16 type; | ||
| 284 | } info; | ||
| 285 | s32 next_free_index; | ||
| 286 | 271 | ||
| 287 | constexpr u16 GetLinearId() const { | 272 | constexpr u16 GetLinearId() const { |
| 288 | return info.linear_id; | 273 | return linear_id; |
| 289 | } | ||
| 290 | constexpr u16 GetType() const { | ||
| 291 | return info.type; | ||
| 292 | } | 274 | } |
| 293 | constexpr s32 GetNextFreeIndex() const { | 275 | constexpr s16 GetNextFreeIndex() const { |
| 294 | return next_free_index; | 276 | return next_free_index; |
| 295 | } | 277 | } |
| 296 | }; | 278 | }; |
diff --git a/src/core/hle/kernel/k_page_buffer.cpp b/src/core/hle/kernel/k_page_buffer.cpp new file mode 100644 index 000000000..f7df4a9a8 --- /dev/null +++ b/src/core/hle/kernel/k_page_buffer.cpp | |||
| @@ -0,0 +1,19 @@ | |||
| 1 | // Copyright 2022 yuzu Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #include "common/alignment.h" | ||
| 6 | #include "common/assert.h" | ||
| 7 | #include "core/core.h" | ||
| 8 | #include "core/device_memory.h" | ||
| 9 | #include "core/hle/kernel/k_page_buffer.h" | ||
| 10 | #include "core/hle/kernel/memory_types.h" | ||
| 11 | |||
| 12 | namespace Kernel { | ||
| 13 | |||
| 14 | KPageBuffer* KPageBuffer::FromPhysicalAddress(Core::System& system, PAddr phys_addr) { | ||
| 15 | ASSERT(Common::IsAligned(phys_addr, PageSize)); | ||
| 16 | return reinterpret_cast<KPageBuffer*>(system.DeviceMemory().GetPointer(phys_addr)); | ||
| 17 | } | ||
| 18 | |||
| 19 | } // namespace Kernel | ||
diff --git a/src/core/hle/kernel/k_page_buffer.h b/src/core/hle/kernel/k_page_buffer.h index 0a9451228..6ff3c1568 100644 --- a/src/core/hle/kernel/k_page_buffer.h +++ b/src/core/hle/kernel/k_page_buffer.h | |||
| @@ -6,12 +6,10 @@ | |||
| 6 | 6 | ||
| 7 | #include <array> | 7 | #include <array> |
| 8 | 8 | ||
| 9 | #include "common/alignment.h" | ||
| 10 | #include "common/assert.h" | ||
| 11 | #include "common/common_types.h" | 9 | #include "common/common_types.h" |
| 12 | #include "core/core.h" | ||
| 13 | #include "core/device_memory.h" | 10 | #include "core/device_memory.h" |
| 14 | #include "core/hle/kernel/memory_types.h" | 11 | #include "core/hle/kernel/memory_types.h" |
| 12 | #include "core/hle/kernel/slab_helpers.h" | ||
| 15 | 13 | ||
| 16 | namespace Kernel { | 14 | namespace Kernel { |
| 17 | 15 | ||
| @@ -19,10 +17,7 @@ class KPageBuffer final : public KSlabAllocated<KPageBuffer> { | |||
| 19 | public: | 17 | public: |
| 20 | KPageBuffer() = default; | 18 | KPageBuffer() = default; |
| 21 | 19 | ||
| 22 | static KPageBuffer* FromPhysicalAddress(Core::System& system, PAddr phys_addr) { | 20 | static KPageBuffer* FromPhysicalAddress(Core::System& system, PAddr phys_addr); |
| 23 | ASSERT(Common::IsAligned(phys_addr, PageSize)); | ||
| 24 | return reinterpret_cast<KPageBuffer*>(system.DeviceMemory().GetPointer(phys_addr)); | ||
| 25 | } | ||
| 26 | 21 | ||
| 27 | private: | 22 | private: |
| 28 | [[maybe_unused]] alignas(PageSize) std::array<u8, PageSize> m_buffer{}; | 23 | [[maybe_unused]] alignas(PageSize) std::array<u8, PageSize> m_buffer{}; |
diff --git a/src/core/hle/kernel/k_thread_local_page.cpp b/src/core/hle/kernel/k_thread_local_page.cpp index 4653c29f6..17b233fca 100644 --- a/src/core/hle/kernel/k_thread_local_page.cpp +++ b/src/core/hle/kernel/k_thread_local_page.cpp | |||
| @@ -3,6 +3,7 @@ | |||
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include "common/scope_exit.h" | 5 | #include "common/scope_exit.h" |
| 6 | #include "core/core.h" | ||
| 6 | #include "core/hle/kernel/k_memory_block.h" | 7 | #include "core/hle/kernel/k_memory_block.h" |
| 7 | #include "core/hle/kernel/k_page_table.h" | 8 | #include "core/hle/kernel/k_page_table.h" |
| 8 | #include "core/hle/kernel/k_process.h" | 9 | #include "core/hle/kernel/k_process.h" |
diff --git a/src/core/hle/service/sockets/bsd.cpp b/src/core/hle/service/sockets/bsd.cpp index f83272633..3dbac5a23 100644 --- a/src/core/hle/service/sockets/bsd.cpp +++ b/src/core/hle/service/sockets/bsd.cpp | |||
| @@ -569,9 +569,9 @@ std::pair<s32, Errno> BSD::AcceptImpl(s32 fd, std::vector<u8>& write_buffer) { | |||
| 569 | new_descriptor.socket = std::move(result.socket); | 569 | new_descriptor.socket = std::move(result.socket); |
| 570 | new_descriptor.is_connection_based = descriptor.is_connection_based; | 570 | new_descriptor.is_connection_based = descriptor.is_connection_based; |
| 571 | 571 | ||
| 572 | ASSERT(write_buffer.size() == sizeof(SockAddrIn)); | ||
| 573 | const SockAddrIn guest_addr_in = Translate(result.sockaddr_in); | 572 | const SockAddrIn guest_addr_in = Translate(result.sockaddr_in); |
| 574 | std::memcpy(write_buffer.data(), &guest_addr_in, sizeof(guest_addr_in)); | 573 | const size_t length = std::min(sizeof(guest_addr_in), write_buffer.size()); |
| 574 | std::memcpy(write_buffer.data(), &guest_addr_in, length); | ||
| 575 | 575 | ||
| 576 | return {new_fd, Errno::SUCCESS}; | 576 | return {new_fd, Errno::SUCCESS}; |
| 577 | } | 577 | } |
diff --git a/src/video_core/fence_manager.h b/src/video_core/fence_manager.h index 34dc6c596..f80d62c80 100644 --- a/src/video_core/fence_manager.h +++ b/src/video_core/fence_manager.h | |||
| @@ -8,8 +8,6 @@ | |||
| 8 | #include <queue> | 8 | #include <queue> |
| 9 | 9 | ||
| 10 | #include "common/common_types.h" | 10 | #include "common/common_types.h" |
| 11 | #include "common/settings.h" | ||
| 12 | #include "core/core.h" | ||
| 13 | #include "video_core/delayed_destruction_ring.h" | 11 | #include "video_core/delayed_destruction_ring.h" |
| 14 | #include "video_core/gpu.h" | 12 | #include "video_core/gpu.h" |
| 15 | #include "video_core/memory_manager.h" | 13 | #include "video_core/memory_manager.h" |
diff --git a/src/video_core/query_cache.h b/src/video_core/query_cache.h index 392f82eb7..0173b54d8 100644 --- a/src/video_core/query_cache.h +++ b/src/video_core/query_cache.h | |||
| @@ -18,7 +18,6 @@ | |||
| 18 | 18 | ||
| 19 | #include "common/assert.h" | 19 | #include "common/assert.h" |
| 20 | #include "common/settings.h" | 20 | #include "common/settings.h" |
| 21 | #include "core/core.h" | ||
| 22 | #include "video_core/engines/maxwell_3d.h" | 21 | #include "video_core/engines/maxwell_3d.h" |
| 23 | #include "video_core/gpu.h" | 22 | #include "video_core/gpu.h" |
| 24 | #include "video_core/memory_manager.h" | 23 | #include "video_core/memory_manager.h" |
diff --git a/src/video_core/renderer_opengl/gl_state_tracker.h b/src/video_core/renderer_opengl/gl_state_tracker.h index 5864c7c07..550ed6d36 100644 --- a/src/video_core/renderer_opengl/gl_state_tracker.h +++ b/src/video_core/renderer_opengl/gl_state_tracker.h | |||
| @@ -9,7 +9,6 @@ | |||
| 9 | #include <glad/glad.h> | 9 | #include <glad/glad.h> |
| 10 | 10 | ||
| 11 | #include "common/common_types.h" | 11 | #include "common/common_types.h" |
| 12 | #include "core/core.h" | ||
| 13 | #include "video_core/dirty_flags.h" | 12 | #include "video_core/dirty_flags.h" |
| 14 | #include "video_core/engines/maxwell_3d.h" | 13 | #include "video_core/engines/maxwell_3d.h" |
| 15 | 14 | ||
diff --git a/src/video_core/renderer_vulkan/vk_state_tracker.h b/src/video_core/renderer_vulkan/vk_state_tracker.h index 40a149832..8240c83e1 100644 --- a/src/video_core/renderer_vulkan/vk_state_tracker.h +++ b/src/video_core/renderer_vulkan/vk_state_tracker.h | |||
| @@ -8,7 +8,6 @@ | |||
| 8 | #include <limits> | 8 | #include <limits> |
| 9 | 9 | ||
| 10 | #include "common/common_types.h" | 10 | #include "common/common_types.h" |
| 11 | #include "core/core.h" | ||
| 12 | #include "video_core/dirty_flags.h" | 11 | #include "video_core/dirty_flags.h" |
| 13 | #include "video_core/engines/maxwell_3d.h" | 12 | #include "video_core/engines/maxwell_3d.h" |
| 14 | 13 | ||
diff --git a/src/video_core/texture_cache/texture_cache.h b/src/video_core/texture_cache/texture_cache.h index 198bb0cfb..72eeb8bbd 100644 --- a/src/video_core/texture_cache/texture_cache.h +++ b/src/video_core/texture_cache/texture_cache.h | |||
| @@ -343,7 +343,7 @@ template <bool has_blacklists> | |||
| 343 | void TextureCache<P>::FillImageViews(DescriptorTable<TICEntry>& table, | 343 | void TextureCache<P>::FillImageViews(DescriptorTable<TICEntry>& table, |
| 344 | std::span<ImageViewId> cached_image_view_ids, | 344 | std::span<ImageViewId> cached_image_view_ids, |
| 345 | std::span<ImageViewInOut> views) { | 345 | std::span<ImageViewInOut> views) { |
| 346 | bool has_blacklisted; | 346 | bool has_blacklisted = false; |
| 347 | do { | 347 | do { |
| 348 | has_deleted_images = false; | 348 | has_deleted_images = false; |
| 349 | if constexpr (has_blacklists) { | 349 | if constexpr (has_blacklists) { |
| @@ -1725,7 +1725,7 @@ void TextureCache<P>::SynchronizeAliases(ImageId image_id) { | |||
| 1725 | }); | 1725 | }); |
| 1726 | const auto& resolution = Settings::values.resolution_info; | 1726 | const auto& resolution = Settings::values.resolution_info; |
| 1727 | for (const AliasedImage* const aliased : aliased_images) { | 1727 | for (const AliasedImage* const aliased : aliased_images) { |
| 1728 | if (!resolution.active | !any_rescaled) { | 1728 | if (!resolution.active || !any_rescaled) { |
| 1729 | CopyImage(image_id, aliased->id, aliased->copies); | 1729 | CopyImage(image_id, aliased->id, aliased->copies); |
| 1730 | continue; | 1730 | continue; |
| 1731 | } | 1731 | } |
| @@ -1736,19 +1736,7 @@ void TextureCache<P>::SynchronizeAliases(ImageId image_id) { | |||
| 1736 | continue; | 1736 | continue; |
| 1737 | } | 1737 | } |
| 1738 | ScaleUp(aliased_image); | 1738 | ScaleUp(aliased_image); |
| 1739 | 1739 | CopyImage(image_id, aliased->id, aliased->copies); | |
| 1740 | const bool both_2d{image.info.type == ImageType::e2D && | ||
| 1741 | aliased_image.info.type == ImageType::e2D}; | ||
| 1742 | auto copies = aliased->copies; | ||
| 1743 | for (auto copy : copies) { | ||
| 1744 | copy.extent.width = std::max<u32>( | ||
| 1745 | (copy.extent.width * resolution.up_scale) >> resolution.down_shift, 1); | ||
| 1746 | if (both_2d) { | ||
| 1747 | copy.extent.height = std::max<u32>( | ||
| 1748 | (copy.extent.height * resolution.up_scale) >> resolution.down_shift, 1); | ||
| 1749 | } | ||
| 1750 | } | ||
| 1751 | CopyImage(image_id, aliased->id, copies); | ||
| 1752 | } | 1740 | } |
| 1753 | } | 1741 | } |
| 1754 | 1742 | ||
diff --git a/src/yuzu_cmd/config.cpp b/src/yuzu_cmd/config.cpp index b74411c84..131bc2201 100644 --- a/src/yuzu_cmd/config.cpp +++ b/src/yuzu_cmd/config.cpp | |||
| @@ -3,6 +3,7 @@ | |||
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include <memory> | 5 | #include <memory> |
| 6 | #include <optional> | ||
| 6 | #include <sstream> | 7 | #include <sstream> |
| 7 | 8 | ||
| 8 | // Ignore -Wimplicit-fallthrough due to https://github.com/libsdl-org/SDL/issues/4307 | 9 | // Ignore -Wimplicit-fallthrough due to https://github.com/libsdl-org/SDL/issues/4307 |
| @@ -29,11 +30,12 @@ | |||
| 29 | 30 | ||
| 30 | namespace FS = Common::FS; | 31 | namespace FS = Common::FS; |
| 31 | 32 | ||
| 32 | Config::Config() { | 33 | const std::filesystem::path default_config_path = |
| 33 | // TODO: Don't hardcode the path; let the frontend decide where to put the config files. | 34 | FS::GetYuzuPath(FS::YuzuPath::ConfigDir) / "sdl2-config.ini"; |
| 34 | sdl2_config_loc = FS::GetYuzuPath(FS::YuzuPath::ConfigDir) / "sdl2-config.ini"; | ||
| 35 | sdl2_config = std::make_unique<INIReader>(FS::PathToUTF8String(sdl2_config_loc)); | ||
| 36 | 35 | ||
| 36 | Config::Config(std::optional<std::filesystem::path> config_path) | ||
| 37 | : sdl2_config_loc{config_path.value_or(default_config_path)}, | ||
| 38 | sdl2_config{std::make_unique<INIReader>(FS::PathToUTF8String(sdl2_config_loc))} { | ||
| 37 | Reload(); | 39 | Reload(); |
| 38 | } | 40 | } |
| 39 | 41 | ||
diff --git a/src/yuzu_cmd/config.h b/src/yuzu_cmd/config.h index 1ee932be2..f61ba23ec 100644 --- a/src/yuzu_cmd/config.h +++ b/src/yuzu_cmd/config.h | |||
| @@ -6,6 +6,7 @@ | |||
| 6 | 6 | ||
| 7 | #include <filesystem> | 7 | #include <filesystem> |
| 8 | #include <memory> | 8 | #include <memory> |
| 9 | #include <optional> | ||
| 9 | #include <string> | 10 | #include <string> |
| 10 | 11 | ||
| 11 | #include "common/settings.h" | 12 | #include "common/settings.h" |
| @@ -13,14 +14,14 @@ | |||
| 13 | class INIReader; | 14 | class INIReader; |
| 14 | 15 | ||
| 15 | class Config { | 16 | class Config { |
| 16 | std::unique_ptr<INIReader> sdl2_config; | ||
| 17 | std::filesystem::path sdl2_config_loc; | 17 | std::filesystem::path sdl2_config_loc; |
| 18 | std::unique_ptr<INIReader> sdl2_config; | ||
| 18 | 19 | ||
| 19 | bool LoadINI(const std::string& default_contents = "", bool retry = true); | 20 | bool LoadINI(const std::string& default_contents = "", bool retry = true); |
| 20 | void ReadValues(); | 21 | void ReadValues(); |
| 21 | 22 | ||
| 22 | public: | 23 | public: |
| 23 | Config(); | 24 | explicit Config(std::optional<std::filesystem::path> config_path); |
| 24 | ~Config(); | 25 | ~Config(); |
| 25 | 26 | ||
| 26 | void Reload(); | 27 | void Reload(); |
diff --git a/src/yuzu_cmd/yuzu.cpp b/src/yuzu_cmd/yuzu.cpp index b44ea0cc4..f6d563017 100644 --- a/src/yuzu_cmd/yuzu.cpp +++ b/src/yuzu_cmd/yuzu.cpp | |||
| @@ -66,7 +66,8 @@ static void PrintHelp(const char* argv0) { | |||
| 66 | "-f, --fullscreen Start in fullscreen mode\n" | 66 | "-f, --fullscreen Start in fullscreen mode\n" |
| 67 | "-h, --help Display this help and exit\n" | 67 | "-h, --help Display this help and exit\n" |
| 68 | "-v, --version Output version information and exit\n" | 68 | "-v, --version Output version information and exit\n" |
| 69 | "-p, --program Pass following string as arguments to executable\n"; | 69 | "-p, --program Pass following string as arguments to executable\n" |
| 70 | "-c, --config Load the specified configuration file\n"; | ||
| 70 | } | 71 | } |
| 71 | 72 | ||
| 72 | static void PrintVersion() { | 73 | static void PrintVersion() { |
| @@ -78,7 +79,6 @@ int main(int argc, char** argv) { | |||
| 78 | Common::Log::Initialize(); | 79 | Common::Log::Initialize(); |
| 79 | Common::Log::SetColorConsoleBackendEnabled(true); | 80 | Common::Log::SetColorConsoleBackendEnabled(true); |
| 80 | Common::DetachedTasks detached_tasks; | 81 | Common::DetachedTasks detached_tasks; |
| 81 | Config config; | ||
| 82 | 82 | ||
| 83 | int option_index = 0; | 83 | int option_index = 0; |
| 84 | #ifdef _WIN32 | 84 | #ifdef _WIN32 |
| @@ -91,19 +91,24 @@ int main(int argc, char** argv) { | |||
| 91 | } | 91 | } |
| 92 | #endif | 92 | #endif |
| 93 | std::string filepath; | 93 | std::string filepath; |
| 94 | std::optional<std::string> config_path; | ||
| 95 | std::string program_args; | ||
| 94 | 96 | ||
| 95 | bool fullscreen = false; | 97 | bool fullscreen = false; |
| 96 | 98 | ||
| 97 | static struct option long_options[] = { | 99 | static struct option long_options[] = { |
| 100 | // clang-format off | ||
| 98 | {"fullscreen", no_argument, 0, 'f'}, | 101 | {"fullscreen", no_argument, 0, 'f'}, |
| 99 | {"help", no_argument, 0, 'h'}, | 102 | {"help", no_argument, 0, 'h'}, |
| 100 | {"version", no_argument, 0, 'v'}, | 103 | {"version", no_argument, 0, 'v'}, |
| 101 | {"program", optional_argument, 0, 'p'}, | 104 | {"program", optional_argument, 0, 'p'}, |
| 105 | {"config", required_argument, 0, 'c'}, | ||
| 102 | {0, 0, 0, 0}, | 106 | {0, 0, 0, 0}, |
| 107 | // clang-format on | ||
| 103 | }; | 108 | }; |
| 104 | 109 | ||
| 105 | while (optind < argc) { | 110 | while (optind < argc) { |
| 106 | int arg = getopt_long(argc, argv, "g:fhvp::", long_options, &option_index); | 111 | int arg = getopt_long(argc, argv, "g:fhvp::c:", long_options, &option_index); |
| 107 | if (arg != -1) { | 112 | if (arg != -1) { |
| 108 | switch (static_cast<char>(arg)) { | 113 | switch (static_cast<char>(arg)) { |
| 109 | case 'f': | 114 | case 'f': |
| @@ -117,9 +122,12 @@ int main(int argc, char** argv) { | |||
| 117 | PrintVersion(); | 122 | PrintVersion(); |
| 118 | return 0; | 123 | return 0; |
| 119 | case 'p': | 124 | case 'p': |
| 120 | Settings::values.program_args = argv[optind]; | 125 | program_args = argv[optind]; |
| 121 | ++optind; | 126 | ++optind; |
| 122 | break; | 127 | break; |
| 128 | case 'c': | ||
| 129 | config_path = optarg; | ||
| 130 | break; | ||
| 123 | } | 131 | } |
| 124 | } else { | 132 | } else { |
| 125 | #ifdef _WIN32 | 133 | #ifdef _WIN32 |
| @@ -131,6 +139,12 @@ int main(int argc, char** argv) { | |||
| 131 | } | 139 | } |
| 132 | } | 140 | } |
| 133 | 141 | ||
| 142 | Config config{config_path}; | ||
| 143 | |||
| 144 | if (!program_args.empty()) { | ||
| 145 | Settings::values.program_args = program_args; | ||
| 146 | } | ||
| 147 | |||
| 134 | #ifdef _WIN32 | 148 | #ifdef _WIN32 |
| 135 | LocalFree(argv_w); | 149 | LocalFree(argv_w); |
| 136 | #endif | 150 | #endif |