//----------------------------------------------------------------------------- void ProgramProcessor::bindAutoParameters(Program* pCpuProgram, GpuProgramPtr pGpuProgram) { GpuProgramParametersSharedPtr pGpuParams = pGpuProgram->getDefaultParameters(); const UniformParameterList& progParams = pCpuProgram->getParameters(); UniformParameterConstIterator itParams; for (itParams=progParams.begin(); itParams != progParams.end(); ++itParams) { const UniformParameterPtr pCurParam = *itParams; const GpuConstantDefinition* gpuConstDef = pGpuParams->_findNamedConstantDefinition(pCurParam->getName()); if (gpuConstDef != NULL) { // Handle auto parameters. if (pCurParam->isAutoConstantParameter()) { if (pCurParam->isAutoConstantRealParameter()) { pGpuParams->setNamedAutoConstantReal(pCurParam->getName(), pCurParam->getAutoConstantType(), pCurParam->getAutoConstantRealData()); } else if (pCurParam->isAutoConstantIntParameter()) { pGpuParams->setNamedAutoConstant(pCurParam->getName(), pCurParam->getAutoConstantType(), pCurParam->getAutoConstantIntData()); } } // Case this is not auto constant - we have to update its variability ourself. else { gpuConstDef->variability |= pCurParam->getVariability(); // Update variability in the float map. if (gpuConstDef->isSampler() == false) { GpuLogicalBufferStructPtr floatLogical = pGpuParams->getFloatLogicalBufferStruct(); if (floatLogical.get()) { for (GpuLogicalIndexUseMap::const_iterator i = floatLogical->map.begin(); i != floatLogical->map.end(); ++i) { if (i->second.physicalIndex == gpuConstDef->physicalIndex) { i->second.variability |= gpuConstDef->variability; break; } } } } } } } }
void ATI_FS_GLGpuProgram::bindProgramParameters(GpuProgramParametersSharedPtr params) { // only supports float constants const GpuLogicalBufferStruct* floatStruct = params->getFloatLogicalBufferStruct(); for (GpuLogicalIndexUseMap::const_iterator i = floatStruct->map.begin(); i != floatStruct->map.end(); ++i) { size_t logicalIndex = i->first; const float* pFloat = params->getFloatPointer(i->second.physicalIndex); // Iterate over the params, set in 4-float chunks (low-level) for (size_t j = 0; j < i->second.currentSize; j+=4) { glSetFragmentShaderConstantATI(GL_CON_0_ATI + logicalIndex, pFloat); pFloat += 4; ++logicalIndex; } } }
void GLArbGpuProgram::bindProgramParameters(GpuProgramParametersSharedPtr params) { GLenum type = (mType == GPT_VERTEX_PROGRAM) ? GL_VERTEX_PROGRAM_ARB : GL_FRAGMENT_PROGRAM_ARB; // only supports float constants const GpuLogicalBufferStruct* floatStruct = params->getFloatLogicalBufferStruct(); for (GpuLogicalIndexUseMap::const_iterator i = floatStruct->map.begin(); i != floatStruct->map.end(); ++i) { size_t logicalIndex = i->first; const float* pFloat = params->getFloatPointer(i->second.physicalIndex); // Iterate over the params, set in 4-float chunks (low-level) for (size_t j = 0; j < i->second.currentSize; j+=4) { glProgramLocalParameter4fvARB(type, logicalIndex, pFloat); pFloat += 4; ++logicalIndex; } } }
void GLArbGpuProgram::bindProgramParameters(GpuProgramParametersSharedPtr params, uint16 mask) { GLenum type = getGLShaderType(mType); // only supports float constants GpuLogicalBufferStructPtr floatStruct = params->getFloatLogicalBufferStruct(); for (GpuLogicalIndexUseMap::const_iterator i = floatStruct->map.begin(); i != floatStruct->map.end(); ++i) { if (i->second.variability & mask) { size_t logicalIndex = i->first; const float* pFloat = params->getFloatPointer(i->second.physicalIndex); // Iterate over the params, set in 4-float chunks (low-level) for (size_t j = 0; j < i->second.currentSize; j+=4) { glProgramLocalParameter4fvARB(type, logicalIndex, pFloat); pFloat += 4; ++logicalIndex; } } } }