| 31 | Tr2EnumerableThreadSpecific<Tr2BindlessResourcesAL> s_perThreadUsedTextures; |
| 32 | |
| 33 | void UseTextures( ITriRenderBatchAccumulator* batches, const BlueSharedString& techniqueName, Tr2RenderContextAL& renderContext ) |
| 34 | { |
| 35 | #if TRINITY_PLATFORM_SUPPORTS_HEAP_VIEW |
| 36 | CCP_STATS_ZONE( __FUNCTION__ ); |
| 37 | Tr2BindlessResourcesAL usedTextures; |
| 38 | |
| 39 | usedTextures.Add( Tr2Renderer::GetFallbackTexture( Tr2EffectResource::TEXTURE_2D, "" ) ); |
| 40 | usedTextures.Add( Tr2Renderer::GetFallbackTexture( Tr2EffectResource::TEXTURE_3D, "" ) ); |
| 41 | usedTextures.Add( Tr2Renderer::GetFallbackTexture( Tr2EffectResource::TEXTURE_CUBE, "" ) ); |
| 42 | |
| 43 | auto ProcessBatch = [&techniqueName]( auto& batch, Tr2BindlessResourcesAL& resources ) { |
| 44 | uint32_t technique; |
| 45 | if( batch.m_shader->GetTechniqueIndex( techniqueName, technique ) ) |
| 46 | { |
| 47 | batch.m_material->GetUsedBindlessTextures( technique, resources ); |
| 48 | } |
| 49 | }; |
| 50 | auto ProcessBatches = [&ProcessBatch, &usedTextures]( auto& batches ) { |
| 51 | const size_t partitionSize = 500; |
| 52 | if( batches.size() > partitionSize ) |
| 53 | { |
| 54 | Tr2ParallelFor( Tr2BlockedRange<size_t>( 0, batches.size(), partitionSize ), [&]( Tr2BlockedRange<size_t> range ) { |
| 55 | for( auto i = range.begin(); i != range.end(); ++i ) |
| 56 | { |
| 57 | ProcessBatch( batches[i], s_perThreadUsedTextures.local() ); |
| 58 | } |
| 59 | } ); |
| 60 | for( auto& threadResources : s_perThreadUsedTextures ) |
| 61 | { |
| 62 | usedTextures.Add( threadResources ); |
| 63 | threadResources.Clear(); |
| 64 | } |
| 65 | } |
| 66 | else |
| 67 | { |
| 68 | for( auto& batch : batches ) |
| 69 | { |
| 70 | ProcessBatch( batch, usedTextures ); |
| 71 | } |
| 72 | } |
| 73 | }; |
| 74 | ProcessBatches( batches->GetGdprBatches() ); |
| 75 | ProcessBatches( batches->GetBatches() ); |
| 76 | { |
| 77 | CCP_STATS_ZONE( "renderContext.UseResources" ); |
| 78 | renderContext.UseResources( Tr2UseResourceDestination::RENDER, Tr2GpuUsage::SHADER_RESOURCE, usedTextures ); |
| 79 | } |
| 80 | #endif |
| 81 | } |
| 82 | |
| 83 | void SubmitGeometry( const Tr2RenderBatch& batch, Tr2RenderContext& renderContext ) |
| 84 | { |
no test coverage detected