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

@ -972,16 +972,16 @@ namespace bgfx
m_viewRemap[ii] = ii;
}
memset(m_fb, 0xff, sizeof(m_fb) );
memset(m_clear, 0, sizeof(m_clear) );
memset(m_rect, 0, sizeof(m_rect) );
memset(m_fb, 0xff, sizeof(m_fb) );
memset(m_clear, 0, sizeof(m_clear) );
memset(m_rect, 0, sizeof(m_rect) );
memset(m_scissor, 0, sizeof(m_scissor) );
memset(m_seq, 0, sizeof(m_seq) );
memset(m_seq, 0, sizeof(m_seq) );
memset(m_seqMask, 0, sizeof(m_seqMask) );
for (uint32_t ii = 0; ii < BX_COUNTOF(m_rect); ++ii)
{
m_rect[ii].m_width = 1;
m_rect[ii].m_width = 1;
m_rect[ii].m_height = 1;
}
@ -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()
{
}