diff options
-rw-r--r-- | src/audio_core/sink/cubeb_sink.cpp | 3 | ||||
-rw-r--r-- | src/audio_core/sink/sdl2_sink.cpp | 3 | ||||
-rw-r--r-- | src/audio_core/sink/sink.h | 12 | ||||
-rw-r--r-- | src/audio_core/sink/sink_stream.cpp | 41 | ||||
-rw-r--r-- | src/core/hle/service/audio/audren_u.cpp | 2 | ||||
-rw-r--r-- | src/core/hle/service/nvnflinger/buffer_queue_consumer.cpp | 35 | ||||
-rw-r--r-- | src/core/hle/service/nvnflinger/buffer_queue_core.cpp | 4 | ||||
-rw-r--r-- | src/core/hle/service/nvnflinger/buffer_slot.h | 1 | ||||
-rw-r--r-- | src/tests/video_core/memory_tracker.cpp | 6 | ||||
-rw-r--r-- | src/video_core/buffer_cache/word_manager.h | 2 | ||||
-rw-r--r-- | src/video_core/rasterizer_accelerated.cpp | 99 | ||||
-rw-r--r-- | src/video_core/rasterizer_accelerated.h | 29 | ||||
-rw-r--r-- | src/video_core/rasterizer_interface.h | 2 | ||||
-rw-r--r-- | src/video_core/shader_cache.cpp | 4 | ||||
-rw-r--r-- | src/video_core/texture_cache/texture_cache.h | 10 | ||||
-rw-r--r-- | src/yuzu/configuration/configure_ui.cpp | 4 | ||||
-rw-r--r-- | src/yuzu/configuration/qt_config.cpp | 5 | ||||
-rw-r--r-- | src/yuzu/main.cpp | 6 | ||||
-rw-r--r-- | src/yuzu/uisettings.h | 3 |
19 files changed, 163 insertions, 108 deletions
diff --git a/src/audio_core/sink/cubeb_sink.cpp b/src/audio_core/sink/cubeb_sink.cpp index 51a23fe15..d97ca2a40 100644 --- a/src/audio_core/sink/cubeb_sink.cpp +++ b/src/audio_core/sink/cubeb_sink.cpp @@ -253,8 +253,9 @@ CubebSink::~CubebSink() { #endif } -SinkStream* CubebSink::AcquireSinkStream(Core::System& system, u32 system_channels, +SinkStream* CubebSink::AcquireSinkStream(Core::System& system, u32 system_channels_, const std::string& name, StreamType type) { + system_channels = system_channels_; SinkStreamPtr& stream = sink_streams.emplace_back(std::make_unique<CubebSinkStream>( ctx, device_channels, system_channels, output_device, input_device, name, type, system)); diff --git a/src/audio_core/sink/sdl2_sink.cpp b/src/audio_core/sink/sdl2_sink.cpp index 96e0efce2..7dd155ff0 100644 --- a/src/audio_core/sink/sdl2_sink.cpp +++ b/src/audio_core/sink/sdl2_sink.cpp @@ -168,8 +168,9 @@ SDLSink::SDLSink(std::string_view target_device_name) { SDLSink::~SDLSink() = default; -SinkStream* SDLSink::AcquireSinkStream(Core::System& system, u32 system_channels, +SinkStream* SDLSink::AcquireSinkStream(Core::System& system, u32 system_channels_, const std::string&, StreamType type) { + system_channels = system_channels_; SinkStreamPtr& stream = sink_streams.emplace_back(std::make_unique<SDLSinkStream>( device_channels, system_channels, output_device, input_device, type, system)); return stream.get(); diff --git a/src/audio_core/sink/sink.h b/src/audio_core/sink/sink.h index f28c6d126..e22e8c3e5 100644 --- a/src/audio_core/sink/sink.h +++ b/src/audio_core/sink/sink.h @@ -85,9 +85,21 @@ public: */ virtual void SetSystemVolume(f32 volume) = 0; + /** + * Get the number of channels the game has set, can be different to the host hardware's support. + * Either 2 or 6. + * + * @return Number of device channels. + */ + u32 GetSystemChannels() const { + return system_channels; + } + protected: /// Number of device channels supported by the hardware u32 device_channels{2}; + /// Number of channels the game is sending + u32 system_channels{2}; }; using SinkPtr = std::unique_ptr<Sink>; diff --git a/src/audio_core/sink/sink_stream.cpp b/src/audio_core/sink/sink_stream.cpp index 2a09db599..c047b0668 100644 --- a/src/audio_core/sink/sink_stream.cpp +++ b/src/audio_core/sink/sink_stream.cpp @@ -40,29 +40,36 @@ void SinkStream::AppendBuffer(SinkBuffer& buffer, std::span<s16> samples) { if (system_channels == 6 && device_channels == 2) { // We're given 6 channels, but our device only outputs 2, so downmix. - static constexpr std::array<f32, 4> down_mix_coeff{1.0f, 0.707f, 0.251f, 0.707f}; + // Front = 1.0 + // Center = 0.596 + // LFE = 0.354 + // Back = 0.707 + static constexpr std::array<f32, 4> down_mix_coeff{1.0, 0.596f, 0.354f, 0.707f}; for (u32 read_index = 0, write_index = 0; read_index < samples.size(); read_index += system_channels, write_index += device_channels) { + const auto fl = + static_cast<f32>(samples[read_index + static_cast<u32>(Channels::FrontLeft)]); + const auto fr = + static_cast<f32>(samples[read_index + static_cast<u32>(Channels::FrontRight)]); + const auto c = + static_cast<f32>(samples[read_index + static_cast<u32>(Channels::Center)]); + const auto lfe = + static_cast<f32>(samples[read_index + static_cast<u32>(Channels::LFE)]); + const auto bl = + static_cast<f32>(samples[read_index + static_cast<u32>(Channels::BackLeft)]); + const auto br = + static_cast<f32>(samples[read_index + static_cast<u32>(Channels::BackRight)]); + const auto left_sample{ - ((Common::FixedPoint<49, 15>( - samples[read_index + static_cast<u32>(Channels::FrontLeft)]) * - down_mix_coeff[0] + - samples[read_index + static_cast<u32>(Channels::Center)] * down_mix_coeff[1] + - samples[read_index + static_cast<u32>(Channels::LFE)] * down_mix_coeff[2] + - samples[read_index + static_cast<u32>(Channels::BackLeft)] * down_mix_coeff[3]) * - volume) - .to_int()}; + static_cast<s32>((fl * down_mix_coeff[0] + c * down_mix_coeff[1] + + lfe * down_mix_coeff[2] + bl * down_mix_coeff[3]) * + volume)}; const auto right_sample{ - ((Common::FixedPoint<49, 15>( - samples[read_index + static_cast<u32>(Channels::FrontRight)]) * - down_mix_coeff[0] + - samples[read_index + static_cast<u32>(Channels::Center)] * down_mix_coeff[1] + - samples[read_index + static_cast<u32>(Channels::LFE)] * down_mix_coeff[2] + - samples[read_index + static_cast<u32>(Channels::BackRight)] * down_mix_coeff[3]) * - volume) - .to_int()}; + static_cast<s32>((fr * down_mix_coeff[0] + c * down_mix_coeff[1] + + lfe * down_mix_coeff[2] + br * down_mix_coeff[3]) * + volume)}; samples[write_index + static_cast<u32>(Channels::FrontLeft)] = static_cast<s16>(std::clamp(left_sample, min, max)); diff --git a/src/core/hle/service/audio/audren_u.cpp b/src/core/hle/service/audio/audren_u.cpp index 2f09cade5..23e56c77a 100644 --- a/src/core/hle/service/audio/audren_u.cpp +++ b/src/core/hle/service/audio/audren_u.cpp @@ -359,7 +359,7 @@ private: void GetActiveChannelCount(HLERequestContext& ctx) { const auto& sink{system.AudioCore().GetOutputSink()}; - u32 channel_count{sink.GetDeviceChannels()}; + u32 channel_count{sink.GetSystemChannels()}; LOG_DEBUG(Service_Audio, "(STUBBED) called. Channels={}", channel_count); diff --git a/src/core/hle/service/nvnflinger/buffer_queue_consumer.cpp b/src/core/hle/service/nvnflinger/buffer_queue_consumer.cpp index d91886bed..bbe8e06d4 100644 --- a/src/core/hle/service/nvnflinger/buffer_queue_consumer.cpp +++ b/src/core/hle/service/nvnflinger/buffer_queue_consumer.cpp @@ -90,6 +90,18 @@ Status BufferQueueConsumer::AcquireBuffer(BufferItem* out_buffer, LOG_DEBUG(Service_Nvnflinger, "acquiring slot={}", slot); + // If the front buffer is still being tracked, update its slot state + if (core->StillTracking(*front)) { + slots[slot].acquire_called = true; + slots[slot].needs_cleanup_on_release = false; + slots[slot].buffer_state = BufferState::Acquired; + + // TODO: for now, avoid resetting the fence, so that when we next return this + // slot to the producer, it will wait for the fence to pass. We should fix this + // by properly waiting for the fence in the BufferItemConsumer. + // slots[slot].fence = Fence::NoFence(); + } + // If the buffer has previously been acquired by the consumer, set graphic_buffer to nullptr to // avoid unnecessarily remapping this buffer on the consumer side. if (out_buffer->acquire_called) { @@ -132,11 +144,28 @@ Status BufferQueueConsumer::ReleaseBuffer(s32 slot, u64 frame_number, const Fenc ++current; } - slots[slot].buffer_state = BufferState::Free; + if (slots[slot].buffer_state == BufferState::Acquired) { + // TODO: for now, avoid resetting the fence, so that when we next return this + // slot to the producer, it can wait for its own fence to pass. We should fix this + // by properly waiting for the fence in the BufferItemConsumer. + // slots[slot].fence = release_fence; + slots[slot].buffer_state = BufferState::Free; - listener = core->connected_producer_listener; + listener = core->connected_producer_listener; - LOG_DEBUG(Service_Nvnflinger, "releasing slot {}", slot); + LOG_DEBUG(Service_Nvnflinger, "releasing slot {}", slot); + } else if (slots[slot].needs_cleanup_on_release) { + LOG_DEBUG(Service_Nvnflinger, "releasing a stale buffer slot {} (state = {})", slot, + slots[slot].buffer_state); + slots[slot].needs_cleanup_on_release = false; + return Status::StaleBufferSlot; + } else { + LOG_ERROR(Service_Nvnflinger, + "attempted to release buffer slot {} but its state was {}", slot, + slots[slot].buffer_state); + + return Status::BadValue; + } core->SignalDequeueCondition(); } diff --git a/src/core/hle/service/nvnflinger/buffer_queue_core.cpp b/src/core/hle/service/nvnflinger/buffer_queue_core.cpp index 4ed5e5978..5d8c861fa 100644 --- a/src/core/hle/service/nvnflinger/buffer_queue_core.cpp +++ b/src/core/hle/service/nvnflinger/buffer_queue_core.cpp @@ -74,6 +74,10 @@ void BufferQueueCore::FreeBufferLocked(s32 slot) { slots[slot].graphic_buffer.reset(); + if (slots[slot].buffer_state == BufferState::Acquired) { + slots[slot].needs_cleanup_on_release = true; + } + slots[slot].buffer_state = BufferState::Free; slots[slot].frame_number = UINT32_MAX; slots[slot].acquire_called = false; diff --git a/src/core/hle/service/nvnflinger/buffer_slot.h b/src/core/hle/service/nvnflinger/buffer_slot.h index d25bca049..37daca78b 100644 --- a/src/core/hle/service/nvnflinger/buffer_slot.h +++ b/src/core/hle/service/nvnflinger/buffer_slot.h @@ -31,6 +31,7 @@ struct BufferSlot final { u64 frame_number{}; Fence fence; bool acquire_called{}; + bool needs_cleanup_on_release{}; bool attached_by_consumer{}; bool is_preallocated{}; }; diff --git a/src/tests/video_core/memory_tracker.cpp b/src/tests/video_core/memory_tracker.cpp index 2dbff21af..618793668 100644 --- a/src/tests/video_core/memory_tracker.cpp +++ b/src/tests/video_core/memory_tracker.cpp @@ -23,13 +23,13 @@ constexpr VAddr c = 16 * HIGH_PAGE_SIZE; class RasterizerInterface { public: - void UpdatePagesCachedCount(VAddr addr, u64 size, bool cache) { + void UpdatePagesCachedCount(VAddr addr, u64 size, int delta) { const u64 page_start{addr >> Core::Memory::YUZU_PAGEBITS}; const u64 page_end{(addr + size + Core::Memory::YUZU_PAGESIZE - 1) >> Core::Memory::YUZU_PAGEBITS}; for (u64 page = page_start; page < page_end; ++page) { int& value = page_table[page]; - value += (cache ? 1 : -1); + value += delta; if (value < 0) { throw std::logic_error{"negative page"}; } @@ -546,4 +546,4 @@ TEST_CASE("MemoryTracker: Cached write downloads") { REQUIRE(!memory_track->IsRegionGpuModified(c + PAGE, PAGE)); memory_track->MarkRegionAsCpuModified(c, WORD); REQUIRE(rasterizer.Count() == 0); -} +}
\ No newline at end of file diff --git a/src/video_core/buffer_cache/word_manager.h b/src/video_core/buffer_cache/word_manager.h index 95b752055..a336bde41 100644 --- a/src/video_core/buffer_cache/word_manager.h +++ b/src/video_core/buffer_cache/word_manager.h @@ -473,7 +473,7 @@ private: VAddr addr = cpu_addr + word_index * BYTES_PER_WORD; IteratePages(changed_bits, [&](size_t offset, size_t size) { rasterizer->UpdatePagesCachedCount(addr + offset * BYTES_PER_PAGE, - size * BYTES_PER_PAGE, add_to_rasterizer); + size * BYTES_PER_PAGE, add_to_rasterizer ? 1 : -1); }); } diff --git a/src/video_core/rasterizer_accelerated.cpp b/src/video_core/rasterizer_accelerated.cpp index 3c9477f6e..f200a650f 100644 --- a/src/video_core/rasterizer_accelerated.cpp +++ b/src/video_core/rasterizer_accelerated.cpp @@ -3,7 +3,6 @@ #include <atomic> -#include "common/alignment.h" #include "common/assert.h" #include "common/common_types.h" #include "common/div_ceil.h" @@ -12,65 +11,61 @@ namespace VideoCore { -static constexpr u16 IdentityValue = 1; - using namespace Core::Memory; -RasterizerAccelerated::RasterizerAccelerated(Memory& cpu_memory_) : map{}, cpu_memory{cpu_memory_} { - // We are tracking CPU memory, which cannot map more than 39 bits. - const VAddr start_address = 0; - const VAddr end_address = (1ULL << 39); - const IntervalType address_space_interval(start_address, end_address); - const auto value = std::make_pair(address_space_interval, IdentityValue); - - map.add(value); -} +RasterizerAccelerated::RasterizerAccelerated(Memory& cpu_memory_) + : cached_pages(std::make_unique<CachedPages>()), cpu_memory{cpu_memory_} {} RasterizerAccelerated::~RasterizerAccelerated() = default; -void RasterizerAccelerated::UpdatePagesCachedCount(VAddr addr, u64 size, bool cache) { - std::scoped_lock lk{map_lock}; - - // Align sizes. - addr = Common::AlignDown(addr, YUZU_PAGESIZE); - size = Common::AlignUp(size, YUZU_PAGESIZE); - - // Declare the overall interval we are going to operate on. - const VAddr start_address = addr; - const VAddr end_address = addr + size; - const IntervalType modification_range(start_address, end_address); - - // Find the boundaries of where to iterate. - const auto lower = map.lower_bound(modification_range); - const auto upper = map.upper_bound(modification_range); - - // Iterate over the contained intervals. - for (auto it = lower; it != upper; it++) { - // Intersect interval range with modification range. - const auto current_range = modification_range & it->first; - - // Calculate the address and size to operate over. - const auto current_addr = current_range.lower(); - const auto current_size = current_range.upper() - current_addr; - - // Get the current value of the range. - const auto value = it->second; +void RasterizerAccelerated::UpdatePagesCachedCount(VAddr addr, u64 size, int delta) { + u64 uncache_begin = 0; + u64 cache_begin = 0; + u64 uncache_bytes = 0; + u64 cache_bytes = 0; + + std::atomic_thread_fence(std::memory_order_acquire); + const u64 page_end = Common::DivCeil(addr + size, YUZU_PAGESIZE); + for (u64 page = addr >> YUZU_PAGEBITS; page != page_end; ++page) { + std::atomic_uint16_t& count = cached_pages->at(page >> 2).Count(page); + + if (delta > 0) { + ASSERT_MSG(count.load(std::memory_order::relaxed) < UINT16_MAX, "Count may overflow!"); + } else if (delta < 0) { + ASSERT_MSG(count.load(std::memory_order::relaxed) > 0, "Count may underflow!"); + } else { + ASSERT_MSG(false, "Delta must be non-zero!"); + } - if (cache && value == IdentityValue) { - // If we are going to cache, and the value is not yet referenced, then cache this range. - cpu_memory.RasterizerMarkRegionCached(current_addr, current_size, true); - } else if (!cache && value == IdentityValue + 1) { - // If we are going to uncache, and this is the last reference, then uncache this range. - cpu_memory.RasterizerMarkRegionCached(current_addr, current_size, false); + // Adds or subtracts 1, as count is a unsigned 8-bit value + count.fetch_add(static_cast<u16>(delta), std::memory_order_release); + + // Assume delta is either -1 or 1 + if (count.load(std::memory_order::relaxed) == 0) { + if (uncache_bytes == 0) { + uncache_begin = page; + } + uncache_bytes += YUZU_PAGESIZE; + } else if (uncache_bytes > 0) { + cpu_memory.RasterizerMarkRegionCached(uncache_begin << YUZU_PAGEBITS, uncache_bytes, + false); + uncache_bytes = 0; + } + if (count.load(std::memory_order::relaxed) == 1 && delta > 0) { + if (cache_bytes == 0) { + cache_begin = page; + } + cache_bytes += YUZU_PAGESIZE; + } else if (cache_bytes > 0) { + cpu_memory.RasterizerMarkRegionCached(cache_begin << YUZU_PAGEBITS, cache_bytes, true); + cache_bytes = 0; } } - - // Update the set. - const auto value = std::make_pair(modification_range, IdentityValue); - if (cache) { - map.add(value); - } else { - map.subtract(value); + if (uncache_bytes > 0) { + cpu_memory.RasterizerMarkRegionCached(uncache_begin << YUZU_PAGEBITS, uncache_bytes, false); + } + if (cache_bytes > 0) { + cpu_memory.RasterizerMarkRegionCached(cache_begin << YUZU_PAGEBITS, cache_bytes, true); } } diff --git a/src/video_core/rasterizer_accelerated.h b/src/video_core/rasterizer_accelerated.h index f1968f186..e6c0ea87a 100644 --- a/src/video_core/rasterizer_accelerated.h +++ b/src/video_core/rasterizer_accelerated.h @@ -3,8 +3,8 @@ #pragma once -#include <mutex> -#include <boost/icl/interval_map.hpp> +#include <array> +#include <atomic> #include "common/common_types.h" #include "video_core/rasterizer_interface.h" @@ -21,17 +21,28 @@ public: explicit RasterizerAccelerated(Core::Memory::Memory& cpu_memory_); ~RasterizerAccelerated() override; - void UpdatePagesCachedCount(VAddr addr, u64 size, bool cache) override; + void UpdatePagesCachedCount(VAddr addr, u64 size, int delta) override; private: - using PageIndex = VAddr; - using PageReferenceCount = u16; + class CacheEntry final { + public: + CacheEntry() = default; - using IntervalMap = boost::icl::interval_map<PageIndex, PageReferenceCount>; - using IntervalType = IntervalMap::interval_type; + std::atomic_uint16_t& Count(std::size_t page) { + return values[page & 3]; + } - IntervalMap map; - std::mutex map_lock; + const std::atomic_uint16_t& Count(std::size_t page) const { + return values[page & 3]; + } + + private: + std::array<std::atomic_uint16_t, 4> values{}; + }; + static_assert(sizeof(CacheEntry) == 8, "CacheEntry should be 8 bytes!"); + + using CachedPages = std::array<CacheEntry, 0x2000000>; + std::unique_ptr<CachedPages> cached_pages; Core::Memory::Memory& cpu_memory; }; diff --git a/src/video_core/rasterizer_interface.h b/src/video_core/rasterizer_interface.h index fd42d26b5..af1469147 100644 --- a/src/video_core/rasterizer_interface.h +++ b/src/video_core/rasterizer_interface.h @@ -162,7 +162,7 @@ public: } /// Increase/decrease the number of object in pages touching the specified region - virtual void UpdatePagesCachedCount(VAddr addr, u64 size, bool cache) {} + virtual void UpdatePagesCachedCount(VAddr addr, u64 size, int delta) {} /// Initialize disk cached resources for the game being emulated virtual void LoadDiskResources(u64 title_id, std::stop_token stop_loading, diff --git a/src/video_core/shader_cache.cpp b/src/video_core/shader_cache.cpp index a109f9cbe..e81cd031b 100644 --- a/src/video_core/shader_cache.cpp +++ b/src/video_core/shader_cache.cpp @@ -132,7 +132,7 @@ void ShaderCache::Register(std::unique_ptr<ShaderInfo> data, VAddr addr, size_t storage.push_back(std::move(data)); - rasterizer.UpdatePagesCachedCount(addr, size, true); + rasterizer.UpdatePagesCachedCount(addr, size, 1); } void ShaderCache::InvalidatePagesInRegion(VAddr addr, size_t size) { @@ -209,7 +209,7 @@ void ShaderCache::UnmarkMemory(Entry* entry) { const VAddr addr = entry->addr_start; const size_t size = entry->addr_end - addr; - rasterizer.UpdatePagesCachedCount(addr, size, false); + rasterizer.UpdatePagesCachedCount(addr, size, -1); } void ShaderCache::RemoveShadersFromStorage(std::span<ShaderInfo*> removed_shaders) { diff --git a/src/video_core/texture_cache/texture_cache.h b/src/video_core/texture_cache/texture_cache.h index d7941f6a4..0d5a1709f 100644 --- a/src/video_core/texture_cache/texture_cache.h +++ b/src/video_core/texture_cache/texture_cache.h @@ -2080,7 +2080,7 @@ void TextureCache<P>::TrackImage(ImageBase& image, ImageId image_id) { ASSERT(False(image.flags & ImageFlagBits::Tracked)); image.flags |= ImageFlagBits::Tracked; if (False(image.flags & ImageFlagBits::Sparse)) { - rasterizer.UpdatePagesCachedCount(image.cpu_addr, image.guest_size_bytes, true); + rasterizer.UpdatePagesCachedCount(image.cpu_addr, image.guest_size_bytes, 1); return; } if (True(image.flags & ImageFlagBits::Registered)) { @@ -2091,13 +2091,13 @@ void TextureCache<P>::TrackImage(ImageBase& image, ImageId image_id) { const auto& map = slot_map_views[map_view_id]; const VAddr cpu_addr = map.cpu_addr; const std::size_t size = map.size; - rasterizer.UpdatePagesCachedCount(cpu_addr, size, true); + rasterizer.UpdatePagesCachedCount(cpu_addr, size, 1); } return; } ForEachSparseSegment(image, [this]([[maybe_unused]] GPUVAddr gpu_addr, VAddr cpu_addr, size_t size) { - rasterizer.UpdatePagesCachedCount(cpu_addr, size, true); + rasterizer.UpdatePagesCachedCount(cpu_addr, size, 1); }); } @@ -2106,7 +2106,7 @@ void TextureCache<P>::UntrackImage(ImageBase& image, ImageId image_id) { ASSERT(True(image.flags & ImageFlagBits::Tracked)); image.flags &= ~ImageFlagBits::Tracked; if (False(image.flags & ImageFlagBits::Sparse)) { - rasterizer.UpdatePagesCachedCount(image.cpu_addr, image.guest_size_bytes, false); + rasterizer.UpdatePagesCachedCount(image.cpu_addr, image.guest_size_bytes, -1); return; } ASSERT(True(image.flags & ImageFlagBits::Registered)); @@ -2117,7 +2117,7 @@ void TextureCache<P>::UntrackImage(ImageBase& image, ImageId image_id) { const auto& map = slot_map_views[map_view_id]; const VAddr cpu_addr = map.cpu_addr; const std::size_t size = map.size; - rasterizer.UpdatePagesCachedCount(cpu_addr, size, false); + rasterizer.UpdatePagesCachedCount(cpu_addr, size, -1); } } diff --git a/src/yuzu/configuration/configure_ui.cpp b/src/yuzu/configuration/configure_ui.cpp index dd43f0a0e..c8e871151 100644 --- a/src/yuzu/configuration/configure_ui.cpp +++ b/src/yuzu/configuration/configure_ui.cpp @@ -193,8 +193,8 @@ void ConfigureUi::RequestGameListUpdate() { void ConfigureUi::SetConfiguration() { ui->theme_combobox->setCurrentIndex( ui->theme_combobox->findData(QString::fromStdString(UISettings::values.theme))); - ui->language_combobox->setCurrentIndex( - ui->language_combobox->findData(QString::fromStdString(UISettings::values.language))); + ui->language_combobox->setCurrentIndex(ui->language_combobox->findData( + QString::fromStdString(UISettings::values.language.GetValue()))); ui->show_add_ons->setChecked(UISettings::values.show_add_ons.GetValue()); ui->show_compat->setChecked(UISettings::values.show_compat.GetValue()); ui->show_size->setChecked(UISettings::values.show_size.GetValue()); diff --git a/src/yuzu/configuration/qt_config.cpp b/src/yuzu/configuration/qt_config.cpp index 636c5e640..417a43ec5 100644 --- a/src/yuzu/configuration/qt_config.cpp +++ b/src/yuzu/configuration/qt_config.cpp @@ -187,7 +187,6 @@ void QtConfig::ReadPathValues() { BeginGroup(Settings::TranslateCategory(Settings::Category::Paths)); UISettings::values.roms_path = ReadStringSetting(std::string("romsPath")); - UISettings::values.symbols_path = ReadStringSetting(std::string("symbolsPath")); UISettings::values.game_dir_deprecated = ReadStringSetting(std::string("gameListRootDir"), std::string(".")); UISettings::values.game_dir_deprecated_deepscan = @@ -225,8 +224,6 @@ void QtConfig::ReadPathValues() { UISettings::values.recent_files = QString::fromStdString(ReadStringSetting(std::string("recentFiles"))) .split(QStringLiteral(", "), Qt::SkipEmptyParts, Qt::CaseSensitive); - UISettings::values.language = - ReadStringSetting(std::string("language"), std::make_optional(std::string(""))); EndGroup(); } @@ -409,7 +406,6 @@ void QtConfig::SavePathValues() { BeginGroup(Settings::TranslateCategory(Settings::Category::Paths)); WriteSetting(std::string("romsPath"), UISettings::values.roms_path); - WriteSetting(std::string("symbolsPath"), UISettings::values.symbols_path); BeginArray(std::string("gamedirs")); for (int i = 0; i < UISettings::values.game_dirs.size(); ++i) { SetArrayIndex(i); @@ -422,7 +418,6 @@ void QtConfig::SavePathValues() { WriteSetting(std::string("recentFiles"), UISettings::values.recent_files.join(QStringLiteral(", ")).toStdString()); - WriteSetting(std::string("language"), UISettings::values.language); EndGroup(); } diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index f31ed7ebb..059fcf041 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp @@ -5147,12 +5147,12 @@ void GMainWindow::UpdateUITheme() { void GMainWindow::LoadTranslation() { bool loaded; - if (UISettings::values.language.empty()) { + if (UISettings::values.language.GetValue().empty()) { // If the selected language is empty, use system locale loaded = translator.load(QLocale(), {}, {}, QStringLiteral(":/languages/")); } else { // Otherwise load from the specified file - loaded = translator.load(QString::fromStdString(UISettings::values.language), + loaded = translator.load(QString::fromStdString(UISettings::values.language.GetValue()), QStringLiteral(":/languages/")); } @@ -5164,7 +5164,7 @@ void GMainWindow::LoadTranslation() { } void GMainWindow::OnLanguageChanged(const QString& locale) { - if (UISettings::values.language != std::string("en")) { + if (UISettings::values.language.GetValue() != std::string("en")) { qApp->removeTranslator(&translator); } diff --git a/src/yuzu/uisettings.h b/src/yuzu/uisettings.h index 549a39e1b..f9906be33 100644 --- a/src/yuzu/uisettings.h +++ b/src/yuzu/uisettings.h @@ -154,12 +154,11 @@ struct Values { Setting<u32> screenshot_height{linkage, 0, "screenshot_height", Category::Screenshots}; std::string roms_path; - std::string symbols_path; std::string game_dir_deprecated; bool game_dir_deprecated_deepscan; QVector<GameDir> game_dirs; QStringList recent_files; - std::string language; + Setting<std::string> language{linkage, {}, "language", Category::Paths}; std::string theme; |