#include <dali/public-api/common/vector-wrapper.h>
#include <dali/public-api/object/ref-object.h>
#include <dali/integration-api/gl-abstraction.h>
-#include <dali/integration-api/shader-data.h>
+#include <dali/internal/common/shader-data.h>
namespace Dali
{
{
ATTRIB_UNKNOWN = -1,
ATTRIB_POSITION,
- ATTRIB_NORMAL,
ATTRIB_TEXCOORD,
- ATTRIB_COLOR,
- ATTRIB_BONE_WEIGHTS,
- ATTRIB_BONE_INDICES,
ATTRIB_TYPE_LAST
};
UNIFORM_VIEW_MATRIX,
UNIFORM_NORMAL_MATRIX,
UNIFORM_COLOR,
- UNIFORM_CUSTOM_TEXTURE_COORDS,
UNIFORM_SAMPLER,
UNIFORM_SAMPLER_RECT,
UNIFORM_EFFECT_SAMPLER,
- UNIFORM_EFFECT_SAMPLER_RECT,
- UNIFORM_TIME_DELTA,
- UNIFORM_SAMPLER_OPACITY,
- UNIFORM_SAMPLER_NORMAL_MAP,
+ UNIFORM_SIZE,
UNIFORM_TYPE_LAST
};
* @param[in] modifiesGeometry True if the shader modifies geometry
* @return pointer to the program
*/
- static Program* New( ProgramCache& cache, Integration::ShaderDataPtr shaderData, bool modifiesGeometry );
+ static Program* New( ProgramCache& cache, Internal::ShaderDataPtr shaderData, bool modifiesGeometry );
/**
* Takes this program into use
GLint GetAttribLocation( AttribType type );
/**
+ * Register an attribute name in our local cache
+ * @param [in] name attribute name
+ * @return the index of the attribute name in local cache
+ */
+ unsigned int RegisterCustomAttribute( const std::string& name );
+
+ /**
+ * Gets the location of a pre-registered attribute.
+ * @param [in] attributeIndex of the attribute in local cache
+ * @return the index of the attribute in the GL program
+ */
+ GLint GetCustomAttributeLocation( unsigned int attributeIndex );
+
+ /**
* Register a uniform name in our local cache
* @param [in] name uniform name
* @return the index of the uniform name in local cache
GLint GetUniformLocation( unsigned int uniformIndex );
/**
+ * Introspect the newly loaded shader to get the active sampler locations
+ */
+ void GetActiveSamplerUniforms();
+
+ /**
+ * Gets the uniform location for a sampler
+ * @param [in] index The index of the active sampler
+ * @param [out] location The location of the requested sampler
+ * @return true if the active sampler was found
+ */
+ bool GetSamplerUniformLocation( unsigned int index, GLint& location );
+
+ /**
+ * Get the number of active samplers present in the shader
+ * @return The number of active samplers
+ */
+ size_t GetActiveSamplerCount() const;
+
+ /**
* Sets the uniform value
* @param [in] location of uniform
* @param [in] value0 as int
void SetUniform2f( GLint location, GLfloat value0, GLfloat value1 );
/**
+ * Special handling for size as we're using uniform geometry so size is passed on to most programs
+ * but it rarely changes so we can cache it
+ * @param [in] location of uniform
+ * @param [in] value0 as float
+ * @param [in] value1 as float
+ * @param [in] value2 as float
+ */
+ void SetSizeUniform3f( GLint location, GLfloat value0, GLfloat value1, GLfloat value2 );
+
+ /**
* Sets the uniform value
* @param [in] location of uniform
* @param [in] value0 as float
* @param[in] shaderData A smart pointer to a data structure containing the program source and binary
* @param[in] modifiesGeometry True if the vertex shader changes geometry
*/
- Program( ProgramCache& cache, Integration::ShaderDataPtr shaderData, bool modifiesGeometry );
+ Program( ProgramCache& cache, Internal::ShaderDataPtr shaderData, bool modifiesGeometry );
public:
GLuint mVertexShaderId; ///< GL identifier for vertex shader
GLuint mFragmentShaderId; ///< GL identifier for fragment shader
GLuint mProgramId; ///< GL identifier for program
- Integration::ShaderDataPtr mProgramData; ///< Shader program source and binary (when compiled & linked or loaded)
+ Internal::ShaderDataPtr mProgramData; ///< Shader program source and binary (when compiled & linked or loaded)
// location caches
- GLint mAttribLocations[ ATTRIB_TYPE_LAST ]; ///< attribute location cache
- std::vector< std::pair< std::string, GLint > > mUniformLocations; ///< uniform location cache
+ typedef std::pair< std::string, GLint > NameLocationPair;
+ typedef std::vector< NameLocationPair > Locations;
+
+ Locations mAttributeLocations; ///< attribute location cache
+ Locations mUniformLocations; ///< uniform location cache
+ std::vector<GLint> mSamplerUniformLocations; ///< sampler uniform location cache
// uniform value caching
GLint mUniformCacheInt[ MAX_UNIFORM_CACHE_SIZE ]; ///< Value cache for uniforms of single int
GLfloat mUniformCacheFloat[ MAX_UNIFORM_CACHE_SIZE ]; ///< Value cache for uniforms of single float
- GLfloat mUniformCacheFloat4[ MAX_UNIFORM_CACHE_SIZE ][4]; ///< Value cache for uniforms of four float
+ GLfloat mUniformCacheFloat2[ MAX_UNIFORM_CACHE_SIZE ][2]; ///< Value cache for uniforms of two floats
+ GLfloat mUniformCacheFloat4[ MAX_UNIFORM_CACHE_SIZE ][4]; ///< Value cache for uniforms of four floats
+ Vector3 mSizeUniformCache; ///< Cache value for size uniform
bool mModifiesGeometry; ///< True if the program changes geometry
};