mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-02-18 21:40:53 +00:00
Fixed the crazy code in r5161.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5163 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
6376645b69
commit
2dabcb881c
@ -35,7 +35,7 @@
|
|||||||
class VertexLoaderUID
|
class VertexLoaderUID
|
||||||
{
|
{
|
||||||
u32 vid[5];
|
u32 vid[5];
|
||||||
size_t hashValue;
|
size_t hash;
|
||||||
public:
|
public:
|
||||||
VertexLoaderUID() {}
|
VertexLoaderUID() {}
|
||||||
void InitFromCurrentState(int vtx_attr_group) {
|
void InitFromCurrentState(int vtx_attr_group) {
|
||||||
@ -44,7 +44,7 @@ public:
|
|||||||
vid[2] = g_VtxAttr[vtx_attr_group].g0.Hex & ~VAT_0_FRACBITS;
|
vid[2] = g_VtxAttr[vtx_attr_group].g0.Hex & ~VAT_0_FRACBITS;
|
||||||
vid[3] = g_VtxAttr[vtx_attr_group].g1.Hex & ~VAT_1_FRACBITS;
|
vid[3] = g_VtxAttr[vtx_attr_group].g1.Hex & ~VAT_1_FRACBITS;
|
||||||
vid[4] = g_VtxAttr[vtx_attr_group].g2.Hex & ~VAT_2_FRACBITS;
|
vid[4] = g_VtxAttr[vtx_attr_group].g2.Hex & ~VAT_2_FRACBITS;
|
||||||
hashValue = hash(*this);
|
hash = CalculateHash();
|
||||||
}
|
}
|
||||||
bool operator < (const VertexLoaderUID &other) const {
|
bool operator < (const VertexLoaderUID &other) const {
|
||||||
// This is complex because of speed.
|
// This is complex because of speed.
|
||||||
@ -60,16 +60,20 @@ public:
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
static size_t hash(const VertexLoaderUID& rh) {
|
bool operator == (const VertexLoaderUID& rh) const {
|
||||||
|
return hash == rh.hash && std::equal(vid, vid + sizeof(vid) / sizeof(vid[0]), rh.vid);
|
||||||
|
}
|
||||||
|
size_t GetHash() const {
|
||||||
|
return hash;
|
||||||
|
}
|
||||||
|
private:
|
||||||
|
size_t CalculateHash() {
|
||||||
size_t h = -1;
|
size_t h = -1;
|
||||||
for (int i = 0; i < sizeof(rh.vid) / sizeof(rh.vid[0]); ++i) {
|
for (int i = 0; i < sizeof(vid) / sizeof(vid[0]); ++i) {
|
||||||
h = h * 137 + rh.vid[i];
|
h = h * 137 + vid[i];
|
||||||
}
|
}
|
||||||
return h;
|
return h;
|
||||||
}
|
}
|
||||||
operator size_t() const {
|
|
||||||
return hashValue;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class VertexLoader : public Gen::XCodeBlock
|
class VertexLoader : public Gen::XCodeBlock
|
||||||
|
@ -37,11 +37,17 @@ static int s_attr_dirty; // bitfield
|
|||||||
|
|
||||||
static VertexLoader *g_VertexLoaders[8];
|
static VertexLoader *g_VertexLoaders[8];
|
||||||
|
|
||||||
#ifndef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
|
namespace stdext {
|
||||||
|
inline size_t hash_value(const VertexLoaderUID& uid) {
|
||||||
|
return uid.GetHash();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#else
|
||||||
namespace __gnu_cxx {
|
namespace __gnu_cxx {
|
||||||
template<> struct hash<VertexLoaderUID> {
|
template<> struct hash<VertexLoaderUID> {
|
||||||
size_t operator()(const VertexLoaderUID& __x) const {
|
size_t operator()(const VertexLoaderUID& uid) const {
|
||||||
return __x;
|
return uid.GetHash();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user