Cleanup. Added state cache.

This commit is contained in:
Branimir Karadžić 2015-03-05 21:11:44 -08:00
parent 2ce33465d5
commit 918b111eb5
3 changed files with 54 additions and 5 deletions

View file

@ -1450,6 +1450,10 @@ again:
{
_type = RendererType::OpenGLES;
}
else if (s_rendererCreator[RendererType::Vulkan].supported)
{
_type = RendererType::Vulkan;
}
}
else if (BX_ENABLED(0
|| BX_PLATFORM_ANDROID

View file

@ -138,6 +138,50 @@ namespace bgfx
HashMap m_hashMap;
};
class StateCache
{
public:
void add(uint64_t _id, uint16_t _item)
{
invalidate(_id);
m_hashMap.insert(stl::make_pair(_id, _item));
}
uint16_t find(uint64_t _id)
{
HashMap::iterator it = m_hashMap.find(_id);
if (it != m_hashMap.end())
{
return it->second;
}
return UINT16_MAX;
}
void invalidate(uint64_t _id)
{
HashMap::iterator it = m_hashMap.find(_id);
if (it != m_hashMap.end())
{
m_hashMap.erase(it);
}
}
void invalidate()
{
m_hashMap.clear();
}
uint32_t getCount() const
{
return uint32_t(m_hashMap.size());
}
private:
typedef stl::unordered_map<uint64_t, uint16_t> HashMap;
HashMap m_hashMap;
};
} // namespace bgfx
#endif // BGFX_RENDERER_D3D_H_HEADER_GUARD

View file

@ -14,6 +14,7 @@ namespace bgfx
{
return NULL;
}
void rendererDestroyVK()
{
}