diff options
Diffstat (limited to 'src')
| -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/video_core/buffer_cache/buffer_cache.h | 20 | ||||
| -rw-r--r-- | src/video_core/renderer_vulkan/vk_texture_cache.cpp | 5 | ||||
| -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 |
8 files changed, 56 insertions, 66 deletions
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/video_core/buffer_cache/buffer_cache.h b/src/video_core/buffer_cache/buffer_cache.h index 77fdd6547..200d792dd 100644 --- a/src/video_core/buffer_cache/buffer_cache.h +++ b/src/video_core/buffer_cache/buffer_cache.h | |||
| @@ -1467,19 +1467,27 @@ typename BufferCache<P>::OverlapResult BufferCache<P>::ResolveOverlaps(VAddr cpu | |||
| 1467 | overlap_ids.push_back(overlap_id); | 1467 | overlap_ids.push_back(overlap_id); |
| 1468 | overlap.Pick(); | 1468 | overlap.Pick(); |
| 1469 | const VAddr overlap_cpu_addr = overlap.CpuAddr(); | 1469 | const VAddr overlap_cpu_addr = overlap.CpuAddr(); |
| 1470 | if (overlap_cpu_addr < begin) { | 1470 | const bool expands_left = overlap_cpu_addr < begin; |
| 1471 | if (expands_left) { | ||
| 1471 | cpu_addr = begin = overlap_cpu_addr; | 1472 | cpu_addr = begin = overlap_cpu_addr; |
| 1472 | } | 1473 | } |
| 1473 | end = std::max(end, overlap_cpu_addr + overlap.SizeBytes()); | 1474 | const VAddr overlap_end = overlap_cpu_addr + overlap.SizeBytes(); |
| 1474 | 1475 | const bool expands_right = overlap_end > end; | |
| 1476 | if (overlap_end > end) { | ||
| 1477 | end = overlap_end; | ||
| 1478 | } | ||
| 1475 | stream_score += overlap.StreamScore(); | 1479 | stream_score += overlap.StreamScore(); |
| 1476 | if (stream_score > STREAM_LEAP_THRESHOLD && !has_stream_leap) { | 1480 | if (stream_score > STREAM_LEAP_THRESHOLD && !has_stream_leap) { |
| 1477 | // When this memory region has been joined a bunch of times, we assume it's being used | 1481 | // When this memory region has been joined a bunch of times, we assume it's being used |
| 1478 | // as a stream buffer. Increase the size to skip constantly recreating buffers. | 1482 | // as a stream buffer. Increase the size to skip constantly recreating buffers. |
| 1479 | has_stream_leap = true; | 1483 | has_stream_leap = true; |
| 1480 | begin -= PAGE_SIZE * 256; | 1484 | if (expands_right) { |
| 1481 | cpu_addr = begin; | 1485 | begin -= PAGE_SIZE * 256; |
| 1482 | end += PAGE_SIZE * 256; | 1486 | cpu_addr = begin; |
| 1487 | } | ||
| 1488 | if (expands_left) { | ||
| 1489 | end += PAGE_SIZE * 256; | ||
| 1490 | } | ||
| 1483 | } | 1491 | } |
| 1484 | } | 1492 | } |
| 1485 | return OverlapResult{ | 1493 | return OverlapResult{ |
diff --git a/src/video_core/renderer_vulkan/vk_texture_cache.cpp b/src/video_core/renderer_vulkan/vk_texture_cache.cpp index 8101eb42c..83a23b66a 100644 --- a/src/video_core/renderer_vulkan/vk_texture_cache.cpp +++ b/src/video_core/renderer_vulkan/vk_texture_cache.cpp | |||
| @@ -781,11 +781,6 @@ bool TextureCacheRuntime::ShouldReinterpret(Image& dst, Image& src) { | |||
| 781 | !device.IsExtShaderStencilExportSupported()) { | 781 | !device.IsExtShaderStencilExportSupported()) { |
| 782 | return true; | 782 | return true; |
| 783 | } | 783 | } |
| 784 | if (VideoCore::Surface::GetFormatType(src.info.format) == | ||
| 785 | VideoCore::Surface::SurfaceType::DepthStencil && | ||
| 786 | !device.IsExtShaderStencilExportSupported()) { | ||
| 787 | return true; | ||
| 788 | } | ||
| 789 | if (dst.info.format == PixelFormat::D32_FLOAT_S8_UINT || | 784 | if (dst.info.format == PixelFormat::D32_FLOAT_S8_UINT || |
| 790 | src.info.format == PixelFormat::D32_FLOAT_S8_UINT) { | 785 | src.info.format == PixelFormat::D32_FLOAT_S8_UINT) { |
| 791 | return true; | 786 | return true; |
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 f93b76a4f..fc16f0f0c 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 |
| @@ -28,11 +29,12 @@ | |||
| 28 | 29 | ||
| 29 | namespace FS = Common::FS; | 30 | namespace FS = Common::FS; |
| 30 | 31 | ||
| 31 | Config::Config() { | 32 | const std::filesystem::path default_config_path = |
| 32 | // TODO: Don't hardcode the path; let the frontend decide where to put the config files. | 33 | FS::GetYuzuPath(FS::YuzuPath::ConfigDir) / "sdl2-config.ini"; |
| 33 | sdl2_config_loc = FS::GetYuzuPath(FS::YuzuPath::ConfigDir) / "sdl2-config.ini"; | ||
| 34 | sdl2_config = std::make_unique<INIReader>(FS::PathToUTF8String(sdl2_config_loc)); | ||
| 35 | 34 | ||
| 35 | Config::Config(std::optional<std::filesystem::path> config_path) | ||
| 36 | : sdl2_config_loc{config_path.value_or(default_config_path)}, | ||
| 37 | sdl2_config{std::make_unique<INIReader>(FS::PathToUTF8String(sdl2_config_loc))} { | ||
| 36 | Reload(); | 38 | Reload(); |
| 37 | } | 39 | } |
| 38 | 40 | ||
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 8198cde16..14bf82f39 100644 --- a/src/yuzu_cmd/yuzu.cpp +++ b/src/yuzu_cmd/yuzu.cpp | |||
| @@ -62,7 +62,8 @@ static void PrintHelp(const char* argv0) { | |||
| 62 | "-f, --fullscreen Start in fullscreen mode\n" | 62 | "-f, --fullscreen Start in fullscreen mode\n" |
| 63 | "-h, --help Display this help and exit\n" | 63 | "-h, --help Display this help and exit\n" |
| 64 | "-v, --version Output version information and exit\n" | 64 | "-v, --version Output version information and exit\n" |
| 65 | "-p, --program Pass following string as arguments to executable\n"; | 65 | "-p, --program Pass following string as arguments to executable\n" |
| 66 | "-c, --config Load the specified configuration file\n"; | ||
| 66 | } | 67 | } |
| 67 | 68 | ||
| 68 | static void PrintVersion() { | 69 | static void PrintVersion() { |
| @@ -74,7 +75,6 @@ int main(int argc, char** argv) { | |||
| 74 | Common::Log::Initialize(); | 75 | Common::Log::Initialize(); |
| 75 | Common::Log::SetColorConsoleBackendEnabled(true); | 76 | Common::Log::SetColorConsoleBackendEnabled(true); |
| 76 | Common::DetachedTasks detached_tasks; | 77 | Common::DetachedTasks detached_tasks; |
| 77 | Config config; | ||
| 78 | 78 | ||
| 79 | int option_index = 0; | 79 | int option_index = 0; |
| 80 | #ifdef _WIN32 | 80 | #ifdef _WIN32 |
| @@ -87,19 +87,24 @@ int main(int argc, char** argv) { | |||
| 87 | } | 87 | } |
| 88 | #endif | 88 | #endif |
| 89 | std::string filepath; | 89 | std::string filepath; |
| 90 | std::optional<std::string> config_path; | ||
| 91 | std::string program_args; | ||
| 90 | 92 | ||
| 91 | bool fullscreen = false; | 93 | bool fullscreen = false; |
| 92 | 94 | ||
| 93 | static struct option long_options[] = { | 95 | static struct option long_options[] = { |
| 96 | // clang-format off | ||
| 94 | {"fullscreen", no_argument, 0, 'f'}, | 97 | {"fullscreen", no_argument, 0, 'f'}, |
| 95 | {"help", no_argument, 0, 'h'}, | 98 | {"help", no_argument, 0, 'h'}, |
| 96 | {"version", no_argument, 0, 'v'}, | 99 | {"version", no_argument, 0, 'v'}, |
| 97 | {"program", optional_argument, 0, 'p'}, | 100 | {"program", optional_argument, 0, 'p'}, |
| 101 | {"config", required_argument, 0, 'c'}, | ||
| 98 | {0, 0, 0, 0}, | 102 | {0, 0, 0, 0}, |
| 103 | // clang-format on | ||
| 99 | }; | 104 | }; |
| 100 | 105 | ||
| 101 | while (optind < argc) { | 106 | while (optind < argc) { |
| 102 | int arg = getopt_long(argc, argv, "g:fhvp::", long_options, &option_index); | 107 | int arg = getopt_long(argc, argv, "g:fhvp::c:", long_options, &option_index); |
| 103 | if (arg != -1) { | 108 | if (arg != -1) { |
| 104 | switch (static_cast<char>(arg)) { | 109 | switch (static_cast<char>(arg)) { |
| 105 | case 'f': | 110 | case 'f': |
| @@ -113,9 +118,12 @@ int main(int argc, char** argv) { | |||
| 113 | PrintVersion(); | 118 | PrintVersion(); |
| 114 | return 0; | 119 | return 0; |
| 115 | case 'p': | 120 | case 'p': |
| 116 | Settings::values.program_args = argv[optind]; | 121 | program_args = argv[optind]; |
| 117 | ++optind; | 122 | ++optind; |
| 118 | break; | 123 | break; |
| 124 | case 'c': | ||
| 125 | config_path = optarg; | ||
| 126 | break; | ||
| 119 | } | 127 | } |
| 120 | } else { | 128 | } else { |
| 121 | #ifdef _WIN32 | 129 | #ifdef _WIN32 |
| @@ -127,6 +135,12 @@ int main(int argc, char** argv) { | |||
| 127 | } | 135 | } |
| 128 | } | 136 | } |
| 129 | 137 | ||
| 138 | Config config{config_path}; | ||
| 139 | |||
| 140 | if (!program_args.empty()) { | ||
| 141 | Settings::values.program_args = program_args; | ||
| 142 | } | ||
| 143 | |||
| 130 | #ifdef _WIN32 | 144 | #ifdef _WIN32 |
| 131 | LocalFree(argv_w); | 145 | LocalFree(argv_w); |
| 132 | #endif | 146 | #endif |