summaryrefslogtreecommitdiff
path: root/Source
diff options
context:
space:
mode:
authorRyan Houdek <Sonicadvance1@gmail.com>2013-01-28 15:18:54 -0600
committerRyan Houdek <Sonicadvance1@gmail.com>2013-01-28 15:18:54 -0600
commitd94f3c4155d8248bb08cbbf7fcd96d8d3d44516d (patch)
treeb8ecb5d946551a975334932b98fa5f313c1d2de2 /Source
parentc5fa3e0f3dbb1fdc5f95e9e3fbfb7de62c718e9c (diff)
Stop using std::pair and std::map. Switch over to u64 and std::unordered_map. Provides a very small speed boost.
Diffstat (limited to 'Source')
-rw-r--r--Source/Plugins/Plugin_VideoOGL/Src/ProgramShaderCache.cpp10
-rw-r--r--Source/Plugins/Plugin_VideoOGL/Src/ProgramShaderCache.h12
2 files changed, 15 insertions, 7 deletions
diff --git a/Source/Plugins/Plugin_VideoOGL/Src/ProgramShaderCache.cpp b/Source/Plugins/Plugin_VideoOGL/Src/ProgramShaderCache.cpp
index 974d839900..e1763038ec 100644
--- a/Source/Plugins/Plugin_VideoOGL/Src/ProgramShaderCache.cpp
+++ b/Source/Plugins/Plugin_VideoOGL/Src/ProgramShaderCache.cpp
@@ -37,7 +37,11 @@ GLenum ProgramFormat;
GLuint ProgramShaderCache::PCacheEntry::prog_format = 0;
-std::pair<u32, u32> ProgramShaderCache::CurrentShaderProgram;
+u64 ProgramShaderCache::CurrentShaderProgram;
+u64 Create_Pair(u32 key1, u32 key2)
+{
+ return (((u64)key1) << 32) | key2;
+}
const char *UniformNames[NUM_UNIFORMS] =
{
// PIXEL SHADER UNIFORMS
@@ -142,7 +146,7 @@ void ProgramShaderCache::SetBothShaders(GLuint PS, GLuint VS)
return;
}
- std::pair<u32, u32> ShaderPair = std::make_pair(PS, VS);
+ u64 ShaderPair = Create_Pair(PS, VS);
// program is already bound
if(ShaderPair == CurrentShaderProgram) return;
@@ -264,7 +268,7 @@ void ProgramShaderCache::Init(void)
}
CurrentProgram = 0;
- CurrentShaderProgram = std::pair<u32,u32>(0,0);
+ CurrentShaderProgram = 0;
}
void ProgramShaderCache::Shutdown(void)
diff --git a/Source/Plugins/Plugin_VideoOGL/Src/ProgramShaderCache.h b/Source/Plugins/Plugin_VideoOGL/Src/ProgramShaderCache.h
index 004f820def..1f4fefdc6f 100644
--- a/Source/Plugins/Plugin_VideoOGL/Src/ProgramShaderCache.h
+++ b/Source/Plugins/Plugin_VideoOGL/Src/ProgramShaderCache.h
@@ -15,7 +15,8 @@
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
-#pragma once
+#ifndef PROGRAM_SHADER_CACHE_H_
+#define PROGRAM_SHADER_CACHE_H_
#include "GLUtil.h"
@@ -27,16 +28,18 @@
#include "LinearDiskCache.h"
#include "ConfigManager.h"
+#include <unordered_map>
+
namespace OGL
{
const int NUM_UNIFORMS = 19;
extern const char *UniformNames[NUM_UNIFORMS];
+u64 Create_Pair(u32 key1, u32 key2);
class ProgramShaderCache
{
public:
- typedef std::pair<u32, u32> ShaderUID;
struct PCacheEntry
{
@@ -59,7 +62,7 @@ public:
{
psid = pix_id;
vsid = vert_id;
- uid = std::make_pair(psid, vsid);
+ uid = Create_Pair(psid, vsid);
prog_id = glCreateProgram();
}
@@ -147,7 +150,7 @@ private:
}
};
- typedef std::map<ShaderUID, PCacheEntry> PCache;
+ typedef std::unordered_map<u64, PCacheEntry> PCache;
static PCache pshaders;
static GLuint CurrentProgram;
@@ -164,3 +167,4 @@ private:
};
} // namespace OGL
+#endif