Invalidate depth and stencil buffers after finishing the rendering
[platform/core/uifw/dali-adaptor.git] / dali / internal / graphics / gles-impl / gles-context.cpp
index 31e0713..89a6010 100644 (file)
@@ -246,7 +246,7 @@ void Context::Flush(bool reset, const GLES::DrawCallDescriptor& drawCall)
   }
 
   // for each attribute bind vertices
-  const auto& pipelineState = mImpl->mNewPipeline->GetCreateInfo();
+  const auto& pipelineState = mImpl->mNewPipeline ? mImpl->mNewPipeline->GetCreateInfo() : mImpl->mCurrentPipeline->GetCreateInfo();
   const auto& vi            = pipelineState.vertexInputState;
   for(const auto& attr : vi->attributes)
   {
@@ -270,7 +270,7 @@ void Context::Flush(bool reset, const GLES::DrawCallDescriptor& drawCall)
   }
 
   // Resolve topology
-  const auto& ia = mImpl->mNewPipeline->GetCreateInfo().inputAssemblyState;
+  const auto& ia = pipelineState.inputAssemblyState;
 
   // Bind uniforms
 
@@ -509,106 +509,12 @@ void Context::ResolveUniformBuffers()
 
 void Context::ResolveStandaloneUniforms()
 {
-  auto& gl = *mImpl->mController.GetGL();
-
   // Find reflection for program
   const auto program = static_cast<const GLES::Program*>(mImpl->mNewPipeline->GetCreateInfo().programState->program);
+  const auto ptr     = reinterpret_cast<const char*>(mImpl->mCurrentStandaloneUBOBinding.buffer->GetCPUAllocatedAddress()) + mImpl->mCurrentStandaloneUBOBinding.offset;
 
-  const auto& reflection = program->GetReflection();
-
-  auto extraInfos = reflection.GetStandaloneUniformExtraInfo();
-
-  const auto ptr = reinterpret_cast<const char*>(mImpl->mCurrentStandaloneUBOBinding.buffer->GetCPUAllocatedAddress()) + mImpl->mCurrentStandaloneUBOBinding.offset;
-
-  for(const auto& info : extraInfos)
-  {
-    auto type   = GLTypeConversion(info.type).type;
-    auto offset = info.offset;
-    switch(type)
-    {
-      case GLType::FLOAT_VEC2:
-      {
-        gl.Uniform2fv(info.location, info.arraySize, reinterpret_cast<const float*>(&ptr[offset]));
-        break;
-      }
-      case GLType::FLOAT_VEC3:
-      {
-        gl.Uniform3fv(info.location, info.arraySize, reinterpret_cast<const float*>(&ptr[offset]));
-        break;
-      }
-      case GLType::FLOAT_VEC4:
-      {
-        gl.Uniform4fv(info.location, info.arraySize, reinterpret_cast<const float*>(&ptr[offset]));
-        break;
-      }
-      case GLType::INT_VEC2:
-      {
-        gl.Uniform2iv(info.location, info.arraySize, reinterpret_cast<const GLint*>(&ptr[offset]));
-        break;
-      }
-      case GLType::INT_VEC3:
-      {
-        gl.Uniform3iv(info.location, info.arraySize, reinterpret_cast<const GLint*>(&ptr[offset]));
-        break;
-      }
-      case GLType::INT_VEC4:
-      {
-        gl.Uniform4iv(info.location, info.arraySize, reinterpret_cast<const GLint*>(&ptr[offset]));
-        break;
-      }
-      case GLType::BOOL:
-      {
-        // not supported by DALi
-        break;
-      }
-      case GLType::BOOL_VEC2:
-      {
-        // not supported by DALi
-        break;
-      }
-      case GLType::BOOL_VEC3:
-      {
-        // not supported by DALi
-        break;
-      }
-      case GLType::BOOL_VEC4:
-      {
-        // not supported by DALi
-        break;
-      }
-      case GLType::FLOAT:
-      {
-        gl.Uniform1fv(info.location, info.arraySize, reinterpret_cast<const float*>(&ptr[offset]));
-        break;
-      }
-      case GLType::FLOAT_MAT2:
-      {
-        gl.UniformMatrix2fv(info.location, info.arraySize, GL_FALSE, reinterpret_cast<const float*>(&ptr[offset]));
-        break;
-      }
-      case GLType::FLOAT_MAT3:
-      {
-        gl.UniformMatrix3fv(info.location, info.arraySize, GL_FALSE, reinterpret_cast<const float*>(&ptr[offset]));
-        break;
-      }
-      case GLType::FLOAT_MAT4:
-      {
-        gl.UniformMatrix4fv(info.location, info.arraySize, GL_FALSE, reinterpret_cast<const float*>(&ptr[offset]));
-        break;
-      }
-      case GLType::SAMPLER_2D:
-      {
-        break;
-      }
-      case GLType::SAMPLER_CUBE:
-      {
-        break;
-      }
-      default:
-      {
-      }
-    }
-  }
+  // Update program uniforms
+  program->GetImplementation()->UpdateStandaloneUniformBlock(ptr);
 }
 
 void Context::BeginRenderPass(const BeginRenderPassDescriptor& renderPassBegin)
@@ -748,6 +654,14 @@ void Context::ClearBuffer(uint32_t mask, bool forceClear)
   }
 }
 
+void Context::InvalidateDepthStencilBuffers()
+{
+  auto& gl = *mImpl->mController.GetGL();
+
+  GLenum attachments[] = {GL_DEPTH, GL_STENCIL};
+  gl.InvalidateFramebuffer(GL_FRAMEBUFFER, 2, attachments);
+}
+
 void Context::SetScissorTestEnabled(bool scissorEnabled)
 {
   if(mImpl->mGlStateCache.mScissorTestEnabled != scissorEnabled)