mirror of
https://github.com/cemu-project/Cemu.git
synced 2026-06-04 05:35:00 -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
|
// Fallback cache
|
||||||
auto& fallbackEntry = m_fallbackViewCache[gpuSamplerSwizzle];
|
auto it = m_fallbackViewCache.find(gpuSamplerSwizzle);
|
||||||
if (fallbackEntry)
|
if (it != m_fallbackViewCache.end())
|
||||||
{
|
{
|
||||||
return fallbackEntry;
|
return it->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
MTL::Texture* texture = CreateSwizzledView(gpuSamplerSwizzle);
|
MTL::Texture* texture = CreateSwizzledView(gpuSamplerSwizzle);
|
||||||
if (freeIndex != -1)
|
if (freeIndex != -1)
|
||||||
m_viewCache[freeIndex] = {gpuSamplerSwizzle, texture};
|
m_viewCache[freeIndex] = {gpuSamplerSwizzle, texture};
|
||||||
else
|
else
|
||||||
fallbackEntry = texture;
|
m_fallbackViewCache[gpuSamplerSwizzle] = texture;
|
||||||
|
|
||||||
return texture;
|
return texture;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user