mirror of
https://github.com/cemu-project/Cemu.git
synced 2026-04-12 03:11:27 -06:00
Metal: fix null pointer use in LatteTextureViewMtl destructor
std::map::operator[] inserts a default-constructed (null) value when the key is absent. In GetSwizzledView, m_fallbackViewCache[key] would insert a null entry, but if a free slot existed in m_viewCache the texture was stored there instead, leaving the null entry in m_fallbackViewCache. The destructor then iterated the map and called ->release() on that null pointer.
This commit is contained in:
parent
9ad8b44b52
commit
555469974c
@ -104,17 +104,17 @@ MTL::Texture* LatteTextureViewMtl::GetSwizzledView(uint32 gpuSamplerSwizzle)
|
||||
}
|
||||
|
||||
// Fallback cache
|
||||
auto& fallbackEntry = m_fallbackViewCache[gpuSamplerSwizzle];
|
||||
if (fallbackEntry)
|
||||
auto it = m_fallbackViewCache.find(gpuSamplerSwizzle);
|
||||
if (it != m_fallbackViewCache.end())
|
||||
{
|
||||
return fallbackEntry;
|
||||
return it->second;
|
||||
}
|
||||
|
||||
MTL::Texture* texture = CreateSwizzledView(gpuSamplerSwizzle);
|
||||
if (freeIndex != -1)
|
||||
m_viewCache[freeIndex] = {gpuSamplerSwizzle, texture};
|
||||
else
|
||||
fallbackEntry = texture;
|
||||
m_fallbackViewCache[gpuSamplerSwizzle] = texture;
|
||||
|
||||
return texture;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user