-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
159 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#pragma once | ||
|
||
#include <functional> | ||
#include <vector> | ||
#include <map> | ||
|
||
namespace Ubpa::UECS { | ||
class CommandBuffer { | ||
public: | ||
void AddCommand(std::function<void()> command, int layer) { lcommands[layer].push_back(std::move(command)); } | ||
void AddCommandBuffer(CommandBuffer cb) { | ||
for (auto& [layer, cmds] : cb.lcommands) { | ||
auto& dst = lcommands[layer]; | ||
dst.reserve(dst.size() + cmds.size()); | ||
for (auto& cmd : cmds) | ||
dst.push_back(std::move(cmd)); | ||
} | ||
} | ||
bool Empty() const noexcept { | ||
for (const auto& [layer, cmds] : lcommands) { | ||
if (!cmds.empty()) | ||
return false; | ||
} | ||
return true; | ||
} | ||
void Clear() { lcommands.clear(); } | ||
|
||
auto& GetCommands() noexcept { return lcommands; } | ||
const auto& GetCommands() const noexcept { return lcommands; } | ||
private: | ||
std::map<int, std::vector<std::function<void()>>> lcommands; | ||
}; | ||
|
||
class CommandBufferView { | ||
public: | ||
CommandBufferView(CommandBuffer* cb = nullptr) : commandBuffer{ cb } {} | ||
CommandBuffer* GetCommandBuffer() const noexcept { return commandBuffer; } | ||
CommandBuffer* operator->()const noexcept { return commandBuffer; } | ||
private: | ||
CommandBuffer* commandBuffer; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.