1 #ifndef DALI_GLES_TEXTURE_DEPENDENCY_CHECKER_H
2 #define DALI_GLES_TEXTURE_DEPENDENCY_CHECKER_H
5 * Copyright (c) 2022 Samsung Electronics Co., Ltd.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
20 #include <dali/public-api/common/vector-wrapper.h>
22 namespace Dali::Graphics
24 class EglGraphicsController;
31 class AgingSyncObject;
34 * Class to handle dependency checks between textures on different
37 * We have a shared (resource) context for writing to offscreen framebuffers,
38 * and separate contexts for each window/scene.
39 * If a framebuffer attachment is used in a scene, then it needs a sync point
40 * in the GPU in order to ensure that the first context finishes writing to the
41 * texture before it is read in the scene context.
43 class TextureDependencyChecker
46 explicit TextureDependencyChecker(EglGraphicsController& controller)
47 : mController(controller)
52 * Clear all the textures. Call at the start of a frame
57 * Add Texture dependencies
59 * @param[in] writeContext The context of the framebuffer's render pass
60 * @param[in] framebuffer The framebuffer to collect textures from
62 void AddTextures(const Context* writeContext, const Framebuffer* framebuffer);
65 * Check if the given texture needs syncing before being read. This
66 * will perform a glWaitSync() (GPU side semaphore) if the texture
68 * @param[in] readContext The context that the texture is being read (drawn with)
69 * @param[in] texture The texture being read
71 void CheckNeedsSync(const Context* readContext, const Texture* texture);
74 struct TextureDependency
76 std::vector<Texture*> textures;
77 Context* writeContext{nullptr};
78 Framebuffer* framebuffer{nullptr};
79 AgingSyncObject* agingSyncObject;
82 std::vector<TextureDependency> mTextureDependencies;
83 EglGraphicsController& mController;
87 } // namespace Dali::Graphics
89 #endif //DALI_GLES_TEXTURE_DEPENDENCY_CHECKER_H