From d26564d020460dd15f79b5e8e9229f2b99b6b50d Mon Sep 17 00:00:00 2001 From: Khangaroo Date: Thu, 2 Apr 2020 00:59:24 -0400 Subject: [PATCH] Don't dump textures that aren't a power of 2 (#5152) * don't dump textures that aren't a power of 2 * early return * include bitset * revert change to comment block * explain change --- .../renderer_opengl/gl_rasterizer_cache.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp index cbf7d4926..56d65133f 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -884,6 +885,16 @@ bool CachedSurface::LoadCustomTexture(u64 tex_hash, Core::CustomTexInfo& tex_inf } void CachedSurface::DumpTexture(GLuint target_tex, u64 tex_hash) { + // Make sure the texture size is a power of 2 + // If not, the surface is actually a framebuffer + std::bitset<32> width_bits(width); + std::bitset<32> height_bits(height); + if (width_bits.count() != 1 || height_bits.count() != 1) { + LOG_WARNING(Render_OpenGL, "Not dumping {:016X} because size isn't a power of 2 ({}x{})", + tex_hash, width, height); + return; + } + // Dump texture to RGBA8 and encode as PNG const auto& image_interface = Core::System::GetInstance().GetImageInterface(); auto& custom_tex_cache = Core::System::GetInstance().CustomTexCache();