Don't generate and cache shaders if they are set up from outside of the driver.

--HG--
branch : gsoc2013-dfighter
hg/feature/gsoc2013-dfighter
dfighter1985 11 years ago
parent 43ad0189c6
commit 681a0bc8f3

@ -584,8 +584,10 @@ namespace NL3D
generateShaderDesc( desc, mat );
// See if we've already generated and compiled this shader
sp = shaderCache.findShader( desc );
// Yes we have!
if( !sp.empty() )
{
if( currentProgram.vp == NULL )
@ -600,18 +602,22 @@ namespace NL3D
return false;
}
}
// No we need to generate it now
else
{
std::string vs;
std::string ps;
bool cacheShaders = true;
shaderGenerator->reset();
shaderGenerator->setMaterial( &mat );
shaderGenerator->setVBFormat( _CurrentVertexBufferHard->VB->getVertexFormat() );
shaderGenerator->setShaderDesc( &desc );
shaderGenerator->generateVS( vs );
shaderGenerator->generatePS( ps );
// If we don't already have a vertex program attached, we'll generate it now
if( currentProgram.vp == NULL )
{
shaderGenerator->generateVS( vs );
vp = new CVertexProgram();
{
IProgram::CSource *src = new IProgram::CSource();
@ -628,6 +634,20 @@ namespace NL3D
return false;
}
if( !activeVertexProgram( vp ) )
{
delete vp;
vp = NULL;
return false;
}
}
else
cacheShaders = false;
// If we don't already have a pixel program attached, we'll generate it now
if( currentProgram.pp == NULL )
{
shaderGenerator->generatePS( ps );
pp = new CPixelProgram();
{
IProgram::CSource *src = new IProgram::CSource();
@ -646,20 +666,6 @@ namespace NL3D
return false;
}
if( currentProgram.vp == NULL )
{
if( !activeVertexProgram( vp ) )
{
delete vp;
vp = NULL;
delete pp;
pp = NULL;
return false;
}
}
if( currentProgram.pp == NULL )
{
if( !activePixelProgram( pp ) )
{
delete vp;
@ -669,12 +675,19 @@ namespace NL3D
return false;
}
}
else
cacheShaders = false;
// If we already have a shader attached we won't cache this shaderpair, since we didn't generate it
if( cacheShaders )
{
sp.vp = vp;
sp.pp = pp;
desc.setShaders( sp );
shaderCache.cacheShader( desc );
}
}
setupUniforms();

Loading…
Cancel
Save