// The scissor test is enabled if we have any children on the stack, OR, if there are none but it is a user specified layer scissor box.
// IE. It is not enabled if we are at the top of the stack and the layer does not have a specified clipping box.
- const bool scissorEnabled = (mScissorStack.size() > 0u) || mHasLayerScissor;
+ const bool scissorEnabled = (!mScissorStack.empty()) || mHasLayerScissor;
// Enable the scissor test based on the above calculation
if(scissorEnabled)
}
}
}
- if(buffers.size() > 0)
+ if(!buffers.empty())
{
mGraphicsCommandBuffer->ExecuteCommandBuffers(std::move(buffers));
}
*
* @param[in] graphicsController The graphics controller
*/
- RenderAlgorithms(Graphics::Controller& graphicsController);
+ explicit RenderAlgorithms(Graphics::Controller& graphicsController);
+ RenderAlgorithms(RenderAlgorithms& rhs) = delete; // Prevent copying
+
+ RenderAlgorithms& operator=(const RenderAlgorithms& rhs) = delete; // Prevent Copying
/**
* Process a render-instruction.
* @param[in] instruction The render-instruction to process.
const Rect<int>& rootClippingRect,
int orientation);
- // Prevent copying:
- RenderAlgorithms(RenderAlgorithms& rhs);
- RenderAlgorithms& operator=(const RenderAlgorithms& rhs);
-
// Member variables:
using ScissorStackType = std::vector<Dali::ClippingBox>; ///< The container type used to maintain the applied scissor hierarchy
mInstructions.push_back(renderInstruction);
}
-void RenderInstructionContainer::DiscardCurrentInstruction(BufferIndex updateBufferIndex)
-{
- mInstructions.pop_back();
-}
-
} // namespace SceneGraph
} // namespace Internal
*/
void PushBack(BufferIndex index, RenderInstruction* renderInstruction);
- /**
- * Discard an instruction from the end of the container
- * @param bufferIndex to use
- */
- void DiscardCurrentInstruction(BufferIndex updateBufferIndex);
-
private:
std::vector<RenderInstruction*> mInstructions;
};
mRenderLists.Reserve(6);
}
-RenderInstruction::~RenderInstruction()
-{ // pointer container releases the renderlists
-}
+RenderInstruction::~RenderInstruction() = default;
RenderList& RenderInstruction::GetNextFreeRenderList(size_t capacityRequired)
{
*/
~RenderInstruction();
+ RenderInstruction(const RenderInstruction&) = delete;
+
+ RenderInstruction& operator=(const RenderInstruction& rhs) = delete;
+
/**
* Get the next free Renderlist
* @param capacityRequired in this list
/**
* @return the count of active Renderlists
*/
- RenderListContainer::SizeType RenderListCount() const;
+ [[nodiscard]] RenderListContainer::SizeType RenderListCount() const;
/**
* Return the renderlist at given index
* @param index of list to return
* @return pointer to the renderlist, or null if the index is out of bounds.
*/
- const RenderList* GetRenderList(RenderListContainer::SizeType index) const;
+ [[nodiscard]] const RenderList* GetRenderList(RenderListContainer::SizeType index) const;
/**
* Reset render-instruction
* @param index of the rendering side
* @return the view matrix
*/
- const Matrix* GetViewMatrix(BufferIndex index) const
+ [[nodiscard]] const Matrix* GetViewMatrix(BufferIndex index) const
{
// inlined as this is called once per frame per render instruction
return &mCamera->GetViewMatrix(index);
* @param index of the rendering side
* @return the projection matrix
*/
- const Matrix* GetProjectionMatrix(BufferIndex index) const
+ [[nodiscard]] const Matrix* GetProjectionMatrix(BufferIndex index) const
{
// inlined as this is called once per frame per render instruction
return &mCamera->GetFinalProjectionMatrix(index);
}
// for reflection effect
- const Camera* GetCamera() const
+ [[nodiscard]] const Camera* GetCamera() const
{
return mCamera;
}
-private:
- // Undefined
- RenderInstruction(const RenderInstruction&);
- // Undefined
- RenderInstruction& operator=(const RenderInstruction& rhs);
-
public: // Data
Render::RenderTracker* mRenderTracker; ///< Pointer to an optional tracker object (not owned)
delete mClippingBox;
}
+ /*
+ * Copy constructor and assignment operator not defined
+ */
+ RenderList(const RenderList& rhs) = delete;
+ const RenderList& operator=(const RenderList& rhs) = delete;
+
/**
* Reset the render list for next frame
*/
{
delete mClippingBox;
mClippingBox = new ClippingBox(box);
- ;
}
}
}
private:
- /*
- * Copy constructor and assignment operator not defined
- */
- RenderList(const RenderList& rhs);
- const RenderList& operator=(const RenderList& rhs);
-
RenderItemContainer mItems; ///< Each item is a renderer and matrix pair
uint32_t mNextFree; ///< index for the next free item to use
void AddRenderTracker(Render::RenderTracker* renderTracker)
{
- DALI_ASSERT_DEBUG(renderTracker != NULL);
+ DALI_ASSERT_DEBUG(renderTracker != nullptr);
mRenderTrackers.PushBack(renderTracker);
}
Integration::StencilBufferAvailable stencilBufferAvailable,
Integration::PartialUpdateAvailable partialUpdateAvailable)
{
- RenderManager* manager = new RenderManager;
- manager->mImpl = new Impl(graphicsController,
+ auto* manager = new RenderManager;
+ manager->mImpl = new Impl(graphicsController,
depthBufferAvailable,
stencilBufferAvailable,
partialUpdateAvailable);
void RenderManager::SetShaderSaver(ShaderSaver& upstream)
{
- mImpl->programController.SetShaderSaver(upstream);
}
void RenderManager::AddRenderer(OwnerPointer<Render::Renderer>& renderer)
void RenderManager::RemoveFrameBuffer(Render::FrameBuffer* frameBuffer)
{
- DALI_ASSERT_DEBUG(NULL != frameBuffer);
+ DALI_ASSERT_DEBUG(nullptr != frameBuffer);
// Find the sampler, use reference so we can safely do the erase
for(auto&& iter : mImpl->frameBufferContainer)
void RenderManager::AttachVertexBuffer(Render::Geometry* geometry, Render::VertexBuffer* vertexBuffer)
{
- DALI_ASSERT_DEBUG(NULL != geometry);
+ DALI_ASSERT_DEBUG(nullptr != geometry);
// Find the geometry
for(auto&& iter : mImpl->geometryContainer)
void RenderManager::RemoveVertexBuffer(Render::Geometry* geometry, Render::VertexBuffer* vertexBuffer)
{
- DALI_ASSERT_DEBUG(NULL != geometry);
+ DALI_ASSERT_DEBUG(nullptr != geometry);
// Find the geometry
for(auto&& iter : mImpl->geometryContainer)
mImpl->RemoveRenderTracker(renderTracker);
}
-ProgramCache* RenderManager::GetProgramCache()
-{
- return &(mImpl->programController);
-}
-
void RenderManager::PreRender(Integration::RenderStatus& status, bool forceClear, bool uploadOnly)
{
DALI_PRINT_RENDER_START(mImpl->renderBufferIndex);
mImpl->renderQueue.ProcessMessages(mImpl->renderBufferIndex);
uint32_t count = 0u;
- for(uint32_t i = 0; i < mImpl->sceneContainer.size(); ++i)
+ for(auto& i : mImpl->sceneContainer)
{
- count += mImpl->sceneContainer[i]->GetRenderInstructions().Count(mImpl->renderBufferIndex);
+ count += i->GetRenderInstructions().Count(mImpl->renderBufferIndex);
}
const bool haveInstructions = count > 0u;
DALI_LOG_INFO(gLogFilter, Debug::General, "Render: Processing\n");
// Upload the geometries
- for(uint32_t i = 0; i < mImpl->sceneContainer.size(); ++i)
+ for(auto& i : mImpl->sceneContainer)
{
- RenderInstructionContainer& instructions = mImpl->sceneContainer[i]->GetRenderInstructions();
+ RenderInstructionContainer& instructions = i->GetRenderInstructions();
for(uint32_t j = 0; j < instructions.Count(mImpl->renderBufferIndex); ++j)
{
RenderInstruction& instruction = instructions.At(mImpl->renderBufferIndex, j);
class DamagedRectsCleaner
{
public:
- DamagedRectsCleaner(std::vector<Rect<int>>& damagedRects)
+ explicit DamagedRectsCleaner(std::vector<Rect<int>>& damagedRects)
: mDamagedRects(damagedRects),
mCleanOnReturn(true)
{
dirtyRect.visited = false;
}
- uint32_t count = sceneObject->GetRenderInstructions().Count(mImpl->renderBufferIndex);
- for(uint32_t i = 0; i < count; ++i)
+ uint32_t instructionCount = sceneObject->GetRenderInstructions().Count(mImpl->renderBufferIndex);
+ for(uint32_t i = 0; i < instructionCount; ++i)
{
RenderInstruction& instruction = sceneObject->GetRenderInstructions().At(mImpl->renderBufferIndex, i);
const RenderList* renderList = instruction.GetRenderList(index);
if(renderList && !renderList->IsEmpty())
{
- const std::size_t count = renderList->Count();
- for(uint32_t index = 0u; index < count; ++index)
+ const std::size_t listCount = renderList->Count();
+ for(uint32_t listIndex = 0u; listIndex < listCount; ++listIndex)
{
- RenderItem& item = renderList->GetItem(index);
+ RenderItem& item = renderList->GetItem(listIndex);
// If the item does 3D transformation, do early exit and clean the damaged rect array
if(item.mUpdateSize == Vector3::ZERO)
{
status.SetNeedsPostRender(true);
Rect<int32_t> viewportRect;
- Vector4 clearColor;
-
- if(instruction.mIsClearColorSet)
- {
- clearColor = instruction.mClearColor;
- }
- else
- {
- clearColor = Dali::RenderTask::DEFAULT_CLEAR_COLOR;
- }
Rect<int32_t> surfaceRect = sceneObject->GetSurfaceRect();
int32_t surfaceOrientation = sceneObject->GetSurfaceOrientation();
if(instruction.mFrameBuffer)
{
- // Ensure graphics framebuffer is created, bind atachments and create render passes
+ // Ensure graphics framebuffer is created, bind attachments and create render passes
// Only happens once per framebuffer. If the create fails, e.g. no attachments yet,
// then don't render to this framebuffer.
if(!instruction.mFrameBuffer->GetGraphicsObject())
auto& clearValues = instruction.mFrameBuffer->GetGraphicsRenderPassClearValues();
// Set the clear color for first color attachment
- if(instruction.mIsClearColorSet && clearValues.size() > 0)
+ if(instruction.mIsClearColorSet && !clearValues.empty())
{
clearValues[0].color = {
instruction.mClearColor.r,
// was: mImpl->currentContext->SetSurfaceOrientation(surfaceOrientation);
/*** Clear region of framebuffer or surface before drawing ***/
-
- bool clearFullFrameRect = true;
+ bool clearFullFrameRect = (surfaceRect == viewportRect);
if(instruction.mFrameBuffer != nullptr)
{
Viewport frameRect(0, 0, instruction.mFrameBuffer->GetWidth(), instruction.mFrameBuffer->GetHeight());
clearFullFrameRect = (frameRect == viewportRect);
}
- else
- {
- clearFullFrameRect = (surfaceRect == viewportRect);
- }
if(!clippingRect.IsEmpty())
{
mImpl->UpdateTrackers();
uint32_t count = 0u;
- for(uint32_t i = 0; i < mImpl->sceneContainer.size(); ++i)
+ for(auto& scene : mImpl->sceneContainer)
{
- count += mImpl->sceneContainer[i]->GetRenderInstructions().Count(mImpl->renderBufferIndex);
+ count += scene->GetRenderInstructions().Count(mImpl->renderBufferIndex);
}
const bool haveInstructions = count > 0u;
*/
void RemoveRenderTracker(Render::RenderTracker* renderTracker);
- /**
- * returns the Program controller for sending program messages
- * @return the ProgramController
- */
- ProgramCache* GetProgramCache();
-
// This method should be called from Core::PreRender()
/**
* The RendererAttachment that creates this object will initialize the members
* directly.
*/
- RenderDataProvider(AnimatableProperty<float>& opacity);
+ explicit RenderDataProvider(AnimatableProperty<float>& opacity);
/**
* Destructor
/**
* Get the uniform map data provider
*/
- const UniformMapDataProvider& GetUniformMap() const;
+ [[nodiscard]] const UniformMapDataProvider& GetUniformMap() const;
/**
* Set the shader data provider
* Returns the shader
* @return The shader
*/
- Shader& GetShader() const;
+ [[nodiscard]] Shader& GetShader() const;
/**
* Returns the list of samplers
* @param[in] bufferIndex The buffer index
* @return true if the uniform map has changed
*/
- virtual bool GetUniformMapChanged(BufferIndex bufferIndex) const = 0;
+ [[nodiscard]] virtual bool GetUniformMapChanged(BufferIndex bufferIndex) const = 0;
/**
* Get the complete map of uniforms to property value addresses
* @param[in] bufferIndex The bufferIndex
* @return the uniform map
*/
- virtual const CollectedUniformMap& GetUniformMap(BufferIndex bufferIndex) const = 0;
+ [[nodiscard]] virtual const CollectedUniformMap& GetUniformMap(BufferIndex bufferIndex) const = 0;
protected:
/**
{
MessageBase* message = reinterpret_cast<MessageBase*>(iter.Get());
- // Call virtual destructor explictly; since delete will not be called after placement new
+ // Call virtual destructor explicitly; since delete will not be called after placement new
message->~MessageBase();
}
{
MessageBase* message = reinterpret_cast<MessageBase*>(iter.Get());
- // Call virtual destructor explictly; since delete will not be called after placement new
+ // Call virtual destructor explicitly; since delete will not be called after placement new
message->~MessageBase();
}
uint32_t elementBufferCount)
{
//Bind buffers to attribute locations
- const uint32_t vertexBufferCount = static_cast<uint32_t>(mVertexBuffers.Count());
+ const auto vertexBufferCount = static_cast<uint32_t>(mVertexBuffers.Count());
std::vector<const Graphics::Buffer*> buffers;
std::vector<uint32_t> offsets;
}
//@todo Figure out why this is being drawn without geometry having been uploaded
}
- if(buffers.size() == 0)
+ if(buffers.empty())
{
return false;
}
}
else
{
- //Unindex draw call
+ // Un-indexed draw call
GLsizei numVertices(0u);
if(vertexBufferCount > 0)
{
* Get the vertex buffers
* @return the list of vertex buffers
*/
- const Vector<Render::VertexBuffer*>& GetVertexBuffers() const;
+ [[nodiscard]] const Vector<Render::VertexBuffer*>& GetVertexBuffers() const;
/**
* Called from RenderManager to notify the geometry that current rendering pass has finished.
* Check if the attributes for the geometry have changed
* @return True if vertex buffers have been added or removed since last frame, false otherwise
*/
- bool AttributesChanged() const
+ [[nodiscard]] bool AttributesChanged() const
{
return mAttributesChanged;
}
/**
* @return the topology of this geometry
*/
- Graphics::PrimitiveTopology GetTopology() const;
+ [[nodiscard]] Graphics::PrimitiveTopology GetTopology() const;
/**
* Upload the geometry if it has changed
break;
}
case Property::MATRIX3:
- {
- type = Dali::Graphics::VertexInputFormat::FLOAT;
- break;
- }
case Property::MATRIX:
{
type = Dali::Graphics::VertexInputFormat::FLOAT;
mDepthWriteMode(depthWriteMode),
mDepthTestMode(depthTestMode),
mUpdateAttributeLocations(true),
- mPremultipledAlphaEnabled(preMultipliedAlphaEnabled),
+ mPremultipliedAlphaEnabled(preMultipliedAlphaEnabled),
mShaderChanged(false),
mUpdated(true)
{
}
}
- if(textureBindings.size() > 0)
+ if(!textureBindings.empty())
{
commandBuffer.BindTextures(textureBindings);
}
void Renderer::EnablePreMultipliedAlpha(bool enable)
{
- mPremultipledAlphaEnabled = enable;
- mUpdated = true;
+ mPremultipliedAlphaEnabled = enable;
+ mUpdated = true;
}
void Renderer::SetDepthWriteMode(DepthWriteMode::Type depthWriteMode)
// Set blending mode
if(!mDrawCommands.empty())
{
- blend = (commands[0]->queue == DevelRenderer::RENDER_QUEUE_OPAQUE ? false : blend);
+ blend = (commands[0]->queue != DevelRenderer::RENDER_QUEUE_OPAQUE) && blend;
}
// Create Program
Vector4 finalColor;
const Vector4& color = node.GetRenderColor(bufferIndex);
- if(mPremultipledAlphaEnabled)
+ if(mPremultipliedAlphaEnabled)
{
float alpha = color.a * mRenderDataProvider->GetOpacity(bufferIndex);
finalColor = Vector4(color.r * alpha, color.g * alpha, color.b * alpha, alpha);
offset = dataOffset;
}
-void Renderer::SetSortAttributes(BufferIndex bufferIndex,
- SceneGraph::RenderInstructionProcessor::SortAttributes& sortAttributes) const
+void Renderer::SetSortAttributes(SceneGraph::RenderInstructionProcessor::SortAttributes& sortAttributes) const
{
sortAttributes.shader = &(mRenderDataProvider->GetShader());
sortAttributes.geometry = mGeometry;
mAttributeLocations.PushBack(pLocation);
}
- uint32_t location = static_cast<uint32_t>(mAttributeLocations[base + i]);
+ auto location = static_cast<uint32_t>(mAttributeLocations[base + i]);
vertexInputState.attributes.emplace_back(location,
bindingIndex,
Graphics::BlendOp rgbOp = ConvertBlendEquation(mBlendingOptions.GetBlendEquationRgb());
Graphics::BlendOp alphaOp = ConvertBlendEquation(mBlendingOptions.GetBlendEquationRgb());
- if(mBlendingOptions.IsAdvancedBlendEquationApplied() && mPremultipledAlphaEnabled)
+ if(mBlendingOptions.IsAdvancedBlendEquationApplied() && mPremultipliedAlphaEnabled)
{
if(rgbOp != alphaOp)
{
.SetAlphaBlendOp(alphaOp);
// Blend color is optional and rarely used
- Vector4* blendColor = const_cast<Vector4*>(mBlendingOptions.GetBlendColor());
+ auto* blendColor = const_cast<Vector4*>(mBlendingOptions.GetBlendColor());
if(blendColor)
{
colorBlendState.SetBlendConstants(blendColor->AsFloat());
.SetVertexInputState(&vertexInputState)
.SetRasterizationState(&rasterizationState)
.SetColorBlendState(&colorBlendState)
- .SetProgramState(&programState)
- .SetNextExtension(&mLegacyProgram);
+ .SetProgramState(&programState);
// Store a pipeline per renderer per render (renderer can be owned by multiple nodes,
// and re-drawn in multiple instructions).
class SceneController;
class Shader;
class NodeDataProvider;
-
-class RenderInstruction; //for relfection effect
+class RenderInstruction; //for reflection effect
} // namespace SceneGraph
namespace Render
* @brief Returns a reference to an array of draw commands
* @return Valid array of draw commands (may be empty)
*/
- const std::vector<Dali::DevelRenderer::DrawCommand>& GetDrawCommands() const
+ [[nodiscard]] const std::vector<Dali::DevelRenderer::DrawCommand>& GetDrawCommands() const
{
return mDrawCommands;
}
* Query the Renderer's depth write mode
* @return The renderer depth write mode
*/
- DepthWriteMode::Type GetDepthWriteMode() const;
+ [[nodiscard]] DepthWriteMode::Type GetDepthWriteMode() const;
/**
* Sets the depth test mode
* Query the Renderer's depth test mode
* @return The renderer depth test mode
*/
- DepthTestMode::Type GetDepthTestMode() const;
+ [[nodiscard]] DepthTestMode::Type GetDepthTestMode() const;
/**
* Sets the depth function
* Query the Renderer's depth function
* @return The renderer depth function
*/
- DepthFunction::Type GetDepthFunction() const;
+ [[nodiscard]] DepthFunction::Type GetDepthFunction() const;
/**
* Sets the render mode
* Gets the render mode
* @return The render mode
*/
- RenderMode::Type GetRenderMode() const;
+ [[nodiscard]] RenderMode::Type GetRenderMode() const;
/**
* Sets the stencil function
* Gets the stencil function
* @return The stencil function
*/
- StencilFunction::Type GetStencilFunction() const;
+ [[nodiscard]] StencilFunction::Type GetStencilFunction() const;
/**
* Sets the stencil function mask
* Gets the stencil function mask
* @return The stencil function mask
*/
- int GetStencilFunctionMask() const;
+ [[nodiscard]] int GetStencilFunctionMask() const;
/**
* Sets the stencil function reference
* Gets the stencil function reference
* @return The stencil function reference
*/
- int GetStencilFunctionReference() const;
+ [[nodiscard]] int GetStencilFunctionReference() const;
/**
* Sets the stencil mask
* Gets the stencil mask
* @return The stencil mask
*/
- int GetStencilMask() const;
+ [[nodiscard]] int GetStencilMask() const;
/**
* Sets the stencil operation for when the stencil test fails
* Gets the stencil operation for when the stencil test fails
* @return The stencil operation
*/
- StencilOperation::Type GetStencilOperationOnFail() const;
+ [[nodiscard]] StencilOperation::Type GetStencilOperationOnFail() const;
/**
* Sets the stencil operation for when the depth test fails
* Gets the stencil operation for when the depth test fails
* @return The stencil operation
*/
- StencilOperation::Type GetStencilOperationOnZFail() const;
+ [[nodiscard]] StencilOperation::Type GetStencilOperationOnZFail() const;
/**
* Sets the stencil operation for when the depth test passes
* Gets the stencil operation for when the depth test passes
* @return The stencil operation
*/
- StencilOperation::Type GetStencilOperationOnZPass() const;
+ [[nodiscard]] StencilOperation::Type GetStencilOperationOnZPass() const;
/**
* Called to upload during RenderManager::Render().
/**
* Write the renderer's sort attributes to the passed in reference
*
- * @param[in] bufferIndex The current update buffer index.
* @param[out] sortAttributes
*/
- void SetSortAttributes(BufferIndex bufferIndex, SceneGraph::RenderInstructionProcessor::SortAttributes& sortAttributes) const;
+ void SetSortAttributes(SceneGraph::RenderInstructionProcessor::SortAttributes& sortAttributes) const;
/**
* Sets the flag indicating whether shader changed.
const void* data,
uint32_t size);
- /**
- * Returns the pointer to valid command buffer
- *
- * CommandBuffer associated with Renderer contains baked commands
- * needed to issue draw call for this renderer.
- *
- * @return Pointer to valid CommandBuffer
- */
- [[nodiscard]] Graphics::CommandBuffer* GetGraphicsCommandBuffer() const
- {
- return mGraphicsCommandBuffer.get();
- }
-
private:
struct UniformIndexMap;
Render::Geometry* mGeometry;
- Graphics::UniquePtr<Graphics::CommandBuffer> mGraphicsCommandBuffer{};
-
ProgramCache* mProgramCache{nullptr};
Render::ShaderCache* mShaderCache{nullptr};
Render::UniformBufferManager* mUniformBufferManager{};
std::vector<Graphics::UniformBufferBinding> mUniformBufferBindings{};
- std::vector<Graphics::ShaderState> mShaderStates{};
-
using Hash = unsigned long;
struct UniformIndexMap
{
uint32_t mIndexedDrawFirstElement; ///< Offset of first element to draw
uint32_t mIndexedDrawElementsCount; ///< Number of elements to draw
- DepthFunction::Type mDepthFunction : 4; ///< The depth function
- FaceCullingMode::Type mFaceCullingMode : 3; ///< The mode of face culling
- DepthWriteMode::Type mDepthWriteMode : 3; ///< The depth write mode
- DepthTestMode::Type mDepthTestMode : 3; ///< The depth test mode
- bool mUpdateAttributeLocations : 1; ///< Indicates attribute locations have changed
- bool mPremultipledAlphaEnabled : 1; ///< Flag indicating whether the Pre-multiplied Alpha Blending is required
- bool mShaderChanged : 1; ///< Flag indicating the shader changed and uniform maps have to be updated
+ DepthFunction::Type mDepthFunction : 4; ///< The depth function
+ FaceCullingMode::Type mFaceCullingMode : 3; ///< The mode of face culling
+ DepthWriteMode::Type mDepthWriteMode : 3; ///< The depth write mode
+ DepthTestMode::Type mDepthTestMode : 3; ///< The depth test mode
+ bool mUpdateAttributeLocations : 1; ///< Indicates attribute locations have changed
+ bool mPremultipliedAlphaEnabled : 1; ///< Flag indicating whether the Pre-multiplied Alpha Blending is required
+ bool mShaderChanged : 1; ///< Flag indicating the shader changed and uniform maps have to be updated
bool mUpdated : 1;
std::vector<Dali::DevelRenderer::DrawCommand> mDrawCommands; // Devel stuff
- struct LegacyProgram : Graphics::ExtensionCreateInfo
- {
- uint32_t programId{0};
- };
-
- LegacyProgram mLegacyProgram; ///< The structure to pass the program ID into Graphics::PipelineCreateInfo
-
Graphics::UniquePtr<Render::UniformBuffer> mUniformBuffer[2]{nullptr, nullptr}; ///< The double-buffered uniform buffer
};
return mGraphicsSampler.get();
}
-void Sampler::DestroyGraphicsObjects()
-{
- mGraphicsSampler.reset();
-}
-
void Sampler::Initialize(Graphics::Controller& graphicsController)
{
mGraphicsController = &graphicsController;
*/
const Dali::Graphics::Sampler* GetGraphicsObject();
- void DestroyGraphicsObjects();
-
- inline Graphics::SamplerAddressMode GetGraphicsSamplerAddressMode(WrapMode mode) const
+ [[nodiscard]] static inline Graphics::SamplerAddressMode GetGraphicsSamplerAddressMode(WrapMode mode)
{
switch(mode)
{
case WrapMode::MIRRORED_REPEAT:
return Graphics::SamplerAddressMode::MIRRORED_REPEAT;
case WrapMode::CLAMP_TO_EDGE:
- return Graphics::SamplerAddressMode::CLAMP_TO_EDGE;
case WrapMode::DEFAULT:
return Graphics::SamplerAddressMode::CLAMP_TO_EDGE;
}
return {};
}
- inline Graphics::SamplerMipmapMode GetGraphicsSamplerMipmapMode(FilterMode mode) const
+ [[nodiscard]] static inline Graphics::SamplerMipmapMode GetGraphicsSamplerMipmapMode(FilterMode mode)
{
switch(mode)
{
case FilterMode::LINEAR_MIPMAP_LINEAR:
- return Graphics::SamplerMipmapMode::LINEAR;
case FilterMode::NEAREST_MIPMAP_LINEAR:
return Graphics::SamplerMipmapMode::LINEAR;
case FilterMode::NEAREST_MIPMAP_NEAREST:
- return Graphics::SamplerMipmapMode::NEAREST;
case FilterMode::LINEAR_MIPMAP_NEAREST:
return Graphics::SamplerMipmapMode::NEAREST;
default:
return {};
}
- inline Graphics::SamplerFilter GetGraphicsFilter(FilterMode mode) const
+ [[nodiscard]] static inline Graphics::SamplerFilter GetGraphicsFilter(FilterMode mode)
{
switch(mode)
{
/**
* Check if the sampler has default values
*/
- inline bool IsDefaultSampler()
+ [[nodiscard]] inline bool IsDefaultSampler() const
{
return (mMagnificationFilter == FilterMode::DEFAULT &&
mMinificationFilter == FilterMode::DEFAULT &&
* Constructor from native image
* @param[in] nativeImageInterface The native image
*/
- Texture(NativeImageInterfacePtr nativeImageInterface);
+ explicit Texture(NativeImageInterfacePtr nativeImageInterface);
/**
* Destructor
void Upload(PixelDataPtr pixelData, const Internal::Texture::UploadParams& params);
/**
- * Called when the texture is about to be used for drawing.
- * Allows native textures to be set up appropriately.
- */
- void Prepare();
-
- /**
* Auto generates mipmaps for the texture
*/
void GenerateMipmaps();
* Retrieve whether the texture has an alpha channel
* @return True if the texture has alpha channel, false otherwise
*/
- bool HasAlphaChannel() const;
+ [[nodiscard]] bool HasAlphaChannel() const;
/**
* Get the graphics object associated with this texture
*/
- Graphics::Texture* GetGraphicsObject() const;
+ [[nodiscard]] Graphics::Texture* GetGraphicsObject() const;
/**
* Get the type of the texture
* @return Type of the texture
*/
- Type GetType() const
+ [[nodiscard]] Type GetType() const
{
return mType;
}
* Check if the texture is a native image
* @return if the texture is a native image
*/
- bool IsNativeImage() const
+ [[nodiscard]] bool IsNativeImage() const
{
return mNativeImage;
}
void SetData(Dali::Vector<uint8_t>* data, uint32_t size);
/**
- * @brief Set the number of elements
- * @param[in] size The number of elements
- */
- void SetSize(uint32_t size);
-
- /**
* Perform the upload of the buffer only when required
* @param[in] graphicsController The controller
*/
* Get the number of attributes present in the buffer
* @return The number of attributes stored in this buffer
*/
- inline uint32_t GetAttributeCount() const
+ [[nodiscard]] inline uint32_t GetAttributeCount() const
{
DALI_ASSERT_DEBUG(mFormat && "Format should be set ");
return static_cast<uint32_t>(mFormat->components.size());
* @param[in] index The index of the attribute
* @return The name of the attribute
*/
- inline ConstString GetAttributeName(uint32_t index) const
+ [[nodiscard]] inline ConstString GetAttributeName(uint32_t index) const
{
DALI_ASSERT_DEBUG(mFormat && "Format should be set ");
return mFormat->components[index].name;
* Retrieve the size of the buffer in bytes
* @return The total size of the buffer
*/
- inline uint32_t GetDataSize() const
+ [[nodiscard]] inline uint32_t GetDataSize() const
{
DALI_ASSERT_DEBUG(mFormat && "Format should be set ");
return mFormat->size * mSize;
* Retrieve the size of one element of the buffer
* @return The size of one element
*/
- inline uint32_t GetElementSize() const
+ [[nodiscard]] inline uint32_t GetElementSize() const
{
DALI_ASSERT_DEBUG(mFormat && "Format should be set ");
return mFormat->size;
* Retrieve the number of elements in the buffer
* @return The total number of elements
*/
- inline uint32_t GetElementCount() const
+ [[nodiscard]] inline uint32_t GetElementCount() const
{
return mSize;
}
- /**
- * Retrieve reference to the data storage vector
- * @return Reference to the data storage
- */
- inline const Dali::Vector<uint8_t>& GetData() const
- {
- return *mData.Get();
- }
-
- /**
- * Retrieve data writeable pointer ( direct access to the buffer data )
- * @return Pointer to data converted to requested type
- */
- template<typename T>
- inline T* GetDataTypedPtr()
- {
- Dali::Vector<uint8_t>* data = mData.Release();
- mData = data;
- return reinterpret_cast<T*>(&data->operator[](0));
- }
-
- inline const VertexBuffer::Format* GetFormat() const
+ [[nodiscard]] inline const VertexBuffer::Format* GetFormat() const
{
return mFormat.Get();
}
- inline const GpuBuffer* GetGpuBuffer() const
+ [[nodiscard]] inline const GpuBuffer* GetGpuBuffer() const
{
return mGpuBuffer.Get();
}
*/
virtual void AddProgram(size_t shaderHash, Program* program) = 0;
- /**
- * Get currently bound program
- * @return program that is currently used
- */
- virtual Program* GetCurrentProgram() = 0;
-
- /**
- * Set the currently bound program
- * @param program that is used
- */
- virtual void SetCurrentProgram(Program* program) = 0;
-
- /**
- * @return true if program binaries are supported
- */
- virtual bool IsBinarySupported() = 0;
-
- /**
- * @return the binary format to use
- */
- virtual GLenum ProgramBinaryFormat() = 0;
-
- /**
- * @param programData to store/save
- */
- virtual void StoreBinary(Internal::ShaderDataPtr programData) = 0;
-
ProgramCache(const ProgramCache& rhs) = delete;
ProgramCache& operator=(const ProgramCache& rhs) = delete;
};
namespace Internal
{
ProgramController::ProgramController(Graphics::Controller& graphicsController)
-: mShaderSaver(nullptr),
- mGraphicsController(graphicsController),
- mCurrentProgram(nullptr),
- mProgramBinaryFormat(0),
- mNumberOfProgramBinaryFormats(0)
+: mGraphicsController(graphicsController)
{
- // we have 17 default programs so make room for those and a few custom ones as well
mProgramCache.Reserve(32);
}
void ProgramController::AddProgram(size_t shaderHash, Program* program)
{
- // we expect unique hash values so its event thread sides job to guarantee that
+ // we expect unique hash values so it is event thread side's job to guarantee that
// AddProgram is only called after program checks that GetProgram returns NULL
mProgramCache.PushBack(new ProgramPair(program, shaderHash));
}
-Program* ProgramController::GetCurrentProgram()
-{
- return mCurrentProgram;
-}
-
-void ProgramController::SetCurrentProgram(Program* program)
-{
- mCurrentProgram = program;
-}
-
-bool ProgramController::IsBinarySupported()
-{
- return mNumberOfProgramBinaryFormats > 0;
-}
-
-GLenum ProgramController::ProgramBinaryFormat()
-{
- return mProgramBinaryFormat;
-}
-
-void ProgramController::StoreBinary(Internal::ShaderDataPtr programData)
-{
- DALI_ASSERT_DEBUG(programData->GetBufferSize() > 0);
- DALI_ASSERT_DEBUG(mShaderSaver && "SetShaderSaver() should have been called during startup.");
-
- if(mShaderSaver != nullptr)
- {
- mShaderSaver->SaveBinary(programData);
- }
-}
-
-void ProgramController::SetShaderSaver(ShaderSaver& shaderSaver)
-{
- mShaderSaver = &shaderSaver;
-}
-
} // namespace Internal
} // namespace Dali
class ShaderSaver;
/**
- * This class is the owner of GL shader programs
+ * This class is the owner of shader programs
*/
class ProgramController : public ProgramCache
{
* Inline getter for the hash
* @return the hash
*/
- inline size_t GetHash() const
+ [[nodiscard]] inline size_t GetHash() const
{
return mShaderHash;
}
*/
void ResetProgramMatrices();
- /**
- * Set the destination for compiler shader binaries so they can be saved.
- * @note Must be called during initialisation.
- */
- void SetShaderSaver(ShaderSaver& shaderSaver);
-
private: // From ProgramCache
/**
* @copydoc ProgramCache::GetProgram
*/
void AddProgram(size_t shaderHash, Program* program) override;
- /**
- * @copydoc ProgramCache::GetCurrentProgram
- */
- Program* GetCurrentProgram() override;
-
- /**
- * @copydoc ProgramCache::SetCurrentProgram
- */
- void SetCurrentProgram(Program* program) override;
-
- /**
- * @copydoc ProgramCache::IsBinarySupported
- */
- bool IsBinarySupported() override;
-
- /**
- * @copydoc ProgramCache::ProgramBinaryFormat
- */
- GLenum ProgramBinaryFormat() override;
-
- /**
- * @copydoc ProgramCache::StoreBinary
- */
- void StoreBinary(Internal::ShaderDataPtr programData) override;
-
private: // Data
- ShaderSaver* mShaderSaver;
Graphics::Controller& mGraphicsController;
- Program* mCurrentProgram;
using ProgramContainer = OwnerContainer<ProgramPair*>;
using ProgramIterator = ProgramContainer::Iterator;
ProgramContainer mProgramCache;
-
- GLint mProgramBinaryFormat;
- GLint mNumberOfProgramBinaryFormats;
};
} // namespace Internal
// EXTERNAL INCLUDES
#include <cstring>
-#include <iomanip>
#include <map>
// INTERNAL INCLUDES
BuildReflection(controller.GetProgramReflection(*mGfxProgram.get()));
}
-Program::~Program()
-{
-}
+Program::~Program() = default;
void Program::BuildReflection(const Graphics::Reflection& graphicsReflection)
{
mReflection.back().uniformInfo.bufferIndex = i;
// Update default uniforms
- for(auto i = 0u; i < NUMBER_OF_DEFAULT_UNIFORMS; ++i)
+ for(auto j = 0u; j < NUMBER_OF_DEFAULT_UNIFORMS; ++j)
{
- if(hashValue == DEFAULT_UNIFORM_HASHTABLE[i])
+ if(hashValue == DEFAULT_UNIFORM_HASHTABLE[j])
{
- mReflectionDefaultUniforms[i] = mReflection.back();
+ mReflectionDefaultUniforms[j] = mReflection.back();
break;
}
}
if(item.mRenderer)
{
- item.mRenderer->SetSortAttributes(bufferIndex, mSortingHelper[index]);
+ item.mRenderer->SetSortAttributes(mSortingHelper[index]);
}
// texture set
{
RenderItem& item = renderList.GetItem(index);
- item.mRenderer->SetSortAttributes(bufferIndex, mSortingHelper[index]);
+ item.mRenderer->SetSortAttributes(mSortingHelper[index]);
// texture set
mSortingHelper[index].textureSet = item.mTextureSet;