| 520 | } |
| 521 | |
| 522 | static 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 ) |
no test coverage detected