Revert "Removed need for sampler uniform names"
[platform/core/uifw/dali-core.git] / dali / internal / render / renderers / render-renderer.cpp
index 8d666b7..2a93574 100644 (file)
@@ -367,34 +367,39 @@ bool Renderer::BindTextures( SceneGraph::TextureCache& textureCache, Program& pr
 
       if( result )
       {
-        GLint uniformLocation;
-
-        bool result = program.GetSamplerUniformLocation( i, uniformLocation );
-        if( result && Program::UNIFORM_UNKNOWN != uniformLocation )
+        Render::Texture& textureMapping = textures[i];
+        // Set sampler uniform location for the texture
+        int32_t uniqueIndex = textureMapping.GetUniformUniqueIndex();
+        if( Render::Texture::NOT_INITIALIZED == uniqueIndex )
+        {
+          uniqueIndex = mUniformNameCache->GetSamplerUniformUniqueIndex( textureMapping.GetUniformName() );
+          textureMapping.SetUniformUniqueIndex( uniqueIndex );
+        }
+        GLint uniformLocation = program.GetSamplerUniformLocation( uniqueIndex, textureMapping.GetUniformName() );
+        if( Program::UNIFORM_UNKNOWN != uniformLocation )
         {
           program.SetUniform1i( uniformLocation, textureUnit );
+        }
 
-          unsigned int samplerBitfield(0);
-          Render::Texture& textureMapping = textures[i];
-          const Render::Sampler* sampler( textureMapping.GetSampler() );
-          if( sampler )
-          {
-            samplerBitfield = ImageSampler::PackBitfield(
-              static_cast< FilterMode::Type >(sampler->GetMinifyFilterMode()),
-              static_cast< FilterMode::Type >(sampler->GetMagnifyFilterMode()),
-              static_cast< WrapMode::Type >(sampler->GetUWrapMode()),
-              static_cast< WrapMode::Type >(sampler->GetVWrapMode())
-                                                         );
-          }
-          else
-          {
-            samplerBitfield = ImageSampler::DEFAULT_BITFIELD;
-          }
-
-          texture->ApplySampler( (TextureUnit)textureUnit, samplerBitfield );
-
-          ++textureUnit;
+        unsigned int samplerBitfield(0);
+        const Render::Sampler* sampler( textureMapping.GetSampler() );
+        if( sampler )
+        {
+          samplerBitfield = ImageSampler::PackBitfield(
+            static_cast< FilterMode::Type >(sampler->GetMinifyFilterMode()),
+            static_cast< FilterMode::Type >(sampler->GetMagnifyFilterMode()),
+            static_cast< WrapMode::Type >(sampler->GetUWrapMode()),
+            static_cast< WrapMode::Type >(sampler->GetVWrapMode())
+                                                       );
         }
+        else
+        {
+          samplerBitfield = ImageSampler::DEFAULT_BITFIELD;
+        }
+
+        texture->ApplySampler( (TextureUnit)textureUnit, samplerBitfield );
+
+        ++textureUnit;
       }
     }
   }