rename buffer cache type to buffer cache mode

This commit is contained in:
Samuliak 2024-11-04 16:10:37 +01:00
parent a00d409ab7
commit 2e93b08b39
No known key found for this signature in database
8 changed files with 33 additions and 33 deletions

View File

@ -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!");
}

View File

@ -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;

View File

@ -32,7 +32,7 @@ public:
[[nodiscard]] const std::optional<GraphicAPI>& 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<PrecompiledShaderOption>& GetPrecompiledShadersState() const { return m_precompiledShaders; }
[[nodiscard]] uint32 GetThreadQuantum() const { return m_threadQuantum; }
@ -57,7 +57,7 @@ private:
std::optional<GraphicAPI> m_graphics_api{};
AccurateShaderMulOption m_accurateShaderMul = AccurateShaderMulOption::True;
bool m_fastMath = false;
BufferCacheType m_bufferCacheType = BufferCacheType::DevicePrivate;
BufferCacheMode m_bufferCacheMode = BufferCacheMode::DevicePrivate;
std::optional<PrecompiledShaderOption> m_precompiledShaders{};
// cpu settings
uint32 m_threadQuantum = kThreadQuantumDefault; // values: 20000 45000 60000 80000 100000

View File

@ -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);

View File

@ -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;
};

View File

@ -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<AccurateShaderMulOption> : formatter<string_view> {
}
};
template <>
struct fmt::formatter<BufferCacheType> : formatter<string_view> {
struct fmt::formatter<BufferCacheMode> : formatter<string_view> {
template <typename FormatContext>
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<string_view>::format(name, ctx);

View File

@ -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

View File

@ -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