From 02cc116528908062074029218831bf1e65d063ff Mon Sep 17 00:00:00 2001 From: Kimmo Hoikka Date: Fri, 14 Nov 2014 16:28:03 +0000 Subject: [PATCH] Reduce texture binds and active texture calls for draw calls by better caching [Problem] [Cause] [Solution] Change-Id: Ic9d57d4016cd2fd732fac4688aa30f9ad41b2846 --- .../render/gl-resources/bitmap-texture.cpp | 8 ++--- .../gl-resources/compressed-bitmap-texture.cpp | 2 +- dali/internal/render/gl-resources/context.cpp | 12 +++---- dali/internal/render/gl-resources/context.h | 40 ++++++++++++++-------- .../render/gl-resources/frame-buffer-texture.cpp | 4 +-- .../gl-resources/native-frame-buffer-texture.cpp | 2 +- .../render/gl-resources/native-texture.cpp | 4 +-- dali/internal/render/gl-resources/native-texture.h | 2 +- .../internal/render/gl-resources/texture-cache.cpp | 2 +- dali/internal/render/gl-resources/texture-cache.h | 5 +-- dali/internal/render/gl-resources/texture-units.h | 4 ++- dali/internal/render/gl-resources/texture.cpp | 16 +++++---- dali/internal/render/gl-resources/texture.h | 9 +++-- dali/internal/render/renderers/render-material.cpp | 9 +++-- .../renderers/scene-graph-image-renderer.cpp | 4 +-- .../render/renderers/scene-graph-text-renderer.cpp | 4 +-- dali/internal/render/shaders/shader.cpp | 4 +-- 17 files changed, 75 insertions(+), 56 deletions(-) diff --git a/dali/internal/render/gl-resources/bitmap-texture.cpp b/dali/internal/render/gl-resources/bitmap-texture.cpp index d3d11cb..e6967ce 100644 --- a/dali/internal/render/gl-resources/bitmap-texture.cpp +++ b/dali/internal/render/gl-resources/bitmap-texture.cpp @@ -85,7 +85,7 @@ void BitmapTexture::UploadBitmapArray( const BitmapUploadArray& bitmapArray ) CreateGlTexture(); } - mContext.ActiveTexture( TextureUnitAsGLenum( TEXTURE_UNIT_UPLOAD ) ); // bind in unused unit so rebind works the first time + mContext.ActiveTexture( TEXTURE_UNIT_UPLOAD ); mContext.Bind2dTexture(mId); mContext.PixelStorei(GL_UNPACK_ALIGNMENT, 1); // We always use tightly packed data @@ -159,7 +159,7 @@ void BitmapTexture::AreaUpdated( const RectArea& updateArea, const unsigned char GLenum pixelDataType = GL_UNSIGNED_BYTE; Integration::ConvertToGlFormat(mPixelFormat, pixelDataType, pixelFormat); - mContext.ActiveTexture( TextureUnitAsGLenum( TEXTURE_UNIT_UPLOAD ) ); // bind in unused unit so rebind works the first time + mContext.ActiveTexture( TEXTURE_UNIT_UPLOAD ); mContext.Bind2dTexture(mId); @@ -218,7 +218,7 @@ void BitmapTexture::AssignBitmap( bool generateTexture, const unsigned char* pix } DALI_ASSERT_DEBUG( mId != 0 ); - mContext.ActiveTexture( TextureUnitAsGLenum( TEXTURE_UNIT_UPLOAD ) ); // bind in unused unit so rebind works the first time + mContext.ActiveTexture( TEXTURE_UNIT_UPLOAD ); mContext.Bind2dTexture(mId); Integration::ConvertToGlFormat(mPixelFormat, pixelDataType, pixelFormat); @@ -329,7 +329,7 @@ void BitmapTexture::ClearAreas( const BitmapClearArray& areaArray, std::size_t b GLenum pixelDataType = GL_UNSIGNED_BYTE; Integration::ConvertToGlFormat(mPixelFormat, pixelDataType, pixelFormat); - mContext.ActiveTexture( TextureUnitAsGLenum( TEXTURE_UNIT_UPLOAD ) ); // bind in unused unit so rebind works the first time + mContext.ActiveTexture( TEXTURE_UNIT_UPLOAD ); mContext.Bind2dTexture(mId); size_t numPixels = blockSize*blockSize; diff --git a/dali/internal/render/gl-resources/compressed-bitmap-texture.cpp b/dali/internal/render/gl-resources/compressed-bitmap-texture.cpp index 7155704..53d270f 100644 --- a/dali/internal/render/gl-resources/compressed-bitmap-texture.cpp +++ b/dali/internal/render/gl-resources/compressed-bitmap-texture.cpp @@ -81,7 +81,7 @@ void CompressedBitmapTexture::AssignBitmap( bool generateTexture, const unsigned } DALI_ASSERT_DEBUG( mId != 0 ); - mContext.ActiveTexture(TextureUnitAsGLenum( TEXTURE_UNIT_UPLOAD )); // bind in unused unit so rebind works the first time + mContext.ActiveTexture( TEXTURE_UNIT_UPLOAD ); mContext.Bind2dTexture(mId); GLenum pixelFormat = GL_RGBA; diff --git a/dali/internal/render/gl-resources/context.cpp b/dali/internal/render/gl-resources/context.cpp index d943940..5138ca3 100644 --- a/dali/internal/render/gl-resources/context.cpp +++ b/dali/internal/render/gl-resources/context.cpp @@ -24,6 +24,7 @@ // INTERNAL INCLUDES #include +#include #include #include #include @@ -38,6 +39,8 @@ namespace Internal namespace // unnamed namespace { +DALI_COMPILE_TIME_ASSERT( TEXTURE_UNIT_LAST <= Context::MAX_TEXTURE_UNITS ); + /** * GL error strings */ @@ -64,8 +67,6 @@ void deletePrograms(std::pair< std::size_t, Program* > hashProgram) delete hashProgram.second; } -const unsigned int UNINITIALIZED_TEXTURE_UNIT = std::numeric_limits::max();// GL_MAX_TEXTURE_UNITS can't be used because it's depreciated in gles2 - } // unnamed namespace #ifdef DEBUG_ENABLED @@ -91,7 +92,7 @@ Context::Context(Integration::GlAbstraction& glAbstraction) mBoundArrayBufferId(0), mBoundElementArrayBufferId(0), mBoundTransformFeedbackBufferId(0), - mActiveTextureUnit( UNINITIALIZED_TEXTURE_UNIT ), + mActiveTextureUnit( TEXTURE_UNIT_LAST ), mUsingDefaultBlendColor(true), mBlendFuncSeparateSrcRGB(GL_ONE), mBlendFuncSeparateDstRGB(GL_ZERO), @@ -310,7 +311,7 @@ void Context::ResetGlState() mGlAbstraction.BindBuffer(GL_TRANSFORM_FEEDBACK_BUFFER, mBoundTransformFeedbackBufferId); #endif - mActiveTextureUnit = UNINITIALIZED_TEXTURE_UNIT; + mActiveTextureUnit = TEXTURE_UNIT_LAST; mUsingDefaultBlendColor = true; mGlAbstraction.BlendColor( 0.0f, 0.0f, 0.0f, 0.0f ); @@ -332,13 +333,12 @@ void Context::ResetGlState() mGlAbstraction.FrontFace(GL_CCW); mGlAbstraction.CullFace(GL_BACK); - // rebind texture units + // rebind texture units to 0 for( unsigned int i=0; i < MAX_TEXTURE_UNITS; ++i ) { mBound2dTextureId[ i ] = 0; // set active texture mGlAbstraction.ActiveTexture( GL_TEXTURE0 + i ); - // bind the previous texture mGlAbstraction.BindTexture(GL_TEXTURE_2D, mBound2dTextureId[ i ] ); } diff --git a/dali/internal/render/gl-resources/context.h b/dali/internal/render/gl-resources/context.h index e285ae6..289e86d 100644 --- a/dali/internal/render/gl-resources/context.h +++ b/dali/internal/render/gl-resources/context.h @@ -20,15 +20,16 @@ // INTERNAL INCLUDES #include +#include #include #include -#include -#include -#include -#include #include #include #include +#include +#include +#include +#include namespace Dali { @@ -64,7 +65,7 @@ public: */ static const unsigned int MAX_ATTRIBUTE_CACHE_SIZE = 8; - static const unsigned int MAX_TEXTURE_UNITS = 8; // for GLES 2.0 its 8, which is more than DALi uses anyways + static const unsigned int MAX_TEXTURE_UNITS = 8; // for GLES 2.0 8 is guaranteed, which is more than DALi uses anyways /** * Creates the Dali Context object. @@ -148,16 +149,13 @@ public: /** * Wrapper for OpenGL ES 2.0 glActiveTexture() */ - void ActiveTexture(GLenum textureUnit) + void ActiveTexture( TextureUnit textureUnit ) { - // GL texture units are #defines in growing order to converting that to index - unsigned int unit = textureUnit - GL_TEXTURE0; - - if ( unit != mActiveTextureUnit ) + if ( textureUnit != mActiveTextureUnit ) { - mActiveTextureUnit = unit; + mActiveTextureUnit = textureUnit; LOG_GL("ActiveTexture %x\n", textureUnit); - CHECK_GL( *this, mGlAbstraction.ActiveTexture(textureUnit) ); + CHECK_GL( *this, mGlAbstraction.ActiveTexture(TextureUnitAsGLenum(textureUnit)) ); } } @@ -271,8 +269,22 @@ public: } /** - * The wrapper for OpenGL ES 2.0 glBindTexture() has been replaced by Bind2dTexture and BindCubeMapTexture. + * Helper to bind texture for rendering. If given texture is + * already bound in the given textureunit, this method does nothing. + * Otherwise changes the active texture unit and binds the texture. + * Note! after this call active texture unit may not necessarily be the one + * passed in as argument so you cannot change texture unit state!! + * @param textureunit to bind to + * @param texture to bind */ + void BindTextureForUnit( TextureUnit textureunit, GLuint texture ) + { + if( mBound2dTextureId[ textureunit ] != texture ) + { + ActiveTexture( textureunit ); + Bind2dTexture( texture ); + } + } /** * Wrapper for OpenGL ES 2.0 glBindTexture(GL_TEXTURE_2D) @@ -1798,7 +1810,7 @@ private: // Data GLuint mBoundTransformFeedbackBufferId; ///< The ID passed to glBindBuffer(GL_TRANSFORM_FEEDBACK_BUFFER) // glBindTexture() state - unsigned int mActiveTextureUnit; + TextureUnit mActiveTextureUnit; GLuint mBound2dTextureId[ MAX_TEXTURE_UNITS ]; ///< The ID passed to glBindTexture(GL_TEXTURE_2D) // glBlendColor() state diff --git a/dali/internal/render/gl-resources/frame-buffer-texture.cpp b/dali/internal/render/gl-resources/frame-buffer-texture.cpp index 37a7134..542efb4 100644 --- a/dali/internal/render/gl-resources/frame-buffer-texture.cpp +++ b/dali/internal/render/gl-resources/frame-buffer-texture.cpp @@ -67,7 +67,7 @@ bool FrameBufferTexture::Init() bool FrameBufferTexture::Prepare() { // bind texture - Bind(GL_TEXTURE_2D, GL_TEXTURE0); + Bind( GL_TEXTURE_2D, TEXTURE_UNIT_FRAMEBUFFER ); if( 0 != mId ) { @@ -99,7 +99,7 @@ bool FrameBufferTexture::CreateGlTexture() DALI_LOG_TRACE_METHOD(Debug::Filter::gImage); mContext.GenTextures(1, &mId); - mContext.ActiveTexture( TextureUnitAsGLenum( TEXTURE_UNIT_UPLOAD ) ); // bind in unused unit so rebind works the first time + mContext.ActiveTexture( TEXTURE_UNIT_UPLOAD ); // bind in unused unit so rebind works the first time mContext.Bind2dTexture(mId); // set texture parameters diff --git a/dali/internal/render/gl-resources/native-frame-buffer-texture.cpp b/dali/internal/render/gl-resources/native-frame-buffer-texture.cpp index acd2136..48f23e7 100644 --- a/dali/internal/render/gl-resources/native-frame-buffer-texture.cpp +++ b/dali/internal/render/gl-resources/native-frame-buffer-texture.cpp @@ -77,7 +77,7 @@ bool NativeFrameBufferTexture::CreateGlTexture() if( mNativeImage->GlExtensionCreate() ) { mContext.GenTextures(1, &mId); - mContext.ActiveTexture( TextureUnitAsGLenum( TEXTURE_UNIT_UPLOAD ) ); // bind in unused unit so rebind works the first time + mContext.ActiveTexture( TEXTURE_UNIT_UPLOAD ); // bind in unused unit so rebind works the first time mContext.Bind2dTexture(mId); mContext.PixelStorei(GL_UNPACK_ALIGNMENT, 1); // We always use tightly packed data diff --git a/dali/internal/render/gl-resources/native-texture.cpp b/dali/internal/render/gl-resources/native-texture.cpp index 239a915..5e227e8 100644 --- a/dali/internal/render/gl-resources/native-texture.cpp +++ b/dali/internal/render/gl-resources/native-texture.cpp @@ -50,7 +50,7 @@ NativeTexture::~NativeTexture() // on the render thread. (And avoiding a potentially problematic virtual call in the destructor) } -bool NativeTexture::Bind(GLenum target, GLenum textureunit ) +bool NativeTexture::Bind(GLenum target, TextureUnit textureunit ) { bool created = false; @@ -90,7 +90,7 @@ bool NativeTexture::CreateGlTexture() if( mNativeImage->GlExtensionCreate() ) { mContext.GenTextures( 1, &mId ); - mContext.ActiveTexture( TextureUnitAsGLenum( TEXTURE_UNIT_UPLOAD ) ); // bind in unused unit so rebind works the first time + mContext.ActiveTexture( TEXTURE_UNIT_UPLOAD ); // bind in unused unit so rebind works the first time mContext.Bind2dTexture( mId ); mContext.PixelStorei( GL_UNPACK_ALIGNMENT, 1 ); // We always use tightly packed data diff --git a/dali/internal/render/gl-resources/native-texture.h b/dali/internal/render/gl-resources/native-texture.h index f17c3bb..b91a04e 100644 --- a/dali/internal/render/gl-resources/native-texture.h +++ b/dali/internal/render/gl-resources/native-texture.h @@ -56,7 +56,7 @@ public: /** * @copydoc Texture::Bind */ - virtual bool Bind(GLenum target, GLenum textureunit = GL_TEXTURE0); + virtual bool Bind( GLenum target, TextureUnit textureunit ); /** * @copydoc Texture::IsFullyOpaque diff --git a/dali/internal/render/gl-resources/texture-cache.cpp b/dali/internal/render/gl-resources/texture-cache.cpp index 2191b23..db4f027 100644 --- a/dali/internal/render/gl-resources/texture-cache.cpp +++ b/dali/internal/render/gl-resources/texture-cache.cpp @@ -254,7 +254,7 @@ void TextureCache::DiscardTexture( ResourceId id ) } } -void TextureCache::BindTexture( Texture *texture, ResourceId id, GLenum target, GLenum textureunit ) +void TextureCache::BindTexture( Texture *texture, ResourceId id, GLenum target, TextureUnit textureunit ) { bool created = texture->Bind(target, textureunit); if( created && texture->UpdateOnCreate() ) // i.e. the pixel data was sent to GL diff --git a/dali/internal/render/gl-resources/texture-cache.h b/dali/internal/render/gl-resources/texture-cache.h index dad0f54..656d103 100644 --- a/dali/internal/render/gl-resources/texture-cache.h +++ b/dali/internal/render/gl-resources/texture-cache.h @@ -34,6 +34,7 @@ #include #include #include +#include namespace Dali { @@ -176,9 +177,9 @@ public: * @param[in] texture pointer to the texture * @param[in] id Resource id of texture * @param[in] target (e.g. GL_TEXTURE_2D) - * @param[in] textureunit ( e.g.: GL_TEXTURE0 ) + * @param[in] textureunit to use */ - void BindTexture( Texture* texture, ResourceId id, GLenum target, GLenum textureunit ); + void BindTexture( Texture* texture, ResourceId id, GLenum target, TextureUnit textureunit ); /** * Get the texture associated with the resource ID diff --git a/dali/internal/render/gl-resources/texture-units.h b/dali/internal/render/gl-resources/texture-units.h index 86fa36f..6b8a44b 100644 --- a/dali/internal/render/gl-resources/texture-units.h +++ b/dali/internal/render/gl-resources/texture-units.h @@ -29,12 +29,14 @@ namespace Internal enum TextureUnit { TEXTURE_UNIT_IMAGE = 0, - TEXTURE_UNIT_TEXT = 0, // for now use same texture unit as text to avoid too many ActiveTexture Calls + TEXTURE_UNIT_TEXT, TEXTURE_UNIT_MATERIAL_DIFFUSE, TEXTURE_UNIT_MATERIAL_OPACITY, TEXTURE_UNIT_MATERIAL_NORMAL_MAP, TEXTURE_UNIT_SHADER, TEXTURE_UNIT_UPLOAD, + TEXTURE_UNIT_FRAMEBUFFER, + TEXTURE_UNIT_LAST }; inline unsigned int TextureUnitAsGLenum( TextureUnit unit ) diff --git a/dali/internal/render/gl-resources/texture.cpp b/dali/internal/render/gl-resources/texture.cpp index 32b41a5..d2c1b0d 100644 --- a/dali/internal/render/gl-resources/texture.cpp +++ b/dali/internal/render/gl-resources/texture.cpp @@ -128,7 +128,7 @@ bool Texture::UpdateOnCreate() return false; } -bool Texture::Bind(GLenum target, GLenum textureunit ) +bool Texture::Bind(GLenum target, TextureUnit textureunit ) { // This is the only supported type at the moment DALI_ASSERT_DEBUG( target == GL_TEXTURE_2D ); @@ -143,8 +143,7 @@ bool Texture::Bind(GLenum target, GLenum textureunit ) } // Bind the texture id - mContext.ActiveTexture(textureunit); - mContext.Bind2dTexture(mId); + mContext.BindTextureForUnit(textureunit, mId ); return created; } @@ -261,28 +260,31 @@ void Texture::GetDefaultTextureCoordinates(UvRect& uv) const } -void Texture::ApplyTextureParameter( GLint filterType, FilterMode::Type currentFilterMode, FilterMode::Type newFilterMode, GLint daliDefault, GLint systemDefault ) +void Texture::ApplyTextureParameter( TextureUnit unit, GLint filterType, FilterMode::Type currentFilterMode, FilterMode::Type newFilterMode, GLint daliDefault, GLint systemDefault ) { GLint newFilterModeGL = FilterModeToGL( newFilterMode, daliDefault, systemDefault ); GLint currentFilterModeGL = FilterModeToGL( currentFilterMode, daliDefault, systemDefault ); if( newFilterModeGL != currentFilterModeGL ) { + mContext.ActiveTexture( unit ); mContext.TexParameteri( GL_TEXTURE_2D, filterType, newFilterModeGL ); } } -void Texture::ApplySampler( unsigned int samplerBitfield ) +void Texture::ApplySampler( TextureUnit unit, unsigned int samplerBitfield ) { if( mSamplerBitfield != samplerBitfield && mId != 0 ) { - ApplyTextureParameter( GL_TEXTURE_MIN_FILTER, + ApplyTextureParameter( unit, + GL_TEXTURE_MIN_FILTER, ImageSampler::GetMinifyFilterMode( mSamplerBitfield ), ImageSampler::GetMinifyFilterMode( samplerBitfield ), DALI_MINIFY_DEFAULT, SYSTEM_MINIFY_DEFAULT ); - ApplyTextureParameter( GL_TEXTURE_MAG_FILTER, + ApplyTextureParameter( unit, + GL_TEXTURE_MAG_FILTER, ImageSampler::GetMagnifyFilterMode( mSamplerBitfield ), ImageSampler::GetMagnifyFilterMode( samplerBitfield ), DALI_MAGNIFY_DEFAULT, diff --git a/dali/internal/render/gl-resources/texture.h b/dali/internal/render/gl-resources/texture.h index 805c47d..5c0b182 100644 --- a/dali/internal/render/gl-resources/texture.h +++ b/dali/internal/render/gl-resources/texture.h @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -92,7 +93,7 @@ public: * @return True if the opengl texture was created, false if there was already a texture * or no texture could be created yet ( e.g. no bitmap data after context loss ) */ - virtual bool Bind(GLenum target, GLenum textureunit); + virtual bool Bind(GLenum target, TextureUnit textureunit); /** * Returns GL texture ID @@ -174,9 +175,10 @@ public: /** * @brief Apply the given sampler to the texture. * + * @param[in] texture unit to use * @param[in] samplerBitfield A bitfield with packed sampler options. */ - void ApplySampler( unsigned int samplerBitfield ); + void ApplySampler( TextureUnit unit, unsigned int samplerBitfield ); protected: @@ -252,13 +254,14 @@ private: /** * @brief Apply the given texture parameters. * + * @param[in] texture unit to use * @param[in] filterType Minification or magnification. * @param[in] currentFilterMode The current filter mode. * @param[in] newFilterMode The new filter mode. * @param[in] daliDefault The default dali filter mode for the given filterType. * @param[in] systemDefault The default system filter mode for the given filterType. */ - void ApplyTextureParameter( GLint filterType, FilterMode::Type currentFilterMode, FilterMode::Type newFilterMode, GLint daliDefault, GLint systemDefault ); + void ApplyTextureParameter( TextureUnit unit, GLint filterType, FilterMode::Type currentFilterMode, FilterMode::Type newFilterMode, GLint daliDefault, GLint systemDefault ); protected: diff --git a/dali/internal/render/renderers/render-material.cpp b/dali/internal/render/renderers/render-material.cpp index f3ffdb7..66b2ee0 100644 --- a/dali/internal/render/renderers/render-material.cpp +++ b/dali/internal/render/renderers/render-material.cpp @@ -231,7 +231,7 @@ void RenderMaterial::BindTexture( Program& program, ResourceId id, Texture* text if( texture != NULL ) { - mTextureCache->BindTexture( texture, id, GL_TEXTURE_2D, TextureUnitAsGLenum( textureUnit ) ); + mTextureCache->BindTexture( texture, id, GL_TEXTURE_2D, textureUnit ); // Set sampler uniforms for textures GLint samplerLoc = program.GetUniformLocation( samplerIndex ); if( Program::UNIFORM_UNKNOWN != samplerLoc ) @@ -283,22 +283,21 @@ void RenderMaterial::BindTextures( Program& program, unsigned int textureSampler if( mDiffuseTexture ) { - mDiffuseTexture->ApplySampler( textureSampler ); + mDiffuseTexture->ApplySampler( TEXTURE_UNIT_MATERIAL_DIFFUSE, textureSampler ); } - // GL_TEXTURE1 is used by shader effect texture BindTexture( program, mOpacityTextureId, mOpacityTexture, TEXTURE_UNIT_MATERIAL_OPACITY, Program::UNIFORM_SAMPLER_OPACITY ); if( mOpacityTexture ) { - mOpacityTexture->ApplySampler( textureSampler ); + mOpacityTexture->ApplySampler( TEXTURE_UNIT_MATERIAL_OPACITY, textureSampler ); } BindTexture( program, mNormalMapTextureId, mNormalMapTexture, TEXTURE_UNIT_MATERIAL_NORMAL_MAP, Program::UNIFORM_SAMPLER_NORMAL_MAP ); if( mNormalMapTexture ) { - mNormalMapTexture->ApplySampler( textureSampler ); + mNormalMapTexture->ApplySampler( TEXTURE_UNIT_MATERIAL_NORMAL_MAP, textureSampler ); } } diff --git a/dali/internal/render/renderers/scene-graph-image-renderer.cpp b/dali/internal/render/renderers/scene-graph-image-renderer.cpp index e35f5de..50853c3 100644 --- a/dali/internal/render/renderers/scene-graph-image-renderer.cpp +++ b/dali/internal/render/renderers/scene-graph-image-renderer.cpp @@ -266,14 +266,14 @@ void ImageRenderer::DoRender( BufferIndex bufferIndex, Program& program, const M DALI_ASSERT_DEBUG( mVertexBuffer ); - mTextureCache->BindTexture( mTexture, mTextureId, GL_TEXTURE_2D, TextureUnitAsGLenum( TEXTURE_UNIT_IMAGE ) ); + mTextureCache->BindTexture( mTexture, mTextureId, GL_TEXTURE_2D, TEXTURE_UNIT_IMAGE ); if( mTexture->GetTextureId() == 0 ) { return; // early out if we haven't got a GL texture yet (e.g. due to context loss) } - mTexture->ApplySampler( mSamplerBitfield ); + mTexture->ApplySampler( TEXTURE_UNIT_IMAGE, mSamplerBitfield ); // Set sampler uniform GLint samplerLoc = program.GetUniformLocation( Program::UNIFORM_SAMPLER ); diff --git a/dali/internal/render/renderers/scene-graph-text-renderer.cpp b/dali/internal/render/renderers/scene-graph-text-renderer.cpp index b988751..7ed5e8c 100644 --- a/dali/internal/render/renderers/scene-graph-text-renderer.cpp +++ b/dali/internal/render/renderers/scene-graph-text-renderer.cpp @@ -357,7 +357,7 @@ void TextRenderer::DoRender( BufferIndex bufferIndex, Program& program, const Ma DALI_LOG_INFO( gTextFilter, Debug::General, "TextRenderer::DoRender(this: %p) textureId:%d\n", this, mTextureId ); - mTextureCache->BindTexture( mTexture, mTextureId, GL_TEXTURE_2D, TextureUnitAsGLenum( TEXTURE_UNIT_TEXT ) ); + mTextureCache->BindTexture( mTexture, mTextureId, GL_TEXTURE_2D, TEXTURE_UNIT_TEXT ); if( mTexture->GetTextureId() == 0 ) { return; // early out if we haven't got a GL texture yet (e.g. due to context loss) @@ -371,7 +371,7 @@ void TextRenderer::DoRender( BufferIndex bufferIndex, Program& program, const Ma program.SetUniform1i( samplerLoc, TEXTURE_UNIT_TEXT ); } - mTexture->ApplySampler( mSamplerBitfield ); + mTexture->ApplySampler( TEXTURE_UNIT_TEXT, mSamplerBitfield ); const float SMOOTHING_ADJUSTMENT( 12.0f ); const float SMOOTHING_ADJUSTMENT_PIXEL_SIZE( 32.0f ); diff --git a/dali/internal/render/shaders/shader.cpp b/dali/internal/render/shaders/shader.cpp index edf5750..92eb46e 100644 --- a/dali/internal/render/shaders/shader.cpp +++ b/dali/internal/render/shaders/shader.cpp @@ -310,10 +310,10 @@ void Shader::SetUniforms( Context& context, if( mTexture ) { // got effect texture, bind it to texture unit 1 - mTextureCache->BindTexture( mTexture, mRenderTextureId, GL_TEXTURE_2D, TextureUnitAsGLenum( TEXTURE_UNIT_SHADER ) ); + mTextureCache->BindTexture( mTexture, mRenderTextureId, GL_TEXTURE_2D, TEXTURE_UNIT_SHADER); // Just apply the default sampling options for now - mTexture->ApplySampler( ImageSampler::PackBitfield( FilterMode::DEFAULT, FilterMode::DEFAULT ) ); + mTexture->ApplySampler( TEXTURE_UNIT_SHADER, ImageSampler::PackBitfield( FilterMode::DEFAULT, FilterMode::DEFAULT ) ); // get effect sampler uniform const GLint loc = program.GetUniformLocation( Program::UNIFORM_EFFECT_SAMPLER ); -- 2.7.4