From d04071d6b30dd1babdd8eacee0664188fd29e701 Mon Sep 17 00:00:00 2001 From: BreadFish64 Date: Wed, 27 May 2020 22:14:27 -0500 Subject: [PATCH] video_core/GLES: fix issues cause by missing glTextureBarrier create a duplicate for sampling instead --- src/video_core/renderer_opengl/gl_rasterizer.cpp | 14 ++++++++++++++ .../renderer_opengl/gl_rasterizer_cache.cpp | 2 +- .../renderer_opengl/gl_rasterizer_cache.h | 3 +++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp index 0b826fd90..aff65e42d 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp @@ -776,6 +776,20 @@ bool RasterizerOpenGL::Draw(bool accelerate, bool is_indexed) { } } + OGLTexture temp_tex; + if (need_texture_barrier && GLES) { + 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 (auto& unit : state.texture_units) { + if (unit.texture_2d == color_surface->texture.handle) + unit.texture_2d = temp_tex.handle; + } + } + // Sync and bind the shader if (shader_dirty) { SetShader(); diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp index 88310a0ac..480bc1d53 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp @@ -311,7 +311,7 @@ static constexpr std::array gl }; // Allocate an uninitialized texture of appropriate size and format for the surface -static void AllocateSurfaceTexture(GLuint texture, const FormatTuple& format_tuple, u32 width, +void AllocateSurfaceTexture(GLuint texture, const FormatTuple& format_tuple, u32 width, u32 height) { OpenGLState cur_state = OpenGLState::GetCurState(); diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.h b/src/video_core/renderer_opengl/gl_rasterizer_cache.h index 1a9b6a3b3..ca2159a4d 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer_cache.h +++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.h @@ -339,4 +339,7 @@ struct FormatTuple { constexpr FormatTuple tex_tuple = {GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE}; const FormatTuple& GetFormatTuple(SurfaceParams::PixelFormat pixel_format); + +void AllocateSurfaceTexture(GLuint texture, const FormatTuple& format_tuple, u32 width, + u32 height); } // namespace OpenGL