summaryrefslogtreecommitdiff
path: root/src/video_core/renderer_opengl
diff options
context:
space:
mode:
authorGravatar Liam2024-01-26 22:27:34 -0500
committerGravatar Liam2024-01-31 11:27:20 -0500
commit453091f61100effba637950dc840da41d95be477 (patch)
tree0e1d46a7c5a354769d04b9bde090b5a9b1f02eb7 /src/video_core/renderer_opengl
parentvideo_core: simplify accelerated surface fetch and crop handling between APIs (diff)
downloadyuzu-453091f61100effba637950dc840da41d95be477.tar.gz
yuzu-453091f61100effba637950dc840da41d95be477.tar.xz
yuzu-453091f61100effba637950dc840da41d95be477.zip
video_core: consistently account for resolution scaling when rendering
Diffstat (limited to 'src/video_core/renderer_opengl')
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer.cpp8
-rw-r--r--src/video_core/renderer_opengl/gl_texture_cache.cpp4
-rw-r--r--src/video_core/renderer_opengl/gl_texture_cache.h2
-rw-r--r--src/video_core/renderer_opengl/renderer_opengl.cpp28
-rw-r--r--src/video_core/renderer_opengl/renderer_opengl.h2
5 files changed, 22 insertions, 22 deletions
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp
index 050a74cca..b42fb110c 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer.cpp
+++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp
@@ -747,16 +747,20 @@ std::optional<FramebufferTextureInfo> RasterizerOpenGL::AccelerateDisplay(
747 MICROPROFILE_SCOPE(OpenGL_CacheManagement); 747 MICROPROFILE_SCOPE(OpenGL_CacheManagement);
748 748
749 std::scoped_lock lock{texture_cache.mutex}; 749 std::scoped_lock lock{texture_cache.mutex};
750 ImageView* const image_view{ 750 const auto [image_view, scaled] =
751 texture_cache.TryFindFramebufferImageView(config, framebuffer_addr)}; 751 texture_cache.TryFindFramebufferImageView(config, framebuffer_addr);
752 if (!image_view) { 752 if (!image_view) {
753 return {}; 753 return {};
754 } 754 }
755 755
756 const auto& resolution = Settings::values.resolution_info;
757
756 FramebufferTextureInfo info{}; 758 FramebufferTextureInfo info{};
757 info.display_texture = image_view->Handle(Shader::TextureType::Color2D); 759 info.display_texture = image_view->Handle(Shader::TextureType::Color2D);
758 info.width = image_view->size.width; 760 info.width = image_view->size.width;
759 info.height = image_view->size.height; 761 info.height = image_view->size.height;
762 info.scaled_width = scaled ? resolution.ScaleUp(info.width) : info.width;
763 info.scaled_height = scaled ? resolution.ScaleUp(info.height) : info.height;
760 return info; 764 return info;
761} 765}
762 766
diff --git a/src/video_core/renderer_opengl/gl_texture_cache.cpp b/src/video_core/renderer_opengl/gl_texture_cache.cpp
index 66a5ca03e..be14494ca 100644
--- a/src/video_core/renderer_opengl/gl_texture_cache.cpp
+++ b/src/video_core/renderer_opengl/gl_texture_cache.cpp
@@ -1051,6 +1051,10 @@ void Image::Scale(bool up_scale) {
1051 state_tracker.NotifyScissor0(); 1051 state_tracker.NotifyScissor0();
1052} 1052}
1053 1053
1054bool Image::IsRescaled() const {
1055 return True(flags & ImageFlagBits::Rescaled);
1056}
1057
1054bool Image::ScaleUp(bool ignore) { 1058bool Image::ScaleUp(bool ignore) {
1055 const auto& resolution = runtime->resolution; 1059 const auto& resolution = runtime->resolution;
1056 if (!resolution.active) { 1060 if (!resolution.active) {
diff --git a/src/video_core/renderer_opengl/gl_texture_cache.h b/src/video_core/renderer_opengl/gl_texture_cache.h
index 34870c81f..3e54edcc2 100644
--- a/src/video_core/renderer_opengl/gl_texture_cache.h
+++ b/src/video_core/renderer_opengl/gl_texture_cache.h
@@ -217,6 +217,8 @@ public:
217 return gl_type; 217 return gl_type;
218 } 218 }
219 219
220 bool IsRescaled() const;
221
220 bool ScaleUp(bool ignore = false); 222 bool ScaleUp(bool ignore = false);
221 223
222 bool ScaleDown(bool ignore = false); 224 bool ScaleDown(bool ignore = false);
diff --git a/src/video_core/renderer_opengl/renderer_opengl.cpp b/src/video_core/renderer_opengl/renderer_opengl.cpp
index ea5ed3e2f..2b9ebff92 100644
--- a/src/video_core/renderer_opengl/renderer_opengl.cpp
+++ b/src/video_core/renderer_opengl/renderer_opengl.cpp
@@ -229,6 +229,8 @@ FramebufferTextureInfo RendererOpenGL::LoadFBToScreenInfo(
229 info.display_texture = framebuffer_texture.resource.handle; 229 info.display_texture = framebuffer_texture.resource.handle;
230 info.width = framebuffer.width; 230 info.width = framebuffer.width;
231 info.height = framebuffer.height; 231 info.height = framebuffer.height;
232 info.scaled_width = framebuffer.width;
233 info.scaled_height = framebuffer.height;
232 234
233 // TODO(Rodrigo): Read this from HLE 235 // TODO(Rodrigo): Read this from HLE
234 constexpr u32 block_height_log2 = 4; 236 constexpr u32 block_height_log2 = 4;
@@ -476,25 +478,13 @@ void RendererOpenGL::DrawScreen(const Tegra::FramebufferConfig& framebuffer,
476 478
477 if (anti_aliasing != Settings::AntiAliasing::None) { 479 if (anti_aliasing != Settings::AntiAliasing::None) {
478 glEnablei(GL_SCISSOR_TEST, 0); 480 glEnablei(GL_SCISSOR_TEST, 0);
479 auto viewport_width = info.width; 481 auto scissor_width = Settings::values.resolution_info.ScaleUp(framebuffer_texture.width);
480 auto scissor_width = static_cast<u32>(crop.GetWidth()); 482 auto viewport_width = static_cast<GLfloat>(scissor_width);
481 if (scissor_width <= 0) { 483 auto scissor_height = Settings::values.resolution_info.ScaleUp(framebuffer_texture.height);
482 scissor_width = viewport_width; 484 auto viewport_height = static_cast<GLfloat>(scissor_height);
483 }
484 auto viewport_height = info.height;
485 auto scissor_height = static_cast<u32>(crop.GetHeight());
486 if (scissor_height <= 0) {
487 scissor_height = viewport_height;
488 }
489
490 viewport_width = Settings::values.resolution_info.ScaleUp(viewport_width);
491 scissor_width = Settings::values.resolution_info.ScaleUp(scissor_width);
492 viewport_height = Settings::values.resolution_info.ScaleUp(viewport_height);
493 scissor_height = Settings::values.resolution_info.ScaleUp(scissor_height);
494 485
495 glScissorIndexed(0, 0, 0, scissor_width, scissor_height); 486 glScissorIndexed(0, 0, 0, scissor_width, scissor_height);
496 glViewportIndexedf(0, 0.0f, 0.0f, static_cast<GLfloat>(viewport_width), 487 glViewportIndexedf(0, 0.0f, 0.0f, viewport_width, viewport_height);
497 static_cast<GLfloat>(viewport_height));
498 488
499 glBindSampler(0, present_sampler.handle); 489 glBindSampler(0, present_sampler.handle);
500 GLint old_read_fb; 490 GLint old_read_fb;
@@ -557,10 +547,8 @@ void RendererOpenGL::DrawScreen(const Tegra::FramebufferConfig& framebuffer,
557 fsr->InitBuffers(); 547 fsr->InitBuffers();
558 } 548 }
559 549
560 const auto fsr_input_width = Settings::values.resolution_info.ScaleUp(info.width);
561 const auto fsr_input_height = Settings::values.resolution_info.ScaleUp(info.height);
562 glBindSampler(0, present_sampler.handle); 550 glBindSampler(0, present_sampler.handle);
563 fsr->Draw(program_manager, layout.screen, fsr_input_width, fsr_input_height, crop); 551 fsr->Draw(program_manager, layout.screen, info.scaled_width, info.scaled_height, crop);
564 } else { 552 } else {
565 if (fsr->AreBuffersInitialized()) { 553 if (fsr->AreBuffersInitialized()) {
566 fsr->ReleaseBuffers(); 554 fsr->ReleaseBuffers();
diff --git a/src/video_core/renderer_opengl/renderer_opengl.h b/src/video_core/renderer_opengl/renderer_opengl.h
index cde8c5702..3a83a9b78 100644
--- a/src/video_core/renderer_opengl/renderer_opengl.h
+++ b/src/video_core/renderer_opengl/renderer_opengl.h
@@ -54,6 +54,8 @@ struct FramebufferTextureInfo {
54 GLuint display_texture{}; 54 GLuint display_texture{};
55 u32 width; 55 u32 width;
56 u32 height; 56 u32 height;
57 u32 scaled_width;
58 u32 scaled_height;
57}; 59};
58 60
59class RendererOpenGL final : public VideoCore::RendererBase { 61class RendererOpenGL final : public VideoCore::RendererBase {