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

Method MapPassResources

trinity/Shader/Tr2Effect.cpp:1436–1489  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1434
1435
1436void Tr2Effect::MapPassResources( const Tr2EffectResourceMap& resources, Tr2EffectParamVector& pv, bool& compatibleWithGdr )
1437{
1438 CCP_STATS_ZONE( __FUNCTION__ );
1439
1440 for( auto it = resources.begin(); it != resources.end(); ++it )
1441 {
1442 const Tr2EffectResource& ss = it->second;
1443 const char* name = ss.name;
1444
1445 Tr2EffectParam param;
1446
1447 // First search in effect resource list
1448 if( ITriEffectParameter* p = GetResourceByName( name ) )
1449 {
1450 param.m_sourceValue = p;
1451 compatibleWithGdr = false;
1452 AddLoddable( p, name );
1453 }
1454 // Secondly search in effect parameter list
1455 else if( ITriEffectParameter* p = FindParameterByName( name ) )
1456 {
1457 // The only parameter that can point to a resource is the TriVariableParameter
1458 TriVariableParameter* vp = dynamic_cast<TriVariableParameter*>( p );
1459 if( vp && vp->m_variable && ( vp->m_variable->GetType() == TRIVARIABLE_TEXTURE_RES || vp->m_variable->GetType() == TRIVARIABLE_GPUBUFFER ) )
1460 {
1461 compatibleWithGdr = false;
1462 param.m_sourceValue = p;
1463 }
1464 }
1465 // Fallback to variable store
1466 else if( TriVariable* v = GetVariableStore().FindVariable( name ) )
1467 {
1468 if( v->GetType() == TRIVARIABLE_TEXTURE_RES ||
1469 v->GetType() == TRIVARIABLE_GPUBUFFER ||
1470 ss.isAutoregister )
1471 {
1472 param.m_sourceValue = v;
1473 }
1474 }
1475 else if( ss.isAutoregister )
1476 {
1477 param.m_sourceValue = GetVariableStore().GetVariable( name );
1478 }
1479
1480 if( param.m_sourceValue )
1481 {
1482 param.m_sourceName = ss.name;
1483 param.m_registerIndex = it->first;
1484 param.m_registerCount = it->second.isSRGB ? ITr2EffectValue::RESOURCE_FLAG_SRGB : 0;
1485
1486 pv.push_back( param );
1487 }
1488 }
1489}
1490
1491void Tr2Effect::Render( IRenderCallback* cb, Tr2RenderContext& renderContext )
1492{

Callers

nothing calls this directly

Calls 5

FindVariableMethod · 0.80
beginMethod · 0.45
endMethod · 0.45
GetTypeMethod · 0.45
GetVariableMethod · 0.45

Tested by

no test coverage detected