Fix zipped texture packs (it didn't load the ini from the zip, the rest worked).

Plus a few other things.
This commit is contained in:
Henrik Rydgård 2023-03-14 17:52:40 +01:00
parent 42aa5f0c32
commit d8c3269cc6
4 changed files with 18 additions and 10 deletions

View file

@ -232,20 +232,23 @@ void ReplacedTexture::Prepare(VFSBackend *vfs) {
}
}
delete desc_;
desc_ = nullptr;
if (levels_.empty()) {
// Bad.
WARN_LOG(G3D, "Failed to load texture");
// No replacement found.
std::string name = TextureReplacer::HashName(desc_->cachekey, desc_->hash, 0);
INFO_LOG(G3D, "Failed to load replacement texture. %s", name.c_str());
SetState(ReplacementState::NOT_FOUND);
levelData_ = nullptr;
delete desc_;
desc_ = nullptr;
return;
}
levelData_->fmt = fmt;
SetState(ReplacementState::ACTIVE);
delete desc_;
desc_ = nullptr;
if (threadWaitable_)
threadWaitable_->Notify();
}

View file

@ -135,7 +135,7 @@ bool TextureReplacer::LoadIni() {
}
IniFile ini;
bool iniLoaded = ini.LoadFromVFS(g_VFS, (basePath_ / INI_FILENAME).ToString());
bool iniLoaded = ini.LoadFromVFS(*dir, INI_FILENAME);
if (iniLoaded) {
if (!LoadIniValues(ini)) {
@ -183,7 +183,11 @@ bool TextureReplacer::LoadIni() {
repl.second->vfs_ = vfs_;
}
INFO_LOG(G3D, "Texture pack activated from '%s'", basePath_.c_str());
if (vfsIsZip_) {
INFO_LOG(G3D, "Texture pack activated from '%s'", (basePath_ / ZIP_FILENAME).c_str());
} else {
INFO_LOG(G3D, "Texture pack activated from '%s'", basePath_.c_str());
}
// The ini doesn't have to exist for the texture directory or zip to be valid.
return true;

View file

@ -301,7 +301,7 @@ void TextureCacheD3D11::BuildTexture(TexCacheEntry *const entry) {
if (plan.replaceValid) {
int blockSize = 0;
if (Draw::DataFormatIsBlockCompressed(plan.replaced->Format(), &blockSize)) {
stride = ((mipWidth + 3) & ~3) * 4; // This stride value doesn't quite make sense to me, but it works.
stride = ((mipWidth + 3) & ~3) * blockSize / 4; // This stride value doesn't quite make sense to me, but it works?
dataSize = plan.replaced->GetLevelDataSize(i);
} else {
int bpp = (int)Draw::DataFormatSizeInBytes(plan.replaced->Format());
@ -364,7 +364,6 @@ void TextureCacheD3D11::BuildTexture(TexCacheEntry *const entry) {
desc.Format = dstFmt;
desc.MipLevels = levels;
desc.BindFlags = D3D11_BIND_SHADER_RESOURCE;
ASSERT_SUCCESS(device_->CreateTexture2D(&desc, subresData, &tex));
texture = tex;
} else {

View file

@ -129,7 +129,9 @@ void DrawEngineDX9::InitDeviceObjects() {
}
void DrawEngineDX9::DestroyDeviceObjects() {
draw_->SetInvalidationCallback(InvalidationCallback());
if (draw_) {
draw_->SetInvalidationCallback(InvalidationCallback());
}
ClearTrackedVertexArrays();
}