| 798 | } |
| 799 | |
| 800 | int32_t GL46Engine::ProgramIndexUnitMap::AcquireUnit(GLint program, GLint index) |
| 801 | { |
| 802 | int32_t availUnit = -1; |
| 803 | for (int32_t unit = 0; unit < static_cast<int32_t>(mLinkMap.size()); ++unit) |
| 804 | { |
| 805 | auto& item = mLinkMap[unit]; |
| 806 | |
| 807 | // Increment link count if already assigned and in use? |
| 808 | if (program == item.program && index == item.index) |
| 809 | { |
| 810 | ++item.linkCount; |
| 811 | return unit; |
| 812 | } |
| 813 | |
| 814 | // Found a unit that was previously used but is now available. |
| 815 | if (0 == item.linkCount) |
| 816 | { |
| 817 | if (-1 == availUnit) |
| 818 | { |
| 819 | availUnit = unit; |
| 820 | } |
| 821 | } |
| 822 | } |
| 823 | |
| 824 | // New unit number not previously used? |
| 825 | if (-1 == availUnit) |
| 826 | { |
| 827 | // TODO: Consider querying the max number of units and check that |
| 828 | // this number is not exceeded. |
| 829 | availUnit = static_cast<int32_t>(mLinkMap.size()); |
| 830 | mLinkMap.push_back({ 0, 0, 0 }); |
| 831 | } |
| 832 | |
| 833 | auto& item = mLinkMap[availUnit]; |
| 834 | item.linkCount = 1; |
| 835 | item.program = program; |
| 836 | item.index = index; |
| 837 | return availUnit; |
| 838 | } |
| 839 | |
| 840 | int32_t GL46Engine::ProgramIndexUnitMap::GetUnit(GLint program, GLint index) const |
| 841 | { |
no outgoing calls
no test coverage detected