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

Method MapPassParameters

trinity/Shader/Tr2Effect.cpp:1722–2027  ·  view source on GitHub ↗

-------------------------------------------------------------------------------------- Description: Maps the parameters for a pass to indices in the constant mirror. --------------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

1720// Maps the parameters for a pass to indices in the constant mirror.
1721// --------------------------------------------------------------------------------------
1722void Tr2Effect::MapPassParameters(
1723 Tr2RenderContextEnum::ShaderType stage,
1724 Tr2MaterialStageInput& stageInput,
1725 PassParametersOwner& ppOwner,
1726 const Tr2EffectStageInput& stageInputDesc,
1727 const Tr2EffectDescription& descriptionDesc,
1728 Tr2RenderContext& renderContext )
1729{
1730 CCP_STATS_ZONE( __FUNCTION__ );
1731
1732 static const size_t MAX_PARAMS = 128;
1733
1734 Tr2EffectParamVector& pv = stageInput.m_shaderParameters;
1735 auto& constants = stageInputDesc.constants;
1736 Tr2VariableStore& variableStore = GetVariableStore();
1737
1738 unsigned int perObjectStart = 0xffffffff;
1739
1740 CCP_ASSERT( constants.size() < MAX_PARAMS );
1741 ITr2EffectValue* foundParams[MAX_PARAMS];
1742 unsigned constantSize = 0;
1743 unsigned index = 0;
1744 bool hasConstantParams = false;
1745 bool hasVariableParams = false;
1746
1747 size_t constParamCount;
1748 auto constParams = GetConstParameters( constParamCount );
1749 uint32_t constIndexes[MAX_PARAMS];
1750
1751 // First pass: determine the size of the constant buffer
1752 for( auto constantIx = constants.begin(); constantIx != constants.end(); ++constantIx )
1753 {
1754 constIndexes[index] = -1;
1755 bool foundConstant = false;
1756 for( size_t i = 0; i < constParamCount; ++i )
1757 {
1758 if( constantIx->name == constParams[i].name )
1759 {
1760 constIndexes[index] = uint32_t( i );
1761 foundConstant = true;
1762 hasConstantParams = true;
1763 break;
1764 }
1765 }
1766 ITr2EffectValue* paramAsEffectValue = NULL;
1767 if( !foundConstant )
1768 {
1769 // First search in effect parameter list and see if we have a match
1770 if( ITriEffectParameter* p = FindParameterByName( constantIx->name.c_str() ) )
1771 {
1772 paramAsEffectValue = p;
1773 }
1774 else if( auto r = GetResourceByName( constantIx->name.c_str() ) )
1775 {
1776 paramAsEffectValue = r;
1777 AddLoddable( r, constantIx->name.c_str() );
1778 ppOwner.AddUsedResource( r );
1779 }

Callers

nothing calls this directly

Calls 15

FindSamplerByNameFunction · 0.85
sizeMethod · 0.80
AddUsedResourceMethod · 0.80
FindVariableMethod · 0.80
getMethod · 0.80
AllocateConstantsMethod · 0.80
AddReroutableMethod · 0.80
DetachMethod · 0.80
beginMethod · 0.45

Tested by

no test coverage detected