More code movin' .. split Vertex/Pixelshadermngr into xxCache and xxManager.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@1677 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
hrydgard
2008-12-26 10:43:18 +00:00
parent 3669d711a2
commit fa9f5c44fb
17 changed files with 436 additions and 424 deletions

View File

@ -22,6 +22,7 @@
#include <string>
#include "GLUtil.h"
#include "VertexShader.h"
struct VERTEXSHADER
{
@ -33,56 +34,7 @@ struct VERTEXSHADER
#endif
};
class VERTEXSHADERUID
{
public:
u32 values[9];
VERTEXSHADERUID() {
memset(values, 0, sizeof(values));
}
VERTEXSHADERUID(const VERTEXSHADERUID& r) {
for (size_t i = 0; i < sizeof(values) / sizeof(u32); ++i)
values[i] = r.values[i];
}
int GetNumValues() const {
return (((values[0] >> 23) & 0xf)*3 + 3)/4 + 3; // numTexGens*3/4+1
}
bool operator <(const VERTEXSHADERUID& _Right) const
{
if (values[0] < _Right.values[0])
return true;
else if (values[0] > _Right.values[0])
return false;
int N = GetNumValues();
for (int i = 1; i < N; ++i) {
if (values[i] < _Right.values[i])
return true;
else if (values[i] > _Right.values[i])
return false;
}
return false;
}
bool operator ==(const VERTEXSHADERUID& _Right) const
{
if (values[0] != _Right.values[0])
return false;
int N = GetNumValues();
for (int i = 1; i < N; ++i) {
if (values[i] != _Right.values[i])
return false;
}
return true;
}
};
class VertexShaderMngr
class VertexShaderCache
{
struct VSCacheEntry
{
@ -99,18 +51,22 @@ class VertexShaderMngr
typedef std::map<VERTEXSHADERUID, VSCacheEntry> VSCache;
static VSCache vshaders;
static VERTEXSHADER* pShaderLast;
static void GetVertexShaderId(VERTEXSHADERUID& uid, u32 components);
static void SetVSConstant4f(int const_number, float f1, float f2, float f3, float f4);
static void SetVSConstant4fv(int const_number, const float *f);
public:
static void Init();
static void Cleanup();
static void Shutdown();
static VERTEXSHADER* GetShader(u32 components);
static VERTEXSHADER* GetShader(u32 components);
static bool CompileVertexShader(VERTEXSHADER& ps, const char* pstrprogram);
};
// The non-API dependent parts.
class VertexShaderManager
{
public:
static void Init();
static void Shutdown();
// constant management
static void SetConstants();
@ -123,7 +79,6 @@ public:
static void SetTexMatrixChangedB(u32 Value);
static float* GetPosNormalMat();
static float GetPixelAspectRatio();
};
#endif