mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-02-19 13:42:00 +00:00
Replacement: Ensurely orderly stop on reset.
If the texture is being loaded and we stop or reset, make sure it stops to avoid any crash or hang.
This commit is contained in:
parent
09f0578a64
commit
c0054dc6cf
@ -781,6 +781,8 @@ public:
|
||||
|
||||
void Run() override {
|
||||
for (int i = (int)tex_.levelData_.size(); i <= tex_.MaxLevel(); ++i) {
|
||||
if (tex_.cancelPrepare_)
|
||||
break;
|
||||
tex_.levelData_.resize(i + 1);
|
||||
tex_.PrepareData(i);
|
||||
}
|
||||
@ -931,6 +933,14 @@ void ReplacedTexture::PurgeIfOlder(double t) {
|
||||
}
|
||||
}
|
||||
|
||||
ReplacedTexture::~ReplacedTexture() {
|
||||
if (threadWaitable_) {
|
||||
cancelPrepare_ = true;
|
||||
threadWaitable_->WaitAndRelease();
|
||||
threadWaitable_ = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
bool ReplacedTexture::Load(int level, void *out, int rowPitch) {
|
||||
_assert_msg_((size_t)level < levels_.size(), "Invalid miplevel");
|
||||
_assert_msg_(out != nullptr && rowPitch > 0, "Invalid out/pitch");
|
||||
|
@ -127,6 +127,8 @@ namespace std {
|
||||
}
|
||||
|
||||
struct ReplacedTexture {
|
||||
~ReplacedTexture();
|
||||
|
||||
inline bool Valid() {
|
||||
return !levels_.empty();
|
||||
}
|
||||
@ -167,7 +169,8 @@ protected:
|
||||
std::vector<std::vector<uint8_t>> levelData_;
|
||||
ReplacedTextureAlpha alphaStatus_;
|
||||
double lastUsed_ = 0.0;
|
||||
LimitedWaitable * threadWaitable_ = nullptr;
|
||||
LimitedWaitable *threadWaitable_ = nullptr;
|
||||
bool cancelPrepare_ = false;
|
||||
|
||||
friend TextureReplacer;
|
||||
friend ReplacedTextureTask;
|
||||
|
Loading…
x
Reference in New Issue
Block a user