Permalink
Browse files

Merge pull request #10260 from hrydgard/replace-fixup

Don't try to load replacement mipmaps with bad sizes.
  • Loading branch information...
unknownbrackets committed Dec 5, 2017
2 parents 1d2dbdc + b3086b1 commit db68d38a0655332f79957f439c888ab8339bc2ad
Showing with 29 additions and 3 deletions.
  1. +15 −3 Core/TextureReplacer.cpp
  2. +14 −0 ext/native/thin3d/VulkanQueueRunner.cpp
@@ -33,7 +33,7 @@
static const std::string INI_FILENAME = "textures.ini";
static const std::string NEW_TEXTURE_DIR = "new/";
static const int VERSION = 1;
static const int MAX_MIP_LEVELS = 64;
static const int MAX_MIP_LEVELS = 12; // 12 should be plenty, 8 is the max mip levels supported by the PSP.
TextureReplacer::TextureReplacer() : enabled_(false), allowVideo_(false), ignoreAddress_(false), hash_(ReplacedTextureHash::QUICK) {
none_.alphaStatus_ = ReplacedTextureAlpha::UNKNOWN;
@@ -293,8 +293,20 @@ void TextureReplacer::PopulateReplacement(ReplacedTexture *result, u64 cachekey,
// We pad files that have been hashrange'd so they are the same texture size.
level.w = (png.width * w) / newW;
level.h = (png.height * h) / newH;
result->levels_.push_back(level);
bool bad = false;
if (i != 0) {
// Check that the mipmap size is correct. Can't load mips of the wrong size.
if (level.w != (result->levels_[0].w >> i)) {
WARN_LOG(G3D, "Replacement mipmap invalid: width=%d, expected=%d (level %d, '%s')", level.w, result->levels_[0].w >> i, i, filename.c_str());
bad = true;
}
if (level.h != (result->levels_[0].h >> i)) {
WARN_LOG(G3D, "Replacement mipmap invalid: height=%d, expected=%d (level %d, '%s')", level.h, result->levels_[0].h >> i, i, filename.c_str());
bad = true;
}
}
if (!bad)
result->levels_.push_back(level);
} else {
ERROR_LOG(G3D, "Could not load texture replacement info: %s - %s", filename.c_str(), png.message);
}
@@ -8,6 +8,20 @@ void VulkanQueueRunner::CreateDeviceObjects() {
ILOG("VulkanQueueRunner::CreateDeviceObjects");
InitBackbufferRenderPass();
InitRenderpasses();
#if 0
// Just to check whether it makes sense to split some of these. drawidx is way bigger than the others...
// We should probably just move to variable-size data in a raw buffer anyway...
VkRenderData rd;
ILOG("sizeof(pipeline): %d", (int)sizeof(rd.pipeline));
ILOG("sizeof(draw): %d", (int)sizeof(rd.draw));
ILOG("sizeof(drawidx): %d", (int)sizeof(rd.drawIndexed));
ILOG("sizeof(clear): %d", (int)sizeof(rd.clear));
ILOG("sizeof(viewport): %d", (int)sizeof(rd.viewport));
ILOG("sizeof(scissor): %d", (int)sizeof(rd.scissor));
ILOG("sizeof(blendColor): %d", (int)sizeof(rd.blendColor));
ILOG("sizeof(push): %d", (int)sizeof(rd.push));
#endif
}
void VulkanQueueRunner::ResizeReadbackBuffer(VkDeviceSize requiredSize) {

0 comments on commit db68d38

Please sign in to comment.