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

Function PatchCalls

shadercompiler/TextureFunctionConversionDX11.cpp:522–627  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

520}
521
522static void PatchCalls( ParserState& state,
523 ASTNode* node,
524 std::map<Symbol*, SamplerToTexture>& samplers,
525 const std::map<Symbol*, std::vector<ParameterInfo>>& functions )
526{
527 if( node == nullptr )
528 {
529 return;
530 }
531 if( node->GetNodeType() == NT_FUNCTION_CALL )
532 {
533 auto found = functions.find( node->GetSymbol() );
534 if( found != functions.end() )
535 {
536 for( auto it = found->second.rbegin(); it != found->second.rend(); ++it )
537 {
538 Symbol* samplerArg = nullptr;
539 ASTNode* arg = GetSamplerArg( node->GetChildOrNull( it->argumentIndex ) );
540 if( arg )
541 {
542 samplerArg = arg->GetSymbol();
543 }
544 if( samplerArg == nullptr )
545 {
546 assert( false );
547 return;
548 }
549 Symbol* texture = nullptr;
550 auto textureFound = samplers.find( samplerArg );
551 if( textureFound == samplers.end() )
552 {
553 if( samplerArg->definition && samplerArg->definition->GetNodeType() != NT_FUNCTION_PARAMETER )
554 {
555 texture = ExtractTextureState( samplerArg );
556
557 if( texture )
558 {
559 if( !samplerArg->registerSpecifier.empty() )
560 {
561 if( texture->registerSpecifier.empty() )
562 {
563 texture->registerSpecifier = samplerArg->registerSpecifier;
564 for( auto& registerSpecifier : texture->registerSpecifier )
565 {
566 registerSpecifier.second.registerType = 't';
567 }
568 }
569 }
570 }
571 }
572 }
573 else
574 {
575 texture = textureFound->second.texture;
576 }
577 if( texture == nullptr )
578 {
579 if( samplerArg->definition && samplerArg->definition->GetNodeType() == NT_FUNCTION_PARAMETER && node->GetSymbol() && node->GetSymbol()->definition )

Callers 1

Calls 15

GetSamplerArgFunction · 0.85
ExtractTextureStateFunction · 0.85
FindTextureToSamplerFunction · 0.85
AssignTextureTypeFunction · 0.85
GetNodeTypeMethod · 0.80
GetSymbolMethod · 0.80
GetChildOrNullMethod · 0.80
emptyMethod · 0.80
GetTokenMethod · 0.80
GetScopeMethod · 0.80
SetSymbolMethod · 0.80
InsertChildMethod · 0.80

Tested by

no test coverage detected