This is to reduce the number of glBindTexture calls.
Change-Id: Iad24b18c5a42a53a85cdcf9522c5de71e3bf44a2
* Dali::Internal::ImageFactoryCache::RequestId
*/
typedef unsigned int ResourceId;
+const ResourceId InvalidResourceId = (ResourceId)-1;
/**
* Used to inform the current loading status
* @param[in] bufferIndex The buffer index
* @param[out] sortAttributes
*/
- void SetSortAttributes( SceneGraph::RendererWithSortAttributes& sortAttributes ) const
+ void SetSortAttributes( BufferIndex bufferIndex, SceneGraph::RendererWithSortAttributes& sortAttributes ) const
{
- sortAttributes.shader = &(mRenderDataProvider->GetShader());
- sortAttributes.material = &(mRenderDataProvider->GetMaterial());
+ sortAttributes.shader = &( mRenderDataProvider->GetShader() );
+ const SceneGraph::RenderDataProvider::Samplers& samplers = mRenderDataProvider->GetSamplers();
+
+ sortAttributes.textureResourceId = samplers.Empty() ? Integration::InvalidResourceId : samplers[ 0 ]->GetTextureId( bufferIndex );
sortAttributes.geometry = mRenderGeometry;
}
DoRender( context, textureCache, node, bufferIndex, *program, modelViewMatrix, viewMatrix );
}
-void Renderer::SetSortAttributes( SceneGraph::RendererWithSortAttributes& sortAttributes ) const
+void Renderer::SetSortAttributes( BufferIndex bufferIndex, SceneGraph::RendererWithSortAttributes& sortAttributes ) const
{
sortAttributes.shader = mShader;
- sortAttributes.material = NULL;
+ sortAttributes.textureResourceId = Integration::InvalidResourceId;
sortAttributes.geometry = NULL;
}
* @param[in] bufferIndex The current update buffer index.
* @param[out] sortAttributes
*/
- virtual void SetSortAttributes( SceneGraph::RendererWithSortAttributes& sortAttributes ) const;
+ virtual void SetSortAttributes( BufferIndex bufferIndex, SceneGraph::RendererWithSortAttributes& sortAttributes ) const;
protected:
/**
{
if( lhs.shader == rhs.shader )
{
- if( lhs.material == rhs.material )
+ if( lhs.textureResourceId == rhs.textureResourceId )
{
return lhs.geometry < rhs.geometry;
}
- return lhs.material < rhs.material;
+ return lhs.textureResourceId < rhs.textureResourceId;
}
return lhs.shader < rhs.shader;;
}
//If both RenderItems are opaque, sort using shader, then material then geometry
if( lhs.shader == rhs.shader )
{
- if( lhs.material == rhs.material )
+ if( lhs.textureResourceId == rhs.textureResourceId )
{
return lhs.geometry < rhs.geometry;
}
- return lhs.material < rhs.material;
+ return lhs.textureResourceId < rhs.textureResourceId;
}
return lhs.shader < rhs.shader;
}
{
if( lhs.shader == rhs.shader )
{
- if( lhs.material == rhs.material )
+ if( lhs.textureResourceId == rhs.textureResourceId )
{
return lhs.geometry < rhs.geometry;
}
- return lhs.material < rhs.material;
+ return lhs.textureResourceId < rhs.textureResourceId;
}
return lhs.shader < rhs.shader;
}
{
RenderItem& item = renderList.GetItem( index );
- item.GetRenderer().SetSortAttributes(sortingHelper[ index ]);
+ item.GetRenderer().SetSortAttributes( bufferIndex, sortingHelper[ index ] );
// the default sorting function should get inlined here
sortingHelper[ index ].zValue = Internal::Layer::ZValue( item.GetModelViewMatrix().GetTranslation3() ) - item.GetDepthIndex();
{
RenderItem& item = renderList.GetItem( index );
- item.GetRenderer().SetSortAttributes(sortingHelper[ index ]);
+ item.GetRenderer().SetSortAttributes( bufferIndex, sortingHelper[ index ] );
sortingHelper[ index ].zValue = (*sortFunction)( item.GetModelViewMatrix().GetTranslation3() ) - item.GetDepthIndex();
// keep the renderitem pointer in the helper so we can quickly reorder items after sort
// INTERNAL INCLUDES
#include <dali/internal/common/buffer-index.h>
#include <dali/internal/update/manager/sorted-layers.h>
+#include <dali/integration-api/resource-declarations.h>
namespace Dali
{
RendererWithSortAttributes()
: renderItem( NULL ),
shader(NULL),
- material(NULL),
+ textureResourceId( Integration::InvalidResourceId ),
geometry(NULL),
zValue(0.0f)
{
RenderItem* renderItem; ///< The render item that is being sorted (includes depth index)
const Shader* shader; ///< The shader instance
- const MaterialDataProvider* material; ///< The material instance
+ Integration::ResourceId textureResourceId;///< The first texture resource ID of the sampler instance, is InvalidResourceId if the material doesn't have any samplers
const RenderGeometry* geometry; ///< The geometry instance
- float zValue; // The zValue of the given renderer (either distance from camera, or a custom calculated value)
+ float zValue; ///< The zValue of the given renderer (either distance from camera, or a custom calculated value)
};
typedef std::vector< RendererWithSortAttributes > RendererSortingHelper;
void RenderableAttachment::SetSortAttributes( BufferIndex bufferIndex, RendererWithSortAttributes& sortAttributes )
{
sortAttributes.shader = mShader;
- sortAttributes.material = NULL;
+ sortAttributes.textureResourceId = Integration::InvalidResourceId;
sortAttributes.geometry = NULL;
}