Split a couple of huge files up, to make them easier to handle.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@24 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
hrydgard
2008-07-17 21:09:18 +00:00
parent af0e52554e
commit 91ccda69ef
18 changed files with 1696 additions and 1574 deletions

View File

@ -21,6 +21,25 @@
#include "Render.h"
#include "BPStructs.h"
#define I_COLORS "color"
#define I_KCOLORS "k"
#define I_ALPHA "alphaRef"
#define I_TEXDIMS "texdim"
#define I_ZBIAS "czbias"
#define I_INDTEXSCALE "cindscale"
#define I_INDTEXMTX "cindmtx"
#define C_COLORS 0
#define C_KCOLORS (C_COLORS+4)
#define C_ALPHA (C_KCOLORS+4)
#define C_TEXDIMS (C_ALPHA+1)
#define C_ZBIAS (C_TEXDIMS+8)
#define C_INDTEXSCALE (C_ZBIAS+2)
#define C_INDTEXMTX (C_INDTEXSCALE+2)
#define C_ENVCONST_END (C_INDTEXMTX+6)
#define C_COLORMATRIX (C_INDTEXMTX+6)
struct FRAGMENTSHADER
{
FRAGMENTSHADER() : glprogid(0) { }
@ -31,124 +50,6 @@ struct FRAGMENTSHADER
#endif
};
class PixelShaderMngr
{
class PIXELSHADERUID
{
public:
PIXELSHADERUID() { values = new u32[3+32+6+11]; tevstages = indstages = 0; }
~PIXELSHADERUID() { delete[] values; }
PIXELSHADERUID(const PIXELSHADERUID& r)
{
values = new u32[4+32+6+11];
tevstages = r.tevstages; indstages = r.indstages;
int N = tevstages + indstages + 3;
_assert_(N <= 4+32+6+11);
for(int i = 0; i < N; ++i)
values[i] = r.values[i];
}
bool operator <(const PIXELSHADERUID& _Right) const
{
if( values[0] < _Right.values[0] )
return true;
else if( values[0] > _Right.values[0] )
return false;
int N = tevstages + 3; // numTevStages*3/2+1
int i = 1;
for(; i < N; ++i) {
if( values[i] < _Right.values[i] )
return true;
else if( values[i] > _Right.values[i] )
return false;
}
N += indstages;
for(; 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 PIXELSHADERUID& _Right) const
{
if( values[0] != _Right.values[0] )
return false;
int N = tevstages + 3; // numTevStages*3/2+1
int i = 1;
for(; i < N; ++i) {
if( values[i] != _Right.values[i] )
return false;
}
N += indstages;
for(; i < N; ++i) {
if( values[i] != _Right.values[i] )
return false;
}
return true;
}
u32* values;
u16 tevstages, indstages;
};
struct PSCacheEntry
{
FRAGMENTSHADER shader;
int frameCount;
PSCacheEntry() : frameCount(0) {}
~PSCacheEntry() {}
void Destroy() {
glDeleteProgramsARB(1, &shader.glprogid);
}
};
typedef std::map<PIXELSHADERUID,PSCacheEntry> PSCache;
static FRAGMENTSHADER* pShaderLast; // last used shader
static PSCache pshaders;
static bool GeneratePixelShader(FRAGMENTSHADER& ps);
static void GetPixelShaderId(PIXELSHADERUID&);
static PIXELSHADERUID s_curuid; // the current pixel shader uid (progressively changed as memory is written)
public:
static void Init();
static void Cleanup();
static void Shutdown();
static FRAGMENTSHADER* GetShader();
static bool CompilePixelShader(FRAGMENTSHADER& ps, const char* pstrprogram);
static void SetConstants(FRAGMENTSHADER& ps); // sets pixel shader constants
// constant management, should be called after memory is committed
static void SetColorChanged(int type, int index);
static void SetAlpha(const AlphaFunc& alpha);
static void SetDestAlpha(const ConstantAlpha& alpha);
static void SetTexDims(int texmapid, u32 width, u32 height, u32 wraps, u32 wrapt);
static void SetZTetureBias(u32 bias);
static void SetIndTexScaleChanged();
static void SetIndMatrixChanged(int matrixidx);
static void SetGenModeChanged();
static void SetTevCombinerChanged(int id);
static void SetTevKSelChanged(int id);
static void SetTevOrderChanged(int id);
static void SetTevIndirectChanged(int id);
static void SetZTetureOpChanged();
static void SetTexturesUsed(u32 nonpow2tex);
static void SetTexDimsChanged(int texmapid);
static void SetColorMatrix(const float* pmatrix, const float* pfConstAdd);
static GLuint GetColorMatrixProgram();
};
bool GeneratePixelShader(FRAGMENTSHADER& ps);
#endif