mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 06:09:50 -06:00
TextureCacheBase: Remove the texture size limit for custom textures. Only the GPU restrictions for maximum texture size remain.
This commit is contained in:
@ -99,7 +99,6 @@ bool HiresTexExists(const char* filename)
|
||||
PC_TexFormat GetHiresTex(const char *fileName, unsigned int *pWidth, unsigned int *pHeight, unsigned int *required_size, int texformat, unsigned int data_size, u8 *data)
|
||||
{
|
||||
std::string key(fileName);
|
||||
|
||||
if (textureMap.find(key) == textureMap.end())
|
||||
return PC_TEX_FMT_NONE;
|
||||
|
||||
@ -108,23 +107,17 @@ PC_TexFormat GetHiresTex(const char *fileName, unsigned int *pWidth, unsigned in
|
||||
int channels;
|
||||
|
||||
u8 *temp = SOIL_load_image(textureMap[key].c_str(), &width, &height, &channels, SOIL_LOAD_RGBA);
|
||||
|
||||
if (temp == NULL)
|
||||
{
|
||||
ERROR_LOG(VIDEO, "Custom texture %s failed to load", textureMap[key].c_str());
|
||||
SOIL_free_image_data(temp);
|
||||
return PC_TEX_FMT_NONE;
|
||||
}
|
||||
|
||||
if (width > 2048 || height > 2048)
|
||||
{
|
||||
ERROR_LOG(VIDEO, "Custom texture %s is too large (%ix%i); textures can only be 2048 pixels tall and wide", textureMap[key].c_str(), width, height);
|
||||
SOIL_free_image_data(temp);
|
||||
return PC_TEX_FMT_NONE;
|
||||
}
|
||||
*pWidth = width;
|
||||
*pHeight = height;
|
||||
|
||||
int offset = 0;
|
||||
PC_TexFormat returnTex;
|
||||
PC_TexFormat returnTex = PC_TEX_FMT_NONE;
|
||||
|
||||
switch (texformat)
|
||||
{
|
||||
@ -132,24 +125,32 @@ PC_TexFormat GetHiresTex(const char *fileName, unsigned int *pWidth, unsigned in
|
||||
case GX_TF_I8:
|
||||
case GX_TF_IA4:
|
||||
case GX_TF_IA8:
|
||||
*required_size = width * height * 8;
|
||||
if (data_size < *required_size)
|
||||
goto cleanup;
|
||||
|
||||
for (int i = 0; i < width * height * 4; i += 4)
|
||||
{
|
||||
// Rather than use a luminosity function, just use the most intense color for luminance
|
||||
// TODO(neobrain): Isn't this kind of.. stupid?
|
||||
data[offset++] = *std::max_element(temp+i, temp+i+3);
|
||||
data[offset++] = temp[i+3];
|
||||
}
|
||||
returnTex = PC_TEX_FMT_IA8;
|
||||
break;
|
||||
default:
|
||||
*required_size = width * height * 4;
|
||||
if (data_size < *required_size)
|
||||
goto cleanup;
|
||||
|
||||
memcpy(data, temp, width * height * 4);
|
||||
returnTex = PC_TEX_FMT_RGBA32;
|
||||
break;
|
||||
}
|
||||
|
||||
*pWidth = width;
|
||||
*pHeight = height;
|
||||
SOIL_free_image_data(temp);
|
||||
INFO_LOG(VIDEO, "loading custom texture from %s", textureMap[key].c_str());
|
||||
cleanup:
|
||||
SOIL_free_image_data(temp);
|
||||
return returnTex;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user