Fixed the case when the new program is not set whe GLES Context Flush() is called. 55/259455/1
authorAdam Bialogonski <adam.b@samsung.com>
Tue, 8 Jun 2021 08:28:41 +0000 (09:28 +0100)
committerAdam Bialogonski <adam.b@samsung.com>
Tue, 8 Jun 2021 08:29:29 +0000 (09:29 +0100)
Change-Id: I071cdb6f356f22550d5a319d90ec135d96f8d11a

dali/internal/graphics/gles-impl/gles-context.cpp

index fb32249..31e0713 100644 (file)
@@ -181,11 +181,25 @@ void Context::Flush(bool reset, const GLES::DrawCallDescriptor& drawCall)
 {
   auto& gl = *mImpl->mController.GetGL();
 
+  // early out if neither current nor new pipelines are set
+  // this behaviour may be valid so no assert
+  if(!mImpl->mCurrentPipeline && !mImpl->mNewPipeline)
+  {
+    return;
+  }
+
   // Execute states if pipeline is changed
-  const auto& currentProgram = mImpl->mCurrentPipeline ? static_cast<const GLES::Program*>(mImpl->mCurrentPipeline->GetCreateInfo().programState->program) : nullptr;
-  const auto& newProgram     = static_cast<const GLES::Program*>(mImpl->mNewPipeline->GetCreateInfo().programState->program);
+  const auto currentProgram = mImpl->mCurrentPipeline ? static_cast<const GLES::Program*>(mImpl->mCurrentPipeline->GetCreateInfo().programState->program) : nullptr;
+
+  // case when new pipeline has been set
+  const GLES::Program* newProgram = nullptr;
+
+  if(mImpl->mNewPipeline)
+  {
+    newProgram = static_cast<const GLES::Program*>(mImpl->mNewPipeline->GetCreateInfo().programState->program);
+  }
 
-  if(mImpl->mCurrentPipeline != mImpl->mNewPipeline)
+  if(mImpl->mNewPipeline && mImpl->mCurrentPipeline != mImpl->mNewPipeline)
   {
     if(!currentProgram || currentProgram->GetImplementation()->GetGlProgram() != newProgram->GetImplementation()->GetGlProgram())
     {
@@ -204,7 +218,7 @@ void Context::Flush(bool reset, const GLES::DrawCallDescriptor& drawCall)
 
   // Bind textures
   // Map binding# to sampler location
-  const auto& reflection = newProgram->GetReflection();
+  const auto& reflection = !newProgram ? currentProgram->GetReflection() : newProgram->GetReflection();
   const auto& samplers   = reflection.GetSamplers();
   for(const auto& binding : mImpl->mCurrentTextureBindings)
   {