From 2e93b08b3991370390ede71368a59f4f01a5e484 Mon Sep 17 00:00:00 2001 From: Samuliak Date: Mon, 4 Nov 2024 16:10:37 +0100 Subject: [PATCH] rename buffer cache type to buffer cache mode --- src/Cafe/CafeSystem.cpp | 2 +- src/Cafe/GameProfile/GameProfile.cpp | 8 ++++---- src/Cafe/GameProfile/GameProfile.h | 4 ++-- .../Renderer/Metal/MetalMemoryManager.cpp | 18 +++++++++--------- .../Latte/Renderer/Metal/MetalMemoryManager.h | 6 +++--- src/config/CemuConfig.h | 14 +++++++------- src/gui/GameProfileWindow.cpp | 12 ++++++------ src/gui/GameProfileWindow.h | 2 +- 8 files changed, 33 insertions(+), 33 deletions(-) diff --git a/src/Cafe/CafeSystem.cpp b/src/Cafe/CafeSystem.cpp index a0c072b5..f8c650cb 100644 --- a/src/Cafe/CafeSystem.cpp +++ b/src/Cafe/CafeSystem.cpp @@ -258,7 +258,7 @@ void InfoLog_PrintActiveSettings() { cemuLog_log(LogType::Force, "Async compile: {}", GetConfig().async_compile.GetValue() ? "true" : "false"); cemuLog_log(LogType::Force, "Fast math: {}", g_current_game_profile->GetFastMath() ? "true" : "false"); - cemuLog_log(LogType::Force, "Buffer cache type: {}", g_current_game_profile->GetBufferCacheType()); + cemuLog_log(LogType::Force, "Buffer cache type: {}", g_current_game_profile->GetBufferCacheMode()); if (!GetConfig().vk_accurate_barriers.GetValue()) cemuLog_log(LogType::Force, "Accurate barriers are disabled!"); } diff --git a/src/Cafe/GameProfile/GameProfile.cpp b/src/Cafe/GameProfile/GameProfile.cpp index 9389b279..f8e1305c 100644 --- a/src/Cafe/GameProfile/GameProfile.cpp +++ b/src/Cafe/GameProfile/GameProfile.cpp @@ -227,7 +227,7 @@ bool GameProfile::Load(uint64_t title_id) gameProfile_loadEnumOption(iniParser, "accurateShaderMul", m_accurateShaderMul); gameProfile_loadBooleanOption2(iniParser, "fastMath", m_fastMath); - gameProfile_loadEnumOption(iniParser, "bufferCacheType", m_bufferCacheType); + gameProfile_loadEnumOption(iniParser, "bufferCacheMode", m_bufferCacheMode); // legacy support auto option_precompiledShaders = iniParser.FindOption("precompiledShaders"); @@ -311,7 +311,7 @@ void GameProfile::Save(uint64_t title_id) fs->writeLine("[Graphics]"); WRITE_ENTRY(accurateShaderMul); WRITE_ENTRY(fastMath); - WRITE_ENTRY(bufferCacheType); + WRITE_ENTRY(bufferCacheMode); WRITE_OPTIONAL_ENTRY(precompiledShaders); WRITE_OPTIONAL_ENTRY(graphics_api); fs->writeLine(""); @@ -342,7 +342,7 @@ void GameProfile::ResetOptional() // graphic settings m_accurateShaderMul = AccurateShaderMulOption::True; m_fastMath = true; - m_bufferCacheType = BufferCacheType::DevicePrivate; + m_bufferCacheMode = BufferCacheMode::DevicePrivate; // cpu settings m_threadQuantum = kThreadQuantumDefault; m_cpuMode.reset(); // CPUModeOption::kSingleCoreRecompiler; @@ -364,7 +364,7 @@ void GameProfile::Reset() // graphic settings m_accurateShaderMul = AccurateShaderMulOption::True; m_fastMath = true; - m_bufferCacheType = BufferCacheType::DevicePrivate; + m_bufferCacheMode = BufferCacheMode::DevicePrivate; m_precompiledShaders = PrecompiledShaderOption::Auto; // cpu settings m_threadQuantum = kThreadQuantumDefault; diff --git a/src/Cafe/GameProfile/GameProfile.h b/src/Cafe/GameProfile/GameProfile.h index 0f68bc3a..078a70a2 100644 --- a/src/Cafe/GameProfile/GameProfile.h +++ b/src/Cafe/GameProfile/GameProfile.h @@ -32,7 +32,7 @@ public: [[nodiscard]] const std::optional& GetGraphicsAPI() const { return m_graphics_api; } [[nodiscard]] const AccurateShaderMulOption& GetAccurateShaderMul() const { return m_accurateShaderMul; } [[nodiscard]] bool GetFastMath() const { return m_fastMath; } - [[nodiscard]] BufferCacheType GetBufferCacheType() const { return m_bufferCacheType; } + [[nodiscard]] BufferCacheMode GetBufferCacheMode() const { return m_bufferCacheMode; } [[nodiscard]] const std::optional& GetPrecompiledShadersState() const { return m_precompiledShaders; } [[nodiscard]] uint32 GetThreadQuantum() const { return m_threadQuantum; } @@ -57,7 +57,7 @@ private: std::optional m_graphics_api{}; AccurateShaderMulOption m_accurateShaderMul = AccurateShaderMulOption::True; bool m_fastMath = false; - BufferCacheType m_bufferCacheType = BufferCacheType::DevicePrivate; + BufferCacheMode m_bufferCacheMode = BufferCacheMode::DevicePrivate; std::optional m_precompiledShaders{}; // cpu settings uint32 m_threadQuantum = kThreadQuantumDefault; // values: 20000 45000 60000 80000 100000 diff --git a/src/Cafe/HW/Latte/Renderer/Metal/MetalMemoryManager.cpp b/src/Cafe/HW/Latte/Renderer/Metal/MetalMemoryManager.cpp index 2d068884..8e0c141f 100644 --- a/src/Cafe/HW/Latte/Renderer/Metal/MetalMemoryManager.cpp +++ b/src/Cafe/HW/Latte/Renderer/Metal/MetalMemoryManager.cpp @@ -28,10 +28,10 @@ void MetalMemoryManager::InitBufferCache(size_t size) { cemu_assert_debug(!m_bufferCache); - m_bufferCacheType = g_current_game_profile->GetBufferCacheType(); + m_bufferCacheMode = g_current_game_profile->GetBufferCacheMode(); // First, try to import the host memory as a buffer - if (m_bufferCacheType == BufferCacheType::Host) + if (m_bufferCacheMode == BufferCacheMode::Host) { if (m_mtlr->HasUnifiedMemory()) { @@ -41,18 +41,18 @@ void MetalMemoryManager::InitBufferCache(size_t size) if (!m_bufferCache) { cemuLog_logDebug(LogType::Force, "Failed to import host memory as a buffer, using device shared mode instead"); - m_bufferCacheType = BufferCacheType::DeviceShared; + m_bufferCacheMode = BufferCacheMode::DeviceShared; } } else { cemuLog_logDebug(LogType::Force, "Host buffer cache mode is only available on unified memory systems, using device shared mode instead"); - m_bufferCacheType = BufferCacheType::DeviceShared; + m_bufferCacheMode = BufferCacheMode::DeviceShared; } } if (!m_bufferCache) - m_bufferCache = m_mtlr->GetDevice()->newBuffer(size, (m_bufferCacheType == BufferCacheType::DevicePrivate ? MTL::ResourceStorageModePrivate : MTL::ResourceStorageModeShared)); + m_bufferCache = m_mtlr->GetDevice()->newBuffer(size, (m_bufferCacheMode == BufferCacheMode::DevicePrivate ? MTL::ResourceStorageModePrivate : MTL::ResourceStorageModeShared)); #ifdef CEMU_DEBUG_ASSERT m_bufferCache->setLabel(GetLabel("Buffer cache", m_bufferCache)); @@ -61,11 +61,11 @@ void MetalMemoryManager::InitBufferCache(size_t size) void MetalMemoryManager::UploadToBufferCache(const void* data, size_t offset, size_t size) { - cemu_assert_debug(m_bufferCacheType != BufferCacheType::Host); + cemu_assert_debug(m_bufferCacheMode != BufferCacheMode::Host); cemu_assert_debug(m_bufferCache); cemu_assert_debug((offset + size) <= m_bufferCache->length()); - if (m_bufferCacheType == BufferCacheType::DevicePrivate) + if (m_bufferCacheMode == BufferCacheMode::DevicePrivate) { auto allocation = m_tempBufferAllocator.GetBufferAllocation(size); auto buffer = m_tempBufferAllocator.GetBufferOutsideOfCommandBuffer(allocation.bufferIndex); @@ -90,10 +90,10 @@ void MetalMemoryManager::UploadToBufferCache(const void* data, size_t offset, si void MetalMemoryManager::CopyBufferCache(size_t srcOffset, size_t dstOffset, size_t size) { - cemu_assert_debug(m_bufferCacheType != BufferCacheType::Host); + cemu_assert_debug(m_bufferCacheMode != BufferCacheMode::Host); cemu_assert_debug(m_bufferCache); - if (m_bufferCacheType == BufferCacheType::DevicePrivate) + if (m_bufferCacheMode == BufferCacheMode::DevicePrivate) m_mtlr->CopyBufferToBuffer(m_bufferCache, srcOffset, m_bufferCache, dstOffset, size, ALL_MTL_RENDER_STAGES, ALL_MTL_RENDER_STAGES); else memcpy((uint8*)m_bufferCache->contents() + dstOffset, (uint8*)m_bufferCache->contents() + srcOffset, size); diff --git a/src/Cafe/HW/Latte/Renderer/Metal/MetalMemoryManager.h b/src/Cafe/HW/Latte/Renderer/Metal/MetalMemoryManager.h index a35df24c..f74d30d0 100644 --- a/src/Cafe/HW/Latte/Renderer/Metal/MetalMemoryManager.h +++ b/src/Cafe/HW/Latte/Renderer/Metal/MetalMemoryManager.h @@ -40,12 +40,12 @@ public: // Getters bool UseHostMemoryForCache() const { - return (m_bufferCacheType == BufferCacheType::Host); + return (m_bufferCacheMode == BufferCacheMode::Host); } bool NeedsReducedLatency() const { - return (m_bufferCacheType == BufferCacheType::DeviceShared || m_bufferCacheType == BufferCacheType::Host); + return (m_bufferCacheMode == BufferCacheMode::DeviceShared || m_bufferCacheMode == BufferCacheMode::Host); } MPTR GetImportedMemBaseAddress() const @@ -68,7 +68,7 @@ private: MetalTemporaryBufferAllocator m_tempBufferAllocator; MTL::Buffer* m_bufferCache = nullptr; - BufferCacheType m_bufferCacheType; + BufferCacheMode m_bufferCacheMode; MPTR m_importedMemBaseAddress; size_t m_hostAllocationSize = 0; }; diff --git a/src/config/CemuConfig.h b/src/config/CemuConfig.h index 32c87aa6..68170456 100644 --- a/src/config/CemuConfig.h +++ b/src/config/CemuConfig.h @@ -124,13 +124,13 @@ enum class AccurateShaderMulOption }; ENABLE_ENUM_ITERATORS(AccurateShaderMulOption, AccurateShaderMulOption::False, AccurateShaderMulOption::True); -enum class BufferCacheType +enum class BufferCacheMode { DevicePrivate, DeviceShared, Host, }; -ENABLE_ENUM_ITERATORS(BufferCacheType, BufferCacheType::DevicePrivate, BufferCacheType::Host); +ENABLE_ENUM_ITERATORS(BufferCacheMode, BufferCacheMode::DevicePrivate, BufferCacheMode::Host); enum class CPUMode { @@ -230,15 +230,15 @@ struct fmt::formatter : formatter { } }; template <> -struct fmt::formatter : formatter { +struct fmt::formatter : formatter { template - auto format(const BufferCacheType c, FormatContext &ctx) const { + auto format(const BufferCacheMode c, FormatContext &ctx) const { string_view name; switch (c) { - case BufferCacheType::DevicePrivate: name = "device private"; break; - case BufferCacheType::DeviceShared: name = "device shared"; break; - case BufferCacheType::Host: name = "host"; break; + case BufferCacheMode::DevicePrivate: name = "device private"; break; + case BufferCacheMode::DeviceShared: name = "device shared"; break; + case BufferCacheMode::Host: name = "host"; break; default: name = "unknown"; break; } return formatter::format(name, ctx); diff --git a/src/gui/GameProfileWindow.cpp b/src/gui/GameProfileWindow.cpp index b26a866d..120dd5e9 100644 --- a/src/gui/GameProfileWindow.cpp +++ b/src/gui/GameProfileWindow.cpp @@ -135,12 +135,12 @@ GameProfileWindow::GameProfileWindow(wxWindow* parent, uint64_t title_id) m_fast_math->SetToolTip(_("Enables fast math for all shaders. May (rarely) cause graphical bugs.\n\nMetal only\n\nRecommended: true")); first_row->Add(m_fast_math, 0, wxALL, 5); - first_row->Add(new wxStaticText(panel, wxID_ANY, _("Buffer cache type")), 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); + first_row->Add(new wxStaticText(panel, wxID_ANY, _("Buffer cache mode")), 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); wxString cache_values[] = { _("device private"), _("device shared"), _("host") }; - m_buffer_cache_type = new wxChoice(panel, wxID_ANY, wxDefaultPosition, wxDefaultSize, (int)std::size(cache_values), cache_values); - m_buffer_cache_type->SetToolTip(_("EXPERT OPTION\nDecides how the buffer cache memory will be managed.\n\nMetal only\n\nRecommended: device private")); - first_row->Add(m_buffer_cache_type, 0, wxALL, 5); + m_buffer_cache_mode = new wxChoice(panel, wxID_ANY, wxDefaultPosition, wxDefaultSize, (int)std::size(cache_values), cache_values); + m_buffer_cache_mode->SetToolTip(_("EXPERT OPTION\nDecides how the buffer cache memory will be managed.\n\nMetal only\n\nRecommended: device private")); + first_row->Add(m_buffer_cache_mode, 0, wxALL, 5); /*first_row->Add(new wxStaticText(panel, wxID_ANY, _("GPU buffer cache accuracy")), 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); wxString accuarcy_values[] = { _("high"), _("medium"), _("low") }; @@ -289,7 +289,7 @@ void GameProfileWindow::ApplyProfile() m_graphic_api->SetSelection(1 + m_game_profile.m_graphics_api.value()); // "", OpenGL, Vulkan, Metal m_shader_mul_accuracy->SetSelection((int)m_game_profile.m_accurateShaderMul); m_fast_math->SetSelection((int)m_game_profile.m_fastMath); - m_buffer_cache_type->SetSelection((int)m_game_profile.m_bufferCacheType); + m_buffer_cache_mode->SetSelection((int)m_game_profile.m_bufferCacheMode); //// audio //m_disable_audio->Set3StateValue(GetCheckboxState(m_game_profile.disableAudio)); @@ -350,7 +350,7 @@ void GameProfileWindow::SaveProfile() // gpu m_game_profile.m_accurateShaderMul = (AccurateShaderMulOption)m_shader_mul_accuracy->GetSelection(); m_game_profile.m_fastMath = (bool)m_fast_math->GetSelection(); - m_game_profile.m_bufferCacheType = (BufferCacheType)m_buffer_cache_type->GetSelection(); + m_game_profile.m_bufferCacheMode = (BufferCacheMode)m_buffer_cache_mode->GetSelection(); if (m_game_profile.m_accurateShaderMul != AccurateShaderMulOption::False && m_game_profile.m_accurateShaderMul != AccurateShaderMulOption::True) m_game_profile.m_accurateShaderMul = AccurateShaderMulOption::True; // force a legal value diff --git a/src/gui/GameProfileWindow.h b/src/gui/GameProfileWindow.h index 88d5b438..8bf0c91c 100644 --- a/src/gui/GameProfileWindow.h +++ b/src/gui/GameProfileWindow.h @@ -41,7 +41,7 @@ private: wxChoice* m_shader_mul_accuracy; wxChoice* m_fast_math; - wxChoice* m_buffer_cache_type; + wxChoice* m_buffer_cache_mode; //wxChoice* m_cache_accuracy; // audio