Cleanup in Aisle #2 99/257699/1
authorDavid Steele <david.steele@samsung.com>
Thu, 29 Apr 2021 13:25:56 +0000 (14:25 +0100)
committerDavid Steele <david.steele@samsung.com>
Thu, 29 Apr 2021 13:25:56 +0000 (14:25 +0100)
Change-Id: I994feedef465bf5427009d0cfc0659816c7d1000

18 files changed:
dali/internal/file.list
dali/internal/render/renderers/gpu-buffer.cpp
dali/internal/render/renderers/gpu-buffer.h
dali/internal/render/renderers/render-renderer.cpp
dali/internal/render/renderers/render-renderer.h
dali/internal/render/shaders/program-cache.h
dali/internal/render/shaders/program-controller.cpp
dali/internal/render/shaders/program-controller.h
dali/internal/render/shaders/program.cpp
dali/internal/render/shaders/program.h
dali/internal/render/shaders/render-shader.cpp [new file with mode: 0644]
dali/internal/render/shaders/render-shader.h [new file with mode: 0644]
dali/internal/render/shaders/scene-graph-shader.cpp [deleted file]
dali/internal/render/shaders/scene-graph-shader.h [deleted file]
dali/internal/update/common/discard-queue.cpp
dali/internal/update/manager/render-instruction-processor.cpp
dali/internal/update/manager/update-manager.h
dali/internal/update/rendering/scene-graph-renderer.cpp

index d46c512dab242cc6acedeaae6ae8a3b93e74e3c5..7f4afe7e76aa8cdf3d8dd7b9dadd84623921b2cc 100644 (file)
@@ -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
index 7e7aeba00fb869d24ed242381f26fe0ee6988f1e..0d2003aacb3c4170804a02690a6cf7d18c24d518 100644 (file)
@@ -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;
index 70a4aea7e8e63c9837a593589557dae3e09c50b4..42b2a75fdc7b2ae621d8f369b002974121a199e1 100644 (file)
@@ -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;
 
   /**
    *
@@ -59,27 +59,22 @@ 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<Graphics::Buffer> 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
index 9ce65ce0718c2211ddb7170b4f07269b06b3559d..22847b9e5f78fbc7ac1f88ddc4cef857727e9f14 100644 (file)
@@ -31,7 +31,7 @@
 #include <dali/internal/render/renderers/render-vertex-buffer.h>
 #include <dali/internal/render/renderers/shader-cache.h>
 #include <dali/internal/render/shaders/program.h>
-#include <dali/internal/render/shaders/scene-graph-shader.h>
+#include <dali/internal/render/shaders/render-shader.h>
 #include <dali/internal/update/common/uniform-map.h>
 
 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<uint32_t>(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<uint32_t>(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;
index 285c4b6437bdce1a9742d4a2249ed3162bff3294..6cd24598b4746c31be4c89e59c2e8620f1b5f532 100644 (file)
@@ -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<UniformIndexMap>;
index 2ebf63c91a52e818d36b0387d4aae8ded982c37a..00d4d5c113df9efd55a259ebdce4b2940cf621ea 100644 (file)
@@ -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
index 2d638ccb6294fe4f3aeefc738a29461a5f8634a1..f01f6d4d20a52dc80655df8d249d475ebf9634cf 100644 (file)
@@ -110,11 +110,6 @@ void ProgramController::SetShaderSaver(ShaderSaver& shaderSaver)
   mShaderSaver = &shaderSaver;
 }
 
-void ProgramController::ClearCurrentProgram()
-{
-  SetCurrentProgram(nullptr);
-}
-
 } // namespace Internal
 
 } // namespace Dali
index 1f4a434bf044a4ffb5cd018d7dd5649c41f414e7..bac710211f9c44cb6c7487354dfdb481b016a0a5 100644 (file)
@@ -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;
index 1c8baccb604749fcff41d83c5447f3b9c1ace534..28c5d34603fc90fe3afe63c216b4fae7efc43503 100644 (file)
@@ -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<unsigned int>(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<Graphics::Program>&& gfxProgram, bool modifiesGeometry)
+Program* Program::New(ProgramCache& cache, Internal::ShaderDataPtr shaderData, Graphics::Controller& gfxController, Graphics::UniquePtr<Graphics::Program>&& 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<uint32_t>(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<Graphics::Program>&& gfxProgram, bool modifiesGeometry)
+Program::Program(ProgramCache& cache, Internal::ShaderDataPtr shaderData, Graphics::Controller& controller, Graphics::UniquePtr<Graphics::Program>&& 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();
index d606b05a56a945a42b5230f55544b4f4d2a6cd8c..980298272962324e87ddd7652bb06b77c9b1a6fb 100644 (file)
@@ -23,7 +23,6 @@
 #include <string>
 
 // INTERNAL INCLUDES
-#include <dali/integration-api/gl-abstraction.h>
 #include <dali/internal/common/const-string.h>
 #include <dali/internal/common/shader-data.h>
 #include <dali/public-api/common/vector-wrapper.h>
@@ -40,12 +39,6 @@ class Reflection;
 
 class Matrix;
 
-namespace Integration
-{
-class GlAbstraction;
-class ShaderData;
-} // namespace Integration
-
 namespace Internal
 {
 class ProgramCache;
@@ -57,40 +50,6 @@ class ProgramCache;
 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
    */
