mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-11-29 09:13:39 +01:00
softgpu: Avoid atomic structs.
Apparently we don't link libatomic and rather than fighting that, I'll just use thread local values.
This commit is contained in:
1 parent
400f6abf9a
commit
eda3ce556e
4 files changed
+35
-25
No files matched your search
@@ -744,6 +744,8 @@ SingleFunc PixelJitCache::GenericSingle(const PixelFuncID &id) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
thread_local PixelJitCache::LastCache PixelJitCache::lastSingle_;
|
||||
|
||||
// 256k should be plenty of space for plenty of variations.
|
||||
PixelJitCache::PixelJitCache() : CodeBlock(1024 * 64 * 4), cache_(64) {
|
||||
}
|
||||
@@ -792,14 +794,13 @@ SingleFunc PixelJitCache::GetSingle(const PixelFuncID &id, BinManager *binner) {
|
||||
return nullptr;
|
||||
|
||||
const size_t key = std::hash<PixelFuncID>()(id);
|
||||
auto last = lastSingle_.load();
|
||||
if (last.key == key)
|
||||
return last.func;
|
||||
if (lastSingle_.key == key)
|
||||
return lastSingle_.func;
|
||||
|
||||
std::unique_lock<std::mutex> guard(jitCacheLock);
|
||||
auto it = cache_.Get(key);
|
||||
if (it != nullptr) {
|
||||
lastSingle_ = { key, it };
|
||||
lastSingle_.Set(key, it);
|
||||
return it;
|
||||
}
|
||||
|
||||
@@ -826,7 +827,7 @@ SingleFunc PixelJitCache::GetSingle(const PixelFuncID &id, BinManager *binner) {
|
||||
Compile(id);
|
||||
|
||||
it = cache_.Get(key);
|
||||
lastSingle_ = { key, it };
|
||||
lastSingle_.Set(key, it);
|
||||
return it;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user