mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-12-03 09:22:53 +00:00
- 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:
parent
a97b58fa27
commit
a63871d170
3 changed files with 22 additions and 4 deletions
|
@ -106,8 +106,7 @@ bool FRenderState::ApplyShader()
|
||||||
}
|
}
|
||||||
else
|
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, mAlphaThreshold >= 0.f);
|
||||||
activeShader = GLRenderer->mShaderManager->Get(mTextureEnabled ? mEffectState : 4);
|
|
||||||
activeShader->Bind();
|
activeShader->Bind();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -387,6 +387,8 @@ void FShaderManager::CompileShaders()
|
||||||
{
|
{
|
||||||
mActiveShader = NULL;
|
mActiveShader = NULL;
|
||||||
|
|
||||||
|
mTextureEffects.Clear();
|
||||||
|
mTextureEffectsNAT.Clear();
|
||||||
for (int i = 0; i < MAX_EFFECTS; i++)
|
for (int i = 0; i < MAX_EFFECTS; i++)
|
||||||
{
|
{
|
||||||
mEffectShaders[i] = NULL;
|
mEffectShaders[i] = NULL;
|
||||||
|
@ -396,6 +398,11 @@ void FShaderManager::CompileShaders()
|
||||||
{
|
{
|
||||||
FShader *shc = Compile(defaultshaders[i].ShaderName, defaultshaders[i].gettexelfunc, true);
|
FShader *shc = Compile(defaultshaders[i].ShaderName, defaultshaders[i].gettexelfunc, true);
|
||||||
mTextureEffects.Push(shc);
|
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++)
|
for(unsigned i = 0; i < usershaders.Size(); i++)
|
||||||
|
@ -430,6 +437,10 @@ void FShaderManager::Clean()
|
||||||
glUseProgram(0);
|
glUseProgram(0);
|
||||||
mActiveShader = NULL;
|
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++)
|
for (unsigned int i = 0; i < mTextureEffects.Size(); i++)
|
||||||
{
|
{
|
||||||
if (mTextureEffects[i] != NULL) delete mTextureEffects[i];
|
if (mTextureEffects[i] != NULL) delete mTextureEffects[i];
|
||||||
|
@ -440,6 +451,7 @@ void FShaderManager::Clean()
|
||||||
mEffectShaders[i] = NULL;
|
mEffectShaders[i] = NULL;
|
||||||
}
|
}
|
||||||
mTextureEffects.Clear();
|
mTextureEffects.Clear();
|
||||||
|
mTextureEffectsNAT.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
@ -504,10 +516,12 @@ EXTERN_CVAR(Int, gl_fuzztype)
|
||||||
|
|
||||||
void FShaderManager::ApplyMatrices(VSMatrix *proj, VSMatrix *view)
|
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);
|
mTextureEffects[i]->ApplyMatrices(proj, view);
|
||||||
|
mTextureEffectsNAT[i]->ApplyMatrices(proj, view);
|
||||||
}
|
}
|
||||||
|
mTextureEffects[4]->ApplyMatrices(proj, view);
|
||||||
if (gl_fuzztype != 0)
|
if (gl_fuzztype != 0)
|
||||||
{
|
{
|
||||||
mTextureEffects[4+gl_fuzztype]->ApplyMatrices(proj, view);
|
mTextureEffects[4+gl_fuzztype]->ApplyMatrices(proj, view);
|
||||||
|
|
|
@ -249,6 +249,7 @@ public:
|
||||||
class FShaderManager
|
class FShaderManager
|
||||||
{
|
{
|
||||||
TArray<FShader*> mTextureEffects;
|
TArray<FShader*> mTextureEffects;
|
||||||
|
TArray<FShader*> mTextureEffectsNAT;
|
||||||
FShader *mActiveShader;
|
FShader *mActiveShader;
|
||||||
FShader *mEffectShaders[MAX_EFFECTS];
|
FShader *mEffectShaders[MAX_EFFECTS];
|
||||||
|
|
||||||
|
@ -268,9 +269,13 @@ public:
|
||||||
return mActiveShader;
|
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
|
// 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())
|
if (eff < mTextureEffects.Size())
|
||||||
{
|
{
|
||||||
return mTextureEffects[eff];
|
return mTextureEffects[eff];
|
||||||
|
|
Loading…
Reference in a new issue