{
mRenderDataProvider = dataProvider;
mUpdateAttributesLocation = true;
+
+ //Check that the number of textures match the number of samplers in the shader
+ size_t textureCount = dataProvider->GetTextures().size() + dataProvider->GetNewTextures().size();
+ Program* program = dataProvider->GetShader().GetProgram();
+ if( program && program->GetActiveSamplerCount() != textureCount )
+ {
+ DALI_LOG_ERROR("The number of active samplers in the shader(%lu) does not match the number of textures in the TextureSet(%lu)\n",
+ program->GetActiveSamplerCount(),
+ textureCount );
+ }
}
void Renderer::SetGeometry( Render::Geometry* geometry )
{
// program not found so create it
program = new Program( cache, shaderData, modifiesGeometry );
-
- // we want to lazy load programs so dont do a Load yet, it gets done in Use()
+ program->Load();
cache.AddProgram( shaderHash, program );
}
void Program::Use()
{
- if ( !mLinked )
- {
- Load();
- }
-
if ( mLinked )
{
if ( this != mCache.GetCurrentProgram() )
if( mTextureSet )
{
size_t textureCount = mTextureSet->GetTextureCount();
- size_t newTextureCount = mTextureSet->GetNewTextureCount();
-
- Program* program = mShader->GetProgram();
- if( program && program->GetActiveSamplerCount() != textureCount + newTextureCount )
- {
- DALI_LOG_ERROR("The number of active samplers in the shader(%lu) does not match the number of textures in the TextureSet(%lu)\n",
- program->GetActiveSamplerCount(),
- textureCount + newTextureCount );
- }
-
dataProvider->mTextures.resize( textureCount );
dataProvider->mSamplers.resize( textureCount );
for( unsigned int i(0); i<textureCount; ++i )
dataProvider->mSamplers[i] = mTextureSet->GetTextureSampler(i);
}
- dataProvider->mNewTextures.resize( newTextureCount );
- dataProvider->mSamplers.resize( newTextureCount );
- for( unsigned int i(0); i<newTextureCount; ++i )
+ textureCount = mTextureSet->GetNewTextureCount();
+ dataProvider->mNewTextures.resize( textureCount );
+ dataProvider->mSamplers.resize( textureCount );
+ for( unsigned int i(0); i<textureCount; ++i )
{
dataProvider->mNewTextures[i] = mTextureSet->GetNewTexture(i);
dataProvider->mSamplers[i] = mTextureSet->GetTextureSampler(i);