From: Adam Bialogonski Date: Thu, 15 Jul 2021 15:41:53 +0000 (+0100) Subject: Uniform data cached locally in the uniform map X-Git-Tag: dali_2.0.36~6^2~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F01%2F260901%2F8;p=platform%2Fcore%2Fuifw%2Fdali-core.git Uniform data cached locally in the uniform map Change-Id: I6667d1d63cafb949f1553318f9b2233d886903df --- diff --git a/dali/internal/render/renderers/render-renderer.cpp b/dali/internal/render/renderers/render-renderer.cpp index 6d0f0b7..c6083a7 100644 --- a/dali/internal/render/renderers/render-renderer.cpp +++ b/dali/internal/render/renderers/render-renderer.cpp @@ -702,21 +702,43 @@ void Renderer::FillUniformBuffer(Program& p 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(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(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(typeSize) * arrayIndex; + const auto func = uniform.uniformFunc; + + ubo.Write(&((*iter).propertyValue->*func)(updateBufferIndex), typeSize, dest); diff --git a/dali/internal/render/renderers/render-renderer.h b/dali/internal/render/renderers/render-renderer.h index b57490f..5583fe0 100644 --- a/dali/internal/render/renderers/render-renderer.h +++ b/dali/internal/render/renderers/render-renderer.h @@ -516,6 +516,9 @@ private: Render::PipelineCache* mPipelineCache{nullptr}; using Hash = unsigned long; + + typedef const float&(PropertyInputImpl::*FuncGetter )(BufferIndex) const; + struct UniformIndexMap { ConstString uniformName; ///< The uniform name @@ -523,6 +526,11 @@ private: 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;