@@ -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<Graphics::Program>&& 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<Graphics::Program>&& 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<Graphics::Program>&& gfxProgram, bool modifiesGeometry);
+  Program(ProgramCache& cache, Internal::ShaderDataPtr shaderData, Graphics::Controller& gfxController, Graphics::UniquePtr<Graphics::Program>&& 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<Graphics::Program> 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<ConstString, GLint>;
-  using Locations        = std::vector<NameLocationPair>;
+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<GLint> mSamplerUniformLocations; ///< sampler uniform location cache
+  Graphics::UniquePtr<Graphics::Program> 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<ReflectionUniformInfo>;
 
diff --git a/dali/internal/render/shaders/render-shader.cpp b/dali/internal/render/shaders/render-shader.cpp
new file mode 100644 (file)
index 0000000..51f997e
--- /dev/null
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2021 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 <dali/internal/render/shaders/render-shader.h>
+
+// INTERNAL INCLUDES
+#include <dali/integration-api/debug.h>
+#include <dali/internal/common/image-sampler.h>
+#include <dali/internal/render/common/render-debug.h>
+#include <dali/internal/render/queue/render-queue.h>
+#include <dali/internal/render/shaders/program.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace SceneGraph
+{
+Shader::Shader(Dali::Shader::Hint::Value& hints)
+: mHints(hints),
+  mConnectionObservers()
+{
+  AddUniformMapObserver(*this);
+}
+
+Shader::~Shader()
+{
+  mConnectionObservers.Destroy(*this);
+}
+
+void Shader::SetShaderData(ShaderDataPtr shaderData)
+{
+  DALI_LOG_TRACE_METHOD_FMT(Debug::Filter::gShader, "%d\n", shaderData->GetHashValue());
+
+  mShaderData = shaderData;
+
+  mConnectionObservers.ConnectionsChanged(*this);
+}
+
+ShaderDataPtr Shader::GetShaderData() const
+{
+  return mShaderData;
+}
+
+void Shader::AddConnectionObserver(ConnectionChangePropagator::Observer& observer)
+{
+  mConnectionObservers.Add(observer);
+}
+
+void Shader::RemoveConnectionObserver(ConnectionChangePropagator::Observer& observer)
+{
+  mConnectionObservers.Remove(observer);
+}
+
+void Shader::UniformMappingsChanged(const UniformMap& mappings)
+{
+  // Our uniform map, or that of one of the watched children has changed.
+  // Inform connected observers.
+  mConnectionObservers.ConnectedUniformMapChanged();
+}
+
+} // namespace SceneGraph
+
+} // namespace Internal
+
+} // namespace Dali
diff --git a/dali/internal/render/shaders/render-shader.h b/dali/internal/render/shaders/render-shader.h
new file mode 100644 (file)
index 0000000..9ddbb6a
--- /dev/null
@@ -0,0 +1,123 @@
+#ifndef DALI_INTERNAL_RENDER_SHADER_H
+#define DALI_INTERNAL_RENDER_SHADER_H
+
+/*
+ * Copyright (c) 2021 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.
+ *
+ */
+
+// INTERNAL INCLUDES
+#include <dali/internal/common/shader-data.h>
+#include <dali/internal/event/common/event-thread-services.h>
+#include <dali/internal/update/common/property-owner.h>
+#include <dali/internal/update/common/scene-graph-connection-change-propagator.h>
+
+namespace Dali
+{
+namespace Internal
+{
+class Program;
+class ProgramCache;
+
+namespace SceneGraph
+{
+class SceneController;
+
+/**
+ * A holder class for Program; also enables sharing of uniform properties
+ */
+class Shader : public PropertyOwner, public UniformMap::Observer
+{
+public:
+  /**
+   * Constructor
+   * @param hints Shader hints
+   */
+  explicit Shader(Dali::Shader::Hint::Value& hints);
+
+  /**
+   * Virtual destructor
+   */
+  ~Shader() override;
+
+  /**
+   * 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.
+   */
+  [[nodiscard]] bool HintEnabled(Dali::Shader::Hint::Value hint) const
+  {
+    return mHints & hint;
+  }
+
+  /**
+   * @brief Set the shader data for this shader.
+   * @param[in] shaderData The program's vertex/fragment source and optionally pre-compiled shader binary.
+   */
+  void SetShaderData(ShaderDataPtr shaderData);
+
+  /**
+   * Get the shader data for this shader.
+   * @return The shader data.
+   */
+  [[nodiscard]] ShaderDataPtr GetShaderData() const;
+
+public:
+  /**
+   * @copydoc ConnectionChangePropagator::AddObserver
+   */
+  void AddConnectionObserver(ConnectionChangePropagator::Observer& observer);
+
+  /**
+   * @copydoc ConnectionChangePropagator::RemoveObserver
+   */
+  void RemoveConnectionObserver(ConnectionChangePropagator::Observer& observer);
+
+public: // UniformMap::Observer
+  /**
+   * @copydoc UniformMap::Observer::UniformMappingsChanged
+   */
+  void UniformMappingsChanged(const UniformMap& mappings) override;
+
+private: // Data
+  Dali::Shader::Hint::Value mHints;
+
+  ShaderDataPtr mShaderData;
+
+  ConnectionChangePropagator mConnectionObservers;
+};
+
+inline void SetShaderDataMessage(EventThreadServices& eventThreadServices, const Shader& shader, ShaderDataPtr shaderData)
+{
+  using LocalType = MessageValue1<Shader, ShaderDataPtr>;
+
+  // Reserve some memory inside the message queue
+  uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
+
+  // Construct message in the message queue memory; note that delete should not be called on the return value
+  new(slot) LocalType(&shader, &Shader::SetShaderData, shaderData);
+}
+
+} // namespace SceneGraph
+
+} // namespace Internal
+
+} // namespace Dali
+
+#endif // DALI_INTERNAL_RENDER_SHADER_H
diff --git a/dali/internal/render/shaders/scene-graph-shader.cpp b/dali/internal/render/shaders/scene-graph-shader.cpp
deleted file mode 100644 (file)
index add0582..0000000
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Copyright (c) 2021 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 <dali/internal/render/shaders/scene-graph-shader.h>
-
-// INTERNAL INCLUDES
-#include <dali/integration-api/debug.h>
-#include <dali/internal/common/image-sampler.h>
-#include <dali/internal/render/common/render-debug.h>
-#include <dali/internal/render/queue/render-queue.h>
-#include <dali/internal/render/shaders/program.h>
-
-namespace Dali
-{
-namespace Internal
-{
-namespace SceneGraph
-{
-Shader::Shader(Dali::Shader::Hint::Value& hints)
-: mHints(hints),
-  mConnectionObservers()
-{
-  AddUniformMapObserver(*this);
-}
-
-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());
-
-  mShaderData = shaderData;
-
-  mConnectionObservers.ConnectionsChanged(*this);
-}
-
-ShaderDataPtr Shader::GetShaderData() const
-{
-  return mShaderData;
-}
-
-void Shader::AddConnectionObserver(ConnectionChangePropagator::Observer& observer)
-{
-  mConnectionObservers.Add(observer);
-}
-
-void Shader::RemoveConnectionObserver(ConnectionChangePropagator::Observer& observer)
-{
-  mConnectionObservers.Remove(observer);
-}
-
-void Shader::UniformMappingsChanged(const UniformMap& mappings)
-{
-  // Our uniform map, or that of one of the watched children has changed.
-  // Inform connected observers.
-  mConnectionObservers.ConnectedUniformMapChanged();
-}
-
-} // namespace SceneGraph
-
-} // namespace Internal
-
-} // namespace Dali
diff --git a/dali/internal/render/shaders/scene-graph-shader.h b/dali/internal/render/shaders/scene-graph-shader.h
deleted file mode 100644 (file)
index b91074b..0000000
+++ /dev/null
@@ -1,148 +0,0 @@
-#ifndef DALI_INTERNAL_SCENE_GRAPH_SHADER_H
-#define DALI_INTERNAL_SCENE_GRAPH_SHADER_H
-
-/*
- * Copyright (c) 2021 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.
- *
- */
-
-// INTERNAL INCLUDES
-#include <dali/internal/common/shader-data.h>
-#include <dali/internal/event/common/event-thread-services.h>
-#include <dali/internal/update/common/property-owner.h>
-#include <dali/internal/update/common/scene-graph-connection-change-propagator.h>
-
-namespace Dali
-{
-namespace Internal
-{
-class Program;
-class ProgramCache;
-
-namespace SceneGraph
-{
-class ConnectionObserver;
-class SceneController;
-
-/**
- * A holder class for Program; also enables sharing of uniform properties
- */
-class Shader : public PropertyOwner, public UniformMap::Observer
-{
-public:
-  /**
-   * Constructor
-   * @param hints Shader hints
-   */
-  Shader(Dali::Shader::Hint::Value& hints);
-
-  /**
-   * Virtual destructor
-   */
-  ~Shader() override;
-
-  ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-  // The following methods are called during Update
-  ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-
-  /**
-   * Query whether a shader hint is set.
-   * @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
-  {
-    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.
-   */
-  void SetShaderData(ShaderDataPtr shaderData);
-
-  /**
-   * Get the shader data for this shader.
-   * @return The shader data.
-   */
-  ShaderDataPtr GetShaderData() const;
-
-public: // Implementation of ConnectionChangePropagator
-  /**
-   * @copydoc ConnectionChangePropagator::AddObserver
-   */
-  void AddConnectionObserver(ConnectionChangePropagator::Observer& observer);
-
-  /**
-   * @copydoc ConnectionChangePropagator::RemoveObserver
-   */
-  void RemoveConnectionObserver(ConnectionChangePropagator::Observer& observer);
-
-public: // UniformMap::Observer
-  /**
-   * @copydoc UniformMap::Observer::UniformMappingsChanged
-   */
-  void UniformMappingsChanged(const UniformMap& mappings) override;
-
-private: // Data
-  Dali::Shader::Hint::Value mHints;
-
-  ShaderDataPtr mShaderData;
-
-  ConnectionChangePropagator mConnectionObservers;
-};
-
-inline void SetShaderDataMessage(EventThreadServices& eventThreadServices, const Shader& shader, ShaderDataPtr shaderData)
-{
-  using LocalType = MessageValue1<Shader, ShaderDataPtr>;
-
-  // Reserve some memory inside the message queue
-  uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
-
-  // Construct message in the message queue memory; note that delete should not be called on the return value
-  new(slot) LocalType(&shader, &Shader::SetShaderData, shaderData);
-}
-
-} // namespace SceneGraph
-
-} // namespace Internal
-
-} // namespace Dali
-
-#endif // DALI_INTERNAL_SCENE_GRAPH_SHADER_H
index 8b645ba5287f024f7d3d0eea1035424ce725871a..947253cb10931371719ab002045fdb803e97b679 100644 (file)
@@ -22,7 +22,7 @@
 #include <dali/internal/common/message.h>
 #include <dali/internal/render/queue/render-queue.h>
 #include <dali/internal/render/renderers/render-renderer.h>
