${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
} // namespace
GpuBuffer::GpuBuffer(Graphics::Controller& graphicsController, Graphics::BufferUsageFlags usage)
-: mUsage(usage),
- mBufferCreated(false)
-{
-}
-
-GpuBuffer::~GpuBuffer()
+: mUsage(usage)
{
}
mCapacity = size;
}
- Graphics::MapBufferInfo info;
+ Graphics::MapBufferInfo info{};
info.buffer = mGraphicsObject.get();
info.usage = 0 | Graphics::MemoryUsageFlagBits::WRITE;
info.offset = 0;
graphicsController.UnmapMemory(std::move(memory));
}
-bool GpuBuffer::BufferIsValid() const
-{
- return mGraphicsObject && (0 != mCapacity);
-}
-
void GpuBuffer::Destroy()
{
mCapacity = 0;
-#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.
/**
* Destructor, non virtual as no virtual methods or inheritance
*/
- ~GpuBuffer();
+ ~GpuBuffer() = default;
/**
*
*/
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();
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
#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
Program* program = Program::New(*mProgramCache,
shaderData,
*mGraphicsController,
- std::move(graphicsProgram),
- (shaderData->GetHints() & Dali::Shader::Hint::MODIFIES_GEOMETRY) != 0x0);
+ std::move(graphicsProgram));
if(!program)
{
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;
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;
{
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;
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>;
*/
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
mShaderSaver = &shaderSaver;
}
-void ProgramController::ClearCurrentProgram()
-{
- SetCurrentProgram(nullptr);
-}
-
} // namespace Internal
} // namespace Dali
* 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;
* 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
*/
void SetShaderSaver(ShaderSaver& shaderSaver);
- /**
- * Clear current cached program
- */
- void ClearCurrentProgram();
-
private: // From ProgramCache
/**
* @copydoc ProgramCache::GetProgram
*/
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;
// 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);
/**
// 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};
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()));
}
{
}
-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();
#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>
class Matrix;
-namespace Integration
-{
-class GlAbstraction;
-class ShaderData;
-} // namespace Integration
-
namespace Internal
{
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
*/
* @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
return mViewMatrix;
}
- GLuint GetProgramId()
- {
- return mProgramId;
- }
-
[[nodiscard]] Graphics::Program& GetGraphicsProgram() const
{
return *mGfxProgram;
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
/**
* @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.
*/
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>;
--- /dev/null
+/*
+ * 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
--- /dev/null
+#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
+++ /dev/null
-/*
- * 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
+++ /dev/null
-#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
#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>
#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>
#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>
#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>