Generate hash of uniform buffer format on the fly

--HG--
branch : opengl3
hg/feature/opengl3
kaetemi 10 years ago
parent 9e00340a0d
commit be428c4901

@ -38,6 +38,8 @@ namespace NL3D {
class CUniformBufferFormat
{
public:
CUniformBufferFormat() : m_Hash(0) { }
// When changing, update
// - s_TypeAlignment
// - s_TypeSize
@ -96,7 +98,7 @@ public:
inline const CEntry &get(sint i) const { return m_Entries[i]; }
inline size_t size() const { return m_Entries.size(); }
inline void clear() { m_Entries.clear(); }
inline void clear() { m_Entries.clear(); m_Hash = 0; }
private:
static const sint s_TypeAlignment[];
@ -104,6 +106,7 @@ private:
typedef std::vector<CEntry> TEntries;
TEntries m_Entries;
size_t m_Hash;
};

@ -30,6 +30,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <nel/3d/uniform_buffer_format.h>
#include <nel/misc/debug.h>
#include <nel/misc/wang_hash.h>
namespace NL3D {
@ -107,6 +108,12 @@ sint CUniformBufferFormat::push(const std::string &name, TType type, sint count)
entry.Type = type;
entry.Offset = alignOffset;
entry.Count = count;
#if (HAVE_X86_64)
m_Hash = NLMISC::wangHash64(m_Hash ^ ((uint64)type | ((uint64)count << 32)));
#else
m_Hash = NLMISC::wangHash(m_Hash ^ (uint32)type);
m_Hash = NLMISC::wangHash(m_Hash ^ (uint32)count);
#endif
return alignOffset;
}

Loading…
Cancel
Save