diff --git a/rpcs3/Emu/RSX/Common/texture_cache.h b/rpcs3/Emu/RSX/Common/texture_cache.h index 146ec52605..054cf4ca8a 100644 --- a/rpcs3/Emu/RSX/Common/texture_cache.h +++ b/rpcs3/Emu/RSX/Common/texture_cache.h @@ -1100,12 +1100,19 @@ namespace rsx return results; } + template section_storage_type *find_texture_from_dimensions(u32 rsx_address, u16 width = 0, u16 height = 0, u16 depth = 0, u16 mipmaps = 0) { auto &block = m_storage.block_for(rsx_address); for (auto &tex : block) { - if (tex.matches(rsx_address, width, height, depth, mipmaps) && !tex.is_dirty()) + if constexpr (check_unlocked) + { + if (!tex.is_locked()) + continue; + } + + if (!tex.is_dirty() && tex.matches(rsx_address, width, height, depth, mipmaps)) { return &tex; } diff --git a/rpcs3/Emu/RSX/GL/GLGSRender.cpp b/rpcs3/Emu/RSX/GL/GLGSRender.cpp index 0c1f3c5aba..6edf225490 100644 --- a/rpcs3/Emu/RSX/GL/GLGSRender.cpp +++ b/rpcs3/Emu/RSX/GL/GLGSRender.cpp @@ -1673,11 +1673,11 @@ void GLGSRender::flip(int buffer) } } } - else if (auto surface = m_gl_texture_cache.find_texture_from_dimensions(absolute_address, buffer_width, buffer_height)) + else if (auto surface = m_gl_texture_cache.find_texture_from_dimensions(absolute_address, buffer_width, buffer_height)) { //Hack - this should be the first location to check for output //The render might have been done offscreen or in software and a blit used to display - image = surface->get_raw_texture()->id(); + if (const auto tex = surface->get_raw_texture(); tex) image = tex->id(); } if (!image) diff --git a/rpcs3/Emu/RSX/VK/VKGSRender.cpp b/rpcs3/Emu/RSX/VK/VKGSRender.cpp index 6320928d55..7c3f7a73b5 100644 --- a/rpcs3/Emu/RSX/VK/VKGSRender.cpp +++ b/rpcs3/Emu/RSX/VK/VKGSRender.cpp @@ -3310,7 +3310,7 @@ void VKGSRender::flip(int buffer) } } } - else if (auto surface = m_texture_cache.find_texture_from_dimensions(absolute_address, buffer_width, buffer_height)) + else if (auto surface = m_texture_cache.find_texture_from_dimensions(absolute_address, buffer_width, buffer_height)) { //Hack - this should be the first location to check for output //The render might have been done offscreen or in software and a blit used to display