renderer_opengl: Minor refactoring of filter selection

This commit is contained in:
ameerj 2021-11-21 02:33:57 -05:00
parent 218d790bd6
commit c22c4f5d59

View file

@ -437,39 +437,29 @@ void RendererOpenGL::DrawScreen(const Layout::FramebufferLayout& layout) {
glBindTextureUnit(0, fxaa_texture.handle); glBindTextureUnit(0, fxaa_texture.handle);
} }
// Set projection matrix
const std::array ortho_matrix = const std::array ortho_matrix =
MakeOrthographicMatrix(static_cast<float>(layout.width), static_cast<float>(layout.height)); MakeOrthographicMatrix(static_cast<float>(layout.width), static_cast<float>(layout.height));
GLuint fragment_handle; const auto fragment_handle = [this]() {
const auto filter = Settings::values.scaling_filter.GetValue(); switch (Settings::values.scaling_filter.GetValue()) {
switch (filter) {
case Settings::ScalingFilter::NearestNeighbor: case Settings::ScalingFilter::NearestNeighbor:
fragment_handle = present_bilinear_fragment.handle;
break;
case Settings::ScalingFilter::Bilinear: case Settings::ScalingFilter::Bilinear:
fragment_handle = present_bilinear_fragment.handle; return present_bilinear_fragment.handle;
break;
case Settings::ScalingFilter::Bicubic: case Settings::ScalingFilter::Bicubic:
fragment_handle = present_bicubic_fragment.handle; return present_bicubic_fragment.handle;
break;
case Settings::ScalingFilter::Gaussian: case Settings::ScalingFilter::Gaussian:
fragment_handle = present_gaussian_fragment.handle; return present_gaussian_fragment.handle;
break;
case Settings::ScalingFilter::ScaleForce: case Settings::ScalingFilter::ScaleForce:
fragment_handle = present_scaleforce_fragment.handle; return present_scaleforce_fragment.handle;
break;
case Settings::ScalingFilter::Fsr: case Settings::ScalingFilter::Fsr:
LOG_WARNING( LOG_WARNING(
Render_OpenGL, Render_OpenGL,
"FidelityFX FSR Super Sampling is not supported in OpenGL, changing to ScaleForce"); "FidelityFX Super Resolution is not supported in OpenGL, changing to ScaleForce");
fragment_handle = present_scaleforce_fragment.handle; return present_scaleforce_fragment.handle;
break;
default: default:
fragment_handle = present_bilinear_fragment.handle; return present_bilinear_fragment.handle;
break;
} }
}();
program_manager.BindPresentPrograms(present_vertex.handle, fragment_handle); program_manager.BindPresentPrograms(present_vertex.handle, fragment_handle);
glProgramUniformMatrix3x2fv(present_vertex.handle, ModelViewMatrixLocation, 1, GL_FALSE, glProgramUniformMatrix3x2fv(present_vertex.handle, ModelViewMatrixLocation, 1, GL_FALSE,
ortho_matrix.data()); ortho_matrix.data());