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

Function GetBindlessFallbackTextureIndex

trinity/Shader/Tr2Effect.cpp:1676–1716  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1674
1675
1676bool GetBindlessFallbackTextureIndex( const Tr2EffectDescription& desc, const Tr2EffectConstant& c, uint32_t& result )
1677{
1678 //Bindless are always 1D uint parameters, so filter out everything else
1679 if( c.type != Tr2EffectConstant::UINT || c.dimension != 1 )
1680 {
1681 return false;
1682 }
1683
1684 //Find annotations for the parameter
1685 auto it = std::find_if( desc.annotations.begin(), desc.annotations.end(), [&]( Tr2EffectAnnotationMap::const_reference key ) {
1686 return strcmp( key.first, c.name.c_str() ) == 0;
1687 } );
1688 if( it == desc.annotations.end() )
1689 {
1690 //No annotations found, early out
1691 return false;
1692 }
1693
1694 //Find the annotation that tells us what type the bindless texture has
1695 auto& map = it->second;
1696 auto found = std::find_if( map.begin(), map.end(), []( auto& x ) {
1697 return strcmp( x.name, "BindlessHandleType" ) == 0 && x.type == Tr2EffectParameterAnnotation::INT;
1698 } );
1699 if( found == map.end() )
1700 {
1701 return false;
1702 }
1703
1704 if( found->intValue == Tr2EffectResource::BINDLESS_SAMPLER )
1705 {
1706 // Fallbacks values for samplers are filled separately
1707 return false;
1708 }
1709 auto resourceType = Tr2EffectResource::Type( found->intValue );
1710
1711 auto& fallbackTexture = Tr2Renderer::GetFallbackTexture( resourceType, c.name.c_str() );
1712
1713 result = fallbackTexture.GetSrvIndexInHeap();
1714
1715 return true;
1716}
1717
1718// --------------------------------------------------------------------------------------
1719// Description:

Callers 1

MapPassParametersMethod · 0.85

Calls 4

TypeEnum · 0.70
beginMethod · 0.45
endMethod · 0.45
GetSrvIndexInHeapMethod · 0.45

Tested by

no test coverage detected