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 "Renderer/BsParamBlocks.h" |
4 | #include "RenderAPI/BsGpuParam.h" |
5 | |
6 | namespace bs { namespace ct |
7 | { |
8 | ParamBlock::~ParamBlock() |
9 | { |
10 | ParamBlockManager::unregisterBlock(this); |
11 | } |
12 | |
13 | Vector<ParamBlock*> ParamBlockManager::sToInitialize; |
14 | |
15 | ParamBlockManager::ParamBlockManager() |
16 | { |
17 | for (auto& entry : sToInitialize) |
18 | entry->initialize(); |
19 | |
20 | sToInitialize.clear(); |
21 | } |
22 | |
23 | void ParamBlockManager::registerBlock(ParamBlock* paramBlock) |
24 | { |
25 | if (isStarted()) |
26 | paramBlock->initialize(); |
27 | else |
28 | sToInitialize.push_back(paramBlock); |
29 | } |
30 | |
31 | void ParamBlockManager::unregisterBlock(ParamBlock* paramBlock) |
32 | { |
33 | auto iterFind = std::find(sToInitialize.begin(), sToInitialize.end(), paramBlock); |
34 | if (iterFind != sToInitialize.end()) |
35 | sToInitialize.erase(iterFind); |
36 | } |
37 | }} |