mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-04-16 05:42:55 +00:00
Reverted the comparison function to r5159 and rewrote map to hash_map. I confirmed that the code can be compiled and run under Visual Studio 2008. And I confirmed the code can be compiled under gcc 4.4.0 (mingw). I could not confirm that the code run under linux.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5161 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
1b61742b53
commit
d69478e539
@ -35,6 +35,7 @@
|
|||||||
class VertexLoaderUID
|
class VertexLoaderUID
|
||||||
{
|
{
|
||||||
u32 vid[5];
|
u32 vid[5];
|
||||||
|
size_t hashValue;
|
||||||
public:
|
public:
|
||||||
VertexLoaderUID() {}
|
VertexLoaderUID() {}
|
||||||
void InitFromCurrentState(int vtx_attr_group) {
|
void InitFromCurrentState(int vtx_attr_group) {
|
||||||
@ -43,9 +44,31 @@ 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);
|
||||||
}
|
}
|
||||||
bool operator < (const VertexLoaderUID &other) const {
|
bool operator < (const VertexLoaderUID &other) const {
|
||||||
return std::lexicographical_compare(vid, vid + sizeof(vid) / sizeof(vid[0]), other.vid, other.vid + sizeof(vid) / sizeof(vid[0]));
|
// This is complex because of speed.
|
||||||
|
if (vid[0] < other.vid[0])
|
||||||
|
return true;
|
||||||
|
else if (vid[0] > other.vid[0])
|
||||||
|
return false;
|
||||||
|
for (int i = 1; i < 5; ++i) {
|
||||||
|
if (vid[i] < other.vid[i])
|
||||||
|
return true;
|
||||||
|
else if (vid[i] > other.vid[i])
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
static size_t hash(const VertexLoaderUID& rh) {
|
||||||
|
size_t h = -1;
|
||||||
|
for (int i = 0; i < sizeof(rh.vid) / sizeof(rh.vid[0]); ++i) {
|
||||||
|
h = h * 137 + rh.vid[i];
|
||||||
|
}
|
||||||
|
return h;
|
||||||
|
}
|
||||||
|
operator size_t() const {
|
||||||
|
return hashValue;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -15,9 +15,16 @@
|
|||||||
// Official SVN repository and contact information can be found at
|
// Official SVN repository and contact information can be found at
|
||||||
// http://code.google.com/p/dolphin-emu/
|
// http://code.google.com/p/dolphin-emu/
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#include <hash_map>
|
||||||
|
using stdext::hash_map;
|
||||||
|
#else
|
||||||
|
#include <ext/hash_map>
|
||||||
|
using __gnu_cxx::hash_map;
|
||||||
|
#endif
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <algorithm>
|
|
||||||
|
|
||||||
#include "VideoCommon.h"
|
#include "VideoCommon.h"
|
||||||
#include "Statistics.h"
|
#include "Statistics.h"
|
||||||
@ -30,10 +37,20 @@ static int s_attr_dirty; // bitfield
|
|||||||
|
|
||||||
static VertexLoader *g_VertexLoaders[8];
|
static VertexLoader *g_VertexLoaders[8];
|
||||||
|
|
||||||
|
#ifndef _MSC_VER
|
||||||
|
namespace __gnu_cxx {
|
||||||
|
template<> struct hash<VertexLoaderUID> {
|
||||||
|
size_t operator()(const VertexLoaderUID& __x) const {
|
||||||
|
return __x;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace VertexLoaderManager
|
namespace VertexLoaderManager
|
||||||
{
|
{
|
||||||
|
|
||||||
typedef std::map<VertexLoaderUID, VertexLoader *> VertexLoaderMap;
|
typedef hash_map<VertexLoaderUID, VertexLoader*> VertexLoaderMap;
|
||||||
static VertexLoaderMap g_VertexLoaderMap;
|
static VertexLoaderMap g_VertexLoaderMap;
|
||||||
// TODO - change into array of pointers. Keep a map of all seen so far.
|
// TODO - change into array of pointers. Keep a map of all seen so far.
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user