-------------------------------------------------------------------------
| 3587 | } |
| 3588 | //------------------------------------------------------------------------- |
| 3589 | static int parseProgramParameterDimensions(String& declarator, BaseConstantType& type) |
| 3590 | { |
| 3591 | // Assume 1 unless otherwise specified |
| 3592 | int dimensions = 1; |
| 3593 | type = BCT_UNKNOWN; |
| 3594 | |
| 3595 | // get the type |
| 3596 | const char* typeStrings[] = {"float", "int", "uint", "double", "bool"}; |
| 3597 | BaseConstantType baseTypes[] = {BCT_FLOAT, BCT_INT, BCT_UINT, BCT_DOUBLE, BCT_BOOL}; |
| 3598 | |
| 3599 | const char* typeStr = ""; |
| 3600 | |
| 3601 | for(int i = 0; i < 5; ++i) |
| 3602 | { |
| 3603 | if(declarator.find(typeStrings[i]) == 0) |
| 3604 | { |
| 3605 | type = baseTypes[i]; |
| 3606 | typeStr = typeStrings[i]; |
| 3607 | break; |
| 3608 | } |
| 3609 | } |
| 3610 | |
| 3611 | if(type == BCT_UNKNOWN) |
| 3612 | return dimensions; |
| 3613 | |
| 3614 | size_t start = declarator.find_first_not_of(typeStr); |
| 3615 | |
| 3616 | if (start != String::npos) |
| 3617 | { |
| 3618 | size_t end = declarator.find_first_of('[', start); |
| 3619 | |
| 3620 | // int1, int2, etc. |
| 3621 | if (end != start) |
| 3622 | { |
| 3623 | dimensions *= StringConverter::parseInt( |
| 3624 | declarator.substr(start, end - start)); |
| 3625 | start = end; |
| 3626 | } |
| 3627 | |
| 3628 | // C-style array |
| 3629 | while (start != String::npos) |
| 3630 | { |
| 3631 | end = declarator.find_first_of(']', start); |
| 3632 | dimensions *= StringConverter::parseInt( |
| 3633 | declarator.substr(start + 1, end - start - 1)); |
| 3634 | start = declarator.find_first_of('[', end); |
| 3635 | } |
| 3636 | } |
| 3637 | return dimensions; |
| 3638 | } |
| 3639 | //------------------------------------------------------------------------- |
| 3640 | template <typename T, typename It> |
| 3641 | static void safeSetConstant(const GpuProgramParametersPtr& params, const String& name, size_t index, It arrayStart, |
no test coverage detected