| 21 | */ |
| 22 | template<typename Context> |
| 23 | RTC_FORCEINLINE bool push(Context context, |
| 24 | unsigned instanceId, |
| 25 | unsigned instancePrimId) |
| 26 | { |
| 27 | #if RTC_MAX_INSTANCE_LEVEL_COUNT > 1 |
| 28 | const bool spaceAvailable = context->instStackSize < RTC_MAX_INSTANCE_LEVEL_COUNT; |
| 29 | /* We assert here because instances are silently dropped when the stack is full. |
| 30 | This might be quite hard to find in production. */ |
| 31 | assert(spaceAvailable); |
| 32 | if (likely(spaceAvailable)) { |
| 33 | context->instID[context->instStackSize] = instanceId; |
| 34 | #if defined(RTC_GEOMETRY_INSTANCE_ARRAY) |
| 35 | context->instPrimID[context->instStackSize] = instancePrimId; |
| 36 | #endif |
| 37 | context->instStackSize++; |
| 38 | } |
| 39 | return spaceAvailable; |
| 40 | #else |
| 41 | const bool spaceAvailable = (context->instID[0] == RTC_INVALID_GEOMETRY_ID); |
| 42 | assert(spaceAvailable); |
| 43 | if (likely(spaceAvailable)) { |
| 44 | context->instID[0] = instanceId; |
| 45 | #if defined(RTC_GEOMETRY_INSTANCE_ARRAY) |
| 46 | context->instPrimID[0] = instancePrimId; |
| 47 | #endif |
| 48 | } |
| 49 | return spaceAvailable; |
| 50 | #endif |
| 51 | } |
| 52 | |
| 53 | /* |
| 54 | * Pop the last instance pushed to the stack. |
no test coverage detected