From 5c6fa8893589fd70bc743c0d0b77c0c375b24bd3 Mon Sep 17 00:00:00 2001 From: Fernando Sahmkow Date: Sat, 23 Oct 2021 01:52:34 +0200 Subject: OpenGlTextureCache: Fix state invalidation on rescaling. --- src/video_core/renderer_opengl/gl_texture_cache.cpp | 11 +++++++++++ src/video_core/renderer_opengl/gl_texture_cache.h | 4 ++++ src/video_core/texture_cache/texture_cache.h | 4 ++-- 3 files changed, 17 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/video_core/renderer_opengl/gl_texture_cache.cpp b/src/video_core/renderer_opengl/gl_texture_cache.cpp index a6e9eb60b..6e7f66ef0 100644 --- a/src/video_core/renderer_opengl/gl_texture_cache.cpp +++ b/src/video_core/renderer_opengl/gl_texture_cache.cpp @@ -942,10 +942,21 @@ bool Image::Scale(bool up_scale) { dst_info.size.height = scaled_height; upscaled_backup = MakeImage(dst_info, gl_internal_format); } + auto& state_tracker = runtime->GetStateTracker(); + state_tracker.NotifyViewport0(); + state_tracker.NotifyScissor0(); // TODO (ameerj): Investigate other GL states that affect blitting. GLboolean scissor_test; glGetBooleani_v(GL_SCISSOR_TEST, 0, &scissor_test); glDisablei(GL_SCISSOR_TEST, 0); + if (up_scale) { + glViewportIndexedf(0, 0.0f, 0.0f, static_cast(scaled_width), + static_cast(scaled_height)); + } else { + glViewportIndexedf(0, 0.0f, 0.0f, static_cast(original_width), + static_cast(original_height)); + } + const GLuint read_fbo = runtime->rescale_read_fbos[fbo_index].handle; const GLuint draw_fbo = runtime->rescale_draw_fbos[fbo_index].handle; diff --git a/src/video_core/renderer_opengl/gl_texture_cache.h b/src/video_core/renderer_opengl/gl_texture_cache.h index eeb5133d5..8161e6b72 100644 --- a/src/video_core/renderer_opengl/gl_texture_cache.h +++ b/src/video_core/renderer_opengl/gl_texture_cache.h @@ -116,6 +116,10 @@ public: void TickFrame() {} + StateTracker& GetStateTracker() { + return state_tracker; + } + private: struct StagingBuffers { explicit StagingBuffers(GLenum storage_flags_, GLenum map_flags_); diff --git a/src/video_core/texture_cache/texture_cache.h b/src/video_core/texture_cache/texture_cache.h index f1254ef62..dd9553806 100644 --- a/src/video_core/texture_cache/texture_cache.h +++ b/src/video_core/texture_cache/texture_cache.h @@ -1810,8 +1810,8 @@ void TextureCache

::BindRenderTarget(ImageViewId* old_id, ImageViewId new_id) if (*old_id == new_id) { return; } - if (*old_id) { - const ImageViewBase& old_view = slot_image_views[*old_id]; + if (new_id) { + const ImageViewBase& old_view = slot_image_views[new_id]; if (True(old_view.flags & ImageViewFlagBits::PreemtiveDownload)) { uncommitted_downloads.push_back(old_view.image_id); } -- cgit v1.2.3