//----------------------------------------------------------------------- void UniformParameter::bind(GpuProgramParametersSharedPtr paramsPtr) { if (paramsPtr.get() != NULL) { const GpuConstantDefinition* def = paramsPtr->_findNamedConstantDefinition(mName); if (def != NULL) { mParamsPtr = paramsPtr.get(); mPhysicalIndex = def->physicalIndex; } } }
//--------------------------------------------------------------------- void GpuProgramUsage::recreateParameters() { // Keep a reference to old ones to copy GpuProgramParametersSharedPtr savedParams = mParameters; // Create new params mParameters = mProgram->createParameters(); // Copy old (matching) values across // Don't use copyConstantsFrom since program may be different if (!savedParams.isNull()) mParameters->copyMatchingNamedConstantsFrom(*savedParams.get()); mRecreateParams = false; }
//----------------------------------------------------------------------------- void GpuProgram::loadImpl(void) { if (mLoadFromFile) { // find & load source code DataStreamPtr stream = ResourceGroupManager::getSingleton().openResource( mFilename, mGroup, true, this); mSource = stream->getAsString(); } // Call polymorphic load try { loadFromSource(); if (!mDefaultParams.isNull()) { // Keep a reference to old ones to copy GpuProgramParametersSharedPtr savedParams = mDefaultParams; // reset params to stop them being referenced in the next create mDefaultParams.setNull(); // Create new params mDefaultParams = createParameters(); // Copy old (matching) values across // Don't use copyConstantsFrom since program may be different mDefaultParams->copyMatchingNamedConstantsFrom(*savedParams.get()); } } catch (const Exception&) { StringStream ss; ss << "Gpu program " << mName << " encountered an error " << "during loading and is thus not supported."; mCompileErrorMessage = ss.str(); // will already have been logged LogManager::getSingleton().stream() << mCompileErrorMessage; mCompileError = true; } }
//--------------------------------------------------------------------------- void HighLevelGpuProgram::loadHighLevel(void) { if (!mHighLevelLoaded) { try { loadHighLevelImpl(); mHighLevelLoaded = true; if (!mDefaultParams.isNull()) { // Keep a reference to old ones to copy GpuProgramParametersSharedPtr savedParams = mDefaultParams; // reset params to stop them being referenced in the next create mDefaultParams.setNull(); // Create new params mDefaultParams = createParameters(); // Copy old (matching) values across // Don't use copyConstantsFrom since program may be different mDefaultParams->copyMatchingNamedConstantsFrom(*savedParams.get()); } } catch (const Exception& e) { // will already have been logged LogManager::getSingleton().stream() << "High-level program " << mName << " encountered an error " << "during loading and is thus not supported.\n" << e.getFullDescription(); mCompileError = true; } } }