Merge pull request #2384 from bunnei/internal-res-option

config: Add option for specifying screen resolution scale factor.
This commit is contained in:
bunnei 2017-01-08 12:25:12 -05:00 committed by GitHub
commit 9fc8ead842
10 changed files with 170 additions and 25 deletions

View file

@ -63,8 +63,7 @@ void Config::ReadValues() {
// Renderer // Renderer
Settings::values.use_hw_renderer = sdl2_config->GetBoolean("Renderer", "use_hw_renderer", true); Settings::values.use_hw_renderer = sdl2_config->GetBoolean("Renderer", "use_hw_renderer", true);
Settings::values.use_shader_jit = sdl2_config->GetBoolean("Renderer", "use_shader_jit", true); Settings::values.use_shader_jit = sdl2_config->GetBoolean("Renderer", "use_shader_jit", true);
Settings::values.use_scaled_resolution = Settings::values.resolution_factor = sdl2_config->GetReal("Renderer", "resolution_factor", 1.0);
sdl2_config->GetBoolean("Renderer", "use_scaled_resolution", false);
Settings::values.use_vsync = sdl2_config->GetBoolean("Renderer", "use_vsync", false); Settings::values.use_vsync = sdl2_config->GetBoolean("Renderer", "use_vsync", false);
Settings::values.toggle_framelimit = Settings::values.toggle_framelimit =
sdl2_config->GetBoolean("Renderer", "toggle_framelimit", true); sdl2_config->GetBoolean("Renderer", "toggle_framelimit", true);

View file

@ -51,9 +51,10 @@ use_hw_renderer =
# 0: Interpreter (slow), 1 (default): JIT (fast) # 0: Interpreter (slow), 1 (default): JIT (fast)
use_shader_jit = use_shader_jit =
# Whether to use native 3DS screen resolution or to scale rendering resolution to the displayed screen size. # Resolution scale factor
# 0 (default): Native, 1: Scaled # 0: Auto (scales resolution to window size), 1: Native 3DS screen resolution, Otherwise a scale
use_scaled_resolution = # factor for the 3DS resolution
resolution_factor =
# Whether to enable V-Sync (caps the framerate at 60FPS) or not. # Whether to enable V-Sync (caps the framerate at 60FPS) or not.
# 0 (default): Off, 1: On # 0 (default): Off, 1: On

View file

@ -44,8 +44,7 @@ void Config::ReadValues() {
qt_config->beginGroup("Renderer"); qt_config->beginGroup("Renderer");
Settings::values.use_hw_renderer = qt_config->value("use_hw_renderer", true).toBool(); Settings::values.use_hw_renderer = qt_config->value("use_hw_renderer", true).toBool();
Settings::values.use_shader_jit = qt_config->value("use_shader_jit", true).toBool(); Settings::values.use_shader_jit = qt_config->value("use_shader_jit", true).toBool();
Settings::values.use_scaled_resolution = Settings::values.resolution_factor = qt_config->value("resolution_factor", 1.0).toFloat();
qt_config->value("use_scaled_resolution", false).toBool();
Settings::values.use_vsync = qt_config->value("use_vsync", false).toBool(); Settings::values.use_vsync = qt_config->value("use_vsync", false).toBool();
Settings::values.toggle_framelimit = qt_config->value("toggle_framelimit", true).toBool(); Settings::values.toggle_framelimit = qt_config->value("toggle_framelimit", true).toBool();
@ -152,7 +151,7 @@ void Config::SaveValues() {
qt_config->beginGroup("Renderer"); qt_config->beginGroup("Renderer");
qt_config->setValue("use_hw_renderer", Settings::values.use_hw_renderer); qt_config->setValue("use_hw_renderer", Settings::values.use_hw_renderer);
qt_config->setValue("use_shader_jit", Settings::values.use_shader_jit); qt_config->setValue("use_shader_jit", Settings::values.use_shader_jit);
qt_config->setValue("use_scaled_resolution", Settings::values.use_scaled_resolution); qt_config->setValue("resolution_factor", (double)Settings::values.resolution_factor);
qt_config->setValue("use_vsync", Settings::values.use_vsync); qt_config->setValue("use_vsync", Settings::values.use_vsync);
qt_config->setValue("toggle_framelimit", Settings::values.toggle_framelimit); qt_config->setValue("toggle_framelimit", Settings::values.toggle_framelimit);

View file

@ -18,10 +18,81 @@ ConfigureGraphics::ConfigureGraphics(QWidget* parent)
ConfigureGraphics::~ConfigureGraphics() {} ConfigureGraphics::~ConfigureGraphics() {}
enum class Resolution : int {
Auto,
Scale1x,
Scale2x,
Scale3x,
Scale4x,
Scale5x,
Scale6x,
Scale7x,
Scale8x,
Scale9x,
Scale10x,
};
float ToResolutionFactor(Resolution option) {
switch (option) {
case Resolution::Auto:
return 0.f;
case Resolution::Scale1x:
return 1.f;
case Resolution::Scale2x:
return 2.f;
case Resolution::Scale3x:
return 3.f;
case Resolution::Scale4x:
return 4.f;
case Resolution::Scale5x:
return 5.f;
case Resolution::Scale6x:
return 6.f;
case Resolution::Scale7x:
return 7.f;
case Resolution::Scale8x:
return 8.f;
case Resolution::Scale9x:
return 9.f;
case Resolution::Scale10x:
return 10.f;
}
return 0.f;
}
Resolution FromResolutionFactor(float factor) {
if (factor == 0.f) {
return Resolution::Auto;
} else if (factor == 1.f) {
return Resolution::Scale1x;
} else if (factor == 2.f) {
return Resolution::Scale2x;
} else if (factor == 3.f) {
return Resolution::Scale3x;
} else if (factor == 4.f) {
return Resolution::Scale4x;
} else if (factor == 5.f) {
return Resolution::Scale5x;
} else if (factor == 6.f) {
return Resolution::Scale6x;
} else if (factor == 7.f) {
return Resolution::Scale7x;
} else if (factor == 8.f) {
return Resolution::Scale8x;
} else if (factor == 9.f) {
return Resolution::Scale9x;
} else if (factor == 10.f) {
return Resolution::Scale10x;
}
return Resolution::Auto;
}
void ConfigureGraphics::setConfiguration() { void ConfigureGraphics::setConfiguration() {
ui->toggle_hw_renderer->setChecked(Settings::values.use_hw_renderer); ui->toggle_hw_renderer->setChecked(Settings::values.use_hw_renderer);
ui->resolution_factor_combobox->setEnabled(Settings::values.use_hw_renderer);
ui->toggle_shader_jit->setChecked(Settings::values.use_shader_jit); ui->toggle_shader_jit->setChecked(Settings::values.use_shader_jit);
ui->toggle_scaled_resolution->setChecked(Settings::values.use_scaled_resolution); ui->resolution_factor_combobox->setCurrentIndex(
static_cast<int>(FromResolutionFactor(Settings::values.resolution_factor)));
ui->toggle_vsync->setChecked(Settings::values.use_vsync); ui->toggle_vsync->setChecked(Settings::values.use_vsync);
ui->toggle_framelimit->setChecked(Settings::values.toggle_framelimit); ui->toggle_framelimit->setChecked(Settings::values.toggle_framelimit);
ui->layout_combobox->setCurrentIndex(static_cast<int>(Settings::values.layout_option)); ui->layout_combobox->setCurrentIndex(static_cast<int>(Settings::values.layout_option));
@ -31,7 +102,8 @@ void ConfigureGraphics::setConfiguration() {
void ConfigureGraphics::applyConfiguration() { void ConfigureGraphics::applyConfiguration() {
Settings::values.use_hw_renderer = ui->toggle_hw_renderer->isChecked(); Settings::values.use_hw_renderer = ui->toggle_hw_renderer->isChecked();
Settings::values.use_shader_jit = ui->toggle_shader_jit->isChecked(); Settings::values.use_shader_jit = ui->toggle_shader_jit->isChecked();
Settings::values.use_scaled_resolution = ui->toggle_scaled_resolution->isChecked(); Settings::values.resolution_factor =
ToResolutionFactor(static_cast<Resolution>(ui->resolution_factor_combobox->currentIndex()));
Settings::values.use_vsync = ui->toggle_vsync->isChecked(); Settings::values.use_vsync = ui->toggle_vsync->isChecked();
Settings::values.toggle_framelimit = ui->toggle_framelimit->isChecked(); Settings::values.toggle_framelimit = ui->toggle_framelimit->isChecked();
Settings::values.layout_option = Settings::values.layout_option =

View file

@ -36,13 +36,6 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QCheckBox" name="toggle_scaled_resolution">
<property name="text">
<string>Enable scaled resolution</string>
</property>
</widget>
</item>
<item> <item>
<widget class="QCheckBox" name="toggle_vsync"> <widget class="QCheckBox" name="toggle_vsync">
<property name="text"> <property name="text">
@ -57,6 +50,76 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Internal Resolution:</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="resolution_factor_combobox">
<item>
<property name="text">
<string notr="true">Auto (Window Size)</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">Native (400x240)</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">2x Native (800x480)</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">3x Native (1200x720)</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">4x Native (1600x960)</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">5x Native (2000x1200)</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">6x Native (2400x1440)</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">7x Native (2800x1680)</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">8x Native (3200x1920)</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">9x Native (3600x2160)</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">10x Native (4000x2400)</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
</layout> </layout>
</widget> </widget>
</item> </item>
@ -128,5 +191,12 @@
</layout> </layout>
</widget> </widget>
<resources/> <resources/>
<connections/> <connections>
<connection>
<sender>toggle_hw_renderer</sender>
<signal>toggled(bool)</signal>
<receiver>resolution_factor_combobox</receiver>
<slot>setEnabled(bool)</slot>
</connection>
</connections>
</ui> </ui>

View file

@ -20,7 +20,6 @@ void Apply() {
VideoCore::g_hw_renderer_enabled = values.use_hw_renderer; VideoCore::g_hw_renderer_enabled = values.use_hw_renderer;
VideoCore::g_shader_jit_enabled = values.use_shader_jit; VideoCore::g_shader_jit_enabled = values.use_shader_jit;
VideoCore::g_scaled_resolution_enabled = values.use_scaled_resolution;
VideoCore::g_toggle_framelimit_enabled = values.toggle_framelimit; VideoCore::g_toggle_framelimit_enabled = values.toggle_framelimit;
if (VideoCore::g_emu_window) { if (VideoCore::g_emu_window) {

View file

@ -88,7 +88,7 @@ struct Values {
// Renderer // Renderer
bool use_hw_renderer; bool use_hw_renderer;
bool use_shader_jit; bool use_shader_jit;
bool use_scaled_resolution; float resolution_factor;
bool use_vsync; bool use_vsync;
bool toggle_framelimit; bool toggle_framelimit;

View file

@ -556,14 +556,21 @@ RasterizerCacheOpenGL::GetFramebufferSurfaces(const Pica::Regs::FramebufferConfi
color_params.width = depth_params.width = config.GetWidth(); color_params.width = depth_params.width = config.GetWidth();
color_params.height = depth_params.height = config.GetHeight(); color_params.height = depth_params.height = config.GetHeight();
color_params.is_tiled = depth_params.is_tiled = true; color_params.is_tiled = depth_params.is_tiled = true;
if (VideoCore::g_scaled_resolution_enabled) {
auto layout = VideoCore::g_emu_window->GetFramebufferLayout();
// Assume same scaling factor for top and bottom screens // Set the internal resolution, assume the same scaling factor for top and bottom screens
const Layout::FramebufferLayout& layout = VideoCore::g_emu_window->GetFramebufferLayout();
if (Settings::values.resolution_factor == 0.0f) {
// Auto - scale resolution to the window size
color_params.res_scale_width = depth_params.res_scale_width = color_params.res_scale_width = depth_params.res_scale_width =
(float)layout.top_screen.GetWidth() / VideoCore::kScreenTopWidth; (float)layout.top_screen.GetWidth() / VideoCore::kScreenTopWidth;
color_params.res_scale_height = depth_params.res_scale_height = color_params.res_scale_height = depth_params.res_scale_height =
(float)layout.top_screen.GetHeight() / VideoCore::kScreenTopHeight; (float)layout.top_screen.GetHeight() / VideoCore::kScreenTopHeight;
} else {
// Otherwise, scale the resolution by the specified factor
color_params.res_scale_width = Settings::values.resolution_factor;
depth_params.res_scale_width = Settings::values.resolution_factor;
color_params.res_scale_height = Settings::values.resolution_factor;
depth_params.res_scale_height = Settings::values.resolution_factor;
} }
color_params.addr = config.GetColorBufferPhysicalAddress(); color_params.addr = config.GetColorBufferPhysicalAddress();

View file

@ -19,7 +19,6 @@ std::unique_ptr<RendererBase> g_renderer; ///< Renderer plugin
std::atomic<bool> g_hw_renderer_enabled; std::atomic<bool> g_hw_renderer_enabled;
std::atomic<bool> g_shader_jit_enabled; std::atomic<bool> g_shader_jit_enabled;
std::atomic<bool> g_scaled_resolution_enabled;
std::atomic<bool> g_vsync_enabled; std::atomic<bool> g_vsync_enabled;
std::atomic<bool> g_toggle_framelimit_enabled; std::atomic<bool> g_toggle_framelimit_enabled;

View file

@ -37,7 +37,6 @@ extern EmuWindow* g_emu_window; ///< Emu window
// qt ui) // qt ui)
extern std::atomic<bool> g_hw_renderer_enabled; extern std::atomic<bool> g_hw_renderer_enabled;
extern std::atomic<bool> g_shader_jit_enabled; extern std::atomic<bool> g_shader_jit_enabled;
extern std::atomic<bool> g_scaled_resolution_enabled;
extern std::atomic<bool> g_toggle_framelimit_enabled; extern std::atomic<bool> g_toggle_framelimit_enabled;
/// Start the video core /// Start the video core