| 1 | //************************************ bs::framework - Copyright 2018 Marko Pintera **************************************// |
|---|---|
| 2 | //*********** Licensed under the MIT license. See LICENSE.md for full terms. This notice is not to be removed. ***********// |
| 3 | #include "BsGLCommandBuffer.h" |
| 4 | |
| 5 | namespace bs { namespace ct |
| 6 | { |
| 7 | GLCommandBuffer::GLCommandBuffer(GpuQueueType type, UINT32 deviceIdx, UINT32 queueIdx, bool secondary) |
| 8 | : CommandBuffer(type, deviceIdx, queueIdx, secondary) |
| 9 | { |
| 10 | if (deviceIdx != 0) |
| 11 | BS_EXCEPT(InvalidParametersException, "Only a single device supported on DX11."); |
| 12 | } |
| 13 | |
| 14 | void GLCommandBuffer::queueCommand(const std::function<void()> command) |
| 15 | { |
| 16 | mCommands.push_back(command); |
| 17 | } |
| 18 | |
| 19 | void GLCommandBuffer::appendSecondary(const SPtr<GLCommandBuffer>& secondaryBuffer) |
| 20 | { |
| 21 | #if BS_DEBUG_MODE |
| 22 | if(!secondaryBuffer->mIsSecondary) |
| 23 | { |
| 24 | LOGERR("Cannot append a command buffer that is not secondary."); |
| 25 | return; |
| 26 | } |
| 27 | |
| 28 | if(mIsSecondary) |
| 29 | { |
| 30 | LOGERR("Cannot append a buffer to a secondary command buffer."); |
| 31 | return; |
| 32 | } |
| 33 | #endif |
| 34 | |
| 35 | for (auto& entry : secondaryBuffer->mCommands) |
| 36 | mCommands.push_back(entry); |
| 37 | } |
| 38 | |
| 39 | void GLCommandBuffer::executeCommands() |
| 40 | { |
| 41 | #if BS_DEBUG_MODE |
| 42 | if (mIsSecondary) |
| 43 | { |
| 44 | LOGERR("Cannot execute commands on a secondary buffer."); |
| 45 | return; |
| 46 | } |
| 47 | #endif |
| 48 | |
| 49 | for (auto& entry : mCommands) |
| 50 | entry(); |
| 51 | } |
| 52 | |
| 53 | void GLCommandBuffer::clear() |
| 54 | { |
| 55 | mCommands.clear(); |
| 56 | } |
| 57 | }} |