include TCW in HD texture hash
Soul Calibur has textures sharing the same data but with different formats
This commit is contained in:
parent
ca0816042e
commit
1ef8caff88
|
@ -50,6 +50,10 @@ void CustomTexture::LoaderThread()
|
|||
texture->ComputeHash();
|
||||
int width, height;
|
||||
u8 *image_data = LoadCustomTexture(texture->texture_hash, width, height);
|
||||
if (image_data == NULL)
|
||||
{
|
||||
image_data = LoadCustomTexture(texture->old_texture_hash, width, height);
|
||||
}
|
||||
if (image_data != NULL)
|
||||
{
|
||||
if (texture->custom_image_data != NULL)
|
||||
|
@ -126,7 +130,7 @@ u8* CustomTexture::LoadCustomTexture(u32 hash, int& width, int& height)
|
|||
std::stringstream path;
|
||||
path << textures_path << std::hex << hash << ".png";
|
||||
|
||||
u8 *image_data = loadPNGData(path.str(), width, height, false);
|
||||
u8 *image_data = loadPNGData(path.str(), width, height);
|
||||
if (image_data == NULL)
|
||||
unknown_hashes.insert(hash);
|
||||
|
||||
|
@ -173,8 +177,8 @@ void CustomTexture::DumpTexture(u32 hash, int w, int h, GLuint textype, void *te
|
|||
png_bytepp rows = (png_bytepp)malloc(h * sizeof(png_bytep));
|
||||
for (int y = 0; y < h; y++)
|
||||
{
|
||||
rows[y] = (png_bytep)malloc(w * 4); // 32-bit per pixel
|
||||
u8 *dst = (u8 *)rows[y];
|
||||
rows[h - y - 1] = (png_bytep)malloc(w * 4); // 32-bit per pixel
|
||||
u8 *dst = (u8 *)rows[h - y - 1];
|
||||
switch (textype)
|
||||
{
|
||||
case GL_UNSIGNED_SHORT_4_4_4_4:
|
||||
|
|
|
@ -2018,7 +2018,7 @@ void png_cstd_read(png_structp png_ptr, png_bytep data, png_size_t length)
|
|||
fread(data,1, length,pngfile);
|
||||
}
|
||||
|
||||
u8* loadPNGData(const string& fname, int &width, int &height, bool bottom_to_top)
|
||||
u8* loadPNGData(const string& fname, int &width, int &height)
|
||||
{
|
||||
const char* filename=fname.c_str();
|
||||
FILE* file = fopen(filename, "rb");
|
||||
|
@ -2136,16 +2136,8 @@ u8* loadPNGData(const string& fname, int &width, int &height, bool bottom_to_top
|
|||
}
|
||||
|
||||
// set the individual row_pointers to point at the correct offsets of image_data
|
||||
if (bottom_to_top)
|
||||
{
|
||||
for (int i = 0; i < height; ++i)
|
||||
row_pointers[height - 1 - i] = image_data + i * rowbytes;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < height; ++i)
|
||||
row_pointers[i] = image_data + i * rowbytes;
|
||||
}
|
||||
for (int i = 0; i < height; ++i)
|
||||
row_pointers[height - 1 - i] = image_data + i * rowbytes;
|
||||
|
||||
//read the png into image_data through row_pointers
|
||||
png_read_image(png_ptr, row_pointers);
|
||||
|
@ -2157,7 +2149,7 @@ u8* loadPNGData(const string& fname, int &width, int &height, bool bottom_to_top
|
|||
return image_data;
|
||||
}
|
||||
|
||||
GLuint loadPNG(const string& fname, int &width, int &height, bool bottom_to_top)
|
||||
GLuint loadPNG(const string& fname, int &width, int &height)
|
||||
{
|
||||
png_byte *image_data = loadPNGData(fname, width, height);
|
||||
if (image_data == NULL)
|
||||
|
|
|
@ -184,8 +184,8 @@ GLuint gl_CompileShader(const char* shader, GLuint type);
|
|||
GLuint gl_CompileAndLink(const char* VertexShader, const char* FragmentShader);
|
||||
bool CompilePipelineShader(PipelineShader* s);
|
||||
#define TEXTURE_LOAD_ERROR 0
|
||||
u8* loadPNGData(const string& subpath, int &width, int &height, bool bottom_to_top = true);
|
||||
GLuint loadPNG(const string& subpath, int &width, int &height, bool bottom_to_top = true);
|
||||
u8* loadPNGData(const string& subpath, int &width, int &height);
|
||||
GLuint loadPNG(const string& subpath, int &width, int &height);
|
||||
|
||||
extern struct ShaderUniforms_t
|
||||
{
|
||||
|
@ -271,6 +271,7 @@ struct TextureCacheData
|
|||
//VQ quantizers table for VQ tex
|
||||
//a texture can't be both VQ and PAL at the same time
|
||||
u32 texture_hash; // xxhash of texture data, used for custom textures
|
||||
u32 old_texture_hash; // legacy hash
|
||||
u8* custom_image_data; // loaded custom image data
|
||||
u32 custom_width;
|
||||
u32 custom_height;
|
||||
|
|
|
@ -243,6 +243,8 @@ void TextureCacheData::ComputeHash()
|
|||
texture_hash = XXH32(&vram[sa], size, 7);
|
||||
if (IsPaletted())
|
||||
texture_hash ^= palette_hash;
|
||||
old_texture_hash = texture_hash;
|
||||
texture_hash ^= tcw.full;
|
||||
}
|
||||
|
||||
void TextureCacheData::Update()
|
||||
|
|
Loading…
Reference in New Issue