From 753418c02d321146a5bd5db43f95b314aceb1702 Mon Sep 17 00:00:00 2001 From: Andrew Cox Date: Wed, 15 Jul 2015 13:56:39 +0100 Subject: [PATCH] Move ShaderData from integration api to internal Change-Id: Ibd3cae2fe9c4c08a78e3f99ce3b81f9dfbb2c8f1 Signed-off-by: Andrew Cox --- dali/integration-api/file.list | 2 -- dali/integration-api/shader-data.cpp | 30 ---------------------- .../common}/shader-data.h | 18 +++++-------- dali/internal/common/shader-saver.h | 8 ++---- dali/internal/event/effects/shader-effect-impl.cpp | 2 +- dali/internal/event/effects/shader-factory.cpp | 12 ++------- dali/internal/event/effects/shader-factory.h | 24 ++++++----------- dali/internal/event/rendering/shader-impl.cpp | 2 +- .../renderers/scene-graph-renderer-debug.cpp | 4 +-- dali/internal/render/shaders/program-cache.h | 2 +- .../internal/render/shaders/program-controller.cpp | 3 +-- dali/internal/render/shaders/program-controller.h | 2 +- dali/internal/render/shaders/program.cpp | 6 ++--- dali/internal/render/shaders/program.h | 8 +++--- .../internal/render/shaders/scene-graph-shader.cpp | 2 +- dali/internal/render/shaders/scene-graph-shader.h | 4 +-- dali/internal/update/manager/update-manager.cpp | 10 ++++---- dali/internal/update/manager/update-manager.h | 8 +++--- 18 files changed, 45 insertions(+), 102 deletions(-) delete mode 100644 dali/integration-api/shader-data.cpp rename dali/{integration-api => internal/common}/shader-data.h (90%) diff --git a/dali/integration-api/file.list b/dali/integration-api/file.list index 5c03098..ec83f66 100644 --- a/dali/integration-api/file.list +++ b/dali/integration-api/file.list @@ -7,7 +7,6 @@ platform_abstraction_src_files = \ $(platform_abstraction_src_dir)/debug.cpp \ $(platform_abstraction_src_dir)/profiling.cpp \ $(platform_abstraction_src_dir)/input-options.cpp \ - $(platform_abstraction_src_dir)/shader-data.cpp \ $(platform_abstraction_src_dir)/system-overlay.cpp \ $(platform_abstraction_src_dir)/lockless-buffer.cpp \ $(platform_abstraction_src_dir)/events/event.cpp \ @@ -42,7 +41,6 @@ platform_abstraction_header_files = \ $(platform_abstraction_src_dir)/gesture-manager.h \ $(platform_abstraction_src_dir)/render-controller.h \ $(platform_abstraction_src_dir)/platform-abstraction.h \ - $(platform_abstraction_src_dir)/shader-data.h \ $(platform_abstraction_src_dir)/system-overlay.h \ $(platform_abstraction_src_dir)/lockless-buffer.h diff --git a/dali/integration-api/shader-data.cpp b/dali/integration-api/shader-data.cpp deleted file mode 100644 index 6bab886..0000000 --- a/dali/integration-api/shader-data.cpp +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// CLASS HEADER -#include - -namespace Dali -{ - -namespace Integration -{ - -const size_t ShaderData::UNINITIALISED_HASH_VALUE = size_t(0) - 1; - -} -} diff --git a/dali/integration-api/shader-data.h b/dali/internal/common/shader-data.h similarity index 90% rename from dali/integration-api/shader-data.h rename to dali/internal/common/shader-data.h index b047650..797568d 100644 --- a/dali/integration-api/shader-data.h +++ b/dali/internal/common/shader-data.h @@ -1,5 +1,5 @@ -#ifndef __DALI_INTEGRATION_SHADER_DATA_H__ -#define __DALI_INTEGRATION_SHADER_DATA_H__ +#ifndef __DALI_INTERNAL_SHADER_DATA_H__ +#define __DALI_INTERNAL_SHADER_DATA_H__ /* * Copyright (c) 2015 Samsung Electronics Co., Ltd. @@ -24,16 +24,14 @@ // INTERNAL INCLUDES #include #include -#include namespace Dali { -namespace Integration +namespace Internal { class ShaderData; - typedef IntrusivePtr ShaderDataPtr; /** @@ -44,15 +42,13 @@ class ShaderData : public Dali::RefObject { public: - static const size_t UNINITIALISED_HASH_VALUE; - /** * Constructor * @param[in] vertexSource Source code for vertex program * @param[in] fragmentSource Source code for fragment program */ ShaderData(const std::string& vertexSource, const std::string& fragmentSource) - : mShaderHash( UNINITIALISED_HASH_VALUE ), + : mShaderHash( -1 ), mVertexShader(vertexSource), mFragmentShader(fragmentSource) { } @@ -75,7 +71,7 @@ public: // API */ void SetHashValue(size_t shaderHash) { - DALI_ASSERT_DEBUG( shaderHash != 0 ); + DALI_ASSERT_DEBUG( shaderHash != size_t(-1) ); mShaderHash = shaderHash; } @@ -85,7 +81,7 @@ public: // API */ size_t GetHashValue() const { - DALI_ASSERT_DEBUG( mShaderHash != UNINITIALISED_HASH_VALUE ); + DALI_ASSERT_DEBUG( mShaderHash != size_t(-1) ); return mShaderHash; } @@ -168,4 +164,4 @@ private: // Data } // namespace Dali -#endif // __DALI_INTEGRATION_SHADER_DATA_H__ +#endif // __DALI_INTERNAL_SHADER_DATA_H__ diff --git a/dali/internal/common/shader-saver.h b/dali/internal/common/shader-saver.h index 1083282..580cab6 100644 --- a/dali/internal/common/shader-saver.h +++ b/dali/internal/common/shader-saver.h @@ -27,14 +27,10 @@ namespace Dali { -namespace Integration +namespace Internal { class ShaderData; typedef IntrusivePtr ShaderDataPtr; -} - -namespace Internal -{ /** * Abstract interface for passing a ShaderData object towards being saved. @@ -47,7 +43,7 @@ public: * A function saving the binary from a ShaderDataPtr or passing it on to where it can be saved. * @param[in] shaderData A smart pointer to a ShaderData for which the program binary should be saved. */ - virtual void SaveBinary( Integration::ShaderDataPtr shaderData ) = 0; + virtual void SaveBinary( Internal::ShaderDataPtr shaderData ) = 0; protected: /** diff --git a/dali/internal/event/effects/shader-effect-impl.cpp b/dali/internal/event/effects/shader-effect-impl.cpp index f659a21..a038ef6 100644 --- a/dali/internal/event/effects/shader-effect-impl.cpp +++ b/dali/internal/event/effects/shader-effect-impl.cpp @@ -292,7 +292,7 @@ void ShaderEffect::SendProgramMessage( const string& vertexSource, const string& ShaderFactory& shaderFactory = tls.GetShaderFactory(); size_t shaderHash; - Integration::ShaderDataPtr shaderData = shaderFactory.Load( vertexSource, fragmentSource, shaderHash ); + Internal::ShaderDataPtr shaderData = shaderFactory.Load( vertexSource, fragmentSource, shaderHash ); DALI_ASSERT_DEBUG( shaderHash != 0U ); // Add shader program to scene-object using a message to the UpdateManager diff --git a/dali/internal/event/effects/shader-factory.cpp b/dali/internal/event/effects/shader-factory.cpp index 88ef6ed..64100a0 100644 --- a/dali/internal/event/effects/shader-factory.cpp +++ b/dali/internal/event/effects/shader-factory.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * Copyright (c) 2015 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,7 +28,6 @@ #include #include #include -#include #include #include @@ -41,13 +40,6 @@ const char* VERSION_SEPARATOR = "-"; const char* SHADER_SUFFIX = ".dali-bin"; } -// Use pre-compiler constants in order to utilize string concatenation -#define SHADER_DEF_USE_BONES "#define USE_BONES\n" -#define SHADER_DEF_USE_COLOR "#define USE_COLOR\n" -#define SHADER_DEF_USE_GRADIENT "#define USE_GRADIENT\n" - -using namespace Dali::Integration; - namespace Dali { @@ -137,7 +129,7 @@ ShaderDataPtr ShaderFactory::Load( const std::string& vertexSource, const std::s return shaderData; } -void ShaderFactory::SaveBinary( Integration::ShaderDataPtr shaderData ) +void ShaderFactory::SaveBinary( Internal::ShaderDataPtr shaderData ) { // Save the binary to the file system: std::string binaryShaderFilename; diff --git a/dali/internal/event/effects/shader-factory.h b/dali/internal/event/effects/shader-factory.h index 29fd221..17a4204 100644 --- a/dali/internal/event/effects/shader-factory.h +++ b/dali/internal/event/effects/shader-factory.h @@ -20,26 +20,18 @@ // INTERNAL INCLUDES #include -#include #include #include #include namespace Dali { -namespace Integration -{ - -class ShaderData; -typedef IntrusivePtr ShaderDataPtr; - -} namespace Internal { -class ResourceClient; -class MessageController; +class ShaderData; +typedef IntrusivePtr ShaderDataPtr; /** * ShaderFactory is an object which manages shader binary resource load requests, @@ -75,7 +67,7 @@ public: * a compiled shader program binary if one could be found, else an * empty binary buffer cleared to size zero. */ - Integration::ShaderDataPtr Load( const std::string& vertexSource, const std::string& fragmentSource, size_t& shaderHash ); + Internal::ShaderDataPtr Load( const std::string& vertexSource, const std::string& fragmentSource, size_t& shaderHash ); /** * @brief Saves shader to memory cache and filesystem. @@ -84,7 +76,7 @@ public: * @param[in] shader The data to be saved. * @sa Load */ - virtual void SaveBinary( Integration::ShaderDataPtr shader ); + virtual void SaveBinary( Internal::ShaderDataPtr shader ); /** * Called during Core initialization to load the default shader. @@ -93,7 +85,7 @@ public: private: - void MemoryCacheInsert( Integration::ShaderData& shaderData ); + void MemoryCacheInsert( Internal::ShaderData& shaderData ); // Undefined ShaderFactory( const ShaderFactory& ); @@ -103,13 +95,13 @@ private: private: ShaderEffectPtr mDefaultShader; - Dali::Vector< Integration::ShaderData* > mShaderBinaryCache; ///< Cache of pre-compiled shaders. + Dali::Vector< Internal::ShaderData* > mShaderBinaryCache; ///< Cache of pre-compiled shaders. }; // class ShaderFactory -inline MessageBase* ShaderCompiledMessage( ShaderSaver& factory, Integration::ShaderDataPtr shaderData ) +inline MessageBase* ShaderCompiledMessage( ShaderSaver& factory, Internal::ShaderDataPtr shaderData ) { - return new MessageValue1< ShaderSaver, Integration::ShaderDataPtr >( &factory, + return new MessageValue1< ShaderSaver, Internal::ShaderDataPtr >( &factory, &ShaderSaver::SaveBinary, shaderData ); } diff --git a/dali/internal/event/rendering/shader-impl.cpp b/dali/internal/event/rendering/shader-impl.cpp index 12b218e..1ff7b5e 100644 --- a/dali/internal/event/rendering/shader-impl.cpp +++ b/dali/internal/event/rendering/shader-impl.cpp @@ -281,7 +281,7 @@ void Shader::Initialize( ThreadLocalStorage& tls = ThreadLocalStorage::Get(); ShaderFactory& shaderFactory = tls.GetShaderFactory(); size_t shaderHash; - Integration::ShaderDataPtr shaderData = shaderFactory.Load( vertexSource, fragmentSource, shaderHash ); + Internal::ShaderDataPtr shaderData = shaderFactory.Load( vertexSource, fragmentSource, shaderHash ); // Add shader program to scene-object using a message to the UpdateManager SetShaderProgramMessage( updateManager, *mSceneObject, shaderData, (hints & Dali::Shader::HINT_MODIFIES_GEOMETRY) != 0x0 ); diff --git a/dali/internal/render/renderers/scene-graph-renderer-debug.cpp b/dali/internal/render/renderers/scene-graph-renderer-debug.cpp index 2059fd4..433cc30 100644 --- a/dali/internal/render/renderers/scene-graph-renderer-debug.cpp +++ b/dali/internal/render/renderers/scene-graph-renderer-debug.cpp @@ -15,7 +15,7 @@ */ #include "scene-graph-renderer-debug.h" -#include +#include #include #include #include @@ -62,7 +62,7 @@ void DebugBoundingBox(Context& context, Rect boundingBox, const Matrix& m #if defined ( DEBUG_ENABLED ) if( gDebugProgram == NULL ) { - Integration::ShaderDataPtr shaderData( new Integration::ShaderData( DEBUG_DRAW_VERTEX_SHADER, DEBUG_DRAW_FRAGMENT_SHADER ) ); + Internal::ShaderDataPtr shaderData( new Internal::ShaderData( DEBUG_DRAW_VERTEX_SHADER, DEBUG_DRAW_FRAGMENT_SHADER ) ); gDebugProgram = Program::New( shaderData.Get(), context, true ); } diff --git a/dali/internal/render/shaders/program-cache.h b/dali/internal/render/shaders/program-cache.h index 1f28969..7c40a01 100644 --- a/dali/internal/render/shaders/program-cache.h +++ b/dali/internal/render/shaders/program-cache.h @@ -94,7 +94,7 @@ public: // API /** * @param programData to store/save */ - virtual void StoreBinary( Integration::ShaderDataPtr programData ) = 0; + virtual void StoreBinary( Internal::ShaderDataPtr programData ) = 0; private: // not implemented as non-copyable diff --git a/dali/internal/render/shaders/program-controller.cpp b/dali/internal/render/shaders/program-controller.cpp index e4163db..0958710 100644 --- a/dali/internal/render/shaders/program-controller.cpp +++ b/dali/internal/render/shaders/program-controller.cpp @@ -141,10 +141,9 @@ unsigned int ProgramController::ProgramBinaryFormat() return mProgramBinaryFormat; } -void ProgramController::StoreBinary( Integration::ShaderDataPtr programData ) +void ProgramController::StoreBinary( Internal::ShaderDataPtr programData ) { DALI_ASSERT_DEBUG( programData->GetBufferSize() > 0 ); - DALI_ASSERT_DEBUG( programData->GetHashValue() != 0 ); DALI_ASSERT_DEBUG( mShaderSaver && "SetShaderSaver() should have been called during startup." ); if( mShaderSaver != NULL ) diff --git a/dali/internal/render/shaders/program-controller.h b/dali/internal/render/shaders/program-controller.h index 8dedd95..3ceb2a9 100644 --- a/dali/internal/render/shaders/program-controller.h +++ b/dali/internal/render/shaders/program-controller.h @@ -163,7 +163,7 @@ private: // From ProgramCache /** * @copydoc ProgramCache::StoreBinary */ - virtual void StoreBinary( Integration::ShaderDataPtr programData ); + virtual void StoreBinary( Internal::ShaderDataPtr programData ); private: // not implemented as non-copyable diff --git a/dali/internal/render/shaders/program.cpp b/dali/internal/render/shaders/program.cpp index 6957698..0c5ba69 100644 --- a/dali/internal/render/shaders/program.cpp +++ b/dali/internal/render/shaders/program.cpp @@ -26,7 +26,7 @@ #include #include #include -#include +#include #include #include #include @@ -110,7 +110,7 @@ const char* gStdUniforms[ Program::UNIFORM_TYPE_LAST ] = // IMPLEMENTATION -Program* Program::New( ProgramCache& cache, Integration::ShaderDataPtr shaderData, bool modifiesGeometry ) +Program* Program::New( ProgramCache& cache, Internal::ShaderDataPtr shaderData, bool modifiesGeometry ) { size_t shaderHash = shaderData->GetHashValue(); Program* program = cache.GetProgram( shaderHash ); @@ -448,7 +448,7 @@ bool Program::ModifiesGeometry() return mModifiesGeometry; } -Program::Program( ProgramCache& cache, Integration::ShaderDataPtr shaderData, bool modifiesGeometry ) +Program::Program( ProgramCache& cache, Internal::ShaderDataPtr shaderData, bool modifiesGeometry ) : mCache( cache ), mGlAbstraction( mCache.GetGlAbstraction() ), mProjectionMatrix( NULL ), diff --git a/dali/internal/render/shaders/program.h b/dali/internal/render/shaders/program.h index 9bfb90b..50d02d6 100644 --- a/dali/internal/render/shaders/program.h +++ b/dali/internal/render/shaders/program.h @@ -25,7 +25,7 @@ #include #include #include -#include +#include namespace Dali { @@ -118,7 +118,7 @@ public: * @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 @@ -293,7 +293,7 @@ private: // Implementation * @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: @@ -353,7 +353,7 @@ private: // Data 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 std::vector< std::pair< std::string, GLint > > mAttributeLocations; ///< attribute location cache diff --git a/dali/internal/render/shaders/scene-graph-shader.cpp b/dali/internal/render/shaders/scene-graph-shader.cpp index 3a078ce..913a071 100644 --- a/dali/internal/render/shaders/scene-graph-shader.cpp +++ b/dali/internal/render/shaders/scene-graph-shader.cpp @@ -203,7 +203,7 @@ void Shader::SetCoordinateTypeInRender( unsigned int index, Dali::ShaderEffect:: mUniformMetadata[ index ]->SetCoordinateType( type ); } -void Shader::SetProgram( Integration::ShaderDataPtr shaderData, +void Shader::SetProgram( Internal::ShaderDataPtr shaderData, ProgramCache* programCache, bool modifiesGeometry ) { diff --git a/dali/internal/render/shaders/scene-graph-shader.h b/dali/internal/render/shaders/scene-graph-shader.h index 1dcb0e0..198b557 100644 --- a/dali/internal/render/shaders/scene-graph-shader.h +++ b/dali/internal/render/shaders/scene-graph-shader.h @@ -22,7 +22,7 @@ #include #include -#include +#include #include #include @@ -243,7 +243,7 @@ public: * @param[in] modifiesGeometry True if the vertex shader changes the positions of vertexes such that * they might exceed the bounding box of vertexes passing through the default transformation. */ - void SetProgram( Integration::ShaderDataPtr shaderData, + void SetProgram( Internal::ShaderDataPtr shaderData, ProgramCache* programCache, bool modifiesGeometry ); diff --git a/dali/internal/update/manager/update-manager.cpp b/dali/internal/update/manager/update-manager.cpp index bdae788..5afcf94 100644 --- a/dali/internal/update/manager/update-manager.cpp +++ b/dali/internal/update/manager/update-manager.cpp @@ -24,7 +24,7 @@ #include #include -#include +#include #include #include @@ -131,7 +131,7 @@ typedef OwnerContainer< Shader* > ShaderContainer; typedef ShaderContainer::Iterator ShaderIter; typedef ShaderContainer::ConstIterator ShaderConstIter; -typedef std::vector ShaderDataBatchedQueue; +typedef std::vector ShaderDataBatchedQueue; typedef ShaderDataBatchedQueue::iterator ShaderDataBatchedQueueIterator; typedef OwnerContainer GestureContainer; @@ -610,12 +610,12 @@ void UpdateManager::RemoveShader( Shader* shader ) } void UpdateManager::SetShaderProgram( Shader* shader, - Integration::ShaderDataPtr shaderData, bool modifiesGeometry ) + Internal::ShaderDataPtr shaderData, bool modifiesGeometry ) { if( shaderData ) { - typedef MessageValue3< Shader, Integration::ShaderDataPtr, ProgramCache*, bool> DerivedType; + typedef MessageValue3< Shader, Internal::ShaderDataPtr, ProgramCache*, bool> DerivedType; // Reserve some memory inside the render queue unsigned int* slot = mImpl->renderQueue.ReserveMessageSlot( mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof( DerivedType ) ); @@ -625,7 +625,7 @@ void UpdateManager::SetShaderProgram( Shader* shader, } } -void UpdateManager::SaveBinary( Integration::ShaderDataPtr shaderData ) +void UpdateManager::SaveBinary( Internal::ShaderDataPtr shaderData ) { DALI_ASSERT_DEBUG( shaderData && "No NULL shader data pointers please." ); DALI_ASSERT_DEBUG( shaderData->GetBufferSize() > 0 && "Shader binary empty so nothing to save." ); diff --git a/dali/internal/update/manager/update-manager.h b/dali/internal/update/manager/update-manager.h index 10bbfcf..5c23c9f 100644 --- a/dali/internal/update/manager/update-manager.h +++ b/dali/internal/update/manager/update-manager.h @@ -309,13 +309,13 @@ public: * @param[in] shaderData Source code, hash over source, and optional compiled binary for the shader program * @param[in] modifiesGeometry True if the vertex shader modifies geometry */ - void SetShaderProgram( Shader* shader, Integration::ShaderDataPtr shaderData, bool modifiesGeometry ); + void SetShaderProgram( Shader* shader, Internal::ShaderDataPtr shaderData, bool modifiesGeometry ); /** * @brief Accept compiled shaders passed back on render thread for saving. * @param[in] shaderData Source code, hash over source, and corresponding compiled binary to be saved. */ - virtual void SaveBinary( Integration::ShaderDataPtr shaderData ); + virtual void SaveBinary( Internal::ShaderDataPtr shaderData ); /** * @brief Set the destination for compiled shader binaries to be passed on to. @@ -724,10 +724,10 @@ inline void RemoveShaderMessage( UpdateManager& manager, Shader& shader ) inline void SetShaderProgramMessage( UpdateManager& manager, Shader& shader, - Integration::ShaderDataPtr shaderData, + Internal::ShaderDataPtr shaderData, bool modifiesGeometry ) { - typedef MessageValue3< UpdateManager, Shader*, Integration::ShaderDataPtr, bool > LocalType; + typedef MessageValue3< UpdateManager, Shader*, Internal::ShaderDataPtr, bool > LocalType; // Reserve some memory inside the message queue unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) ); -- 2.7.4