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:
Unknown W. Brackets committed 2022-12-06 20:35:07 -08:00
1 parent 400f6abf9a
commit eda3ce556e
4 files changed
+35 -25

No files matched your search

+6 -5
View File
@@ -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;
}