BsD3D11CommandBuffer.cpp 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. #include "BsD3D11CommandBuffer.h"
  4. namespace bs { namespace ct
  5. {
  6. D3D11CommandBuffer::D3D11CommandBuffer(GpuQueueType type, UINT32 deviceIdx, UINT32 queueIdx, bool secondary)
  7. : CommandBuffer(type, deviceIdx, queueIdx, secondary), mActiveDrawOp(DOT_TRIANGLE_LIST)
  8. {
  9. if (deviceIdx != 0)
  10. BS_EXCEPT(InvalidParametersException, "Only a single device supported on DX11.");
  11. }
  12. void D3D11CommandBuffer::queueCommand(const std::function<void()> command)
  13. {
  14. mCommands.push_back(command);
  15. }
  16. void D3D11CommandBuffer::appendSecondary(const SPtr<D3D11CommandBuffer>& secondaryBuffer)
  17. {
  18. #if BS_DEBUG_MODE
  19. if (!secondaryBuffer->mIsSecondary)
  20. {
  21. LOGERR("Cannot append a command buffer that is not secondary.");
  22. return;
  23. }
  24. if (mIsSecondary)
  25. {
  26. LOGERR("Cannot append a buffer to a secondary command buffer.");
  27. return;
  28. }
  29. #endif
  30. for (auto& entry : secondaryBuffer->mCommands)
  31. mCommands.push_back(entry);
  32. }
  33. void D3D11CommandBuffer::executeCommands()
  34. {
  35. #if BS_DEBUG_MODE
  36. if (mIsSecondary)
  37. {
  38. LOGERR("Cannot execute commands on a secondary buffer.");
  39. return;
  40. }
  41. #endif
  42. for (auto& entry : mCommands)
  43. entry();
  44. }
  45. void D3D11CommandBuffer::clear()
  46. {
  47. mCommands.clear();
  48. }
  49. }}