-#include <dali/internal/render/shaders/scene-graph-shader.h>
+#include <dali/internal/render/shaders/render-shader.h>
 #include <dali/internal/update/common/scene-graph-scene.h>
 #include <dali/internal/update/nodes/node.h>
 #include <dali/internal/update/render-tasks/scene-graph-camera.h>
index f3f0c5305614e257119c728d5c7b9f284be90035..a33b57d7e46455ba9d5a30715e4a967bdaa5bdcd 100644 (file)
@@ -26,7 +26,7 @@
 #include <dali/internal/render/common/render-item.h>
 #include <dali/internal/render/common/render-tracker.h>
 #include <dali/internal/render/renderers/render-renderer.h>
-#include <dali/internal/render/shaders/scene-graph-shader.h>
+#include <dali/internal/render/shaders/render-shader.h>
 #include <dali/internal/update/manager/sorted-layers.h>
 #include <dali/internal/update/nodes/scene-graph-layer.h>
 #include <dali/internal/update/render-tasks/scene-graph-render-task.h>
index a34cdb6848889821c0c27ed9dc8d0a21dcfbaf7f..3b2ad2bc797124f8cc00575583f44345688728e9 100644 (file)
@@ -31,7 +31,7 @@
 #include <dali/internal/event/rendering/texture-impl.h>
 #include <dali/internal/render/renderers/render-texture.h> // For OwnerPointer<Render::Texture>
 #include <dali/internal/render/renderers/render-vertex-buffer.h>
-#include <dali/internal/render/shaders/scene-graph-shader.h> // for OwnerPointer< Shader >
+#include <dali/internal/render/shaders/render-shader.h> // for OwnerPointer< Shader >
 #include <dali/internal/update/animation/scene-graph-animation.h>
 #include <dali/internal/update/common/property-resetter.h>
 #include <dali/internal/update/common/scene-graph-buffers.h>
index 1ecf4ff06c85d4670a8ce20c0f4cc2ca0c00ee4a..d09f8351eddc68918c11a0eddb8922da89e7f5d8 100644 (file)
@@ -25,7 +25,7 @@
 #include <dali/internal/render/queue/render-queue.h>
 #include <dali/internal/render/renderers/render-geometry.h>
 #include <dali/internal/render/shaders/program.h>
-#include <dali/internal/render/shaders/scene-graph-shader.h>
+#include <dali/internal/render/shaders/render-shader.h>
 #include <dali/internal/update/controllers/render-message-dispatcher.h>
 #include <dali/internal/update/controllers/scene-controller.h>
 #include <dali/internal/update/nodes/node.h>