MCPcopy Create free account
hub / github.com/RenderKit/embree / allocNextSegment

Method allocNextSegment

kernels/subdiv/tessellation_cache.cpp:86–132  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

84 }
85
86 void SharedLazyTessellationCache::allocNextSegment()
87 {
88 if (reset_state.try_lock())
89 {
90 if (next_block >= switch_block_threshold)
91 {
92 /* lock the linked list of thread states */
93
94 linkedlist_mtx.lock();
95
96 /* block all threads */
97 for (ThreadWorkState *t=current_t_state;t!=nullptr;t=t->next)
98 if (lockThread(t,THREAD_BLOCK_ATOMIC_ADD) != 0)
99 waitForUsersLessEqual(t,THREAD_BLOCK_ATOMIC_ADD);
100
101 /* switch to the next segment */
102 addCurrentIndex();
103 CACHE_STATS(PRINT("RESET TESS CACHE"));
104
105#if FORCE_SIMPLE_FLUSH == 1
106 next_block = 0;
107 switch_block_threshold = maxBlocks;
108#else
109 const size_t region = localTime % NUM_CACHE_SEGMENTS;
110 next_block = region * (maxBlocks/NUM_CACHE_SEGMENTS);
111 switch_block_threshold = next_block + (maxBlocks/NUM_CACHE_SEGMENTS);
112 assert( switch_block_threshold <= maxBlocks );
113#endif
114
115 CACHE_STATS(SharedTessellationCacheStats::cache_flushes++);
116
117 /* release all blocked threads */
118
119 for (ThreadWorkState *t=current_t_state;t!=nullptr;t=t->next)
120 unlockThread(t,-THREAD_BLOCK_ATOMIC_ADD);
121
122 /* unlock the linked list of thread states */
123
124 linkedlist_mtx.unlock();
125
126
127 }
128 reset_state.unlock();
129 }
130 else
131 reset_state.wait_until_unlocked();
132 }
133
134
135 void SharedLazyTessellationCache::reset()

Callers 1

mallocFunction · 0.80

Calls 7

lockThreadFunction · 0.85
addCurrentIndexFunction · 0.85
unlockThreadFunction · 0.85
wait_until_unlockedMethod · 0.80
try_lockMethod · 0.45
lockMethod · 0.45
unlockMethod · 0.45

Tested by

no test coverage detected