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

Function AddGlobalInputs

shadercompiler/EffectCompilerDX11.cpp:1090–1199  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1088
1089
1090bool AddGlobalInputs( StageData& globalsData, std::map<StringReference, ParameterAnnotation>& annotations, const std::vector<GlobalInputElement>& globalInputs, ParserState& state, bool useStaticSamplers )
1091{
1092 auto AddAnnotations = [&annotations]( const Symbol* symbol, bool& srgb, bool& autoregister ) {
1093 if( symbol && symbol->annotations )
1094 {
1095 ParameterAnnotation paramAnnotations;
1096 for( auto ai = symbol->annotations->begin(); ai != symbol->annotations->end(); ++ai )
1097 {
1098 Annotation result;
1099 if( DxReflection::MakeEffectAnnotationFromSymbolAnnotation( *ai, result, srgb, autoregister ) )
1100 {
1101 paramAnnotations.annotations[g_stringTable.AddString( ToString( ai->name ).c_str() )] = result;
1102 }
1103 }
1104 if( !paramAnnotations.annotations.empty() )
1105 {
1106 annotations[g_stringTable.AddString( symbol->name )] = paramAnnotations;
1107 }
1108 }
1109 };
1110
1111 for( auto& gi : globalInputs )
1112 {
1113 if( !gi.symbol )
1114 {
1115 continue;
1116 }
1117 auto symbol = gi.symbol;
1118 if( !symbol->registerSpecifier.empty() )
1119 {
1120 auto& reg = symbol->registerSpecifier.begin()->second;
1121 auto outReg = GetRegisterInputDescription( symbol->type, reg );
1122 auto existingReg = find_if( begin( globalsData.registerInputs ), end( globalsData.registerInputs ), [&outReg]( auto& x ) {
1123 return outReg.registerIndex == x.registerIndex && outReg.registerSpace == x.registerSpace && outReg.registerType == x.registerType;
1124 } );
1125 if( existingReg != end( globalsData.registerInputs ) )
1126 {
1127 continue;
1128 }
1129
1130 switch( reg.registerType )
1131 {
1132 case 's': {
1133 Sampler sampler;
1134 if( !GetSamplerState( state, symbol->definition, sampler ) )
1135 {
1136 return false;
1137 }
1138 StaticSampler staticSampler;
1139 if( symbol->type.arrayDimensions == 0 && useStaticSamplers && ConvertToStaticSampler( staticSampler, sampler ) )
1140 {
1141 staticSampler.registerIndex = reg.registerNumber;
1142 staticSampler.registerSpace = uint8_t( reg.space );
1143 auto found = find_if( begin( globalsData.staticSamplers ), end( globalsData.staticSamplers ), [&staticSampler]( auto& x ) {
1144 return staticSampler.registerIndex == x.registerIndex && staticSampler.registerSpace == x.registerSpace;
1145 } );
1146 if( found == end( globalsData.staticSamplers ) )
1147 {

Callers 1

CompileEffectMethod · 0.85

Calls 12

GetSamplerStateFunction · 0.85
ConvertToStaticSamplerFunction · 0.85
AddStringMethod · 0.80
emptyMethod · 0.80
ToStringFunction · 0.70
TypeToTextureTypeFunction · 0.70
beginFunction · 0.50
endFunction · 0.50
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected