Settings: Change resolution scaling to an integer instead of a float
This commit is contained in:
parent
c3c684cd2b
commit
c821c14908
9 changed files with 27 additions and 87 deletions
|
@ -88,7 +88,7 @@ void Config::ReadValues() {
|
||||||
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.resolution_factor =
|
Settings::values.resolution_factor =
|
||||||
(float)sdl2_config->GetReal("Renderer", "resolution_factor", 1.0);
|
static_cast<u16>(sdl2_config->GetInteger("Renderer", "resolution_factor", 1));
|
||||||
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);
|
||||||
|
|
|
@ -73,7 +73,8 @@ 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.resolution_factor = qt_config->value("resolution_factor", 1.0).toFloat();
|
Settings::values.resolution_factor =
|
||||||
|
static_cast<u16>(qt_config->value("resolution_factor", 1).toInt());
|
||||||
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();
|
||||||
|
|
||||||
|
@ -236,7 +237,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("resolution_factor", (double)Settings::values.resolution_factor);
|
qt_config->setValue("resolution_factor", 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);
|
||||||
|
|
||||||
|
|
|
@ -20,81 +20,11 @@ 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->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->resolution_factor_combobox->setCurrentIndex(
|
ui->resolution_factor_combobox->setCurrentIndex(Settings::values.resolution_factor);
|
||||||
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));
|
||||||
|
@ -105,7 +35,7 @@ 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.resolution_factor =
|
Settings::values.resolution_factor =
|
||||||
ToResolutionFactor(static_cast<Resolution>(ui->resolution_factor_combobox->currentIndex()));
|
static_cast<u16>(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 =
|
||||||
|
|
|
@ -29,7 +29,7 @@ struct Rectangle {
|
||||||
T right;
|
T right;
|
||||||
T bottom;
|
T bottom;
|
||||||
|
|
||||||
Rectangle() {}
|
Rectangle() = default;
|
||||||
|
|
||||||
Rectangle(T left, T top, T right, T bottom)
|
Rectangle(T left, T top, T right, T bottom)
|
||||||
: left(left), top(top), right(right), bottom(bottom) {}
|
: left(left), top(top), right(right), bottom(bottom) {}
|
||||||
|
|
|
@ -16,8 +16,8 @@ static const float TOP_SCREEN_ASPECT_RATIO =
|
||||||
static const float BOT_SCREEN_ASPECT_RATIO =
|
static const float BOT_SCREEN_ASPECT_RATIO =
|
||||||
static_cast<float>(Core::kScreenBottomHeight) / Core::kScreenBottomWidth;
|
static_cast<float>(Core::kScreenBottomHeight) / Core::kScreenBottomWidth;
|
||||||
|
|
||||||
float FramebufferLayout::GetScalingRatio() const {
|
u16 FramebufferLayout::GetScalingRatio() const {
|
||||||
return static_cast<float>(top_screen.GetWidth()) / Core::kScreenTopWidth;
|
return static_cast<u16>(((top_screen.GetWidth() - 1) / Core::kScreenTopWidth) + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Finds the largest size subrectangle contained in window area that is confined to the aspect ratio
|
// Finds the largest size subrectangle contained in window area that is confined to the aspect ratio
|
||||||
|
|
|
@ -21,7 +21,7 @@ struct FramebufferLayout {
|
||||||
* Returns the ration of pixel size of the top screen, compared to the native size of the 3DS
|
* Returns the ration of pixel size of the top screen, compared to the native size of the 3DS
|
||||||
* screen.
|
* screen.
|
||||||
*/
|
*/
|
||||||
float GetScalingRatio() const;
|
u16 GetScalingRatio() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -95,7 +95,7 @@ struct Values {
|
||||||
// Renderer
|
// Renderer
|
||||||
bool use_hw_renderer;
|
bool use_hw_renderer;
|
||||||
bool use_shader_jit;
|
bool use_shader_jit;
|
||||||
float resolution_factor;
|
u16 resolution_factor;
|
||||||
bool use_vsync;
|
bool use_vsync;
|
||||||
bool toggle_framelimit;
|
bool toggle_framelimit;
|
||||||
|
|
||||||
|
|
|
@ -525,12 +525,27 @@ CachedSurface* RasterizerCacheOpenGL::GetTextureSurface(
|
||||||
return GetSurface(params, false, true);
|
return GetSurface(params, false, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If the resolution
|
||||||
|
static u16 GetResolutionScaleFactor() {
|
||||||
|
return !Settings::values.resolution_factor
|
||||||
|
? VideoCore::g_emu_window->GetFramebufferLayout().GetScalingRatio()
|
||||||
|
: Settings::values.resolution_factor;
|
||||||
|
}
|
||||||
|
|
||||||
std::tuple<CachedSurface*, CachedSurface*, MathUtil::Rectangle<int>>
|
std::tuple<CachedSurface*, CachedSurface*, MathUtil::Rectangle<int>>
|
||||||
RasterizerCacheOpenGL::GetFramebufferSurfaces(
|
RasterizerCacheOpenGL::GetFramebufferSurfaces(
|
||||||
const Pica::FramebufferRegs::FramebufferConfig& config) {
|
const Pica::FramebufferRegs::FramebufferConfig& config) {
|
||||||
|
|
||||||
const auto& regs = Pica::g_state.regs;
|
const auto& regs = Pica::g_state.regs;
|
||||||
|
|
||||||
|
// update resolution_scale_factor and reset cache if changed
|
||||||
|
static u16 resolution_scale_factor = GetResolutionScaleFactor();
|
||||||
|
if (resolution_scale_factor != GetResolutionScaleFactor()) {
|
||||||
|
resolution_scale_factor = GetResolutionScaleFactor();
|
||||||
|
FlushAll();
|
||||||
|
InvalidateRegion(0, 0xffffffff, nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
// Make sur that framebuffers don't overlap if both color and depth are being used
|
// Make sur that framebuffers don't overlap if both color and depth are being used
|
||||||
u32 fb_area = config.GetWidth() * config.GetHeight();
|
u32 fb_area = config.GetWidth() * config.GetHeight();
|
||||||
bool framebuffers_overlap =
|
bool framebuffers_overlap =
|
||||||
|
@ -561,12 +576,6 @@ RasterizerCacheOpenGL::GetFramebufferSurfaces(
|
||||||
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;
|
||||||
|
|
||||||
// Set the internal resolution, assume the same scaling factor for top and bottom screens
|
|
||||||
float resolution_scale_factor = Settings::values.resolution_factor;
|
|
||||||
if (resolution_scale_factor == 0.0f) {
|
|
||||||
// Auto - scale resolution to the window size
|
|
||||||
resolution_scale_factor = VideoCore::g_emu_window->GetFramebufferLayout().GetScalingRatio();
|
|
||||||
}
|
|
||||||
// Scale the resolution by the specified factor
|
// Scale the resolution by the specified factor
|
||||||
color_params.res_scale_width = resolution_scale_factor;
|
color_params.res_scale_width = resolution_scale_factor;
|
||||||
depth_params.res_scale_width = resolution_scale_factor;
|
depth_params.res_scale_width = resolution_scale_factor;
|
||||||
|
|
|
@ -41,7 +41,7 @@ struct LightSrc {
|
||||||
};
|
};
|
||||||
|
|
||||||
layout (std140) uniform shader_data {
|
layout (std140) uniform shader_data {
|
||||||
vec2 framebuffer_scale;
|
int framebuffer_scale;
|
||||||
int alphatest_ref;
|
int alphatest_ref;
|
||||||
float depth_scale;
|
float depth_scale;
|
||||||
float depth_offset;
|
float depth_offset;
|
||||||
|
|
Loading…
Reference in a new issue