mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2024-11-29 12:52:18 -05:00
parent
a72ebbe84d
commit
b9c5b34eba
@ -88,7 +88,7 @@ struct LoadedVertex {
|
|||||||
|
|
||||||
static struct {
|
static struct {
|
||||||
TextureCacheMap map;
|
TextureCacheMap map;
|
||||||
list<TextureCacheMap::iterator> lru;
|
list<TextureCacheMapIter> lru;
|
||||||
vector<uint32_t> free_texture_ids;
|
vector<uint32_t> free_texture_ids;
|
||||||
} gfx_texture_cache;
|
} gfx_texture_cache;
|
||||||
|
|
||||||
@ -527,18 +527,18 @@ static bool gfx_texture_cache_lookup(int i, int tile) {
|
|||||||
key = { orig_addr, { }, fmt, siz, palette_index };
|
key = { orig_addr, { }, fmt, siz, palette_index };
|
||||||
}
|
}
|
||||||
|
|
||||||
auto it = gfx_texture_cache.map.find(key);
|
TextureCacheMap::iterator it = gfx_texture_cache.map.find(key);
|
||||||
|
|
||||||
if (it != gfx_texture_cache.map.end()) {
|
if (it != gfx_texture_cache.map.end()) {
|
||||||
gfx_rapi->select_texture(i, it->second.texture_id);
|
gfx_rapi->select_texture(i, it->second.texture_id);
|
||||||
*n = &*it;
|
*n = &*it;
|
||||||
gfx_texture_cache.lru.splice(gfx_texture_cache.lru.end(), gfx_texture_cache.lru, *(list<TextureCacheMap::iterator>::iterator*)&it->second.lru_location); // move to back
|
gfx_texture_cache.lru.splice(gfx_texture_cache.lru.end(), gfx_texture_cache.lru, it->second.lru_location); // move to back
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gfx_texture_cache.map.size() >= TEXTURE_CACHE_MAX_SIZE) {
|
if (gfx_texture_cache.map.size() >= TEXTURE_CACHE_MAX_SIZE) {
|
||||||
// Remove the texture that was least recently used
|
// Remove the texture that was least recently used
|
||||||
it = gfx_texture_cache.lru.front();
|
it = gfx_texture_cache.lru.front().it;
|
||||||
gfx_texture_cache.free_texture_ids.push_back(it->second.texture_id);
|
gfx_texture_cache.free_texture_ids.push_back(it->second.texture_id);
|
||||||
gfx_texture_cache.map.erase(it);
|
gfx_texture_cache.map.erase(it);
|
||||||
gfx_texture_cache.lru.pop_front();
|
gfx_texture_cache.lru.pop_front();
|
||||||
@ -555,7 +555,7 @@ static bool gfx_texture_cache_lookup(int i, int tile) {
|
|||||||
it = gfx_texture_cache.map.insert(make_pair(key, TextureCacheValue())).first;
|
it = gfx_texture_cache.map.insert(make_pair(key, TextureCacheValue())).first;
|
||||||
TextureCacheNode* node = &*it;
|
TextureCacheNode* node = &*it;
|
||||||
node->second.texture_id = texture_id;
|
node->second.texture_id = texture_id;
|
||||||
*(list<TextureCacheMap::iterator>::iterator*)&node->second.lru_location = gfx_texture_cache.lru.insert(gfx_texture_cache.lru.end(), it);
|
node->second.lru_location = gfx_texture_cache.lru.insert(gfx_texture_cache.lru.end(), { it });
|
||||||
|
|
||||||
gfx_rapi->select_texture(i, texture_id);
|
gfx_rapi->select_texture(i, texture_id);
|
||||||
gfx_rapi->set_sampler_parameters(i, false, 0, 0);
|
gfx_rapi->set_sampler_parameters(i, false, 0, 0);
|
||||||
@ -571,7 +571,7 @@ static void gfx_texture_cache_delete(const uint8_t* orig_addr)
|
|||||||
bool again = false;
|
bool again = false;
|
||||||
for (auto it = gfx_texture_cache.map.begin(bucket); it != gfx_texture_cache.map.end(bucket); ++it) {
|
for (auto it = gfx_texture_cache.map.begin(bucket); it != gfx_texture_cache.map.end(bucket); ++it) {
|
||||||
if (it->first.texture_addr == orig_addr) {
|
if (it->first.texture_addr == orig_addr) {
|
||||||
gfx_texture_cache.lru.erase(*(list<TextureCacheMap::iterator>::iterator*)&it->second.lru_location);
|
gfx_texture_cache.lru.erase(it->second.lru_location);
|
||||||
gfx_texture_cache.free_texture_ids.push_back(it->second.texture_id);
|
gfx_texture_cache.free_texture_ids.push_back(it->second.texture_id);
|
||||||
gfx_texture_cache.map.erase(it->first);
|
gfx_texture_cache.map.erase(it->first);
|
||||||
again = true;
|
again = true;
|
||||||
|
@ -46,12 +46,11 @@ struct TextureCacheValue {
|
|||||||
uint8_t cms, cmt;
|
uint8_t cms, cmt;
|
||||||
bool linear_filter;
|
bool linear_filter;
|
||||||
|
|
||||||
// Old versions of libstdc++ fail to compile this
|
std::list<struct TextureCacheMapIter>::iterator lru_location;
|
||||||
#ifdef _MSC_VER
|
};
|
||||||
std::list<TextureCacheMap::iterator>::iterator lru_location;
|
|
||||||
#else
|
struct TextureCacheMapIter {
|
||||||
std::list<int>::iterator lru_location;
|
TextureCacheMap::iterator it;
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
Loading…
Reference in New Issue
Block a user