BsCommandBufferManager.cpp 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. #include "BsCommandBufferManager.h"
  4. namespace BansheeEngine
  5. {
  6. SPtr<CommandBuffer> CommandBufferManager::create(CommandBufferType type, UINT32 deviceIdx, UINT32 queueIdx,
  7. bool secondary)
  8. {
  9. assert(deviceIdx < BS_MAX_DEVICES);
  10. UINT32 id = -1;
  11. for(UINT32 i = 0; i < BS_MAX_COMMAND_BUFFERS; i++)
  12. {
  13. if (!mActiveCommandBuffers[deviceIdx][i])
  14. {
  15. id = i;
  16. break;
  17. }
  18. }
  19. if(id == -1)
  20. {
  21. LOGERR("Attempting to allocate more than 32 command buffers. This is not supported. ");
  22. return nullptr;
  23. }
  24. SPtr<CommandBuffer> cmdBuffer = createInternal(id, type, deviceIdx, queueIdx, secondary);;
  25. mActiveCommandBuffers[deviceIdx][id] = cmdBuffer.get();
  26. return cmdBuffer;
  27. }
  28. void CommandBufferManager::notifyCommandBufferDestroyed(UINT32 deviceIdx, UINT32 id)
  29. {
  30. mActiveCommandBuffers[deviceIdx][id] = nullptr;
  31. }
  32. }