From 22ea60766107608803f9984c1f93f80a37472b24 Mon Sep 17 00:00:00 2001 From: Kimmo Hoikka Date: Fri, 23 Oct 2015 11:39:55 +0100 Subject: [PATCH] Stop calculating default filter and wrap modes every frame for every sampler Change-Id: I1b21ca06abc140252dbc7db6bd6b9b5959620a88 --- dali/internal/common/image-sampler.cpp | 18 ------------- dali/internal/common/image-sampler.h | 30 ++++++++++++++++++++++ .../render/renderers/render-new-renderer.cpp | 3 +-- dali/internal/render/renderers/render-sampler.h | 17 ++++++------ dali/internal/render/renderers/render-texture.h | 23 +++++++++-------- .../update/rendering/scene-graph-material.h | 4 +-- dali/public-api/actors/sampling.h | 4 +-- 7 files changed, 56 insertions(+), 43 deletions(-) diff --git a/dali/internal/common/image-sampler.cpp b/dali/internal/common/image-sampler.cpp index f008580..4401507 100644 --- a/dali/internal/common/image-sampler.cpp +++ b/dali/internal/common/image-sampler.cpp @@ -30,24 +30,6 @@ namespace Internal namespace ImageSampler { -namespace -{ - -// @todo MESH_REWORK Remove file after image removal - -// Adjust these shift sizes if the FilterMode enum grows -const int MINIFY_BIT_SHIFT = 0; // Room for 16 -const int MAGNIFY_BIT_SHIFT = 4; -const int UWRAP_BIT_SHIFT = 8; -const int VWRAP_BIT_SHIFT = 12; - -const int MASK_MINIFY_FILTER = 0x0000000F; -const int MASK_MAGNIFY_FILTER = 0x000000F0; -const int MASK_UWRAP_MODE = 0x00000F00; -const int MASK_VWRAP_MODE = 0x0000F000; - -} // namespace - /** * Utility to store one of the sampling parameters values. * @param[out] options A bitmask used to store the FilterMode values. diff --git a/dali/internal/common/image-sampler.h b/dali/internal/common/image-sampler.h index 53c3f0b..836253e 100644 --- a/dali/internal/common/image-sampler.h +++ b/dali/internal/common/image-sampler.h @@ -32,6 +32,36 @@ namespace Internal */ namespace ImageSampler { + /** + * Bitshift values + */ + enum + { + MINIFY_BIT_SHIFT = 0, + MAGNIFY_BIT_SHIFT = 4, + UWRAP_BIT_SHIFT = 8, + VWRAP_BIT_SHIFT = 12 + }; + + /** + * Mask values + */ + enum + { + MASK_MINIFY_FILTER = 0x000F, + MASK_MAGNIFY_FILTER = 0x00F0, + MASK_UWRAP_MODE = 0x0F00, + MASK_VWRAP_MODE = 0xF000, + }; + + /** + * Precalculate default sampler bitfield + */ + enum + { + DEFAULT_BITFIELD = (Dali::FilterMode::DEFAULT<& textures( mRenderDataProvider->GetTextures()); @@ -319,7 +318,7 @@ void NewRenderer::BindTextures( } else { - samplerBitfield = ImageSampler::PackBitfield(FilterMode::DEFAULT, FilterMode::DEFAULT, WrapMode::DEFAULT, WrapMode::DEFAULT); + samplerBitfield = ImageSampler::DEFAULT_BITFIELD; } texture->ApplySampler( (TextureUnit)textureUnit, samplerBitfield ); diff --git a/dali/internal/render/renderers/render-sampler.h b/dali/internal/render/renderers/render-sampler.h index d5c94ba..5754e13 100644 --- a/dali/internal/render/renderers/render-sampler.h +++ b/dali/internal/render/renderers/render-sampler.h @@ -37,7 +37,7 @@ public: * Constructor */ Sampler() - : mMinFilter( Dali::FilterMode::DEFAULT), + : mMinFilter( Dali::FilterMode::DEFAULT ), mMagFilter( Dali::FilterMode::DEFAULT ), mUWrapMode( Dali::WrapMode::DEFAULT ), mVWrapMode( Dali::WrapMode::DEFAULT ) @@ -46,7 +46,8 @@ public: /** * Destructor */ - virtual ~Sampler(){} + ~Sampler() + {} /** * Set the filter modes for minify and magnify filters @@ -75,7 +76,7 @@ public: * Get the filter mode * @return The minify filter mode */ - virtual FilterMode GetMinifyFilterMode() const + FilterMode GetMinifyFilterMode() const { return mMinFilter; } @@ -84,7 +85,7 @@ public: * Get the filter mode * @return The magnify filter mode */ - virtual FilterMode GetMagnifyFilterMode() const + FilterMode GetMagnifyFilterMode() const { return mMagFilter; } @@ -93,7 +94,7 @@ public: * Get the horizontal wrap mode * @return The horizontal wrap mode */ - virtual WrapMode GetUWrapMode() const + WrapMode GetUWrapMode() const { return mUWrapMode; } @@ -102,7 +103,7 @@ public: * Get the vertical wrap mode * @return The vertical wrap mode */ - virtual WrapMode GetVWrapMode() const + WrapMode GetVWrapMode() const { return mVWrapMode; } @@ -113,13 +114,13 @@ private: FilterMode mMagFilter; ///< The magnify filter WrapMode mUWrapMode; ///< The horizontal wrap mode WrapMode mVWrapMode; ///< The vertical wrap mode + }; } // namespace Render - - } // namespace Internal + } // namespace Dali diff --git a/dali/internal/render/renderers/render-texture.h b/dali/internal/render/renderers/render-texture.h index bb79d83..35ed3a1 100644 --- a/dali/internal/render/renderers/render-texture.h +++ b/dali/internal/render/renderers/render-texture.h @@ -37,18 +37,18 @@ public: * Constructor */ Texture() - :mUniformName(""), - mTextureId(Integration::InvalidResourceId), - mSampler(0) + :mUniformName(), + mSampler(0), + mTextureId(Integration::InvalidResourceId) {} /** * Constructor */ - Texture( const char* samplerName, Integration::ResourceId textureId, Render::Sampler* sampler ) - :mUniformName(samplerName), - mTextureId( textureId), - mSampler(sampler) + Texture( const std::string& samplerName, Integration::ResourceId textureId, Render::Sampler* sampler ) + :mUniformName( samplerName ), + mSampler( sampler ), + mTextureId( textureId) {} /** @@ -66,7 +66,8 @@ public: return mSampler; } -public: // SamplerDataProvider interface - called from RenderThread +public: // called from RenderThread + /** * Get the texture unit uniform name * @return the name of the texture unit uniform @@ -87,9 +88,9 @@ public: // SamplerDataProvider interface - called from RenderThread } private: - std::string mUniformName; - Integration::ResourceId mTextureId; - Render::Sampler* mSampler; + std::string mUniformName; + Render::Sampler* mSampler; + Integration::ResourceId mTextureId; }; } // namespace SceneGraph diff --git a/dali/internal/update/rendering/scene-graph-material.h b/dali/internal/update/rendering/scene-graph-material.h index e4a7bc2..3f13d1e 100644 --- a/dali/internal/update/rendering/scene-graph-material.h +++ b/dali/internal/update/rendering/scene-graph-material.h @@ -227,9 +227,9 @@ public: * @param[in] index The index of the texture in the textures array * @return the uniform name */ - const char* GetTextureUniformName( size_t index ) + const std::string& GetTextureUniformName( size_t index ) { - return mUniformName[index].c_str(); + return mUniformName[index]; } /** diff --git a/dali/public-api/actors/sampling.h b/dali/public-api/actors/sampling.h index 4cf7a48..233442b 100644 --- a/dali/public-api/actors/sampling.h +++ b/dali/public-api/actors/sampling.h @@ -36,8 +36,8 @@ namespace FilterMode */ enum Type { - NONE = 0, ///< Use GL system defaults (minification NEAREST_MIPMAP_LINEAR, magnification LINEAR) - DEFAULT, ///< Use dali defaults (minification LINEAR, magnification LINEAR) + NONE = 0, ///< Use GL defaults (minification NEAREST_MIPMAP_LINEAR, magnification LINEAR) + DEFAULT, ///< Use Dali defaults (minification LINEAR, magnification LINEAR) NEAREST, ///< Filter nearest LINEAR ///< Filter linear }; -- 2.7.4