From: Richard Huang Date: Tue, 9 Mar 2021 10:37:18 +0000 (+0000) Subject: Write default uniforms in UBO before the properties in the uniform map X-Git-Tag: graphics-backend-pre-release-3~5 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c51ac685c5aac19153c0f29d92a11257887d3177;p=platform%2Fcore%2Fuifw%2Fdali-core.git Write default uniforms in UBO before the properties in the uniform map Change-Id: I331991bd521ade1f8daad4c690e98a20cc56e18b --- diff --git a/dali/internal/render/renderers/render-renderer.cpp b/dali/internal/render/renderers/render-renderer.cpp index 182425670..2915ad5fc 100644 --- a/dali/internal/render/renderers/render-renderer.cpp +++ b/dali/internal/render/renderers/render-renderer.cpp @@ -889,22 +889,13 @@ void Renderer::Render(Context& conte auto ubo = mUniformBuffer[bufferIndex].get(); if(ubo) { - std::vector* bindings{nullptr}; - FillUniformBuffers(*program, instruction, *ubo, bindings, uboOffset, bufferIndex); + auto& reflection = mGraphicsController->GetProgramReflection(program->GetGraphicsProgram()); + auto uboCount = reflection.GetUniformBlockCount(); + mUniformBufferBindings.resize(uboCount); - Vector4 finalColor; - const Vector4& color = node.GetRenderColor(bufferIndex); - if(mPremultipledAlphaEnabled) - { - float alpha = color.a * mRenderDataProvider->GetOpacity(bufferIndex); - finalColor = Vector4(color.r * alpha, color.g * alpha, color.b * alpha, alpha); - } - else - { - finalColor = Vector4(color.r, color.g, color.b, color.a * mRenderDataProvider->GetOpacity(bufferIndex)); - } + std::vector* bindings{&mUniformBufferBindings}; - // We know bindings for this renderer, so we can use 'offset' and write additional uniforms + // Write default uniforms Matrix modelViewProjectionMatrix(false); Matrix::Multiply(modelViewProjectionMatrix, modelViewMatrix, projectionMatrix); @@ -913,8 +904,6 @@ void Renderer::Render(Context& conte WriteDefaultUniform(program->GetDefaultUniform(Program::DefaultUniformIndex::PROJECTION_MATRIX), *ubo, *bindings, projectionMatrix); WriteDefaultUniform(program->GetDefaultUniform(Program::DefaultUniformIndex::MVP_MATRIX), *ubo, *bindings, modelViewProjectionMatrix); WriteDefaultUniform(program->GetDefaultUniform(Program::DefaultUniformIndex::MODEL_VIEW_MATRIX), *ubo, *bindings, modelViewMatrix); - WriteDefaultUniform(program->GetDefaultUniform(Program::DefaultUniformIndex::SIZE), *ubo, *bindings, size); - WriteDefaultUniform(program->GetDefaultUniform(Program::DefaultUniformIndex::COLOR), *ubo, *bindings, finalColor); // Update normal matrix only when used in the shader Matrix3 normalMatrix(modelViewMatrix); @@ -922,6 +911,25 @@ void Renderer::Render(Context& conte normalMatrix.Transpose(); WriteDefaultUniform(program->GetDefaultUniform(Program::DefaultUniformIndex::NORMAL_MATRIX), *ubo, *bindings, normalMatrix); + Vector4 finalColor; + const Vector4& color = node.GetRenderColor(bufferIndex); + if(mPremultipledAlphaEnabled) + { + float alpha = color.a * mRenderDataProvider->GetOpacity(bufferIndex); + finalColor = Vector4(color.r * alpha, color.g * alpha, color.b * alpha, alpha); + } + else + { + finalColor = Vector4(color.r, color.g, color.b, color.a * mRenderDataProvider->GetOpacity(bufferIndex)); + } + WriteDefaultUniform(program->GetDefaultUniform(Program::DefaultUniformIndex::COLOR), *ubo, *bindings, finalColor); + + // Write uniforms from the uniform map + FillUniformBuffers(*program, instruction, *ubo, bindings, uboOffset, bufferIndex); + + // Write uSize in the end, as it shouldn't be overridable by dynamic properties. + WriteDefaultUniform(program->GetDefaultUniform(Program::DefaultUniformIndex::SIZE), *ubo, *bindings, size); + commandBuffer->BindUniformBuffers(*bindings); } @@ -990,8 +998,6 @@ void Renderer::FillUniformBuffers(Program& auto& reflection = mGraphicsController->GetProgramReflection(program.GetGraphicsProgram()); auto uboCount = reflection.GetUniformBlockCount(); - mUniformBufferBindings.resize(uboCount); - // Setup bindings uint32_t dataOffset = offset; for(auto i = 0u; i < uboCount; ++i)