MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / CompressWorker

Method CompressWorker

Source/ThirdParty/tracy/client/TracyProfiler.cpp:2194–2262  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2192
2193#ifndef TRACY_NO_FRAME_IMAGE
2194void Profiler::CompressWorker()
2195{
2196 ThreadExitHandler threadExitHandler;
2197 SetThreadName( "Tracy DXT1" );
2198 while( m_timeBegin.load( std::memory_order_relaxed ) == 0 ) std::this_thread::sleep_for( std::chrono::milliseconds( 10 ) );
2199
2200#ifdef TRACY_USE_RPMALLOC
2201 rpmalloc_thread_initialize();
2202#endif
2203
2204 for(;;)
2205 {
2206 const auto shouldExit = ShouldExit();
2207
2208 {
2209 bool lockHeld = true;
2210 while( !m_fiLock.try_lock() )
2211 {
2212 if( m_shutdownManual.load( std::memory_order_relaxed ) )
2213 {
2214 lockHeld = false;
2215 break;
2216 }
2217 }
2218 if( !m_fiQueue.empty() ) m_fiQueue.swap( m_fiDequeue );
2219 if( lockHeld )
2220 {
2221 m_fiLock.unlock();
2222 }
2223 }
2224
2225 const auto sz = m_fiDequeue.size();
2226 if( sz > 0 )
2227 {
2228 auto fi = m_fiDequeue.data();
2229 auto end = fi + sz;
2230 while( fi != end )
2231 {
2232 const auto w = fi->w;
2233 const auto h = fi->h;
2234 const auto csz = size_t( w * h / 2 );
2235 auto etc1buf = (char*)tracy_malloc( csz );
2236 CompressImageDxt1( (const char*)fi->image, etc1buf, w, h );
2237 tracy_free( fi->image );
2238
2239 TracyLfqPrepare( QueueType::FrameImage );
2240 MemWrite( &item->frameImageFat.image, (uint64_t)etc1buf );
2241 MemWrite( &item->frameImageFat.frame, fi->frame );
2242 MemWrite( &item->frameImageFat.w, w );
2243 MemWrite( &item->frameImageFat.h, h );
2244 uint8_t flip = fi->flip;
2245 MemWrite( &item->frameImageFat.flip, flip );
2246 TracyLfqCommit;
2247
2248 fi++;
2249 }
2250 m_fiDequeue.clear();
2251 }

Callers 1

LaunchCompressWorkerFunction · 0.80

Calls 13

tracy_mallocFunction · 0.85
tracy_freeFunction · 0.85
MemWriteFunction · 0.85
SetThreadNameFunction · 0.50
loadMethod · 0.45
try_lockMethod · 0.45
emptyMethod · 0.45
swapMethod · 0.45
unlockMethod · 0.45
sizeMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected