summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Marshall Mohror2021-10-20 21:40:02 -0500
committerGravatar Fernando Sahmkow2021-11-16 22:11:32 +0100
commit056894f07ae4c1ef295fefb1e8f120964f2e04b4 (patch)
tree777c70aa14ca65af9d5168a50e24b1f9c103d1b0 /src
parentOpenGL: Implement FXAA (diff)
downloadyuzu-056894f07ae4c1ef295fefb1e8f120964f2e04b4.tar.gz
yuzu-056894f07ae4c1ef295fefb1e8f120964f2e04b4.tar.xz
yuzu-056894f07ae4c1ef295fefb1e8f120964f2e04b4.zip
OpenGL: fix FXAA with scaling
Diffstat (limited to 'src')
-rw-r--r--src/video_core/renderer_opengl/renderer_opengl.cpp39
-rw-r--r--src/video_core/renderer_opengl/renderer_opengl.h1
2 files changed, 31 insertions, 9 deletions
diff --git a/src/video_core/renderer_opengl/renderer_opengl.cpp b/src/video_core/renderer_opengl/renderer_opengl.cpp
index dbe66a1b6..e63f0bdd8 100644
--- a/src/video_core/renderer_opengl/renderer_opengl.cpp
+++ b/src/video_core/renderer_opengl/renderer_opengl.cpp
@@ -213,7 +213,9 @@ void RendererOpenGL::LoadFBToScreenInfo(const Tegra::FramebufferConfig& framebuf
213 framebuffer_crop_rect = framebuffer.crop_rect; 213 framebuffer_crop_rect = framebuffer.crop_rect;
214 214
215 const VAddr framebuffer_addr{framebuffer.address + framebuffer.offset}; 215 const VAddr framebuffer_addr{framebuffer.address + framebuffer.offset};
216 if (rasterizer.AccelerateDisplay(framebuffer, framebuffer_addr, framebuffer.stride)) { 216 screen_info.was_accelerated =
217 rasterizer.AccelerateDisplay(framebuffer, framebuffer_addr, framebuffer.stride);
218 if (screen_info.was_accelerated) {
217 return; 219 return;
218 } 220 }
219 221
@@ -346,7 +348,9 @@ void RendererOpenGL::ConfigureFramebufferTexture(TextureInfo& texture,
346 glTextureStorage2D(texture.resource.handle, 1, internal_format, texture.width, texture.height); 348 glTextureStorage2D(texture.resource.handle, 1, internal_format, texture.width, texture.height);
347 fxaa_texture.Release(); 349 fxaa_texture.Release();
348 fxaa_texture.Create(GL_TEXTURE_2D); 350 fxaa_texture.Create(GL_TEXTURE_2D);
349 glTextureStorage2D(fxaa_texture.handle, 1, GL_RGBA16F, texture.width, texture.height); 351 glTextureStorage2D(fxaa_texture.handle, 1, GL_RGBA16F,
352 Settings::values.resolution_info.ScaleUp(screen_info.texture.width),
353 Settings::values.resolution_info.ScaleUp(screen_info.texture.height));
350 glNamedFramebufferTexture(fxaa_framebuffer.handle, GL_COLOR_ATTACHMENT0, fxaa_texture.handle, 354 glNamedFramebufferTexture(fxaa_framebuffer.handle, GL_COLOR_ATTACHMENT0, fxaa_texture.handle,
351 0); 355 0);
352} 356}
@@ -397,13 +401,25 @@ void RendererOpenGL::DrawScreen(const Layout::FramebufferLayout& layout) {
397 program_manager.BindPresentPrograms(fxaa_vertex.handle, fxaa_fragment.handle); 401 program_manager.BindPresentPrograms(fxaa_vertex.handle, fxaa_fragment.handle);
398 402
399 glEnablei(GL_SCISSOR_TEST, 0); 403 glEnablei(GL_SCISSOR_TEST, 0);
400 glScissorIndexed(0, 0, 0, 404 auto viewport_width = screen_info.texture.width;
401 framebuffer_crop_rect.GetWidth() != 0 ? framebuffer_crop_rect.GetWidth() 405 auto scissor_width = framebuffer_crop_rect.GetWidth();
402 : screen_info.texture.width, 406 if (scissor_width <= 0) {
403 framebuffer_crop_rect.GetHeight() != 0 ? framebuffer_crop_rect.GetHeight() 407 scissor_width = viewport_width;
404 : screen_info.texture.height); 408 }
405 glViewportIndexedf(0, 0.0f, 0.0f, static_cast<GLfloat>(screen_info.texture.width), 409 auto viewport_height = screen_info.texture.height;
406 static_cast<GLfloat>(screen_info.texture.height)); 410 auto scissor_height = framebuffer_crop_rect.GetHeight();
411 if (scissor_height <= 0) {
412 scissor_height = viewport_height;
413 }
414 if (screen_info.was_accelerated) {
415 viewport_width = Settings::values.resolution_info.ScaleUp(viewport_width);
416 scissor_width = Settings::values.resolution_info.ScaleUp(scissor_width);
417 viewport_height = Settings::values.resolution_info.ScaleUp(viewport_height);
418 scissor_height = Settings::values.resolution_info.ScaleUp(scissor_height);
419 }
420 glScissorIndexed(0, 0, 0, scissor_width, scissor_height);
421 glViewportIndexedf(0, 0.0f, 0.0f, static_cast<GLfloat>(viewport_width),
422 static_cast<GLfloat>(viewport_height));
407 glDepthRangeIndexed(0, 0.0, 0.0); 423 glDepthRangeIndexed(0, 0.0, 0.0);
408 424
409 glBindSampler(0, present_sampler.handle); 425 glBindSampler(0, present_sampler.handle);
@@ -487,6 +503,11 @@ void RendererOpenGL::DrawScreen(const Layout::FramebufferLayout& layout) {
487 scale_v = static_cast<f32>(framebuffer_crop_rect.GetHeight()) / 503 scale_v = static_cast<f32>(framebuffer_crop_rect.GetHeight()) /
488 static_cast<f32>(screen_info.texture.height); 504 static_cast<f32>(screen_info.texture.height);
489 } 505 }
506 if (Settings::values.anti_aliasing.GetValue() == Settings::AntiAliasing::Fxaa &&
507 !screen_info.was_accelerated) {
508 scale_u /= Settings::values.resolution_info.up_factor;
509 scale_v /= Settings::values.resolution_info.up_factor;
510 }
490 511
491 const auto& screen = layout.screen; 512 const auto& screen = layout.screen;
492 const std::array vertices = { 513 const std::array vertices = {
diff --git a/src/video_core/renderer_opengl/renderer_opengl.h b/src/video_core/renderer_opengl/renderer_opengl.h
index f6c66f804..cda333cad 100644
--- a/src/video_core/renderer_opengl/renderer_opengl.h
+++ b/src/video_core/renderer_opengl/renderer_opengl.h
@@ -50,6 +50,7 @@ struct TextureInfo {
50/// Structure used for storing information about the display target for the Switch screen 50/// Structure used for storing information about the display target for the Switch screen
51struct ScreenInfo { 51struct ScreenInfo {
52 GLuint display_texture{}; 52 GLuint display_texture{};
53 bool was_accelerated = false;
53 bool display_srgb{}; 54 bool display_srgb{};
54 const Common::Rectangle<float> display_texcoords{0.0f, 0.0f, 1.0f, 1.0f}; 55 const Common::Rectangle<float> display_texcoords{0.0f, 0.0f, 1.0f, 1.0f};
55 TextureInfo texture; 56 TextureInfo texture;