diff --git a/src/hmd.cpp b/src/hmd.cpp index df456efeb..fe3ab17da 100644 --- a/src/hmd.cpp +++ b/src/hmd.cpp @@ -60,10 +60,10 @@ namespace bgfx void VR::getViewport(uint8_t _eye, Rect* _viewport) const { - _viewport->m_width = m_desc.m_eyeSize[_eye].m_w; - _viewport->m_x = _eye * (m_desc.m_eyeSize[_eye].m_w + 1); - _viewport->m_height = (uint16_t)m_desc.m_eyeSize[_eye].m_h; - _viewport->m_y = 0; + _viewport->m_x = uint16_t(_eye * (m_desc.m_eyeSize[_eye].m_w + 1) ); + _viewport->m_y = 0; + _viewport->m_width = uint16_t(m_desc.m_eyeSize[_eye].m_w); + _viewport->m_height = uint16_t(m_desc.m_eyeSize[_eye].m_h); } void VR::makeRenderTargetActive() diff --git a/src/renderer.h b/src/renderer.h index 77406e92f..068c68ba2 100644 --- a/src/renderer.h +++ b/src/renderer.h @@ -390,6 +390,50 @@ namespace bgfx Data m_data[MaxHandleT]; }; + class StateCache + { + public: + void add(uint64_t _key, uint16_t _value) + { + invalidate(_key); + m_hashMap.insert(stl::make_pair(_key, _value) ); + } + + uint16_t find(uint64_t _key) + { + HashMap::iterator it = m_hashMap.find(_key); + if (it != m_hashMap.end() ) + { + return it->second; + } + + return UINT16_MAX; + } + + void invalidate(uint64_t _key) + { + HashMap::iterator it = m_hashMap.find(_key); + 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 HashMap; + HashMap m_hashMap; + }; + } // namespace bgfx #endif // BGFX_RENDERER_H_HEADER_GUARD diff --git a/src/renderer_d3d.h b/src/renderer_d3d.h index 1572669b9..99152f8b1 100644 --- a/src/renderer_d3d.h +++ b/src/renderer_d3d.h @@ -167,50 +167,6 @@ namespace bgfx HashMap m_hashMap; }; - class StateCache - { - public: - void add(uint64_t _key, uint16_t _value) - { - invalidate(_key); - m_hashMap.insert(stl::make_pair(_key, _value) ); - } - - uint16_t find(uint64_t _key) - { - HashMap::iterator it = m_hashMap.find(_key); - if (it != m_hashMap.end() ) - { - return it->second; - } - - return UINT16_MAX; - } - - void invalidate(uint64_t _key) - { - HashMap::iterator it = m_hashMap.find(_key); - 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 HashMap; - HashMap m_hashMap; - }; - template<> inline void release(IUnknown* _ptr) {