1 #ifndef DALI_GRAPHICS_GLES_SYNC_POOL_H
2 #define DALI_GRAPHICS_GLES_SYNC_POOL_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/graphics-api/graphics-types.h>
21 #include <dali/integration-api/gl-abstraction.h>
22 #include <dali/public-api/common/vector-wrapper.h>
24 namespace Dali::Graphics
26 class EglGraphicsController;
32 struct AgingSyncObject
34 AgingSyncObject(Graphics::EglGraphicsController& controller, const Context* writeContext);
37 EglGraphicsController& controller;
38 const Context* writeContext;
39 GLsync glSyncObject{0};
43 using AgingSyncPtrRef = std::unique_ptr<AgingSyncObject>&;
46 * A vector of current fence syncs. They only age if glWaitSync is called on them in the
47 * same frame they are created, otherwise they are deleted.
48 * They must be created in the writeContext, but can be synced from a readContext.
49 * (Pool per context? - probably only ever used in resource context!)
54 explicit SyncPool(Graphics::EglGraphicsController& graphicsController)
55 : mController(graphicsController)
62 * Allocate a sync object in the writeContext
64 * @return An owned ptr to a sync object
66 AgingSyncObject* AllocateSyncObject(const Context* writeContext);
69 * Wait on a sync object in any context
70 * @param syncPoolObject The object to wait on.
72 void Wait(AgingSyncObject* syncPoolObject);
75 * Delete the sync object if it's not needed.
78 void FreeSyncObject(AgingSyncObject* agingSyncObject);
81 * Age outstanding sync objects. Call at the end of each frame.
82 * When a sync object is older than 2 frames, delete it.
84 void AgeSyncObjects();
87 std::vector<std::unique_ptr<AgingSyncObject>> mSyncObjects;
88 EglGraphicsController& mController;
92 } // namespace Dali::Graphics
94 #endif //DALI_GRAPHICS_GLES_SYNC_POOL_H