Added shader sharing mechanism; added "cook all dirty packages" button; other various tweaks and fixes

This commit is contained in:
Aruki
2017-02-09 10:54:38 -07:00
parent 9b6376af68
commit 6d77604667
19 changed files with 139 additions and 145 deletions

View File

@@ -13,12 +13,14 @@ u64 gFailedCompileCount = 0;
u64 gSuccessfulCompileCount = 0;
CShader* CShader::spCurrentShader = nullptr;
int CShader::smNumShaders = 0;
CShader::CShader()
{
mVertexShaderExists = false;
mPixelShaderExists = false;
mProgramExists = false;
smNumShaders++;
}
CShader::CShader(const char *pkVertexSource, const char *pkPixelSource)
@@ -26,6 +28,7 @@ CShader::CShader(const char *pkVertexSource, const char *pkPixelSource)
mVertexShaderExists = false;
mPixelShaderExists = false;
mProgramExists = false;
smNumShaders++;
CompileVertexSource(pkVertexSource);
CompilePixelSource(pkPixelSource);
@@ -39,6 +42,7 @@ CShader::~CShader()
if (mProgramExists) glDeleteProgram(mProgram);
if (spCurrentShader == this) spCurrentShader = 0;
smNumShaders--;
}
bool CShader::CompileVertexSource(const char* pkSource)

View File

@@ -23,6 +23,7 @@ class CShader
GLint mTextureUniforms[8];
GLint mNumLightsUniform;
static int smNumShaders;
static CShader* spCurrentShader;
public:
@@ -45,6 +46,8 @@ public:
static CShader* CurrentShader();
static void KillCachedShader();
inline static int NumShaders() { return smNumShaders; }
private:
void CacheCommonUniforms();
void DumpShaderSource(GLuint Shader, const TString& rkOut);