Merge pull request #11879 from iwubcode/texture_data_load_nolevels
VideoCommon: avoid segfault when loading a PNG with no custom texture data levels
This commit is contained in:
commit
80bf175c48
|
@ -515,11 +515,6 @@ bool LoadDDSTexture(CustomTextureData::Level* level, const std::string& filename
|
||||||
info.first_mip_row_length, info.first_mip_size);
|
info.first_mip_row_length, info.first_mip_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LoadPNGTexture(CustomTextureData* texture, const std::string& filename)
|
|
||||||
{
|
|
||||||
return LoadPNGTexture(&texture->m_levels[0], filename);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool LoadPNGTexture(CustomTextureData::Level* level, const std::string& filename)
|
bool LoadPNGTexture(CustomTextureData::Level* level, const std::string& filename)
|
||||||
{
|
{
|
||||||
if (!level) [[unlikely]]
|
if (!level) [[unlikely]]
|
||||||
|
|
|
@ -27,6 +27,5 @@ public:
|
||||||
|
|
||||||
bool LoadDDSTexture(CustomTextureData* texture, const std::string& filename);
|
bool LoadDDSTexture(CustomTextureData* texture, const std::string& filename);
|
||||||
bool LoadDDSTexture(CustomTextureData::Level* level, const std::string& filename, u32 mip_level);
|
bool LoadDDSTexture(CustomTextureData::Level* level, const std::string& filename, u32 mip_level);
|
||||||
bool LoadPNGTexture(CustomTextureData* texture, const std::string& filename);
|
|
||||||
bool LoadPNGTexture(CustomTextureData::Level* level, const std::string& filename);
|
bool LoadPNGTexture(CustomTextureData::Level* level, const std::string& filename);
|
||||||
} // namespace VideoCommon
|
} // namespace VideoCommon
|
||||||
|
|
|
@ -72,8 +72,11 @@ CustomAssetLibrary::LoadInfo DirectFilesystemAssetLibrary::LoadTexture(const Ass
|
||||||
}
|
}
|
||||||
else if (ext == ".png")
|
else if (ext == ".png")
|
||||||
{
|
{
|
||||||
LoadPNGTexture(data, asset_path.string());
|
// If we have no levels, create one to pass into LoadPNGTexture
|
||||||
if (data->m_levels.empty()) [[unlikely]]
|
if (data->m_levels.empty())
|
||||||
|
data->m_levels.push_back({});
|
||||||
|
|
||||||
|
if (!LoadPNGTexture(&data->m_levels[0], asset_path.string()))
|
||||||
return {};
|
return {};
|
||||||
if (!LoadMips(asset_path, data))
|
if (!LoadMips(asset_path, data))
|
||||||
return {};
|
return {};
|
||||||
|
|
Loading…
Reference in New Issue