void RenderManager::RemoveGeometry(Render::Geometry* geometry)
{
- mImpl->geometryContainer.EraseObject(geometry);
+ auto it = std::find_if( mImpl->geometryContainer.begin(), mImpl->geometryContainer.end(),[geometry]( auto& item )
+ {
+ return geometry == item;
+ });
+
+ if(it != mImpl->geometryContainer.end())
+ {
+ mImpl->geometryContainer.Erase(it);
+ }
}
void RenderManager::AttachVertexBuffer(Render::Geometry* geometry, Render::VertexBuffer* vertexBuffer)
DALI_LOG_INFO(gLogFilter, Debug::General, "Render: Processing\n");
// Upload the geometries
- for(auto& i : mImpl->sceneContainer)
+ for(auto&& geom : mImpl->geometryContainer)
{
- RenderInstructionContainer& instructions = i->GetRenderInstructions();
- for(uint32_t j = 0; j < instructions.Count(mImpl->renderBufferIndex); ++j)
- {
- RenderInstruction& instruction = instructions.At(mImpl->renderBufferIndex, j);
-
- const Matrix* viewMatrix = instruction.GetViewMatrix(mImpl->renderBufferIndex);
- const Matrix* projectionMatrix = instruction.GetProjectionMatrix(mImpl->renderBufferIndex);
-
- DALI_ASSERT_DEBUG(viewMatrix);
- DALI_ASSERT_DEBUG(projectionMatrix);
-
- if(viewMatrix && projectionMatrix)
- {
- const RenderListContainer::SizeType renderListCount = instruction.RenderListCount();
-
- // Iterate through each render list.
- for(RenderListContainer::SizeType index = 0; index < renderListCount; ++index)
- {
- const RenderList* renderList = instruction.GetRenderList(index);
-
- if(renderList && !renderList->IsEmpty())
- {
- const std::size_t itemCount = renderList->Count();
- for(uint32_t itemIndex = 0u; itemIndex < itemCount; ++itemIndex)
- {
- const RenderItem& item = renderList->GetItem(itemIndex);
- if(DALI_LIKELY(item.mRenderer))
- {
- item.mRenderer->Upload();
- }
- }
- }
- }
- }
- }
+ geom->Upload( mImpl->graphicsController );
}
}
}
* Check if the attributes for the geometry have changed
* @return True if vertex buffers have been added or removed since last frame, false otherwise
*/
- [[nodiscard]] bool AttributesChanged() const
+ [[maybe_unused]] [[nodiscard]] bool AttributesChanged() const
{
return mAttributesChanged;
}
iter != end;
++iter)
{
- // @todo This means parsing the uniform string every frame. Instead, store the array index if present.
- int arrayIndex = (*iter).arrayIndex;
+ auto& uniform = *iter;
+ int arrayIndex = uniform.arrayIndex;
- auto uniformInfo = Graphics::UniformInfo{};
- auto uniformFound = program.GetUniform((*iter).uniformName.GetCString(),
- (*iter).uniformNameHashNoArray ? (*iter).uniformNameHashNoArray
- : (*iter).uniformNameHash,
- uniformInfo);
+ if(!uniform.uniformFunc)
+ {
+ auto uniformInfo = Graphics::UniformInfo{};
+ auto uniformFound = program.GetUniform(uniform.uniformName.GetCString(),
+ uniform.uniformNameHashNoArray ? uniform.uniformNameHashNoArray
+ : uniform.uniformNameHash,
+ uniformInfo);
+
+ uniform.uniformOffset = uniformInfo.offset;
+ uniform.uniformLocation = uniformInfo.location;
+
+ if (uniformFound)
+ {
+ auto dst = ubo.GetOffset() + uniformInfo.offset;
+ const auto typeSize = GetPropertyValueSizeForUniform((*iter).propertyValue->GetType());
+ const auto dest = dst + static_cast<uint32_t>(typeSize) * arrayIndex;
+ const auto func = GetPropertyValueGetter((*iter).propertyValue->GetType());
+
+ ubo.Write(&((*iter).propertyValue->*func)(updateBufferIndex),
+ typeSize,
+ dest);
- if(uniformFound)
+ uniform.uniformSize = typeSize;
+ uniform.uniformFunc = func;
+ }
+ }
+ else
{
- auto dst = ubo.GetOffset() + uniformInfo.offset;
- const auto typeSize = GetPropertyValueSizeForUniform( (*iter).propertyValue->GetType() );
- const auto dest = dst + static_cast<uint32_t>(typeSize) * arrayIndex;
- const auto func = GetPropertyValueGetter((*iter).propertyValue->GetType());
+ auto dst = ubo.GetOffset() + uniform.uniformOffset;
+ const auto typeSize = uniform.uniformSize;
+ const auto dest = dst + static_cast<uint32_t>(typeSize) * arrayIndex;
+ const auto func = uniform.uniformFunc;
+
+
ubo.Write(&((*iter).propertyValue->*func)(updateBufferIndex),
typeSize,
dest);
Render::PipelineCache* mPipelineCache{nullptr};
using Hash = unsigned long;
+
+ typedef const float&(PropertyInputImpl::*FuncGetter )(BufferIndex) const;
+
struct UniformIndexMap
{
ConstString uniformName; ///< The uniform name
Hash uniformNameHash{0u};
Hash uniformNameHashNoArray{0u};
int32_t arrayIndex{-1}; ///< The array index
+
+ int16_t uniformLocation{0u};
+ uint16_t uniformOffset{0u};
+ uint16_t uniformSize{0u};
+ FuncGetter uniformFunc{0};
};
using UniformIndexMappings = Dali::Vector<UniformIndexMap>;
void* ptr = bufferDesc.memory->LockRegion(bufferOffset, size);
if(ptr && bufferOffset + size < mSize)
{
- memcpy(ptr, data, size);
+ // size always divides by 4 (std140 alignment rules, so we can replace memcpy with unrolled assignments)
+ auto ptr32 = reinterpret_cast<uint32_t*>(ptr);
+ auto data32 = reinterpret_cast<const uint32_t*>(data);
+ for(auto i = 0u; i < size; i +=4 )
+ {
+ *ptr32++ = *data32++;;
+ }
}
bufferDesc.memory->Unlock(true);
}