- // Synchronise the FBO/Texture access when there are multiple contexts
- if(mImpl->currentContext->IsSurfacelessContextSupported())
- {
- // Check whether any bound texture is in the dependency list
- bool textureFound = false;
-
- if(mImpl->boundTextures.Count() > 0u && mImpl->textureDependencyList.Count() > 0u)
- {
- for(auto texture : mImpl->textureDependencyList)
- {
- textureFound = std::find_if(mImpl->boundTextures.Begin(), mImpl->boundTextures.End(), [texture](Graphics::Texture* graphicsTexture) {
- return texture == graphicsTexture;
- }) != mImpl->boundTextures.End();
- }
- }
-
- if(textureFound)
- {
- if(instruction.mFrameBuffer)
- {
- // For off-screen buffer
-
- // Wait until all rendering calls for the currently context are executed
- // mImpl->graphicsController.GetGlContextHelperAbstraction().WaitClient();
-
- // Clear the dependency list
- mImpl->textureDependencyList.Clear();
- }
- else
- {
- // Worker thread lambda function
- auto& glContextHelperAbstraction = mImpl->graphicsController.GetGlContextHelperAbstraction();
- auto workerFunction = [&glContextHelperAbstraction](int workerThread) {
- // Switch to the shared context in the worker thread
- glContextHelperAbstraction.MakeSurfacelessContextCurrent();
-
- // Wait until all rendering calls for the shared context are executed
- glContextHelperAbstraction.WaitClient();
-
- // Must clear the context in the worker thread
- // Otherwise the shared context cannot be switched to from the render thread
- glContextHelperAbstraction.MakeContextNull();
- };
-
- auto future = mImpl->threadPool->SubmitTask(0u, workerFunction);
- if(future)
- {
- mImpl->threadPool->Wait();
-
- // Clear the dependency list
- mImpl->textureDependencyList.Clear();
- }
- }
- }
- }
-
+ Graphics::SyncObject* syncObject{nullptr};
+ // If the render instruction has an associated render tracker (owned separately)
+ // and framebuffer, create a one shot sync object, and use it to determine when
+ // the render pass has finished executing on GPU.