From 29aed69734772b704f9eeb13ed2f23cc91f5347d Mon Sep 17 00:00:00 2001 From: PolarZero Date: Wed, 5 Apr 2023 02:32:14 +0900 Subject: [PATCH] gl_rasterizer: HP Bar Fix for some games (#6334) * HP Bar Fix for some games Can fix #5139 #5563 and log spam * HP Bar Fix for some games Can fix #5139 #5563 and log spam * Add TODO about HP Bar Fix --- .../rasterizer_cache/rasterizer_cache.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/video_core/rasterizer_cache/rasterizer_cache.cpp b/src/video_core/rasterizer_cache/rasterizer_cache.cpp index 1855f5825..ad88e2bc9 100644 --- a/src/video_core/rasterizer_cache/rasterizer_cache.cpp +++ b/src/video_core/rasterizer_cache/rasterizer_cache.cpp @@ -427,7 +427,24 @@ Surface RasterizerCacheOpenGL::GetTextureSurface(const Pica::Texture::TextureInf u32 min_width = info.width >> max_level; u32 min_height = info.height >> max_level; if (min_width % 8 != 0 || min_height % 8 != 0) { - LOG_CRITICAL(Render_OpenGL, "Texture size ({}x{}) is not multiple of 8", min_width, + // This code is Temponary for 8x4 / 4x4 texture (commonly used by Health bar) support + // implementation might not be accurate and needs further testing + if (min_width % 4 == 0 && min_height % 4 == 0 && min_width * min_height <= 32) { + Surface src_surface; + Common::Rectangle rect; + std::tie(src_surface, rect) = GetSurfaceSubRect(params, ScaleMatch::Ignore, true); + + params.res_scale = src_surface->res_scale; + Surface tmp_surface = CreateSurface(params); + const Aspect aspect = ToAspect(tmp_surface->type); + runtime.BlitTextures(src_surface->texture, {aspect, rect}, tmp_surface->texture, + {aspect, tmp_surface->GetScaledRect(), 0}); + + remove_surfaces.emplace(tmp_surface); + return tmp_surface; + } + + LOG_CRITICAL(Render_OpenGL, "Texture size ({}x{}) is not multiple of 4", min_width, min_height); return nullptr; }