From aaa83897fe00e2a011e070117e45cf23a15e5ad8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sun, 12 Mar 2023 13:30:28 +0100 Subject: [PATCH] Some code moving, tweaks --- GPU/Common/ReplacedTexture.cpp | 60 +++++++++++++++++----------------- UI/DevScreens.cpp | 4 +-- 2 files changed, 32 insertions(+), 32 deletions(-) diff --git a/GPU/Common/ReplacedTexture.cpp b/GPU/Common/ReplacedTexture.cpp index 646bc19f06..214b57bc9c 100644 --- a/GPU/Common/ReplacedTexture.cpp +++ b/GPU/Common/ReplacedTexture.cpp @@ -84,6 +84,36 @@ private: LimitedWaitable *waitable_; }; +ReplacedTexture::~ReplacedTexture() { + if (threadWaitable_) { + SetState(ReplacementState::CANCEL_INIT); + + std::unique_lock lock(mutex_); + threadWaitable_->WaitAndRelease(); + threadWaitable_ = nullptr; + } + + for (auto &level : levels_) { + vfs_->ReleaseFile(level.fileRef); + level.fileRef = nullptr; + } +} + +void ReplacedTexture::PurgeIfOlder(double t) { + if (threadWaitable_ && !threadWaitable_->WaitFor(0.0)) + return; + if (lastUsed_ >= t) + return; + + if (levelData_->lastUsed < t) { + // We have to lock since multiple textures might reference this same data. + std::lock_guard guard(levelData_->lock); + levelData_->data.clear(); + // This means we have to reload. If we never purge any, there's no need. + SetState(ReplacementState::POPULATED); + } +} + // This can only return true if ACTIVE or NOT_FOUND. bool ReplacedTexture::IsReady(double budget) { _assert_(vfs_ != nullptr); @@ -476,36 +506,6 @@ bool ReplacedTexture::LoadLevelData(ReplacedTextureLevel &level, int mipLevel, D return true; } -void ReplacedTexture::PurgeIfOlder(double t) { - if (threadWaitable_ && !threadWaitable_->WaitFor(0.0)) - return; - if (lastUsed_ >= t) - return; - - if (levelData_->lastUsed < t) { - // We have to lock since multiple textures might reference this same data. - std::lock_guard guard(levelData_->lock); - levelData_->data.clear(); - // This means we have to reload. If we never purge any, there's no need. - SetState(ReplacementState::POPULATED); - } -} - -ReplacedTexture::~ReplacedTexture() { - if (threadWaitable_) { - SetState(ReplacementState::CANCEL_INIT); - - std::unique_lock lock(mutex_); - threadWaitable_->WaitAndRelease(); - threadWaitable_ = nullptr; - } - - for (auto &level : levels_) { - vfs_->ReleaseFile(level.fileRef); - level.fileRef = nullptr; - } -} - bool ReplacedTexture::CopyLevelTo(int level, void *out, int rowPitch) { _assert_msg_((size_t)level < levels_.size(), "Invalid miplevel"); _assert_msg_(out != nullptr && rowPitch > 0, "Invalid out/pitch"); diff --git a/UI/DevScreens.cpp b/UI/DevScreens.cpp index f54480ef51..d02791a59d 100644 --- a/UI/DevScreens.cpp +++ b/UI/DevScreens.cpp @@ -559,8 +559,8 @@ void SystemInfoScreen::CreateViews() { // Simple non-detailed summary of supported tex compression formats. if (draw->GetDataFormatSupport(Draw::DataFormat::ETC2_R8G8B8_UNORM_BLOCK)) texCompressionFormats += "ETC2 "; if (draw->GetDataFormatSupport(Draw::DataFormat::ASTC_4x4_UNORM_BLOCK)) texCompressionFormats += "ASTC "; - if (draw->GetDataFormatSupport(Draw::DataFormat::BC1_RGBA_UNORM_BLOCK)) texCompressionFormats += "BC1,2,3 "; - if (draw->GetDataFormatSupport(Draw::DataFormat::BC4_UNORM_BLOCK)) texCompressionFormats += "BC4,5 "; + if (draw->GetDataFormatSupport(Draw::DataFormat::BC1_RGBA_UNORM_BLOCK)) texCompressionFormats += "BC1-3 "; + if (draw->GetDataFormatSupport(Draw::DataFormat::BC4_UNORM_BLOCK)) texCompressionFormats += "BC4-5 "; if (draw->GetDataFormatSupport(Draw::DataFormat::BC7_UNORM_BLOCK)) texCompressionFormats += "BC7 "; deviceSpecs->Add(new InfoItem(si->T("Compressed texture formats"), texCompressionFormats));