BsCoreThreadAccessor.cpp 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. #include "BsCoreThreadAccessor.h"
  4. #include "BsCommandQueue.h"
  5. #include "BsRenderAPI.h"
  6. #include "BsBlendState.h"
  7. #include "BsRasterizerState.h"
  8. #include "BsDepthStencilState.h"
  9. #include "BsGpuResourceData.h"
  10. #include "BsIndexBuffer.h"
  11. #include "BsVertexBuffer.h"
  12. #include "BsVideoModeInfo.h"
  13. #include "BsGpuParams.h"
  14. #include "BsPass.h"
  15. #include "BsMaterial.h"
  16. #include "BsCoreThread.h"
  17. namespace BansheeEngine
  18. {
  19. CoreThreadAccessorBase::CoreThreadAccessorBase(CommandQueueBase* commandQueue)
  20. :mCommandQueue(commandQueue)
  21. {
  22. }
  23. CoreThreadAccessorBase::~CoreThreadAccessorBase()
  24. {
  25. bs_delete(mCommandQueue);
  26. }
  27. AsyncOp CoreThreadAccessorBase::queueReturnCommand(std::function<void(AsyncOp&)> commandCallback)
  28. {
  29. return mCommandQueue->queueReturn(commandCallback);
  30. }
  31. void CoreThreadAccessorBase::queueCommand(std::function<void()> commandCallback)
  32. {
  33. mCommandQueue->queue(commandCallback);
  34. }
  35. void CoreThreadAccessorBase::submitToCoreThread(bool blockUntilComplete)
  36. {
  37. Queue<QueuedCommand>* commands = mCommandQueue->flush();
  38. gCoreThread().queueCommand(std::bind(&CommandQueueBase::playback, mCommandQueue, commands), blockUntilComplete);
  39. }
  40. void CoreThreadAccessorBase::cancelAll()
  41. {
  42. // Note that this won't free any Frame data allocated for all the canceled commands since
  43. // frame data will only get cleared at frame start
  44. mCommandQueue->cancelAll();
  45. }
  46. }