renderer: Add disable right eye performance hack

This commit is contained in:
PabloMK7
2024-11-14 20:11:58 +01:00
committed by OpenSauce04
parent 189dccda83
commit 758ded7fae
43 changed files with 590 additions and 168 deletions

View File

@@ -88,6 +88,10 @@ add_library(citra_common STATIC
file_util.cpp
file_util.h
hash.h
hacks/hack_list.h
hacks/hack_list.cpp
hacks/hack_manager.h
hacks/hack_manager.cpp
literals.h
logging/backend.cpp
logging/backend.h

View File

@@ -0,0 +1,62 @@
// Copyright 2024 Azahar Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#include "common/hacks/hack_manager.h"
namespace Common::Hacks {
HackManager hack_manager = {
.entries = {
// The following games cannot use the right eye disable hack due to the way they
// handle rendering.
{HackType::RIGHT_EYE_DISABLE,
HackEntry{
.mode = HackAllowMode::DISALLOW,
.affected_title_ids =
{
// Luigi's Mansion
0x00040000001D1900,
0x00040000001D1A00,
// Luigi's Mansion 2
0x0004000000055F00,
0x0004000000076500,
0x0004000000076400,
0x00040000000D0000,
// Rayman Origins
0x000400000005A500,
0x0004000000084400,
0x0004000000057600,
},
}},
// The following games require accurate multiplication to render properly.
{HackType::ACCURATE_MULTIPLICATION,
HackEntry{
.mode = HackAllowMode::FORCE,
.affected_title_ids =
{
// The Legend of Zelda: Ocarina of Time 3D
0x0004000000033400, // JAP
0x0004000000033500, // USA
0x0004000000033600, // EUR
0x000400000008F800, // KOR
0x000400000008F900, // CHI
// Mario & Luigi: Superstar Saga + Bowsers Minions
0x00040000001B8F00, // USA
0x00040000001B9000, // EUR
0x0004000000194B00, // JAP
// Mario & Luigi: Bowsers Inside Story + Bowser Jrs Journey
0x00040000001D1400, // USA
0x00040000001D1500, // EUR
0x00040000001CA900, // JAP
},
}},
}};
}

View File

@@ -0,0 +1,18 @@
// Copyright 2024 Azahar Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#pragma once
#include "common/common_types.h"
namespace Common::Hacks {
enum class HackType : int {
RIGHT_EYE_DISABLE,
ACCURATE_MULTIPLICATION,
};
class UserHackData {};
} // namespace Common::Hacks

View File

@@ -0,0 +1,21 @@
// Copyright 2024 Azahar Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#include "hack_manager.h"
namespace Common::Hacks {
const HackEntry* HackManager::GetHack(const HackType& type, u64 title_id) {
auto range = entries.equal_range(type);
for (auto it = range.first; it != range.second; it++) {
auto tid_found = std::find(it->second.affected_title_ids.begin(),
it->second.affected_title_ids.end(), title_id);
if (tid_found != it->second.affected_title_ids.end()) {
return &it->second;
}
}
return nullptr;
}
} // namespace Common::Hacks

View File

@@ -0,0 +1,40 @@
// Copyright 2024 Azahar Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#pragma once
#include <map>
#include <vector>
#include "common/common_types.h"
#include "common/hacks/hack_list.h"
namespace Common::Hacks {
enum class HackAllowMode {
ALLOW,
DISALLOW,
FORCE,
};
struct HackEntry {
HackAllowMode mode{};
std::vector<u64> affected_title_ids{};
UserHackData* hack_data{nullptr};
};
struct HackManager {
const HackEntry* GetHack(const HackType& type, u64 title_id);
HackAllowMode GetHackAllowMode(const HackType& type, u64 title_id,
HackAllowMode default_mode = HackAllowMode::ALLOW) {
const HackEntry* hack = GetHack(type, title_id);
return (hack != nullptr) ? hack->mode : default_mode;
}
std::multimap<HackType, HackEntry> entries;
};
extern HackManager hack_manager;
} // namespace Common::Hacks

View File

@@ -102,6 +102,7 @@ void LogSettings() {
log_setting("Renderer_TextureSampling",
GetTextureSamplingName(values.texture_sampling.GetValue()));
log_setting("Renderer_DelayGameRenderThreasUs", values.delay_game_render_thread_us.GetValue());
log_setting("Renderer_DisableRightEyeRender", values.disable_right_eye_render.GetValue());
log_setting("Stereoscopy_Render3d", values.render_3d.GetValue());
log_setting("Stereoscopy_Factor3d", values.factor_3d.GetValue());
log_setting("Stereoscopy_MonoRenderOption", values.mono_render_option.GetValue());
@@ -217,6 +218,7 @@ void RestoreGlobalState(bool is_powered_on) {
values.dump_textures.SetGlobal(true);
values.custom_textures.SetGlobal(true);
values.preload_textures.SetGlobal(true);
values.disable_right_eye_render.SetGlobal(true);
}
void LoadProfile(int index) {

View File

@@ -556,6 +556,7 @@ struct Values {
SwitchableSetting<bool> custom_textures{false, "custom_textures"};
SwitchableSetting<bool> preload_textures{false, "preload_textures"};
SwitchableSetting<bool> async_custom_loading{true, "async_custom_loading"};
SwitchableSetting<bool> disable_right_eye_render{false, "disable_right_eye_render"};
// Audio
bool audio_muted;