mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-10-15 23:40:29 +02:00
Add some checks trying to prevent creation of 0 sized textures.
Saw a crash log with a driver crash in CreateTexture...
This commit is contained in:
1 parent
d23bef1525
commit
c8dfa091fa
2 files changed
+20
-14
No files matched your search
+15
-14
@@ -124,25 +124,26 @@ bool ManagedTexture::LoadFromFileData(const uint8_t *data, size_t dataSize, Imag
|
||||
}
|
||||
|
||||
int potentialLevels = std::min(log2i(width[0]), log2i(height[0]));
|
||||
|
||||
TextureDesc desc{};
|
||||
desc.type = TextureType::LINEAR2D;
|
||||
desc.format = fmt;
|
||||
desc.width = width[0];
|
||||
desc.height = height[0];
|
||||
desc.depth = 1;
|
||||
desc.mipLevels = generateMips ? potentialLevels : num_levels;
|
||||
desc.generateMips = generateMips && potentialLevels > num_levels;
|
||||
desc.tag = name;
|
||||
for (int i = 0; i < num_levels; i++) {
|
||||
desc.initData.push_back(image[i]);
|
||||
if (width[0] > 0 && height[0] > 0) {
|
||||
TextureDesc desc{};
|
||||
desc.type = TextureType::LINEAR2D;
|
||||
desc.format = fmt;
|
||||
desc.width = width[0];
|
||||
desc.height = height[0];
|
||||
desc.depth = 1;
|
||||
desc.mipLevels = generateMips ? potentialLevels : num_levels;
|
||||
desc.generateMips = generateMips && potentialLevels > num_levels;
|
||||
desc.tag = name;
|
||||
for (int i = 0; i < num_levels; i++) {
|
||||
desc.initData.push_back(image[i]);
|
||||
}
|
||||
texture_ = draw_->CreateTexture(desc);
|
||||
}
|
||||
texture_ = draw_->CreateTexture(desc);
|
||||
for (int i = 0; i < num_levels; i++) {
|
||||
if (image[i])
|
||||
free(image[i]);
|
||||
}
|
||||
return texture_;
|
||||
return texture_ != nullptr;
|
||||
}
|
||||
|
||||
bool ManagedTexture::LoadFromFile(const std::string &filename, ImageFileType type, bool generateMips) {
|
||||
|
||||
Reference in new issue
Block a user