Remove annoying log message
[platform/core/uifw/dali-adaptor.git] / dali / internal / graphics / gles-impl / gles-texture-dependency-checker.cpp
1 /*
2  * Copyright (c) 2022 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 // CLASS HEADER
18 #include "gles-texture-dependency-checker.h"
19
20 // EXTERNAL INCLUDES
21 #include <dali/internal/graphics/gles-impl/egl-graphics-controller.h>
22
23 namespace Dali::Graphics::GLES
24 {
25 void TextureDependencyChecker::Reset()
26 {
27   for(auto& textureDependency : mTextureDependencies)
28   {
29     for(auto texture : textureDependency.textures)
30     {
31       texture->SetDependencyIndex(0xffffffff);
32     }
33     if(!textureDependency.syncing)
34     {
35       mController.GetSyncPool().FreeSyncObject(textureDependency.agingSyncObject);
36     }
37   }
38   mTextureDependencies.clear();
39 }
40
41 void TextureDependencyChecker::AddTextures(const GLES::Context* writeContext, const GLES::Framebuffer* framebuffer)
42 {
43   uint32_t index = mTextureDependencies.size();
44   mTextureDependencies.emplace_back();
45   TextureDependency& textureDependency = mTextureDependencies.back();
46
47   for(int i = 0; i < 3; ++i)
48   {
49     GLES::Texture* texture{nullptr};
50     switch(i)
51     {
52       case 0:
53         texture = static_cast<GLES::Texture*>(framebuffer->GetCreateInfo().colorAttachments[0].texture);
54         break;
55       case 1:
56         texture = static_cast<GLES::Texture*>(framebuffer->GetCreateInfo().depthStencilAttachment.depthTexture);
57         break;
58       case 2:
59         texture = static_cast<GLES::Texture*>(framebuffer->GetCreateInfo().depthStencilAttachment.stencilTexture);
60         break;
61     }
62     if(texture != nullptr)
63     {
64       textureDependency.textures.push_back(texture);
65       texture->SetDependencyIndex(index);
66     }
67   }
68   textureDependency.writeContext    = const_cast<GLES::Context*>(writeContext);
69   textureDependency.framebuffer     = const_cast<GLES::Framebuffer*>(framebuffer);
70   textureDependency.agingSyncObject = mController.GetSyncPool().AllocateSyncObject(writeContext);
71 }
72
73 void TextureDependencyChecker::CheckNeedsSync(const GLES::Context* readContext, const GLES::Texture* texture)
74 {
75   uint32_t dependencyIndex = texture->GetDependencyIndex();
76   if(dependencyIndex < mTextureDependencies.size())
77   {
78     auto& textureDependency = mTextureDependencies[dependencyIndex];
79     if(!textureDependency.syncing && textureDependency.writeContext != readContext)
80     {
81       // Needs syncing!
82       textureDependency.syncing = true;
83
84       // Wait on the sync object in GPU. This will ensure that the writeContext completes its tasks prior
85       // to the sync point.
86       mController.GetSyncPool().Wait(textureDependency.agingSyncObject);
87     }
88   }
89 }
90
91 } // namespace Dali::Graphics::GLES