| 532 | } |
| 533 | |
| 534 | void Tr2RenderContextBase::RenderSortedBatches( const std::vector<Tr2RenderBatch>& batches, const BlueSharedString& techniqueName, Tr2RenderContext& renderContext ) |
| 535 | { |
| 536 | size_t batchCount = batches.size(); |
| 537 | |
| 538 | if( batchCount == 0 ) |
| 539 | { |
| 540 | return; |
| 541 | } |
| 542 | |
| 543 | CCP_STATS_ZONE( "Direct drawing" ); |
| 544 | #if TRINITY_PLATFORM != TRINITY_METAL |
| 545 | GPU_REGION( renderContext, "Direct drawing" ); |
| 546 | #endif |
| 547 | |
| 548 | #if TRINITY_PLATFORM_SUPPORTS_PARALLEL_CONTEXTS |
| 549 | extern bool g_useParallelEncoding; |
| 550 | if( g_useParallelEncoding && batchCount > 256 && !Tr2GpuProfiler::GetProfiler().IsCapturing() ) |
| 551 | { |
| 552 | std::vector<std::vector<Tr2RenderBatch>::const_iterator> encodingTasks; |
| 553 | for( auto batch = batches.begin(); batch != batches.end(); ) |
| 554 | { |
| 555 | encodingTasks.push_back( batch ); |
| 556 | batch += batch->m_groupCount; |
| 557 | } |
| 558 | |
| 559 | const uint32_t coresCount = std::thread::hardware_concurrency(); |
| 560 | if( renderContext.BeginParallelEncoding( std::min( coresCount, uint32_t( encodingTasks.size() ) ) ) ) |
| 561 | { |
| 562 | Tr2ParallelDo( encodingTasks.begin(), encodingTasks.end(), [&]( auto& task ) { |
| 563 | #if __APPLE__ |
| 564 | @autoreleasepool |
| 565 | #endif |
| 566 | { |
| 567 | CCP_STATS_ZONE( "Parallel Encoding Task" ); |
| 568 | |
| 569 | Tr2RenderContext* ctx = renderContext.Fork(); |
| 570 | |
| 571 | Tr2ConstantBufferAL* perObjectConstantBuffers[CBUFFER_COUNT]; |
| 572 | for( uint32_t i = 0; i != CBUFFER_COUNT; ++i ) |
| 573 | { |
| 574 | perObjectConstantBuffers[i] = ctx->GetConstantBuffer( i ); |
| 575 | } |
| 576 | ctx->RenderBatchGroup( task, techniqueName, perObjectConstantBuffers, *ctx ); |
| 577 | |
| 578 | renderContext.Join( ctx ); |
| 579 | } |
| 580 | } ); |
| 581 | renderContext.EndParallelEncoding(); |
| 582 | return; |
| 583 | } |
| 584 | } |
| 585 | #endif |
| 586 | |
| 587 | |
| 588 | Tr2ConstantBufferAL* perObjectConstantBuffers[CBUFFER_COUNT]; |
| 589 | for( uint32_t i = 0; i != CBUFFER_COUNT; ++i ) |
| 590 | { |
| 591 | perObjectConstantBuffers[i] = renderContext.GetConstantBuffer( i ); |
nothing calls this directly
no test coverage detected