mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2024-11-26 03:12:18 -05:00
Fix strict aliasing issues
This commit is contained in:
parent
247360cbf0
commit
db2fa61ebb
@ -88,7 +88,7 @@ struct LoadedVertex {
|
||||
|
||||
static struct {
|
||||
TextureCacheMap map;
|
||||
list<TextureCacheMap::iterator> lru;
|
||||
list<TextureCacheMapIter> lru;
|
||||
vector<uint32_t> free_texture_ids;
|
||||
} gfx_texture_cache;
|
||||
|
||||
@ -527,18 +527,18 @@ static bool gfx_texture_cache_lookup(int i, int tile) {
|
||||
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()) {
|
||||
gfx_rapi->select_texture(i, it->second.texture_id);
|
||||
*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;
|
||||
}
|
||||
|
||||
if (gfx_texture_cache.map.size() >= TEXTURE_CACHE_MAX_SIZE) {
|
||||
// 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.map.erase(it);
|
||||
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;
|
||||
TextureCacheNode* node = &*it;
|
||||
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->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;
|
||||
for (auto it = gfx_texture_cache.map.begin(bucket); it != gfx_texture_cache.map.end(bucket); ++it) {
|
||||
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.map.erase(it->first);
|
||||
again = true;
|
||||
|
@ -46,12 +46,11 @@ struct TextureCacheValue {
|
||||
uint8_t cms, cmt;
|
||||
bool linear_filter;
|
||||
|
||||
// Old versions of libstdc++ fail to compile this
|
||||
#ifdef _MSC_VER
|
||||
std::list<TextureCacheMap::iterator>::iterator lru_location;
|
||||
#else
|
||||
std::list<int>::iterator lru_location;
|
||||
#endif
|
||||
std::list<struct TextureCacheMapIter>::iterator lru_location;
|
||||
};
|
||||
|
||||
struct TextureCacheMapIter {
|
||||
TextureCacheMap::iterator it;
|
||||
};
|
||||
|
||||
extern "C" {
|
||||
|
Loading…
Reference in New Issue
Block a user