summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/video_core/renderer_opengl/gl_texture_cache.cpp31
-rw-r--r--src/video_core/renderer_opengl/gl_texture_cache.h3
2 files changed, 15 insertions, 19 deletions
diff --git a/src/video_core/renderer_opengl/gl_texture_cache.cpp b/src/video_core/renderer_opengl/gl_texture_cache.cpp
index 34f74e37d..5e2695576 100644
--- a/src/video_core/renderer_opengl/gl_texture_cache.cpp
+++ b/src/video_core/renderer_opengl/gl_texture_cache.cpp
@@ -480,7 +480,8 @@ void TextureCacheRuntime::Init() {
480 resolution = Settings::values.resolution_info; 480 resolution = Settings::values.resolution_info;
481 is_rescaling_on = resolution.up_scale != 1 || resolution.down_shift != 0; 481 is_rescaling_on = resolution.up_scale != 1 || resolution.down_shift != 0;
482 if (is_rescaling_on) { 482 if (is_rescaling_on) {
483 rescale_fbo.Create(); 483 rescale_draw_fbo.Create();
484 rescale_read_fbo.Create();
484 } 485 }
485} 486}
486 487
@@ -881,8 +882,11 @@ bool Image::Scale(bool scale_src, bool scale_dst) {
881 UNIMPLEMENTED(); 882 UNIMPLEMENTED();
882 return false; 883 return false;
883 } 884 }
885 GLint prev_draw_fbo;
884 GLint prev_read_fbo; 886 GLint prev_read_fbo;
887 glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &prev_draw_fbo);
885 glGetIntegerv(GL_READ_FRAMEBUFFER_BINDING, &prev_read_fbo); 888 glGetIntegerv(GL_READ_FRAMEBUFFER_BINDING, &prev_read_fbo);
889
886 const GLenum attachment = [this] { 890 const GLenum attachment = [this] {
887 switch (GetFormatType(info.format)) { 891 switch (GetFormatType(info.format)) {
888 case SurfaceType::ColorTexture: 892 case SurfaceType::ColorTexture:
@@ -931,35 +935,26 @@ bool Image::Scale(bool scale_src, bool scale_dst) {
931 dst_info.size.height = dst_height; 935 dst_info.size.height = dst_height;
932 auto dst_texture = MakeImage(dst_info, gl_internal_format); 936 auto dst_texture = MakeImage(dst_info, gl_internal_format);
933 937
934 const auto& blit_fbo = runtime->rescale_fbo; 938 const auto& read_fbo = runtime->rescale_read_fbo;
939 const auto& draw_fbo = runtime->rescale_draw_fbo;
940 glBindFramebuffer(GL_DRAW_FRAMEBUFFER, draw_fbo.handle);
941 glBindFramebuffer(GL_READ_FRAMEBUFFER, read_fbo.handle);
935 for (s32 level = 0; level < info.resources.levels; ++level) { 942 for (s32 level = 0; level < info.resources.levels; ++level) {
936 const u32 src_level_width = std::max(1u, src_width >> level); 943 const u32 src_level_width = std::max(1u, src_width >> level);
937 const u32 src_level_height = std::max(1u, src_height >> level); 944 const u32 src_level_height = std::max(1u, src_height >> level);
938 const u32 dst_level_width = std::max(1u, dst_width >> level); 945 const u32 dst_level_width = std::max(1u, dst_width >> level);
939 const u32 dst_level_height = std::max(1u, dst_height >> level); 946 const u32 dst_level_height = std::max(1u, dst_height >> level);
940 947
941 glBindFramebuffer(GL_READ_FRAMEBUFFER, blit_fbo.handle); 948 glNamedFramebufferTexture(read_fbo.handle, attachment, texture.handle, level);
942 glNamedFramebufferTexture(blit_fbo.handle, attachment, texture.handle, level); 949 glNamedFramebufferTexture(draw_fbo.handle, attachment, dst_texture.handle, level);
943 glBlitNamedFramebuffer(blit_fbo.handle, blit_fbo.handle, 0, 0, src_level_width, 950 glBlitNamedFramebuffer(read_fbo.handle, draw_fbo.handle, 0, 0, src_level_width,
944 src_level_height, 0, 0, dst_level_width, dst_level_height, mask, 951 src_level_height, 0, 0, dst_level_width, dst_level_height, mask,
945 filter); 952 filter);
946 switch (info.type) {
947 case ImageType::e1D:
948 glCopyTextureSubImage2D(dst_texture.handle, level, 0, 0, 0, 0, dst_level_width,
949 dst_level_height);
950 break;
951 case ImageType::e2D:
952 glCopyTextureSubImage3D(dst_texture.handle, level, 0, 0, 0, 0, 0, dst_level_width,
953 dst_level_height);
954 break;
955 case ImageType::e3D:
956 default:
957 UNREACHABLE();
958 }
959 } 953 }
960 texture = std::move(dst_texture); 954 texture = std::move(dst_texture);
961 955
962 // Restore previous framebuffers 956 // Restore previous framebuffers
957 glBindFramebuffer(GL_DRAW_FRAMEBUFFER, prev_draw_fbo);
963 glBindFramebuffer(GL_READ_FRAMEBUFFER, prev_read_fbo); 958 glBindFramebuffer(GL_READ_FRAMEBUFFER, prev_read_fbo);
964 return true; 959 return true;
965} 960}
diff --git a/src/video_core/renderer_opengl/gl_texture_cache.h b/src/video_core/renderer_opengl/gl_texture_cache.h
index f2e48b4c7..787b63e87 100644
--- a/src/video_core/renderer_opengl/gl_texture_cache.h
+++ b/src/video_core/renderer_opengl/gl_texture_cache.h
@@ -155,7 +155,8 @@ private:
155 155
156 std::array<GLuint, Shader::NUM_TEXTURE_TYPES> null_image_views{}; 156 std::array<GLuint, Shader::NUM_TEXTURE_TYPES> null_image_views{};
157 157
158 OGLFramebuffer rescale_fbo; 158 OGLFramebuffer rescale_draw_fbo;
159 OGLFramebuffer rescale_read_fbo;
159 Settings::ResolutionScalingInfo resolution; 160 Settings::ResolutionScalingInfo resolution;
160 bool is_rescaling_on{}; 161 bool is_rescaling_on{};
161}; 162};