texture dump hotkey (ctrl+d)

address more comments
This commit is contained in:
khang06 2019-08-17 19:43:40 -04:00 committed by James Rowe
parent 5450d4980d
commit a458155f99
5 changed files with 27 additions and 12 deletions

View file

@ -917,11 +917,21 @@ void CachedSurface::DumpTexture(GLuint target_tex, u64 tex_hash) {
std::vector<u8> decoded_texture;
decoded_texture.resize(width * height * 4);
glBindTexture(GL_TEXTURE_2D, target_tex);
if (GLES)
GetTexImageOES(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_BYTE, height, width, 0,
&decoded_texture[0]);
else
glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_BYTE, &decoded_texture[0]);
/*
GetTexImageOES is used even if not using OpenGL ES to work around a small issue that
happens if using custom textures with texture dumping at the same.
Let's say there's 2 textures that are both 32x32 and one of them gets replaced with a
higher quality 256x256 texture. If the 256x256 texture is displayed first and the 32x32
texture gets uploaded to the same underlying OpenGL texture, the 32x32 texture will
appear in the corner of the 256x256 texture.
If texture dumping is enabled and the 32x32 is undumped, Citra will attempt to dump it.
Since the underlying OpenGL texture is still 256x256, Citra crashes because it thinks the
texture is only 32x32.
GetTexImageOES conveniently only dumps the specified region, and works on both
desktop and ES.
*/
GetTexImageOES(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_BYTE, height, width, 0,
&decoded_texture[0]);
glBindTexture(GL_TEXTURE_2D, 0);
Common::FlipRGBA8Texture(decoded_texture, width, height);
if (!image_interface->EncodePNG(dump_path, decoded_texture, width, height))