Skip to content

Commit

Permalink
Dump textures only when not available and allow usage for dumper and …
Browse files Browse the repository at this point in the history
…highres textures together.
  • Loading branch information
Rinnegatamante committed Dec 15, 2020
1 parent 3d482de commit c589261
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions Source/SysVita/Graphics/NativeTextureVita.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <vitaGL.h>

#define HIGHRES_TEXTURE_CACHE_SIZE 128
static int highres_tex_cache_idx = 0;
static int highres_tex_cache_size = 0;
static int highres_tex_cache_idx = -1;
static int highres_tex_cache_size = -1;
static bool highres_tex_cache_free = false;

struct HighResTex {
Expand Down Expand Up @@ -127,9 +127,8 @@ bool CNativeTexture::HasData() const

void CNativeTexture::InstallTexture()
{
glBindTexture(GL_TEXTURE_2D, mTextureId);
if (gTexturesDumper) DumpForHighRes();
else if (gUseHighResTextures) {
if (gUseHighResTextures) {
if (highResState == HIGH_RES_UNCHECKED) {
if (!crc) crc = daedalus_crc32(0, (u8*)mpData, mCorrectedWidth * mCorrectedHeight);
GLuint tex_id = highres_cache_lookup(crc);
Expand All @@ -139,6 +138,7 @@ void CNativeTexture::InstallTexture()
glBindTexture(GL_TEXTURE_2D, mTextureId);
highResState = HIGH_RES_INSTALLED;
} else {
glBindTexture(GL_TEXTURE_2D, mTextureId);
char filename[128];
sprintf(filename, "%s%04X/%08X.png", DAEDALUS_VITA_PATH("Textures/"), g_ROM.rh.CartID, crc);
int hires_width, hires_height;
Expand All @@ -153,8 +153,8 @@ void CNativeTexture::InstallTexture()
highResState = HIGH_RES_INSTALLED;
} else highResState = HIGH_RES_ABSENT;
}
}
}
} else glBindTexture(GL_TEXTURE_2D, mTextureId);
} else glBindTexture(GL_TEXTURE_2D, mTextureId);
}

void CNativeTexture::GenerateMipmaps()
Expand Down Expand Up @@ -285,7 +285,9 @@ void CNativeTexture::DumpForHighRes()
sprintf(filename, "%s/%08X.png", folder, crc);
sceIoMkdir(DAEDALUS_VITA_PATH("Textures/"), 0777);
sceIoMkdir(folder, 0777);
stbi_write_png(filename, mCorrectedWidth, mCorrectedHeight, 4, mpData, mCorrectedWidth * 4);
SceUID f = sceIoOpen(filename , SCE_O_RDONLY, 0777);
if (f < 0) stbi_write_png(filename, mCorrectedWidth, mCorrectedHeight, 4, mpData, mCorrectedWidth * 4);
else sceIoClose(f);
dumped = true;
}
}
Expand Down

0 comments on commit c589261

Please sign in to comment.