RavEngine
Loading...
Searching...
No Matches
NvFlowDatabase.h
1// Redistribution and use in source and binary forms, with or without
2// modification, are permitted provided that the following conditions
3// are met:
4// * Redistributions of source code must retain the above copyright
5// notice, this list of conditions and the following disclaimer.
6// * Redistributions in binary form must reproduce the above copyright
7// notice, this list of conditions and the following disclaimer in the
8// documentation and/or other materials provided with the distribution.
9// * Neither the name of NVIDIA CORPORATION nor the names of its
10// contributors may be used to endorse or promote products derived
11// from this software without specific prior written permission.
12//
13// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
14// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
17// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24//
25// Copyright (c) 2014-2022 NVIDIA Corporation. All rights reserved.
26
27
28#pragma once
29
30#include "NvFlowReflect.h"
31#include "NvFlowArray.h"
32
33#include "NvFlowDeepCopy.h"
34
35#include <string.h>
36
37struct NvFlowDatabaseContext;
38
40
42
44{
45 NvFlowDatabasePrim*(NV_FLOW_ABI *createPrim)(
46 NvFlowDatabaseContext* context,
47 NvFlowUint64 version,
48 NvFlowDatabasePrim* parent,
49 const char* displayTypename,
50 const char* path,
51 const char* name);
52
53 void(NV_FLOW_ABI* updatePrim)(
54 NvFlowDatabaseContext* context,
55 NvFlowUint64 version,
56 NvFlowUint64 minActiveVersion,
57 NvFlowDatabasePrim* prim);
58
59 void(NV_FLOW_ABI* markDestroyedPrim)(NvFlowDatabaseContext* context, NvFlowDatabasePrim* prim);
60
61 void(NV_FLOW_ABI* destroyPrim)(NvFlowDatabaseContext* context, NvFlowDatabasePrim* prim);
62
63 NvFlowDatabaseAttr*(NV_FLOW_ABI* createAttr)(
64 NvFlowDatabaseContext* context,
65 NvFlowUint64 version,
66 NvFlowDatabasePrim* prim,
67 const NvFlowReflectData* reflectData,
68 NvFlowUint8* mappedData);
69
70 void(NV_FLOW_ABI* updateAttr)(
71 NvFlowDatabaseContext* context,
72 NvFlowUint64 version,
73 NvFlowUint64 minActiveVersion,
74 NvFlowDatabaseAttr* attr,
75 const NvFlowReflectData* reflectData,
76 NvFlowUint8* mappedData);
77
78 void(NV_FLOW_ABI* markDestroyedAttr)(NvFlowDatabaseContext* context, NvFlowDatabaseAttr* attr);
79
80 void(NV_FLOW_ABI* destroyAttr)(NvFlowDatabaseContext* context, NvFlowDatabaseAttr* attr);
81};
82
84{
86 void append(const char* str)
87 {
88 if (data.size > 0u)
89 {
90 data.size--;
91 }
92 if (str)
93 {
94 NvFlowUint64 idx = 0u;
95 while (str[idx])
96 {
97 data.pushBack(str[idx]);
98 idx++;
99 }
100 data.pushBack('\0');
101 }
102 }
103 void set(const char* str)
104 {
105 data.size = 0u;
106 append(str);
107 }
108 const char* get()
109 {
110 return data.data;
111 }
112};
113
115{
116 struct Prim
117 {
118 NvFlowDatabasePrim* prim;
119 NvFlowArrayPointer<Prim*> childPrims;
122 };
123 struct Data
124 {
126 NvFlowUint64 version;
127 NvFlowReflectDeepCopy* deepCopy = nullptr;
128 ~Data()
129 {
130 if (deepCopy)
131 {
132 NvFlowReflectDeepCopy_destroy(deepCopy);
133 deepCopy = nullptr;
134 }
135 }
136 };
137
138 const NvFlowReflectDataType* dataType = nullptr;
139 NvFlowDatabaseString displayTypename;
141 NvFlowUint64 luid = 0llu;
142 NvFlowUint64 luidByteOffset = ~0llu;
143
144 Prim rootPrim;
146 NvFlowBool32 markedForDestroy = NV_FLOW_FALSE;
147
148 NvFlowArray<NvFlowUint8> defaultData;
149
151 {
152 NvFlowUint64 childIdx;
153 const NvFlowReflectDataType* reflectDataType;
154 NvFlowUint8* data;
155 Prim* prim;
156 };
157
158 NvFlowUint8* mapDataVersionAndType(NvFlowUint64 version, const NvFlowReflectDataType** pReflectDataType)
159 {
160 for (NvFlowUint64 idx = datas.activeCount() - 1u; idx < datas.activeCount(); idx--)
161 {
162 if (datas[idx]->version == version)
163 {
164 if (pReflectDataType)
165 {
166 *pReflectDataType = dataType;
167 }
168 return datas[idx]->data.data;
169 }
170 }
171
172 NvFlowDatabaseInstance::Data* data = datas.allocateBackPointer();
173 data->version = version;
174 data->data.reserve(dataType->elementSize);
175 data->data.size = dataType->elementSize;
176 if (datas.activeCount() >= 2u)
177 {
178 NvFlowDatabaseInstance::Data* oldData = datas[datas.activeCount() - 2u];
179 memcpy(data->data.data, oldData->data.data, data->data.size);
180 }
181 else if (dataType->defaultValue)
182 {
183 memcpy(data->data.data, dataType->defaultValue, data->data.size);
184 }
185 else
186 {
187 memset(data->data.data, 0, data->data.size);
188 }
189
190 // enforce luid
191 if (luidByteOffset < dataType->elementSize)
192 {
193 *((NvFlowUint64*)(data->data.data + luidByteOffset)) = luid;
194 }
195
196 if (pReflectDataType)
197 {
198 *pReflectDataType = dataType;
199 }
200 return data->data.data;
201 }
202
203 NvFlowUint8* mapDataVersion(NvFlowUint64 version)
204 {
205 const NvFlowReflectDataType* reflectDataType = nullptr;
206 return mapDataVersionAndType(version, &reflectDataType);
207 }
208
209 void deepCopyDataVersion(NvFlowUint64 version)
210 {
211 Data* data = nullptr;
212 for (NvFlowUint64 idx = datas.activeCount() - 1u; idx < datas.activeCount(); idx--)
213 {
214 if (datas[idx]->version == version)
215 {
216 data = datas[idx];
217 }
218 }
219 if (data)
220 {
221 if (!data->deepCopy)
222 {
223 data->deepCopy = NvFlowReflectDeepCopy_create();
224 }
225
226 NvFlowUint8* copyData = NvFlowReflectDeepCopy_update(data->deepCopy, data->data.data, dataType);
227
228 // copy root struct over mapped to get safe pointers
229 memcpy(data->data.data, copyData, data->data.size);
230 }
231 }
232
233 NvFlowUint8* mapDataVersionReadOnly(NvFlowUint64 version)
234 {
235 // TODO: Simply update version to avoid copy
236 return mapDataVersion(version);
237 }
238
239 template<const NvFlowDatabaseInterface* iface>
240 void init(NvFlowDatabaseContext* context, NvFlowUint64 version, NvFlowUint64 luidIn, const NvFlowReflectDataType* dataTypeIn, const char* displayTypenameIn, const char* pathIn, const char* nameIn)
241 {
242 dataType = dataTypeIn;
243 displayTypename.set(displayTypenameIn);
244 name.set(nameIn);
245 luid = luidIn;
246 luidByteOffset = ~0llu;
247 // try to find luid offset in root
248 for (NvFlowUint64 childIdx = 0u; childIdx < dataType->childReflectDataCount; childIdx++)
249 {
250 if (strcmp(dataType->childReflectDatas[childIdx].name, "luid") == 0)
251 {
252 luidByteOffset = dataType->childReflectDatas[childIdx].dataOffset;
253 break;
254 }
255 }
256
257 rootPrim.path.set(pathIn);
258 rootPrim.prim = nullptr;
259 if (iface->createPrim)
260 {
261 rootPrim.prim = iface->createPrim(
262 context,
263 version,
264 nullptr,
265 displayTypename.get(),
266 rootPrim.path.get(),
267 name.get());
268 }
269
270 NvFlowUint8* mappedData = mapDataVersion(version);
271
272 StackState state = { 0llu, dataType, mappedData, &rootPrim };
274 for (; state.childIdx < state.reflectDataType->childReflectDataCount; state.childIdx++)
275 {
276 // push prims
277 while (state.reflectDataType->childReflectDatas[state.childIdx].dataType->dataType == eNvFlowType_struct)
278 {
279 const NvFlowReflectData* childReflectData = state.reflectDataType->childReflectDatas + state.childIdx;
280 auto childPrim = state.prim->childPrims.allocateBackPointer();
281 state.prim->attrs.pushBack(nullptr);
282
283 // form path
284 childPrim->path.set(state.prim->path.get());
285 childPrim->path.append("/");
286 childPrim->path.append(childReflectData->name);
287
288 childPrim->prim = nullptr;
289 if (iface->createPrim)
290 {
291 childPrim->prim = iface->createPrim(
292 context,
293 version,
294 state.prim->prim,
295 NvFlowReflectTrimPrefix(childReflectData->dataType->structTypename),
296 childPrim->path.get(),
297 childReflectData->name);
298 }
299
300 stateStack.pushBack(state);
301 state.childIdx = 0u;
302 state.reflectDataType = childReflectData->dataType;
303 state.data += childReflectData->dataOffset;
304 state.prim = childPrim;
305 }
306 // attributes
307 if (state.childIdx < state.reflectDataType->childReflectDataCount)
308 {
309 const NvFlowReflectData* childReflectData = state.reflectDataType->childReflectDatas + state.childIdx;
310 NvFlowDatabaseAttr* attr = nullptr;
311 if (iface->createAttr)
312 {
313 attr = iface->createAttr(context, version, state.prim->prim, childReflectData, state.data);
314 }
315 state.prim->attrs.pushBack(attr);
316 state.prim->childPrims.pushBack(nullptr);
317 }
318 // pop prims
319 while (state.childIdx + 1u >= state.reflectDataType->childReflectDataCount && stateStack.size > 0u)
320 {
321 state = stateStack.back();
322 stateStack.popBack();
323 }
324 }
325 }
326
327 void process(NvFlowUint64 version, NvFlowReflectProcess_t processReflect, void* userdata)
328 {
329 NvFlowUint8* mappedData = mapDataVersion(version);
330
331 processReflect(mappedData, dataType, userdata);
332 }
333
334 template<const NvFlowDatabaseInterface* iface>
335 void update(NvFlowDatabaseContext* context, NvFlowUint64 version, NvFlowUint64 minActiveVersion)
336 {
337 if (!markedForDestroy)
338 {
339 NvFlowUint8* mappedData = mapDataVersion(version);
340
341 if (rootPrim.prim)
342 {
343 iface->updatePrim(context, version, minActiveVersion, rootPrim.prim);
344 }
345
346 StackState state = { 0llu, dataType, mappedData, &rootPrim };
348 for (; state.childIdx < state.reflectDataType->childReflectDataCount; state.childIdx++)
349 {
350 // push prims
351 while (state.reflectDataType->childReflectDatas[state.childIdx].dataType->dataType == eNvFlowType_struct)
352 {
353 const NvFlowReflectData* childReflectData = state.reflectDataType->childReflectDatas + state.childIdx;
354 auto childPrim = state.prim->childPrims[state.childIdx];
355 if (childPrim->prim)
356 {
357 iface->updatePrim(context, version, minActiveVersion, childPrim->prim);
358 }
359
360 stateStack.pushBack(state);
361 state.childIdx = 0u;
362 state.reflectDataType = childReflectData->dataType;
363 state.data += childReflectData->dataOffset;
364 state.prim = childPrim;
365 }
366 // attributes
367 if (state.childIdx < state.reflectDataType->childReflectDataCount)
368 {
369 const NvFlowReflectData* childReflectData = state.reflectDataType->childReflectDatas + state.childIdx;
370 auto attr = state.prim->attrs[state.childIdx];
371 if (attr)
372 {
373 iface->updateAttr(context, version, minActiveVersion, attr, childReflectData, state.data);
374 }
375 }
376 // pop prims
377 while (state.childIdx + 1u >= state.reflectDataType->childReflectDataCount && stateStack.size > 0u)
378 {
379 state = stateStack.back();
380 stateStack.popBack();
381 }
382 }
383 }
384
385 NvFlowUint freeTreshold = markedForDestroy ? 0u : 1u;
386 while (datas.activeCount() > freeTreshold && datas.front()->version < minActiveVersion)
387 {
388 datas.popFront();
389 }
390 }
391
392 template<const NvFlowDatabaseInterface* iface>
393 void markForDestroy(NvFlowDatabaseContext* context)
394 {
395 NvFlowUint8* mappedData = nullptr;
396 StackState state = { 0llu, dataType, mappedData, &rootPrim };
398 for (; state.childIdx < state.reflectDataType->childReflectDataCount; state.childIdx++)
399 {
400 // push prims
401 while (state.reflectDataType->childReflectDatas[state.childIdx].dataType->dataType == eNvFlowType_struct)
402 {
403 const NvFlowReflectData* childReflectData = state.reflectDataType->childReflectDatas + state.childIdx;
404 auto childPrim = state.prim->childPrims[state.childIdx];
405
406 stateStack.pushBack(state);
407 state.childIdx = 0u;
408 state.reflectDataType = childReflectData->dataType;
409 state.data += childReflectData->dataOffset;
410 state.prim = childPrim;
411 }
412 // attributes
413 if (state.childIdx < state.reflectDataType->childReflectDataCount)
414 {
415 auto attr = state.prim->attrs[state.childIdx];
416 if (attr)
417 {
418 iface->markDestroyedAttr(context, attr);
419 }
420 }
421 // pop prims
422 while (state.childIdx + 1u >= state.reflectDataType->childReflectDataCount && stateStack.size > 0u)
423 {
424 if (state.prim->prim)
425 {
426 iface->markDestroyedPrim(context, state.prim->prim);
427 }
428 state = stateStack.back();
429 stateStack.popBack();
430 }
431 }
432 if (rootPrim.prim)
433 {
434 iface->markDestroyedPrim(context, rootPrim.prim);
435 }
436
437 markedForDestroy = NV_FLOW_TRUE;
438 }
439
440 template<const NvFlowDatabaseInterface* iface>
441 void destroy(NvFlowDatabaseContext* context)
442 {
443 NvFlowUint8* mappedData = nullptr;
444 StackState state = { 0llu, dataType, mappedData, &rootPrim };
446 for (; state.childIdx < state.reflectDataType->childReflectDataCount; state.childIdx++)
447 {
448 // push prims
449 while (state.reflectDataType->childReflectDatas[state.childIdx].dataType->dataType == eNvFlowType_struct)
450 {
451 const NvFlowReflectData* childReflectData = state.reflectDataType->childReflectDatas + state.childIdx;
452 auto childPrim = state.prim->childPrims[state.childIdx];
453
454 stateStack.pushBack(state);
455 state.childIdx = 0u;
456 state.reflectDataType = childReflectData->dataType;
457 state.data += childReflectData->dataOffset;
458 state.prim = childPrim;
459 }
460 // attributes
461 if (state.childIdx < state.reflectDataType->childReflectDataCount)
462 {
463 auto attr = state.prim->attrs[state.childIdx];
464 if (attr)
465 {
466 iface->destroyAttr(context, attr);
467 attr = nullptr;
468 }
469 }
470 // pop prims
471 while (state.childIdx + 1u >= state.reflectDataType->childReflectDataCount && stateStack.size > 0u)
472 {
473 if (state.prim->prim)
474 {
475 iface->destroyPrim(context, state.prim->prim);
476 state.prim->prim = nullptr;
477 }
478 state = stateStack.back();
479 stateStack.popBack();
480 }
481 }
482 if (rootPrim.prim)
483 {
484 iface->destroyPrim(context, rootPrim.prim);
485 rootPrim.prim = nullptr;
486 }
487 }
488};
489
491{
492 const NvFlowReflectDataType* dataType = nullptr;
493 NvFlowDatabaseString displayTypeName;
495
497 {
499 NvFlowArray<NvFlowUint8*> instanceDatas;
500 };
502
503 void init(const NvFlowReflectDataType* dataTypeIn, const char* displayTypeNameIn)
504 {
505 dataType = dataTypeIn;
506 displayTypeName.set(displayTypeNameIn);
507 }
508
509 template<const NvFlowDatabaseInterface* iface>
510 void update(NvFlowDatabaseContext* context, NvFlowUint64 version, NvFlowUint64 minActiveVersion)
511 {
512 for (NvFlowUint instanceIdx = 0u; instanceIdx < instances.size; instanceIdx++)
513 {
514 instances[instanceIdx]->update<iface>(context, version, minActiveVersion);
515 }
516
517 // release instances
518 {
519 NvFlowUint64 keepCount = 0llu;
520 for (NvFlowUint instanceIdx = 0u; instanceIdx < instances.size; instanceIdx++)
521 {
522 if (instances[instanceIdx]->markedForDestroy && instances[instanceIdx]->datas.activeCount() == 0u)
523 {
524 instances[instanceIdx]->destroy<iface>(context);
525 instances.deletePointerAtIndex(instanceIdx);
526 }
527 else
528 {
529 instances.swapPointers(keepCount, instanceIdx);
530 keepCount++;
531 }
532 }
533 instances.size = keepCount;
534 }
535
536 // release snapshots
537 while (snapshots.activeCount() > 0u && snapshots.front()->snapshot.version < minActiveVersion)
538 {
539 snapshots.popFront();
540 }
541 }
542
543 template<const NvFlowDatabaseInterface* iface>
544 void destroy(NvFlowDatabaseContext* context)
545 {
546 for (NvFlowUint instanceIdx = 0u; instanceIdx < instances.size; instanceIdx++)
547 {
548 instances[instanceIdx]->destroy<iface>(context);
549 }
550 instances.deletePointers();
551 }
552
553 void getSnapshot(NvFlowDatabaseTypeSnapshot* snapshot, NvFlowUint64 version)
554 {
555 auto ptr = snapshots.allocateBackPointer();
556
557 ptr->snapshot.version = version;
558 ptr->snapshot.dataType = dataType;
559 ptr->instanceDatas.size = 0u;
560
561 for (NvFlowUint instanceIdx = 0u; instanceIdx < instances.size; instanceIdx++)
562 {
563 if (!instances[instanceIdx]->markedForDestroy)
564 {
565 NvFlowUint8* data = instances[instanceIdx]->mapDataVersionReadOnly(version);
566
567 ptr->instanceDatas.pushBack(data);
568 }
569 }
570
571 ptr->snapshot.instanceDatas = ptr->instanceDatas.data;
572 ptr->snapshot.instanceCount = ptr->instanceDatas.size;
573
574 if (snapshot)
575 {
576 *snapshot = ptr->snapshot;
577 }
578 }
579};
580
582{
584
585 struct Snapshot
586 {
587 NvFlowDatabaseSnapshot snapshot;
589 };
591
592 NvFlowUint64 luidCounter = 0llu;
593
594 NvFlowDatabaseType* createType(const NvFlowReflectDataType* dataTypeIn, const char* displayTypeName)
595 {
596 auto ptr = types.allocateBackPointer();
597
598 ptr->init(dataTypeIn, displayTypeName);
599
600 return ptr;
601 }
602
603 template<const NvFlowDatabaseInterface* iface>
604 NvFlowDatabaseInstance* createInstance(NvFlowDatabaseContext* context, NvFlowUint64 version, NvFlowDatabaseType* type, const char* pathIn, const char* name)
605 {
606 auto ptr = type->instances.allocateBackPointer();
607
608 luidCounter++;
609
610 ptr->init<iface>(context, version, luidCounter, type->dataType, type->displayTypeName.get(), pathIn, name);
611
612 return ptr;
613 }
614
615 template<const NvFlowDatabaseInterface* iface>
616 void update(NvFlowDatabaseContext* context, NvFlowUint64 version, NvFlowUint64 minActiveVersion)
617 {
618 for (NvFlowUint64 typeIdx = 0u; typeIdx < types.size; typeIdx++)
619 {
620 types[typeIdx]->update<iface>(context, version, minActiveVersion);
621 }
622
623 // release snapshots
624 while (snapshots.activeCount() > 0u && snapshots.front()->snapshot.version < minActiveVersion)
625 {
626 snapshots.popFront();
627 }
628 }
629
630 template<const NvFlowDatabaseInterface* iface>
631 void markInstanceForDestroy(NvFlowDatabaseContext* context, NvFlowDatabaseInstance* ptr)
632 {
633 ptr->markForDestroy<iface>(context);
634 }
635
636 template<const NvFlowDatabaseInterface* iface>
637 void markAllInstancesForDestroy(NvFlowDatabaseContext* context)
638 {
639 for (NvFlowUint64 typeIdx = 0u; typeIdx < types.size; typeIdx++)
640 {
641 NvFlowDatabaseType* type = types[typeIdx];
642 for (NvFlowUint instanceIdx = 0u; instanceIdx < type->instances.size; instanceIdx++)
643 {
644 type->instances[instanceIdx]->markForDestroy<iface>(context);
645 }
646 }
647 }
648
649 template<const NvFlowDatabaseInterface* iface>
650 NvFlowBool32 snapshotPending(NvFlowDatabaseContext* context, NvFlowUint64 version, NvFlowUint64 minActiveVersion)
651 {
652 update<iface>(context, version, minActiveVersion);
653
654 NvFlowBool32 anySnapshotPending = NV_FLOW_FALSE;
655 for (NvFlowUint64 typeIdx = 0u; typeIdx < types.size; typeIdx++)
656 {
657 if (types[typeIdx]->snapshots.activeCount() > 0u)
658 {
659 anySnapshotPending = NV_FLOW_TRUE;
660 }
661 }
662 if (snapshots.activeCount() > 0u)
663 {
664 anySnapshotPending = NV_FLOW_TRUE;
665 }
666 return anySnapshotPending;
667 }
668
669 template<const NvFlowDatabaseInterface* iface>
670 void destroy(NvFlowDatabaseContext* context)
671 {
672 for (NvFlowUint64 typeIdx = 0u; typeIdx < types.size; typeIdx++)
673 {
674 types[typeIdx]->destroy<iface>(context);
675 }
676 }
677
678 void getSnapshot(NvFlowDatabaseSnapshot* snapshot, NvFlowUint64 version)
679 {
680 auto ptr = snapshots.allocateBackPointer();
681
682 ptr->snapshot.version = version;
683 ptr->typeSnapshots.size = 0u;
684
685 for (NvFlowUint64 typeIdx = 0u; typeIdx < types.size; typeIdx++)
686 {
687 NvFlowDatabaseTypeSnapshot typeSnapshot = {};
688 types[typeIdx]->getSnapshot(&typeSnapshot, version);
689
690 ptr->typeSnapshots.pushBack(typeSnapshot);
691 }
692
693 ptr->snapshot.typeSnapshots = ptr->typeSnapshots.data;
694 ptr->snapshot.typeSnapshotCount = ptr->typeSnapshots.size;
695
696 if (snapshot)
697 {
698 *snapshot = ptr->snapshot;
699 }
700 }
701
702 void enumerateActiveInstances(NvFlowDatabaseInstance** pInstances, NvFlowUint64* pInstanceCount)
703 {
704 if (!pInstances && pInstanceCount)
705 {
706 NvFlowUint64 activeCount = 0llu;
707 for (NvFlowUint64 typeIdx = 0u; typeIdx < types.size; typeIdx++)
708 {
709 NvFlowDatabaseType* type = types[typeIdx];
710 for (NvFlowUint instanceIdx = 0u; instanceIdx < type->instances.size; instanceIdx++)
711 {
712 if (!type->instances[instanceIdx]->markedForDestroy)
713 {
714 activeCount++;
715 }
716 }
717 }
718 *pInstanceCount = activeCount;
719 }
720 if (pInstances && pInstanceCount)
721 {
722 NvFlowUint64 activeCount = 0llu;
723 for (NvFlowUint64 typeIdx = 0u; typeIdx < types.size; typeIdx++)
724 {
725 NvFlowDatabaseType* type = types[typeIdx];
726 for (NvFlowUint instanceIdx = 0u; instanceIdx < type->instances.size; instanceIdx++)
727 {
728 if (!type->instances[instanceIdx]->markedForDestroy)
729 {
730 if (activeCount < (*pInstanceCount))
731 {
732 pInstances[activeCount] = type->instances[instanceIdx];
733 activeCount++;
734 }
735 }
736 }
737 }
738 *pInstanceCount = activeCount;
739 }
740 }
741};
Definition base.h:1940
Definition NvFlowArray.h:213
Definition NvFlowArray.h:36
Definition EditorFlow.cpp:102
Definition NvFlowDatabase.h:124
Definition NvFlowDatabase.h:117
Definition NvFlowDatabase.h:151
Definition NvFlowDatabase.h:115
Definition NvFlowDatabase.h:44
Definition EditorFlow.cpp:30
Definition NvFlowReflect.h:488
Definition NvFlowDatabase.h:84
Definition NvFlowReflect.h:480
Definition NvFlowDatabase.h:497
Definition NvFlowDatabase.h:491
Definition NvFlowDatabase.h:586
Definition NvFlowDatabase.h:582
Definition NvFlowReflect.h:182
Definition NvFlowReflect.h:170
Definition NvFlowDeepCopy.h:43
Definition NvFlowArray.h:281