MCPcopy Create free account
hub / github.com/carbonengine/trinity / UseTextures

Function UseTextures

trinity/Tr2RenderContext.cpp:33–81  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

31Tr2EnumerableThreadSpecific<Tr2BindlessResourcesAL> s_perThreadUsedTextures;
32
33void 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
83void SubmitGeometry( const Tr2RenderBatch& batch, Tr2RenderContext& renderContext )
84{

Callers 4

RenderBatchesInOrderMethod · 0.85

Calls 10

Tr2ParallelForFunction · 0.85
GetTechniqueIndexMethod · 0.80
sizeMethod · 0.80
AddMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
ClearMethod · 0.45
GetBatchesMethod · 0.45
UseResourcesMethod · 0.45

Tested by

no test coverage detected