diff options
| -rw-r--r-- | src/video_core/renderer_opengl/gl_texture_cache.cpp | 83 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_texture_cache.h | 2 |
2 files changed, 28 insertions, 57 deletions
diff --git a/src/video_core/renderer_opengl/gl_texture_cache.cpp b/src/video_core/renderer_opengl/gl_texture_cache.cpp index 6e7f66ef0..6841b5450 100644 --- a/src/video_core/renderer_opengl/gl_texture_cache.cpp +++ b/src/video_core/renderer_opengl/gl_texture_cache.cpp | |||
| @@ -883,7 +883,7 @@ void Image::CopyImageToBuffer(const VideoCommon::BufferImageCopy& copy, size_t b | |||
| 883 | } | 883 | } |
| 884 | } | 884 | } |
| 885 | 885 | ||
| 886 | bool Image::Scale(bool up_scale) { | 886 | void Image::Scale(bool up_scale) { |
| 887 | const auto format_type = GetFormatType(info.format); | 887 | const auto format_type = GetFormatType(info.format); |
| 888 | const GLenum attachment = [format_type] { | 888 | const GLenum attachment = [format_type] { |
| 889 | switch (format_type) { | 889 | switch (format_type) { |
| @@ -942,77 +942,54 @@ bool Image::Scale(bool up_scale) { | |||
| 942 | dst_info.size.height = scaled_height; | 942 | dst_info.size.height = scaled_height; |
| 943 | upscaled_backup = MakeImage(dst_info, gl_internal_format); | 943 | upscaled_backup = MakeImage(dst_info, gl_internal_format); |
| 944 | } | 944 | } |
| 945 | auto& state_tracker = runtime->GetStateTracker(); | 945 | const u32 src_width = up_scale ? original_width : scaled_width; |
| 946 | state_tracker.NotifyViewport0(); | 946 | const u32 src_height = up_scale ? original_height : scaled_height; |
| 947 | state_tracker.NotifyScissor0(); | 947 | const u32 dst_width = up_scale ? scaled_width : original_width; |
| 948 | const u32 dst_height = up_scale ? scaled_height : original_height; | ||
| 949 | const auto src_handle = up_scale ? texture.handle : upscaled_backup.handle; | ||
| 950 | const auto dst_handle = up_scale ? upscaled_backup.handle : texture.handle; | ||
| 951 | |||
| 948 | // TODO (ameerj): Investigate other GL states that affect blitting. | 952 | // TODO (ameerj): Investigate other GL states that affect blitting. |
| 949 | GLboolean scissor_test; | ||
| 950 | glGetBooleani_v(GL_SCISSOR_TEST, 0, &scissor_test); | ||
| 951 | glDisablei(GL_SCISSOR_TEST, 0); | 953 | glDisablei(GL_SCISSOR_TEST, 0); |
| 952 | if (up_scale) { | 954 | glViewportIndexedf(0, 0.0f, 0.0f, static_cast<GLfloat>(dst_width), |
| 953 | glViewportIndexedf(0, 0.0f, 0.0f, static_cast<GLfloat>(scaled_width), | 955 | static_cast<GLfloat>(dst_height)); |
| 954 | static_cast<GLfloat>(scaled_height)); | ||
| 955 | } else { | ||
| 956 | glViewportIndexedf(0, 0.0f, 0.0f, static_cast<GLfloat>(original_width), | ||
| 957 | static_cast<GLfloat>(original_height)); | ||
| 958 | } | ||
| 959 | |||
| 960 | 956 | ||
| 961 | const GLuint read_fbo = runtime->rescale_read_fbos[fbo_index].handle; | 957 | const GLuint read_fbo = runtime->rescale_read_fbos[fbo_index].handle; |
| 962 | const GLuint draw_fbo = runtime->rescale_draw_fbos[fbo_index].handle; | 958 | const GLuint draw_fbo = runtime->rescale_draw_fbos[fbo_index].handle; |
| 963 | for (s32 layer = 0; layer < info.resources.layers; ++layer) { | 959 | for (s32 layer = 0; layer < info.resources.layers; ++layer) { |
| 964 | for (s32 level = 0; level < info.resources.levels; ++level) { | 960 | for (s32 level = 0; level < info.resources.levels; ++level) { |
| 965 | const u32 src_level_width = | 961 | const u32 src_level_width = std::max(1u, src_width >> level); |
| 966 | std::max(1u, (up_scale ? original_width : scaled_width) >> level); | 962 | const u32 src_level_height = std::max(1u, src_height >> level); |
| 967 | const u32 src_level_height = | 963 | const u32 dst_level_width = std::max(1u, dst_width >> level); |
| 968 | std::max(1u, (up_scale ? original_height : scaled_height) >> level); | 964 | const u32 dst_level_height = std::max(1u, dst_height >> level); |
| 969 | const u32 dst_level_width = | 965 | |
| 970 | std::max(1u, (up_scale ? scaled_width : original_width) >> level); | 966 | glNamedFramebufferTextureLayer(read_fbo, attachment, src_handle, level, layer); |
| 971 | const u32 dst_level_height = | 967 | glNamedFramebufferTextureLayer(draw_fbo, attachment, dst_handle, level, layer); |
| 972 | std::max(1u, (up_scale ? scaled_height : original_height) >> level); | ||
| 973 | |||
| 974 | if (up_scale) { | ||
| 975 | glNamedFramebufferTextureLayer(read_fbo, attachment, texture.handle, level, layer); | ||
| 976 | glNamedFramebufferTextureLayer(draw_fbo, attachment, upscaled_backup.handle, level, | ||
| 977 | layer); | ||
| 978 | } else { | ||
| 979 | glNamedFramebufferTextureLayer(read_fbo, attachment, upscaled_backup.handle, level, | ||
| 980 | layer); | ||
| 981 | glNamedFramebufferTextureLayer(draw_fbo, attachment, texture.handle, level, layer); | ||
| 982 | } | ||
| 983 | 968 | ||
| 984 | glBlitNamedFramebuffer(read_fbo, draw_fbo, 0, 0, src_level_width, src_level_height, 0, | 969 | glBlitNamedFramebuffer(read_fbo, draw_fbo, 0, 0, src_level_width, src_level_height, 0, |
| 985 | 0, dst_level_width, dst_level_height, mask, filter); | 970 | 0, dst_level_width, dst_level_height, mask, filter); |
| 986 | } | 971 | } |
| 987 | } | 972 | } |
| 988 | if (scissor_test != GL_FALSE) { | 973 | current_texture = dst_handle; |
| 989 | glEnablei(GL_SCISSOR_TEST, 0); | 974 | auto& state_tracker = runtime->GetStateTracker(); |
| 990 | } | 975 | state_tracker.NotifyViewport0(); |
| 991 | if (up_scale) { | 976 | state_tracker.NotifyScissor0(); |
| 992 | current_texture = upscaled_backup.handle; | ||
| 993 | } else { | ||
| 994 | current_texture = texture.handle; | ||
| 995 | } | ||
| 996 | |||
| 997 | return true; | ||
| 998 | } | 977 | } |
| 999 | 978 | ||
| 1000 | bool Image::ScaleUp(bool ignore) { | 979 | bool Image::ScaleUp(bool ignore) { |
| 1001 | if (True(flags & ImageFlagBits::Rescaled)) { | 980 | if (True(flags & ImageFlagBits::Rescaled)) { |
| 1002 | return false; | 981 | return false; |
| 1003 | } | 982 | } |
| 1004 | flags |= ImageFlagBits::Rescaled; | ||
| 1005 | if (!runtime->resolution.active) { | ||
| 1006 | return false; | ||
| 1007 | } | ||
| 1008 | if (gl_format == 0 && gl_type == 0) { | 983 | if (gl_format == 0 && gl_type == 0) { |
| 1009 | // compressed textures | 984 | // compressed textures |
| 1010 | flags &= ~ImageFlagBits::Rescaled; | ||
| 1011 | return false; | 985 | return false; |
| 1012 | } | 986 | } |
| 1013 | if (info.type == ImageType::Linear) { | 987 | if (info.type == ImageType::Linear) { |
| 1014 | UNREACHABLE(); | 988 | UNREACHABLE(); |
| 1015 | flags &= ~ImageFlagBits::Rescaled; | 989 | return false; |
| 990 | } | ||
| 991 | flags |= ImageFlagBits::Rescaled; | ||
| 992 | if (!runtime->resolution.active) { | ||
| 1016 | return false; | 993 | return false; |
| 1017 | } | 994 | } |
| 1018 | has_scaled = true; | 995 | has_scaled = true; |
| @@ -1020,10 +997,7 @@ bool Image::ScaleUp(bool ignore) { | |||
| 1020 | current_texture = upscaled_backup.handle; | 997 | current_texture = upscaled_backup.handle; |
| 1021 | return true; | 998 | return true; |
| 1022 | } | 999 | } |
| 1023 | if (!Scale()) { | 1000 | Scale(true); |
| 1024 | flags &= ~ImageFlagBits::Rescaled; | ||
| 1025 | return false; | ||
| 1026 | } | ||
| 1027 | return true; | 1001 | return true; |
| 1028 | } | 1002 | } |
| 1029 | 1003 | ||
| @@ -1039,10 +1013,7 @@ bool Image::ScaleDown(bool ignore) { | |||
| 1039 | current_texture = texture.handle; | 1013 | current_texture = texture.handle; |
| 1040 | return true; | 1014 | return true; |
| 1041 | } | 1015 | } |
| 1042 | if (!Scale(false)) { | 1016 | Scale(false); |
| 1043 | flags &= ~ImageFlagBits::Rescaled; | ||
| 1044 | return false; | ||
| 1045 | } | ||
| 1046 | return true; | 1017 | return true; |
| 1047 | } | 1018 | } |
| 1048 | 1019 | ||
diff --git a/src/video_core/renderer_opengl/gl_texture_cache.h b/src/video_core/renderer_opengl/gl_texture_cache.h index 8161e6b72..c51a7428d 100644 --- a/src/video_core/renderer_opengl/gl_texture_cache.h +++ b/src/video_core/renderer_opengl/gl_texture_cache.h | |||
| @@ -209,7 +209,7 @@ private: | |||
| 209 | 209 | ||
| 210 | void CopyImageToBuffer(const VideoCommon::BufferImageCopy& copy, size_t buffer_offset); | 210 | void CopyImageToBuffer(const VideoCommon::BufferImageCopy& copy, size_t buffer_offset); |
| 211 | 211 | ||
| 212 | bool Scale(bool up_scale = true); | 212 | void Scale(bool up_scale); |
| 213 | 213 | ||
| 214 | OGLTexture texture; | 214 | OGLTexture texture; |
| 215 | OGLTexture upscaled_backup; | 215 | OGLTexture upscaled_backup; |