- at least for Intel GMA we need shaders without 'discard' to render non-transparent stuff. The performance penalty is rather hefty here.

This commit is contained in:
Christoph Oelckers 2014-08-02 21:06:34 +02:00
parent a97b58fa27
commit a63871d170
3 changed files with 22 additions and 4 deletions

View file

@ -106,8 +106,7 @@ bool FRenderState::ApplyShader()
}
else
{
// todo: check how performance is affected by using 'discard' in a shader and if necessary create a separate set of discard-less shaders.
activeShader = GLRenderer->mShaderManager->Get(mTextureEnabled ? mEffectState : 4);
activeShader = GLRenderer->mShaderManager->Get(mTextureEnabled ? mEffectState : 4, mAlphaThreshold >= 0.f);
activeShader->Bind();
}

View file

@ -387,6 +387,8 @@ void FShaderManager::CompileShaders()
{
mActiveShader = NULL;
mTextureEffects.Clear();
mTextureEffectsNAT.Clear();
for (int i = 0; i < MAX_EFFECTS; i++)
{
mEffectShaders[i] = NULL;
@ -396,6 +398,11 @@ void FShaderManager::CompileShaders()
{
FShader *shc = Compile(defaultshaders[i].ShaderName, defaultshaders[i].gettexelfunc, true);
mTextureEffects.Push(shc);
if (i <= 3)
{
FShader *shc = Compile(defaultshaders[i].ShaderName, defaultshaders[i].gettexelfunc, false);
mTextureEffectsNAT.Push(shc);
}
}
for(unsigned i = 0; i < usershaders.Size(); i++)
@ -430,6 +437,10 @@ void FShaderManager::Clean()
glUseProgram(0);
mActiveShader = NULL;
for (unsigned int i = 0; i < mTextureEffectsNAT.Size(); i++)
{
if (mTextureEffectsNAT[i] != NULL) delete mTextureEffectsNAT[i];
}
for (unsigned int i = 0; i < mTextureEffects.Size(); i++)
{
if (mTextureEffects[i] != NULL) delete mTextureEffects[i];
@ -440,6 +451,7 @@ void FShaderManager::Clean()
mEffectShaders[i] = NULL;
}
mTextureEffects.Clear();
mTextureEffectsNAT.Clear();
}
//==========================================================================
@ -504,10 +516,12 @@ EXTERN_CVAR(Int, gl_fuzztype)
void FShaderManager::ApplyMatrices(VSMatrix *proj, VSMatrix *view)
{
for (int i = 0; i <= 4; i++)
for (int i = 0; i < 4; i++)
{
mTextureEffects[i]->ApplyMatrices(proj, view);
mTextureEffectsNAT[i]->ApplyMatrices(proj, view);
}
mTextureEffects[4]->ApplyMatrices(proj, view);
if (gl_fuzztype != 0)
{
mTextureEffects[4+gl_fuzztype]->ApplyMatrices(proj, view);

View file

@ -249,6 +249,7 @@ public:
class FShaderManager
{
TArray<FShader*> mTextureEffects;
TArray<FShader*> mTextureEffectsNAT;
FShader *mActiveShader;
FShader *mEffectShaders[MAX_EFFECTS];
@ -268,9 +269,13 @@ public:
return mActiveShader;
}
FShader *Get(unsigned int eff)
FShader *Get(unsigned int eff, bool alphateston)
{
// indices 0-2 match the warping modes, 3 is brightmap, 4 no texture, the following are custom
if (!alphateston && eff <= 3)
{
return mTextureEffectsNAT[eff]; // Non-alphatest shaders are only created for default, warp1+2 and brightmap. The rest won't get used anyway
}
if (eff < mTextureEffects.Size())
{
return mTextureEffects[eff];