summaryrefslogtreecommitdiffstats
path: root/src/video_core
diff options
context:
space:
mode:
authorameerj <52414509+ameerj@users.noreply.github.com>2021-07-22 07:34:46 +0200
committerFernando Sahmkow <fsahmkow27@gmail.com>2021-11-16 22:11:28 +0100
commitfad2c92a39cb0cfba2bc3241e779e3a983646d82 (patch)
tree10dce924ce07aae2dac710d120dd86aae2a39dd6 /src/video_core
parenttexture_cache: Fix typo in aliased image rescaling (diff)
downloadyuzu-fad2c92a39cb0cfba2bc3241e779e3a983646d82.tar
yuzu-fad2c92a39cb0cfba2bc3241e779e3a983646d82.tar.gz
yuzu-fad2c92a39cb0cfba2bc3241e779e3a983646d82.tar.bz2
yuzu-fad2c92a39cb0cfba2bc3241e779e3a983646d82.tar.lz
yuzu-fad2c92a39cb0cfba2bc3241e779e3a983646d82.tar.xz
yuzu-fad2c92a39cb0cfba2bc3241e779e3a983646d82.tar.zst
yuzu-fad2c92a39cb0cfba2bc3241e779e3a983646d82.zip
Diffstat (limited to 'src/video_core')
-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() {
resolution = Settings::values.resolution_info;
is_rescaling_on = resolution.up_scale != 1 || resolution.down_shift != 0;
if (is_rescaling_on) {
- rescale_fbo.Create();
+ rescale_draw_fbo.Create();
+ rescale_read_fbo.Create();
}
}
@@ -881,8 +882,11 @@ bool Image::Scale(bool scale_src, bool scale_dst) {
UNIMPLEMENTED();
return false;
}
+ GLint prev_draw_fbo;
GLint prev_read_fbo;
+ glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &prev_draw_fbo);
glGetIntegerv(GL_READ_FRAMEBUFFER_BINDING, &prev_read_fbo);
+
const GLenum attachment = [this] {
switch (GetFormatType(info.format)) {
case SurfaceType::ColorTexture:
@@ -931,35 +935,26 @@ bool Image::Scale(bool scale_src, bool scale_dst) {
dst_info.size.height = dst_height;
auto dst_texture = MakeImage(dst_info, gl_internal_format);
- const auto& blit_fbo = runtime->rescale_fbo;
+ const auto& read_fbo = runtime->rescale_read_fbo;
+ const auto& draw_fbo = runtime->rescale_draw_fbo;
+ glBindFramebuffer(GL_DRAW_FRAMEBUFFER, draw_fbo.handle);
+ glBindFramebuffer(GL_READ_FRAMEBUFFER, read_fbo.handle);
for (s32 level = 0; level < info.resources.levels; ++level) {
const u32 src_level_width = std::max(1u, src_width >> level);
const u32 src_level_height = std::max(1u, src_height >> level);
const u32 dst_level_width = std::max(1u, dst_width >> level);
const u32 dst_level_height = std::max(1u, dst_height >> level);
- glBindFramebuffer(GL_READ_FRAMEBUFFER, blit_fbo.handle);
- glNamedFramebufferTexture(blit_fbo.handle, attachment, texture.handle, level);
- glBlitNamedFramebuffer(blit_fbo.handle, blit_fbo.handle, 0, 0, src_level_width,
+ glNamedFramebufferTexture(read_fbo.handle, attachment, texture.handle, level);
+ glNamedFramebufferTexture(draw_fbo.handle, attachment, dst_texture.handle, level);
+ glBlitNamedFramebuffer(read_fbo.handle, draw_fbo.handle, 0, 0, src_level_width,
src_level_height, 0, 0, dst_level_width, dst_level_height, mask,
filter);
- switch (info.type) {
- case ImageType::e1D:
- glCopyTextureSubImage2D(dst_texture.handle, level, 0, 0, 0, 0, dst_level_width,
- dst_level_height);
- break;
- case ImageType::e2D:
- glCopyTextureSubImage3D(dst_texture.handle, level, 0, 0, 0, 0, 0, dst_level_width,
- dst_level_height);
- break;
- case ImageType::e3D:
- default:
- UNREACHABLE();
- }
}
texture = std::move(dst_texture);
// Restore previous framebuffers
+ glBindFramebuffer(GL_DRAW_FRAMEBUFFER, prev_draw_fbo);
glBindFramebuffer(GL_READ_FRAMEBUFFER, prev_read_fbo);
return true;
}
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:
std::array<GLuint, Shader::NUM_TEXTURE_TYPES> null_image_views{};
- OGLFramebuffer rescale_fbo;
+ OGLFramebuffer rescale_draw_fbo;
+ OGLFramebuffer rescale_read_fbo;
Settings::ResolutionScalingInfo resolution;
bool is_rescaling_on{};
};