FenceImpl.cpp 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. // Copyright (C) 2009-2021, Panagiotis Christopoulos Charitos and contributors.
  2. // All rights reserved.
  3. // Code licensed under the BSD License.
  4. // http://www.anki3d.org/LICENSE
  5. #include <AnKi/Gr/gl/FenceImpl.h>
  6. #include <AnKi/Gr/CommandBuffer.h>
  7. #include <AnKi/Gr/gl/CommandBufferImpl.h>
  8. #include <AnKi/Gr/GrManager.h>
  9. #include <AnKi/Gr/gl/GrManagerImpl.h>
  10. #include <AnKi/Gr/gl/RenderingThread.h>
  11. namespace anki
  12. {
  13. FenceImpl::~FenceImpl()
  14. {
  15. class DeleteFenceCommand final : public GlCommand
  16. {
  17. public:
  18. GLsync m_fence;
  19. DeleteFenceCommand(GLsync fence)
  20. : m_fence(fence)
  21. {
  22. }
  23. Error operator()(GlState&)
  24. {
  25. glDeleteSync(m_fence);
  26. return Error::NONE;
  27. }
  28. };
  29. if(m_fence)
  30. {
  31. GrManagerImpl& manager = static_cast<GrManagerImpl&>(getManager());
  32. RenderingThread& thread = manager.getRenderingThread();
  33. if(!thread.isServerThread())
  34. {
  35. CommandBufferPtr commands;
  36. commands = manager.newCommandBuffer(CommandBufferInitInfo());
  37. static_cast<CommandBufferImpl&>(*commands).pushBackNewCommand<DeleteFenceCommand>(m_fence);
  38. static_cast<CommandBufferImpl&>(*commands).flush();
  39. }
  40. else
  41. {
  42. glDeleteSync(m_fence);
  43. }
  44. }
  45. }
  46. } // end namespace anki