From b80c6f753409cf3d8e1c2c1c3d1e9b861dc14bb4 Mon Sep 17 00:00:00 2001 From: BreadFish64 Date: Sat, 20 Jun 2020 12:52:58 -0500 Subject: [PATCH] handle all cases more robustly --- .../renderer_opengl/gl_rasterizer.cpp | 25 ++++++++++++------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp index aff65e42d..43b8ecc3c 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp @@ -777,16 +777,27 @@ bool RasterizerOpenGL::Draw(bool accelerate, bool is_indexed) { } OGLTexture temp_tex; - if (need_texture_barrier && GLES) { + if (need_texture_barrier) { temp_tex.Create(); AllocateSurfaceTexture(temp_tex.handle, GetFormatTuple(color_surface->pixel_format), color_surface->GetScaledWidth(), color_surface->GetScaledHeight()); - glCopyImageSubData(color_surface->texture.handle, GL_TEXTURE_2D, 0, 0, 0, 0, - temp_tex.handle, GL_TEXTURE_2D, 0, 0, 0, 0, color_surface->GetScaledWidth(), - color_surface->GetScaledHeight(), 1); + for (std::size_t mip{0}; mip <= color_surface->max_level; ++mip) { + glCopyImageSubData(color_surface->texture.handle, GL_TEXTURE_2D, mip, 0, 0, 0, + temp_tex.handle, GL_TEXTURE_2D, mip, 0, 0, 0, + color_surface->GetScaledWidth() >> mip, + color_surface->GetScaledHeight() >> mip, 1); + } for (auto& unit : state.texture_units) { - if (unit.texture_2d == color_surface->texture.handle) + if (unit.texture_2d == color_surface->texture.handle) { unit.texture_2d = temp_tex.handle; + } + } + for (auto shadow_unit : {&state.image_shadow_texture_nx, &state.image_shadow_texture_ny, + &state.image_shadow_texture_nz, &state.image_shadow_texture_px, + &state.image_shadow_texture_py, &state.image_shadow_texture_pz}) { + if (*shadow_unit == color_surface->texture.handle) { + *shadow_unit = temp_tex.handle; + } } } @@ -864,10 +875,6 @@ bool RasterizerOpenGL::Draw(bool accelerate, bool is_indexed) { GL_TEXTURE_UPDATE_BARRIER_BIT | GL_FRAMEBUFFER_BARRIER_BIT); } - if (need_texture_barrier && GLAD_GL_ARB_texture_barrier) { - glTextureBarrier(); - } - // Mark framebuffer surfaces as dirty Common::Rectangle draw_rect_unscaled{draw_rect.left / res_scale, draw_rect.top / res_scale, draw_rect.right / res_scale,