| 731 | } |
| 732 | |
| 733 | void AssignRegisters( ASTNode* root, InputStageType stage, Registers& registers, const std::vector<GlobalInputElement>& globalInput, std::vector<RegisterSpecifier>& globalInputRegisters ) |
| 734 | { |
| 735 | if( !root ) |
| 736 | { |
| 737 | return; |
| 738 | } |
| 739 | switch( root->GetNodeType() ) |
| 740 | { |
| 741 | case NT_CBUFFER: |
| 742 | if( root->GetSymbol()->used ) |
| 743 | { |
| 744 | bool assigned = false; |
| 745 | for( auto& r : root->GetSymbol()->registerSpecifier ) |
| 746 | { |
| 747 | if( r.second.explicitRegister && DoesProfileMatchStage( r.first, stage ) ) |
| 748 | { |
| 749 | assigned = true; |
| 750 | break; |
| 751 | } |
| 752 | } |
| 753 | if( !assigned ) |
| 754 | { |
| 755 | RegisterSpecifier r; |
| 756 | r.shaderProfile = MakeInlineString( "" ); |
| 757 | r.registerType = 'b'; |
| 758 | r.registerNumber = AllocateRegister( registers.b ); |
| 759 | r.subComponent = -1; |
| 760 | r.space = 0; |
| 761 | r.explicitRegister = false; |
| 762 | r.explicitSpace = false; |
| 763 | root->GetSymbol()->registerSpecifier[r.shaderProfile] = r; |
| 764 | } |
| 765 | } |
| 766 | break; |
| 767 | case NT_NAME_DECLARATION: |
| 768 | if( !root->GetSymbol()->used ) |
| 769 | { |
| 770 | return; |
| 771 | } |
| 772 | if( auto registerType = GetRegisterType( root->GetSymbol()->type ) ) |
| 773 | { |
| 774 | auto globalElement = std::find_if( begin( globalInput ), end( globalInput ), [symbol = root->GetSymbol()]( const auto& element ) { return SymbolMatchesGlobalInput( *symbol, element ); } ); |
| 775 | if( globalElement != end( globalInput ) ) |
| 776 | { |
| 777 | auto& r = globalInputRegisters[globalElement - begin( globalInput )]; |
| 778 | root->GetSymbol()->registerSpecifier[r.shaderProfile] = r; |
| 779 | } |
| 780 | else |
| 781 | { |
| 782 | |
| 783 | bool assigned = false; |
| 784 | for( auto& r : root->GetSymbol()->registerSpecifier ) |
| 785 | { |
| 786 | if( r.second.explicitRegister && DoesProfileMatchStage( r.first, stage ) ) |
| 787 | { |
| 788 | assigned = true; |
| 789 | break; |
| 790 | } |
no test coverage detected