//-----------------------------------------------------------------------
    void UnifiedHighLevelGpuProgram::chooseDelegate() const
    {
        OGRE_LOCK_AUTO_MUTEX;

        mChosenDelegate.setNull();

        HighLevelGpuProgramPtr tmpDelegate;
        tmpDelegate.setNull();
        int tmpPriority = -1;

        for (StringVector::const_iterator i = mDelegateNames.begin(); i != mDelegateNames.end(); ++i)
        {
            HighLevelGpuProgramPtr deleg = HighLevelGpuProgramManager::getSingleton().getByName(*i, mGroup);

            //recheck with auto resource group
            if (deleg.isNull())
              deleg = HighLevelGpuProgramManager::getSingleton().getByName(*i);

            // Silently ignore missing links
            if(!deleg.isNull() && deleg->isSupported())
            {
                int priority = getPriority(deleg->getLanguage());
                //Find the delegate with the highest prioriry
                if (priority >= tmpPriority)
                {
                    tmpDelegate = deleg;
                    tmpPriority = priority;
                }
            }

        }

        mChosenDelegate = tmpDelegate;
    }