From 6a2869d6a5c8c4113c20c3d9afc22368e7773e68 Mon Sep 17 00:00:00 2001 From: David Steele Date: Thu, 29 Apr 2021 14:25:56 +0100 Subject: [PATCH] Cleanup in Aisle #2 Change-Id: I994feedef465bf5427009d0cfc0659816c7d1000 --- dali/internal/file.list | 2 +- dali/internal/render/renderers/gpu-buffer.cpp | 14 +-- dali/internal/render/renderers/gpu-buffer.h | 24 ++--- dali/internal/render/renderers/render-renderer.cpp | 20 ++-- dali/internal/render/renderers/render-renderer.h | 7 +- dali/internal/render/shaders/program-cache.h | 5 +- .../internal/render/shaders/program-controller.cpp | 5 - dali/internal/render/shaders/program-controller.h | 21 ++-- dali/internal/render/shaders/program.cpp | 91 +--------------- dali/internal/render/shaders/program.h | 115 ++++----------------- .../{scene-graph-shader.cpp => render-shader.cpp} | 5 +- .../{scene-graph-shader.h => render-shader.h} | 45 ++------ dali/internal/update/common/discard-queue.cpp | 2 +- .../manager/render-instruction-processor.cpp | 2 +- dali/internal/update/manager/update-manager.h | 2 +- .../update/rendering/scene-graph-renderer.cpp | 2 +- 16 files changed, 71 insertions(+), 291 deletions(-) rename dali/internal/render/shaders/{scene-graph-shader.cpp => render-shader.cpp} (85%) rename dali/internal/render/shaders/{scene-graph-shader.h => render-shader.h} (69%) diff --git a/dali/internal/file.list b/dali/internal/file.list index d46c512..7f4afe7 100644 --- a/dali/internal/file.list +++ b/dali/internal/file.list @@ -120,7 +120,7 @@ SET( internal_src_files ${internal_src_dir}/render/shaders/program.cpp ${internal_src_dir}/render/shaders/program-controller.cpp - ${internal_src_dir}/render/shaders/scene-graph-shader.cpp + ${internal_src_dir}/render/shaders/render-shader.cpp ${internal_src_dir}/update/animation/scene-graph-animation.cpp ${internal_src_dir}/update/animation/scene-graph-constraint-base.cpp diff --git a/dali/internal/render/renderers/gpu-buffer.cpp b/dali/internal/render/renderers/gpu-buffer.cpp index 7e7aeba..0d2003a 100644 --- a/dali/internal/render/renderers/gpu-buffer.cpp +++ b/dali/internal/render/renderers/gpu-buffer.cpp @@ -32,12 +32,7 @@ namespace } // namespace GpuBuffer::GpuBuffer(Graphics::Controller& graphicsController, Graphics::BufferUsageFlags usage) -: mUsage(usage), - mBufferCreated(false) -{ -} - -GpuBuffer::~GpuBuffer() +: mUsage(usage) { } @@ -54,7 +49,7 @@ void GpuBuffer::UpdateDataBuffer(Graphics::Controller& graphicsController, uint3 mCapacity = size; } - Graphics::MapBufferInfo info; + Graphics::MapBufferInfo info{}; info.buffer = mGraphicsObject.get(); info.usage = 0 | Graphics::MemoryUsageFlagBits::WRITE; info.offset = 0; @@ -67,11 +62,6 @@ void GpuBuffer::UpdateDataBuffer(Graphics::Controller& graphicsController, uint3 graphicsController.UnmapMemory(std::move(memory)); } -bool GpuBuffer::BufferIsValid() const -{ - return mGraphicsObject && (0 != mCapacity); -} - void GpuBuffer::Destroy() { mCapacity = 0; diff --git a/dali/internal/render/renderers/gpu-buffer.h b/dali/internal/render/renderers/gpu-buffer.h index 70a4aea..42b2a75 100644 --- a/dali/internal/render/renderers/gpu-buffer.h +++ b/dali/internal/render/renderers/gpu-buffer.h @@ -1,5 +1,5 @@ -#ifndef DALI_INTERNAL_GPU_BUFFER_H -#define DALI_INTERNAL_GPU_BUFFER_H +#ifndef DALI_INTERNAL_RENDERERS_GPU_BUFFER_H +#define DALI_INTERNAL_RENDERERS_GPU_BUFFER_H /* * Copyright (c) 2021 Samsung Electronics Co., Ltd. @@ -48,7 +48,7 @@ public: /** * Destructor, non virtual as no virtual methods or inheritance */ - ~GpuBuffer(); + ~GpuBuffer() = default; /** * @@ -60,26 +60,21 @@ public: void UpdateDataBuffer(Graphics::Controller& graphicsController, uint32_t size, const void* data); /** - * @return true if the GPU buffer is valid, i.e. its created and not empty - */ - bool BufferIsValid() const; - - /** * Get the size of the buffer * @return size */ - uint32_t GetBufferSize() const + [[nodiscard]] uint32_t GetBufferSize() const { return mSize; } - inline const Graphics::Buffer* GetGraphicsObject() const + [[nodiscard]] inline const Graphics::Buffer* GetGraphicsObject() const { return mGraphicsObject.get(); } /** - * ??? + * Destroy the graphics buffer and reset. */ void Destroy(); @@ -87,13 +82,10 @@ private: Graphics::UniquePtr mGraphicsObject; uint32_t mCapacity{0}; ///< buffer capacity uint32_t mSize{0}; ///< buffer size - - Graphics::BufferUsageFlags mUsage; - bool mBufferCreated : 1; ///< whether buffer has been created + Graphics::BufferUsageFlags mUsage; }; } // namespace Internal - } // namespace Dali -#endif // DALI_INTERNAL_GPU_BUFFER_H +#endif // DALI_INTERNAL_RENDERERS_GPU_BUFFER_H diff --git a/dali/internal/render/renderers/render-renderer.cpp b/dali/internal/render/renderers/render-renderer.cpp index 9ce65ce..22847b9 100644 --- a/dali/internal/render/renderers/render-renderer.cpp +++ b/dali/internal/render/renderers/render-renderer.cpp @@ -31,7 +31,7 @@ #include #include #include -#include +#include #include namespace Dali @@ -555,8 +555,7 @@ bool Renderer::Render(Graphics::CommandBuffer& comma Program* program = Program::New(*mProgramCache, shaderData, *mGraphicsController, - std::move(graphicsProgram), - (shaderData->GetHints() & Dali::Shader::Hint::MODIFIES_GEOMETRY) != 0x0); + std::move(graphicsProgram)); if(!program) { @@ -612,15 +611,15 @@ void Renderer::BuildUniformIndexMap(BufferIndex bufferIndex, const SceneGraph::N const SceneGraph::CollectedUniformMap& uniformMap = uniformMapDataProvider.GetUniformMap(bufferIndex); const SceneGraph::CollectedUniformMap& uniformMapNode = node.GetUniformMap(bufferIndex); - uint32_t maxMaps = static_cast(uniformMap.Count() + uniformMapNode.Count()); // 4,294,967,295 maps should be enough - mUniformIndexMap.Clear(); // Clear contents, but keep memory if we don't change size + auto maxMaps = static_cast(uniformMap.Count() + uniformMapNode.Count()); // 4,294,967,295 maps should be enough + mUniformIndexMap.Clear(); // Clear contents, but keep memory if we don't change size mUniformIndexMap.Resize(maxMaps); + // Copy uniform map into mUniformIndexMap uint32_t mapIndex = 0; for(; mapIndex < uniformMap.Count(); ++mapIndex) { mUniformIndexMap[mapIndex].propertyValue = uniformMap[mapIndex].propertyPtr; - mUniformIndexMap[mapIndex].uniformIndex = program.RegisterUniform(uniformMap[mapIndex].uniformName); mUniformIndexMap[mapIndex].uniformName = uniformMap[mapIndex].uniformName; mUniformIndexMap[mapIndex].uniformNameHash = uniformMap[mapIndex].uniformNameHash; mUniformIndexMap[mapIndex].uniformNameHashNoArray = uniformMap[mapIndex].uniformNameHashNoArray; @@ -629,11 +628,13 @@ void Renderer::BuildUniformIndexMap(BufferIndex bufferIndex, const SceneGraph::N for(uint32_t nodeMapIndex = 0; nodeMapIndex < uniformMapNode.Count(); ++nodeMapIndex) { - uint32_t uniformIndex = program.RegisterUniform(uniformMapNode[nodeMapIndex].uniformName); - bool found(false); + auto hash = uniformMapNode[nodeMapIndex].uniformNameHash; + auto& name = uniformMapNode[nodeMapIndex].uniformName; + bool found(false); for(uint32_t i = 0; i < uniformMap.Count(); ++i) { - if(mUniformIndexMap[i].uniformIndex == uniformIndex) + if(mUniformIndexMap[i].uniformNameHash == hash && + mUniformIndexMap[i].uniformName == name) { mUniformIndexMap[i].propertyValue = uniformMapNode[nodeMapIndex].propertyPtr; found = true; @@ -645,7 +646,6 @@ void Renderer::BuildUniformIndexMap(BufferIndex bufferIndex, const SceneGraph::N { mUniformIndexMap[mapIndex].propertyValue = uniformMapNode[nodeMapIndex].propertyPtr; mUniformIndexMap[mapIndex].uniformName = uniformMapNode[nodeMapIndex].uniformName; - mUniformIndexMap[mapIndex].uniformIndex = uniformIndex; mUniformIndexMap[mapIndex].uniformNameHash = uniformMapNode[nodeMapIndex].uniformNameHash; mUniformIndexMap[mapIndex].uniformNameHashNoArray = uniformMapNode[nodeMapIndex].uniformNameHashNoArray; mUniformIndexMap[mapIndex].arrayIndex = uniformMapNode[nodeMapIndex].arrayIndex; diff --git a/dali/internal/render/renderers/render-renderer.h b/dali/internal/render/renderers/render-renderer.h index 285c4b6..6cd2459 100644 --- a/dali/internal/render/renderers/render-renderer.h +++ b/dali/internal/render/renderers/render-renderer.h @@ -529,12 +529,11 @@ private: using Hash = unsigned long; struct UniformIndexMap { - uint32_t uniformIndex; ///< The index of the cached location in the Program - ConstString uniformName; ///< The uniform name - const PropertyInputImpl* propertyValue; ///< The property value + ConstString uniformName; ///< The uniform name + const PropertyInputImpl* propertyValue{nullptr}; ///< The property value Hash uniformNameHash{0u}; Hash uniformNameHashNoArray{0u}; - int32_t arrayIndex; ///< The array index + int32_t arrayIndex{-1}; ///< The array index }; using UniformIndexMappings = Dali::Vector; diff --git a/dali/internal/render/shaders/program-cache.h b/dali/internal/render/shaders/program-cache.h index 2ebf63c..00d4d5c 100644 --- a/dali/internal/render/shaders/program-cache.h +++ b/dali/internal/render/shaders/program-cache.h @@ -86,9 +86,8 @@ public: // API */ virtual void StoreBinary(Internal::ShaderDataPtr programData) = 0; -private: // not implemented as non-copyable - ProgramCache(const ProgramCache& rhs); - ProgramCache& operator=(const ProgramCache& rhs); + ProgramCache(const ProgramCache& rhs) = delete; + ProgramCache& operator=(const ProgramCache& rhs) = delete; }; } // namespace Internal diff --git a/dali/internal/render/shaders/program-controller.cpp b/dali/internal/render/shaders/program-controller.cpp index 2d638cc..f01f6d4 100644 --- a/dali/internal/render/shaders/program-controller.cpp +++ b/dali/internal/render/shaders/program-controller.cpp @@ -110,11 +110,6 @@ void ProgramController::SetShaderSaver(ShaderSaver& shaderSaver) mShaderSaver = &shaderSaver; } -void ProgramController::ClearCurrentProgram() -{ - SetCurrentProgram(nullptr); -} - } // namespace Internal } // namespace Dali diff --git a/dali/internal/render/shaders/program-controller.h b/dali/internal/render/shaders/program-controller.h index 1f4a434..bac7102 100644 --- a/dali/internal/render/shaders/program-controller.h +++ b/dali/internal/render/shaders/program-controller.h @@ -75,14 +75,13 @@ public: * Inline getter for the hash * @return the hash */ - inline size_t GetHash() + inline size_t GetHash() const { return mShaderHash; } - private: // Not implemented - ProgramPair(const ProgramPair&); - ProgramPair& operator=(const ProgramPair&); + ProgramPair(const ProgramPair&) = delete; + ProgramPair& operator=(const ProgramPair&) = delete; private: // Data Program* mProgram; @@ -93,13 +92,16 @@ public: * Constructor * graphicsController The graphics backend controller */ - ProgramController(Graphics::Controller& graphicsController); + explicit ProgramController(Graphics::Controller& graphicsController); /** * Destructor, non virtual as not a base class */ ~ProgramController() override; + ProgramController(const ProgramController& rhs) = delete; + ProgramController& operator=(const ProgramController& rhs) = delete; + public: // API /** * Resets the program matrices. Must be called at the beginning of every frame @@ -112,11 +114,6 @@ public: // API */ void SetShaderSaver(ShaderSaver& shaderSaver); - /** - * Clear current cached program - */ - void ClearCurrentProgram(); - private: // From ProgramCache /** * @copydoc ProgramCache::GetProgram @@ -153,10 +150,6 @@ private: // From ProgramCache */ void StoreBinary(Internal::ShaderDataPtr programData) override; -private: // not implemented as non-copyable - ProgramController(const ProgramController& rhs); - ProgramController& operator=(const ProgramController& rhs); - private: // Data ShaderSaver* mShaderSaver; Graphics::Controller& mGraphicsController; diff --git a/dali/internal/render/shaders/program.cpp b/dali/internal/render/shaders/program.cpp index 1c8bacc..28c5d34 100644 --- a/dali/internal/render/shaders/program.cpp +++ b/dali/internal/render/shaders/program.cpp @@ -44,21 +44,6 @@ namespace Internal // LOCAL STUFF namespace { -const char* const gStdUniforms[Program::UNIFORM_TYPE_LAST] = - { - "uMvpMatrix", // UNIFORM_MVP_MATRIX - "uModelView", // UNIFORM_MODELVIEW_MATRIX - "uProjection", // UNIFORM_PROJECTION_MATRIX - "uModelMatrix", // UNIFORM_MODEL_MATRIX, - "uViewMatrix", // UNIFORM_VIEW_MATRIX, - "uNormalMatrix", // UNIFORM_NORMAL_MATRIX - "uColor", // UNIFORM_COLOR - "sTexture", // UNIFORM_SAMPLER - "sTextureRect", // UNIFORM_SAMPLER_RECT - "sEffect", // UNIFORM_EFFECT_SAMPLER - "uSize" // UNIFORM_SIZE -}; - const unsigned int NUMBER_OF_DEFAULT_UNIFORMS = static_cast(Program::DefaultUniformIndex::COUNT); /** @@ -79,7 +64,7 @@ size_t DEFAULT_UNIFORM_HASHTABLE[NUMBER_OF_DEFAULT_UNIFORMS] = // IMPLEMENTATION -Program* Program::New(ProgramCache& cache, Internal::ShaderDataPtr shaderData, Graphics::Controller& gfxController, Graphics::UniquePtr&& gfxProgram, bool modifiesGeometry) +Program* Program::New(ProgramCache& cache, Internal::ShaderDataPtr shaderData, Graphics::Controller& gfxController, Graphics::UniquePtr&& gfxProgram) { uint32_t programId{0u}; @@ -94,61 +79,21 @@ Program* Program::New(ProgramCache& cache, Internal::ShaderDataPtr shaderData, G if(nullptr == program) { // program not found so create it - program = new Program(cache, shaderData, gfxController, std::move(gfxProgram), modifiesGeometry); + program = new Program(cache, shaderData, gfxController, std::move(gfxProgram)); cache.AddProgram(shaderHash, program); } return program; } -uint32_t Program::RegisterUniform(ConstString name) -{ - uint32_t index = 0; - // find the value from cache - for(; index < static_cast(mUniformLocations.size()); ++index) - { - if(mUniformLocations[index].first == name) - { - // name found so return index - return index; - } - } - // if we get here, index is one past end so push back the new name - mUniformLocations.push_back(std::make_pair(name, UNIFORM_NOT_QUERIED)); - return index; -} - -bool Program::ModifiesGeometry() -{ - return mModifiesGeometry; -} - -Program::Program(ProgramCache& cache, Internal::ShaderDataPtr shaderData, Graphics::Controller& controller, Graphics::UniquePtr&& gfxProgram, bool modifiesGeometry) +Program::Program(ProgramCache& cache, Internal::ShaderDataPtr shaderData, Graphics::Controller& controller, Graphics::UniquePtr&& gfxProgram) : mCache(cache), mProjectionMatrix(nullptr), mViewMatrix(nullptr), - mProgramId(0), mGfxProgram(std::move(gfxProgram)), mGfxController(controller), - mProgramData(shaderData), - mModifiesGeometry(modifiesGeometry) + mProgramData(shaderData) { - // reserve space for standard uniforms - mUniformLocations.reserve(UNIFORM_TYPE_LAST); - - // reset built in uniform names in cache - for(uint32_t i = 0; i < UNIFORM_TYPE_LAST; ++i) - { - RegisterUniform(ConstString(gStdUniforms[i])); - } - - // reset values - ResetUniformCache(); - - // Get program id and use it as hash for the cache - // in order to maintain current functionality as long as needed - mGfxController.GetProgramParameter(*mGfxProgram, 1, &mProgramId); - BuildReflection(controller.GetProgramReflection(*mGfxProgram.get())); } @@ -156,34 +101,6 @@ Program::~Program() { } -void Program::ResetUniformCache() -{ - // reset all gl uniform locations - for(uint32_t i = 0; i < mUniformLocations.size(); ++i) - { - // reset gl program locations and names - mUniformLocations[i].second = UNIFORM_NOT_QUERIED; - } - - mSamplerUniformLocations.clear(); - - // reset uniform caches - mSizeUniformCache.x = mSizeUniformCache.y = mSizeUniformCache.z = 0.f; - - for(uint32_t i = 0; i < MAX_UNIFORM_CACHE_SIZE; ++i) - { - // GL initializes uniforms to 0 - mUniformCacheInt[i] = 0; - mUniformCacheFloat[i] = 0.0f; - mUniformCacheFloat2[i][0] = 0.0f; - mUniformCacheFloat2[i][1] = 0.0f; - mUniformCacheFloat4[i][0] = 0.0f; - mUniformCacheFloat4[i][1] = 0.0f; - mUniformCacheFloat4[i][2] = 0.0f; - mUniformCacheFloat4[i][3] = 0.0f; - } -} - void Program::BuildReflection(const Graphics::Reflection& graphicsReflection) { mReflectionDefaultUniforms.clear(); diff --git a/dali/internal/render/shaders/program.h b/dali/internal/render/shaders/program.h index d606b05..9802982 100644 --- a/dali/internal/render/shaders/program.h +++ b/dali/internal/render/shaders/program.h @@ -23,7 +23,6 @@ #include // INTERNAL INCLUDES -#include #include #include #include @@ -40,12 +39,6 @@ class Reflection; class Matrix; -namespace Integration -{ -class GlAbstraction; -class ShaderData; -} // namespace Integration - namespace Internal { class ProgramCache; @@ -58,40 +51,6 @@ class Program { public: /** - * Size of the uniform cache per program - * GLES specification states that minimum uniform count for fragment shader - * is 16 and for vertex shader 128. We're caching the 16 common ones for now - */ - static const int32_t MAX_UNIFORM_CACHE_SIZE = 16; - - /** - * Constant for uniform not found - */ - static const int32_t NOT_FOUND = -1; - - /** - * Common shader uniform names - */ - enum UniformType - { - UNIFORM_NOT_QUERIED = -2, - UNIFORM_UNKNOWN = -1, - UNIFORM_MVP_MATRIX, - UNIFORM_MODELVIEW_MATRIX, - UNIFORM_PROJECTION_MATRIX, - UNIFORM_MODEL_MATRIX, - UNIFORM_VIEW_MATRIX, - UNIFORM_NORMAL_MATRIX, - UNIFORM_COLOR, - UNIFORM_SAMPLER, - UNIFORM_SAMPLER_RECT, - UNIFORM_EFFECT_SAMPLER, - - UNIFORM_SIZE, - UNIFORM_TYPE_LAST - }; - - /** * Indices of default uniforms */ enum class DefaultUniformIndex @@ -114,24 +73,11 @@ public: * @param[in] shaderData A pointer to a data structure containing the program source * and optionally precompiled binary. If the binary is empty the program bytecode * is copied into it after compilation and linking) - * param[in] gfxController Reference to valid graphics Controller object - * param[in] gfxProgram Reference to vali graphics Program object - * @param[in] modifiesGeometry True if the shader modifies geometry + * @param[in] gfxController Reference to valid graphics Controller object + * @param[in] gfxProgram Reference to valid graphics Program object * @return pointer to the program */ - static Program* New(ProgramCache& cache, Internal::ShaderDataPtr shaderData, Graphics::Controller& gfxController, Graphics::UniquePtr&& gfxProgram, bool modifiesGeometry); - - /* - * Register a uniform name in our local cache - * @param [in] name uniform name - * @return the index of the uniform name in local cache - */ - uint32_t RegisterUniform(ConstString name); - - /** - * @return true if this program modifies geometry - */ - bool ModifiesGeometry(); + static Program* New(ProgramCache& cache, Internal::ShaderDataPtr shaderData, Graphics::Controller& gfxController, Graphics::UniquePtr&& gfxProgram); /** * Set the projection matrix that has currently been sent @@ -169,11 +115,6 @@ public: return mViewMatrix; } - GLuint GetProgramId() - { - return mProgramId; - } - [[nodiscard]] Graphics::Program& GetGraphicsProgram() const { return *mGfxProgram; @@ -193,11 +134,11 @@ public: bool GetUniform(const std::string& name, size_t hashedName, Graphics::UniformInfo& out) const; /** - * Retrievs default uniform + * Retrieves default uniform * @param[in] defaultUniformIndex index of the uniform * @return Valid pointer to the UniformInfo object or nullptr */ - const Graphics::UniformInfo* GetDefaultUniform(DefaultUniformIndex defaultUniformIndex) const; + [[nodiscard]] const Graphics::UniformInfo* GetDefaultUniform(DefaultUniformIndex defaultUniformIndex) const; private: // Implementation /** @@ -206,26 +147,20 @@ private: // Implementation * @param[in] shaderData A smart pointer to a data structure containing the program source and binary * @param[in] gfxProgram Graphics Program object * @param[in] gfxController Reference to Graphics Controller object - * @param[in] modifiesGeometry True if the vertex shader changes geometry */ - Program(ProgramCache& cache, Internal::ShaderDataPtr shaderData, Graphics::Controller& gfxController, Graphics::UniquePtr&& gfxProgram, bool modifiesGeometry); + Program(ProgramCache& cache, Internal::ShaderDataPtr shaderData, Graphics::Controller& gfxController, Graphics::UniquePtr&& gfxProgram); public: + Program() = delete; ///< default constructor, not defined + Program(const Program&) = delete; ///< copy constructor, not defined + Program& operator=(const Program&) = delete; ///< assignment operator, not defined + /** * Destructor, non virtual as no virtual methods or inheritance */ ~Program(); -private: - Program(); ///< default constructor, not defined - Program(const Program&); ///< copy constructor, not defined - Program& operator=(const Program&); ///< assignment operator, not defined - - /** - * Resets uniform cache - */ - void ResetUniformCache(); - +public: /** * Struct ReflectionUniformInfo * Contains details of a single uniform buffer field and/or sampler. @@ -243,29 +178,17 @@ private: */ void BuildReflection(const Graphics::Reflection& graphicsReflection); -private: // Data - ProgramCache& mCache; ///< The program cache - const Matrix* mProjectionMatrix; ///< currently set projection matrix - const Matrix* mViewMatrix; ///< currently set view matrix - GLuint mProgramId; ///< GL identifier for program - Graphics::UniquePtr mGfxProgram; ///< Gfx program - Graphics::Controller& mGfxController; /// < Gfx controller - Internal::ShaderDataPtr mProgramData; ///< Shader program source and binary (when compiled & linked or loaded) - - // location caches - using NameLocationPair = std::pair; - using Locations = std::vector; +private: // Data + ProgramCache& mCache; ///< The program cache + const Matrix* mProjectionMatrix; ///< currently set projection matrix + const Matrix* mViewMatrix; ///< currently set view matrix - Locations mUniformLocations; ///< uniform location cache - std::vector mSamplerUniformLocations; ///< sampler uniform location cache + Graphics::UniquePtr mGfxProgram; ///< Gfx program + Graphics::Controller& mGfxController; /// < Gfx controller + Internal::ShaderDataPtr mProgramData; ///< Shader program source and binary (when compiled & linked or loaded) // 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 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 + Vector3 mSizeUniformCache; ///< Cache value for size uniform using UniformReflectionContainer = std::vector; diff --git a/dali/internal/render/shaders/scene-graph-shader.cpp b/dali/internal/render/shaders/render-shader.cpp similarity index 85% rename from dali/internal/render/shaders/scene-graph-shader.cpp rename to dali/internal/render/shaders/render-shader.cpp index add0582..51f997e 100644 --- a/dali/internal/render/shaders/scene-graph-shader.cpp +++ b/dali/internal/render/shaders/render-shader.cpp @@ -16,7 +16,7 @@ */ // CLASS HEADER -#include +#include // INTERNAL INCLUDES #include @@ -43,9 +43,6 @@ Shader::~Shader() mConnectionObservers.Destroy(*this); } -//////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// The following methods are called during RenderManager::Render() -//////////////////////////////////////////////////////////////////////////////////////////////////////////////// void Shader::SetShaderData(ShaderDataPtr shaderData) { DALI_LOG_TRACE_METHOD_FMT(Debug::Filter::gShader, "%d\n", shaderData->GetHashValue()); diff --git a/dali/internal/render/shaders/scene-graph-shader.h b/dali/internal/render/shaders/render-shader.h similarity index 69% rename from dali/internal/render/shaders/scene-graph-shader.h rename to dali/internal/render/shaders/render-shader.h index b91074b..9ddbb6a 100644 --- a/dali/internal/render/shaders/scene-graph-shader.h +++ b/dali/internal/render/shaders/render-shader.h @@ -1,5 +1,5 @@ -#ifndef DALI_INTERNAL_SCENE_GRAPH_SHADER_H -#define DALI_INTERNAL_SCENE_GRAPH_SHADER_H +#ifndef DALI_INTERNAL_RENDER_SHADER_H +#define DALI_INTERNAL_RENDER_SHADER_H /* * Copyright (c) 2021 Samsung Electronics Co., Ltd. @@ -33,7 +33,6 @@ class ProgramCache; namespace SceneGraph { -class ConnectionObserver; class SceneController; /** @@ -46,52 +45,28 @@ public: * Constructor * @param hints Shader hints */ - Shader(Dali::Shader::Hint::Value& hints); + explicit Shader(Dali::Shader::Hint::Value& hints); /** * Virtual destructor */ ~Shader() override; - //////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // The following methods are called during Update - //////////////////////////////////////////////////////////////////////////////////////////////////////////////// - /** * Query whether a shader hint is set. + * + * @warning This method is called from Update Algorithms. + * * @pre The shader has been initialized. * @param[in] hint The hint to check. * @return True if the given hint is set. */ - bool HintEnabled(Dali::Shader::Hint::Value hint) const + [[nodiscard]] bool HintEnabled(Dali::Shader::Hint::Value hint) const { return mHints & hint; } /** - * @return True if the fragment shader outputs only 1.0 on the alpha channel - * - * @note Shaders that can output any value on the alpha channel - * including 1.0 should return false for this. - */ - bool IsOutputOpaque(); - - /** - * @return True if the fragment shader can output any value but 1.0 on the alpha channel - * - * @note Shaders that can output any value on the alpha channel - * including 1.0 should return false for this - */ - bool IsOutputTransparent(); - - /** - * @copydoc Dali::Internal::SceneGraph::PropertyOwner::ResetDefaultProperties - */ - virtual void ResetDefaultProperties(BufferIndex updateBufferIndex) - { - // no default properties - } - /** * @brief Set the shader data for this shader. * @param[in] shaderData The program's vertex/fragment source and optionally pre-compiled shader binary. */ @@ -101,9 +76,9 @@ public: * Get the shader data for this shader. * @return The shader data. */ - ShaderDataPtr GetShaderData() const; + [[nodiscard]] ShaderDataPtr GetShaderData() const; -public: // Implementation of ConnectionChangePropagator +public: /** * @copydoc ConnectionChangePropagator::AddObserver */ @@ -145,4 +120,4 @@ inline void SetShaderDataMessage(EventThreadServices& eventThreadServices, const } // namespace Dali -#endif // DALI_INTERNAL_SCENE_GRAPH_SHADER_H +#endif // DALI_INTERNAL_RENDER_SHADER_H diff --git a/dali/internal/update/common/discard-queue.cpp b/dali/internal/update/common/discard-queue.cpp index 8b645ba..947253c 100644 --- a/dali/internal/update/common/discard-queue.cpp +++ b/dali/internal/update/common/discard-queue.cpp @@ -22,7 +22,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/dali/internal/update/manager/render-instruction-processor.cpp b/dali/internal/update/manager/render-instruction-processor.cpp index f3f0c53..a33b57d 100644 --- a/dali/internal/update/manager/render-instruction-processor.cpp +++ b/dali/internal/update/manager/render-instruction-processor.cpp @@ -26,7 +26,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/dali/internal/update/manager/update-manager.h b/dali/internal/update/manager/update-manager.h index a34cdb6..3b2ad2b 100644 --- a/dali/internal/update/manager/update-manager.h +++ b/dali/internal/update/manager/update-manager.h @@ -31,7 +31,7 @@ #include #include // For OwnerPointer #include -#include // for OwnerPointer< Shader > +#include // for OwnerPointer< Shader > #include #include #include diff --git a/dali/internal/update/rendering/scene-graph-renderer.cpp b/dali/internal/update/rendering/scene-graph-renderer.cpp index 1ecf4ff..d09f835 100644 --- a/dali/internal/update/rendering/scene-graph-renderer.cpp +++ b/dali/internal/update/rendering/scene-graph-renderer.cpp @@ -25,7 +25,7 @@ #include #include #include -#include +#include #include #include #include -- 2.7.4