mirror of
https://github.com/cemu-project/Cemu.git
synced 2024-12-01 21:44:17 +01:00
add an option to use the host memory instead of buffer cache
This commit is contained in:
parent
ab41de4f9f
commit
03d4e86b61
@ -258,6 +258,7 @@ void InfoLog_PrintActiveSettings()
|
|||||||
{
|
{
|
||||||
cemuLog_log(LogType::Force, "Async compile: {}", GetConfig().async_compile.GetValue() ? "true" : "false");
|
cemuLog_log(LogType::Force, "Async compile: {}", GetConfig().async_compile.GetValue() ? "true" : "false");
|
||||||
cemuLog_log(LogType::Force, "Fast math: {}", GetConfig().fast_math.GetValue() ? "true" : "false");
|
cemuLog_log(LogType::Force, "Fast math: {}", GetConfig().fast_math.GetValue() ? "true" : "false");
|
||||||
|
cemuLog_log(LogType::Force, "Use host memory for cache: {}", g_current_game_profile->UseHostMemForCache() ? "true" : "false");
|
||||||
if (!GetConfig().vk_accurate_barriers.GetValue())
|
if (!GetConfig().vk_accurate_barriers.GetValue())
|
||||||
cemuLog_log(LogType::Force, "Accurate barriers are disabled!");
|
cemuLog_log(LogType::Force, "Accurate barriers are disabled!");
|
||||||
}
|
}
|
||||||
|
@ -226,6 +226,7 @@ bool GameProfile::Load(uint64_t title_id)
|
|||||||
m_graphics_api = (GraphicAPI)graphicsApi.value;
|
m_graphics_api = (GraphicAPI)graphicsApi.value;
|
||||||
|
|
||||||
gameProfile_loadEnumOption(iniParser, "accurateShaderMul", m_accurateShaderMul);
|
gameProfile_loadEnumOption(iniParser, "accurateShaderMul", m_accurateShaderMul);
|
||||||
|
gameProfile_loadBooleanOption2(iniParser, "useHostMemForCache", m_useHostMemForCache);
|
||||||
|
|
||||||
// legacy support
|
// legacy support
|
||||||
auto option_precompiledShaders = iniParser.FindOption("precompiledShaders");
|
auto option_precompiledShaders = iniParser.FindOption("precompiledShaders");
|
||||||
@ -308,6 +309,7 @@ void GameProfile::Save(uint64_t title_id)
|
|||||||
|
|
||||||
fs->writeLine("[Graphics]");
|
fs->writeLine("[Graphics]");
|
||||||
WRITE_ENTRY(accurateShaderMul);
|
WRITE_ENTRY(accurateShaderMul);
|
||||||
|
WRITE_ENTRY(useHostMemForCache);
|
||||||
WRITE_OPTIONAL_ENTRY(precompiledShaders);
|
WRITE_OPTIONAL_ENTRY(precompiledShaders);
|
||||||
WRITE_OPTIONAL_ENTRY(graphics_api);
|
WRITE_OPTIONAL_ENTRY(graphics_api);
|
||||||
fs->writeLine("");
|
fs->writeLine("");
|
||||||
@ -337,6 +339,7 @@ void GameProfile::ResetOptional()
|
|||||||
|
|
||||||
// graphic settings
|
// graphic settings
|
||||||
m_accurateShaderMul = AccurateShaderMulOption::True;
|
m_accurateShaderMul = AccurateShaderMulOption::True;
|
||||||
|
m_useHostMemForCache = false;
|
||||||
// cpu settings
|
// cpu settings
|
||||||
m_threadQuantum = kThreadQuantumDefault;
|
m_threadQuantum = kThreadQuantumDefault;
|
||||||
m_cpuMode.reset(); // CPUModeOption::kSingleCoreRecompiler;
|
m_cpuMode.reset(); // CPUModeOption::kSingleCoreRecompiler;
|
||||||
@ -357,6 +360,7 @@ void GameProfile::Reset()
|
|||||||
|
|
||||||
// graphic settings
|
// graphic settings
|
||||||
m_accurateShaderMul = AccurateShaderMulOption::True;
|
m_accurateShaderMul = AccurateShaderMulOption::True;
|
||||||
|
m_useHostMemForCache = false;
|
||||||
m_precompiledShaders = PrecompiledShaderOption::Auto;
|
m_precompiledShaders = PrecompiledShaderOption::Auto;
|
||||||
// cpu settings
|
// cpu settings
|
||||||
m_threadQuantum = kThreadQuantumDefault;
|
m_threadQuantum = kThreadQuantumDefault;
|
||||||
|
@ -31,6 +31,7 @@ public:
|
|||||||
|
|
||||||
[[nodiscard]] const std::optional<GraphicAPI>& GetGraphicsAPI() const { return m_graphics_api; }
|
[[nodiscard]] const std::optional<GraphicAPI>& GetGraphicsAPI() const { return m_graphics_api; }
|
||||||
[[nodiscard]] const AccurateShaderMulOption& GetAccurateShaderMul() const { return m_accurateShaderMul; }
|
[[nodiscard]] const AccurateShaderMulOption& GetAccurateShaderMul() const { return m_accurateShaderMul; }
|
||||||
|
[[nodiscard]] bool UseHostMemForCache() const { return m_useHostMemForCache; }
|
||||||
[[nodiscard]] const std::optional<PrecompiledShaderOption>& GetPrecompiledShadersState() const { return m_precompiledShaders; }
|
[[nodiscard]] const std::optional<PrecompiledShaderOption>& GetPrecompiledShadersState() const { return m_precompiledShaders; }
|
||||||
|
|
||||||
[[nodiscard]] uint32 GetThreadQuantum() const { return m_threadQuantum; }
|
[[nodiscard]] uint32 GetThreadQuantum() const { return m_threadQuantum; }
|
||||||
@ -54,6 +55,7 @@ private:
|
|||||||
// graphic settings
|
// graphic settings
|
||||||
std::optional<GraphicAPI> m_graphics_api{};
|
std::optional<GraphicAPI> m_graphics_api{};
|
||||||
AccurateShaderMulOption m_accurateShaderMul = AccurateShaderMulOption::True;
|
AccurateShaderMulOption m_accurateShaderMul = AccurateShaderMulOption::True;
|
||||||
|
bool m_useHostMemForCache = false;
|
||||||
std::optional<PrecompiledShaderOption> m_precompiledShaders{};
|
std::optional<PrecompiledShaderOption> m_precompiledShaders{};
|
||||||
// cpu settings
|
// cpu settings
|
||||||
uint32 m_threadQuantum = kThreadQuantumDefault; // values: 20000 45000 60000 80000 100000
|
uint32 m_threadQuantum = kThreadQuantumDefault; // values: 20000 45000 60000 80000 100000
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
#include "Cafe/HW/Latte/Renderer/Metal/MetalCommon.h"
|
#include "Cafe/HW/Latte/Renderer/Metal/MetalCommon.h"
|
||||||
#include "Cafe/HW/Latte/Renderer/Metal/MetalMemoryManager.h"
|
#include "Cafe/HW/Latte/Renderer/Metal/MetalMemoryManager.h"
|
||||||
#include "Cafe/HW/Latte/Renderer/Metal/MetalVoidVertexPipeline.h"
|
#include "Cafe/HW/Latte/Renderer/Metal/MetalVoidVertexPipeline.h"
|
||||||
|
|
||||||
#include "Cemu/Logging/CemuLogging.h"
|
#include "Cemu/Logging/CemuLogging.h"
|
||||||
#include "Common/precompiled.h"
|
#include "Common/precompiled.h"
|
||||||
|
#include "GameProfile/GameProfile.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
MetalVertexBufferCache::~MetalVertexBufferCache()
|
MetalVertexBufferCache::~MetalVertexBufferCache()
|
||||||
@ -117,8 +119,7 @@ void MetalMemoryManager::InitBufferCache(size_t size)
|
|||||||
cemu_assert_debug(!m_bufferCache);
|
cemu_assert_debug(!m_bufferCache);
|
||||||
|
|
||||||
// First, try to import the host memory as a buffer
|
// First, try to import the host memory as a buffer
|
||||||
// TODO: only import if the option is ticked in game profile
|
if (g_current_game_profile->UseHostMemForCache() && m_mtlr->IsAppleGPU())
|
||||||
if (m_mtlr->IsAppleGPU())
|
|
||||||
{
|
{
|
||||||
m_importedMemBaseAddress = 0x10000000;
|
m_importedMemBaseAddress = 0x10000000;
|
||||||
size_t hostAllocationSize = 0x40000000ull;
|
size_t hostAllocationSize = 0x40000000ull;
|
||||||
@ -165,7 +166,6 @@ void MetalMemoryManager::UploadToBufferCache(const void* data, size_t offset, si
|
|||||||
|
|
||||||
void MetalMemoryManager::CopyBufferCache(size_t srcOffset, size_t dstOffset, size_t size)
|
void MetalMemoryManager::CopyBufferCache(size_t srcOffset, size_t dstOffset, size_t size)
|
||||||
{
|
{
|
||||||
cemu_assert_debug(!m_useHostMemoryForCache);
|
|
||||||
cemu_assert_debug(m_bufferCache);
|
cemu_assert_debug(m_bufferCache);
|
||||||
|
|
||||||
m_mtlr->CopyBufferToBuffer(m_bufferCache, srcOffset, m_bufferCache, dstOffset, size, ALL_MTL_RENDER_STAGES, ALL_MTL_RENDER_STAGES);
|
m_mtlr->CopyBufferToBuffer(m_bufferCache, srcOffset, m_bufferCache, dstOffset, size, ALL_MTL_RENDER_STAGES, ALL_MTL_RENDER_STAGES);
|
||||||
|
@ -127,6 +127,13 @@ GameProfileWindow::GameProfileWindow(wxWindow* parent, uint64_t title_id)
|
|||||||
m_shader_mul_accuracy->SetToolTip(_("EXPERT OPTION\nControls the accuracy of floating point multiplication in shaders.\n\nRecommended: true"));
|
m_shader_mul_accuracy->SetToolTip(_("EXPERT OPTION\nControls the accuracy of floating point multiplication in shaders.\n\nRecommended: true"));
|
||||||
first_row->Add(m_shader_mul_accuracy, 0, wxALL, 5);
|
first_row->Add(m_shader_mul_accuracy, 0, wxALL, 5);
|
||||||
|
|
||||||
|
first_row->Add(new wxStaticText(panel, wxID_ANY, _("Use host memory for cache")), 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
|
||||||
|
|
||||||
|
wxString mem_values[] = { _("false"), _("true")};
|
||||||
|
m_use_host_mem_for_cache = new wxChoice(panel, wxID_ANY, wxDefaultPosition, wxDefaultSize, (int)std::size(mem_values), mem_values);
|
||||||
|
m_use_host_mem_for_cache->SetToolTip(_("EXPERT OPTION\nAllows the GPU to access data directly without the need for an intermediate cache. May increase performance and reduce memory usage, but can also cause flickering.\n\nMetal only\n\nRecommended: false"));
|
||||||
|
first_row->Add(m_use_host_mem_for_cache, 0, wxALL, 5);
|
||||||
|
|
||||||
/*first_row->Add(new wxStaticText(panel, wxID_ANY, _("GPU buffer cache accuracy")), 0, wxALIGN_CENTER_VERTICAL | 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") };
|
wxString accuarcy_values[] = { _("high"), _("medium"), _("low") };
|
||||||
m_cache_accuracy = new wxChoice(panel, wxID_ANY, wxDefaultPosition, wxDefaultSize, (int)std::size(accuarcy_values), accuarcy_values);
|
m_cache_accuracy = new wxChoice(panel, wxID_ANY, wxDefaultPosition, wxDefaultSize, (int)std::size(accuarcy_values), accuarcy_values);
|
||||||
@ -273,6 +280,7 @@ void GameProfileWindow::ApplyProfile()
|
|||||||
else
|
else
|
||||||
m_graphic_api->SetSelection(1 + m_game_profile.m_graphics_api.value()); // "", OpenGL, Vulkan, Metal
|
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_shader_mul_accuracy->SetSelection((int)m_game_profile.m_accurateShaderMul);
|
||||||
|
m_use_host_mem_for_cache->SetSelection((int)m_game_profile.m_useHostMemForCache);
|
||||||
|
|
||||||
//// audio
|
//// audio
|
||||||
//m_disable_audio->Set3StateValue(GetCheckboxState(m_game_profile.disableAudio));
|
//m_disable_audio->Set3StateValue(GetCheckboxState(m_game_profile.disableAudio));
|
||||||
@ -332,6 +340,7 @@ void GameProfileWindow::SaveProfile()
|
|||||||
|
|
||||||
// gpu
|
// gpu
|
||||||
m_game_profile.m_accurateShaderMul = (AccurateShaderMulOption)m_shader_mul_accuracy->GetSelection();
|
m_game_profile.m_accurateShaderMul = (AccurateShaderMulOption)m_shader_mul_accuracy->GetSelection();
|
||||||
|
m_game_profile.m_useHostMemForCache = (bool)m_use_host_mem_for_cache->GetSelection();
|
||||||
if (m_game_profile.m_accurateShaderMul != AccurateShaderMulOption::False && m_game_profile.m_accurateShaderMul != AccurateShaderMulOption::True)
|
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
|
m_game_profile.m_accurateShaderMul = AccurateShaderMulOption::True; // force a legal value
|
||||||
|
|
||||||
|
@ -40,6 +40,7 @@ private:
|
|||||||
wxChoice* m_graphic_api;
|
wxChoice* m_graphic_api;
|
||||||
|
|
||||||
wxChoice* m_shader_mul_accuracy;
|
wxChoice* m_shader_mul_accuracy;
|
||||||
|
wxChoice* m_use_host_mem_for_cache;
|
||||||
//wxChoice* m_cache_accuracy;
|
//wxChoice* m_cache_accuracy;
|
||||||
|
|
||||||
// audio
|
// audio
|
||||||
|
Loading…
Reference in New Issue
Block a user