当前位置: 首页>>代码示例>>C++>>正文


C++ ShaderParameterList类代码示例

本文整理汇总了C++中ShaderParameterList的典型用法代码示例。如果您正苦于以下问题:C++ ShaderParameterList类的具体用法?C++ ShaderParameterList怎么用?C++ ShaderParameterList使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ShaderParameterList类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: buildTexcoordTable

//-----------------------------------------------------------------------------
void ProgramProcessor::buildTexcoordTable(const ShaderParameterList& paramList, ShaderParameterList outParamsTable[4])
{
	ShaderParameterConstIterator it    = paramList.begin();
	ShaderParameterConstIterator itEnd = paramList.end();

	for (; it != itEnd; ++it)
	{
		const ParameterPtr curParam = *it;

		if (curParam->getSemantic() == Parameter::SPS_TEXTURE_COORDINATES)
		{

			switch (curParam->getType())
			{
			case GCT_FLOAT1:
				outParamsTable[0].push_back(curParam);
				break;

			case GCT_FLOAT2:
				outParamsTable[1].push_back(curParam);
				break;

			case GCT_FLOAT3:
				outParamsTable[2].push_back(curParam);
				break;

			case GCT_FLOAT4:
				outParamsTable[3].push_back(curParam);
				break;
            case GCT_SAMPLER1D:
            case GCT_SAMPLER2D:
            case GCT_SAMPLER2DARRAY:
            case GCT_SAMPLER3D:
            case GCT_SAMPLERCUBE:
            case GCT_SAMPLER1DSHADOW:
            case GCT_SAMPLER2DSHADOW:
            case GCT_MATRIX_2X2:
            case GCT_MATRIX_2X3:
            case GCT_MATRIX_2X4:
            case GCT_MATRIX_3X2:
            case GCT_MATRIX_3X3:
            case GCT_MATRIX_3X4:
            case GCT_MATRIX_4X2:
            case GCT_MATRIX_4X3:
            case GCT_MATRIX_4X4:
            case GCT_INT1:
            case GCT_INT2:
            case GCT_INT3:
            case GCT_INT4:
            case GCT_UNKNOWN:
            default:
                break;
			}
		}
	}
}
开发者ID:changsin,项目名称:ogre,代码行数:57,代码来源:OgreShaderProgramProcessor.cpp

示例2: generateLocalSplitParameters

//-----------------------------------------------------------------------------
void ProgramProcessor::generateLocalSplitParameters(Function* func, GpuProgramType progType,
												   MergeParameterList& mergedParams, 
												   ShaderParameterList& splitParams, LocalParameterMap& localParamsMap)
{
	// No split params created.
	if (splitParams.size() == 0)	
		return;	

	// Create the local parameters + map from source to local.
	for (unsigned int i=0; i < splitParams.size(); ++i)
	{
		ParameterPtr srcParameter   = splitParams[i];
		ParameterPtr localParameter = func->resolveLocalParameter(srcParameter->getSemantic(), srcParameter->getIndex(), "lsplit_" + srcParameter->getName(), srcParameter->getType());

		localParamsMap[srcParameter.get()] = localParameter;		
	}	

	int invocationCounter = 0;

	// Establish link between the local parameter to the merged parameter.
	for (unsigned int i=0; i < mergedParams.size(); ++i)
	{
		MergeParameter& curMergeParameter = mergedParams[i];

		for (unsigned int p=0; p < curMergeParameter.getSourceParameterCount(); ++p)
		{
			ParameterPtr srcMergedParameter    = curMergeParameter.getSourceParameter(p);
			LocalParameterMap::iterator itFind = localParamsMap.find(srcMergedParameter.get());

			// Case the source parameter is split parameter.
			if (itFind != localParamsMap.end())
			{
				// Case it is the vertex shader -> assign the local parameter to the output merged parameter.
				if (progType == GPT_VERTEX_PROGRAM)
				{
					FunctionInvocation* curFuncInvocation = OGRE_NEW FunctionInvocation(FFP_FUNC_ASSIGN, FFP_VS_POST_PROCESS, invocationCounter++);
					
					curFuncInvocation->pushOperand(itFind->second, Operand::OPS_IN, curMergeParameter.getSourceParameterMask(p));
					curFuncInvocation->pushOperand(curMergeParameter.getDestinationParameter(Operand::OPS_OUT, i), Operand::OPS_OUT, curMergeParameter.getDestinationParameterMask(p));		
					func->addAtomInstance(curFuncInvocation);		
				}
				else if (progType == GPT_FRAGMENT_PROGRAM)
				{
					FunctionInvocation* curFuncInvocation = OGRE_NEW FunctionInvocation(FFP_FUNC_ASSIGN, FFP_PS_PRE_PROCESS, invocationCounter++);
					
					curFuncInvocation->pushOperand(curMergeParameter.getDestinationParameter(Operand::OPS_IN, i), Operand::OPS_IN, curMergeParameter.getDestinationParameterMask(p));		
					curFuncInvocation->pushOperand(itFind->second, Operand::OPS_OUT, curMergeParameter.getSourceParameterMask(p));
					func->addAtomInstance(curFuncInvocation);		
				}
			}
		}
	}				
}
开发者ID:changsin,项目名称:ogre,代码行数:54,代码来源:OgreShaderProgramProcessor.cpp

示例3: getParameterByName

//-----------------------------------------------------------------------------
ParameterPtr Function::getParameterByName( const ShaderParameterList& parameterList, const String& name )
{
	ShaderParameterConstIterator it;

	for (it = parameterList.begin(); it != parameterList.end(); ++it)
	{
		if ((*it)->getName() == name)
		{
			return *it;
		}
	}

	return ParameterPtr();
}
开发者ID:Ali-il,项目名称:gamekit,代码行数:15,代码来源:OgreShaderFunction.cpp

示例4: deleteParameter

//-----------------------------------------------------------------------------
void Function::deleteParameter(ShaderParameterList& parameterList, ParameterPtr parameter)
{
	ShaderParameterIterator it;

	for (it = parameterList.begin(); it != parameterList.end(); ++it)
	{
		if (*it == parameter)
		{
			(*it).setNull();
			parameterList.erase(it);
			break;
		}
	}
}
开发者ID:Ali-il,项目名称:gamekit,代码行数:15,代码来源:OgreShaderFunction.cpp

示例5: getParameterBySemantic

//-----------------------------------------------------------------------------
ParameterPtr Function::getParameterBySemantic(const ShaderParameterList& parameterList, 
												const Parameter::Semantic semantic, 
												int index)
{
	ShaderParameterConstIterator it;

	for (it = parameterList.begin(); it != parameterList.end(); ++it)
	{
		if ((*it)->getSemantic() == semantic &&
			(*it)->getIndex() == index)
		{
			return *it;
		}
	}

	return ParameterPtr();
}
开发者ID:Ali-il,项目名称:gamekit,代码行数:18,代码来源:OgreShaderFunction.cpp

示例6: getParameterByContent

//-----------------------------------------------------------------------------
ParameterPtr Function::getParameterByContent(const ShaderParameterList& parameterList, const Parameter::Content content, GpuConstantType type)
{
	ShaderParameterConstIterator it;

	// Search only for known content.
	if (content != Parameter::SPC_UNKNOWN)	
	{
		for (it = parameterList.begin(); it != parameterList.end(); ++it)
		{
			if ((*it)->getContent() == content &&
				(*it)->getType() == type)
			{
				return *it;
			}
		}
	}
	
	return ParameterPtr();
}
开发者ID:Ali-il,项目名称:gamekit,代码行数:20,代码来源:OgreShaderFunction.cpp

示例7: GetUniformParameters

static void GetUniformParameters(GLuint shader, ShaderParameterList& parameters)
{
  GLint numParams;
  glGetProgramiv(shader, GL_ACTIVE_UNIFORMS, &numParams);

	parameters.resize(numParams);

  if (numParams > 0)
  {
		// Get information about the active shader uniform values...
		std::vector<GLuint> indices(numParams);
		std::vector<GLint>  nameLengths(numParams);
		std::vector<GLint>  blockIndices(numParams);
		std::vector<GLint>  types(numParams);

		for (int i = 0; i < numParams; ++i) { indices[i] = i; }
		
		glGetActiveUniformsiv(shader, numParams, indices.data(), GL_UNIFORM_BLOCK_INDEX, blockIndices.data());
		glGetActiveUniformsiv(shader, numParams, indices.data(), GL_UNIFORM_NAME_LENGTH, nameLengths.data());
		glGetActiveUniformsiv(shader, numParams, indices.data(), GL_UNIFORM_TYPE, types.data());

		unsigned int index = 0;
		for (int i = 0; i < numParams; ++i)
		{
			// Only handling non block-based variables for now...
			if (-1 == blockIndices[i])
			{
				GLchar name[128];
				glGetActiveUniformName(shader, i, sizeof(name) - 1, NULL, name);
				const GLuint location = glGetUniformLocation(shader, name);
				const GLenum type = types[i];
				
				ShaderParameter p(new ShaderParameterImpl(name, type, location));
				parameters[index] = p;
				++index;
			}
		}
	}
}
开发者ID:geoff-wode,项目名称:strumpfaffen,代码行数:39,代码来源:shader.cpp

示例8: addParameter

//-----------------------------------------------------------------------------
void Function::addParameter(ShaderParameterList& parameterList, ParameterPtr parameter)
										
{
	// Check that parameter with the same name doest exist in input parameters list.
	if (getParameterByName(mInputParameters, parameter->getName()).get() != NULL)
	{
		OGRE_EXCEPT( Exception::ERR_INVALIDPARAMS, 
			"Parameter <" + parameter->getName() + "> already declared in function <" + getName() + ">", 			
			"Function::addParameter" );
	}

	// Check that parameter with the same name doest exist in output parameters list.
	if (getParameterByName(mOutputParameters, parameter->getName()).get() != NULL)
	{
		OGRE_EXCEPT( Exception::ERR_INVALIDPARAMS, 
			"Parameter <" + parameter->getName() + "> already declared in function <" + getName() + ">", 			
			"Function::addParameter" );
	}


	// Add to given parameters list.
	parameterList.push_back(parameter);
}
开发者ID:Ali-il,项目名称:gamekit,代码行数:24,代码来源:OgreShaderFunction.cpp

示例9: mergeParametersReminders

//-----------------------------------------------------------------------------
void ProgramProcessor::mergeParametersReminders(ShaderParameterList paramsTable[4], MergeParameterList& mergedParams, ShaderParameterList& splitParams)
{
	
	// Handle reminders parameters - All of the parameters that could not packed perfectly. 
	const size_t mergedParamsBaseIndex		= mergedParams.size();
	const size_t remindersFloatCount		= (1 * paramsTable[0].size()) + (2 * paramsTable[1].size()) + (3 * paramsTable[2].size()) + (4 * paramsTable[3].size());
	const size_t remindersFloatMod			= remindersFloatCount % 4;
	const size_t remindersFullSlotCount		= remindersFloatCount / 4;
	const size_t remindersPartialSlotCount	= remindersFloatMod > 0 ? 1 : 0;
	const size_t remindersTotalSlotCount	= remindersFullSlotCount + remindersPartialSlotCount;

	// First pass -> fill the slots with the largest reminders parameters.
	for (unsigned int slot=0; slot < remindersTotalSlotCount; ++slot)
	{
		MergeParameter curMergeParam;

		for (unsigned int row=0; row < 4; ++row)
		{
			ShaderParameterList& curParamList = paramsTable[3 - row];		

			// Case this list contains parameters -> pop it out and add to merged params.
			if (curParamList.size() > 0)
			{
				curMergeParam.addSourceParameter(curParamList.back(), Operand::OPM_ALL);
				curParamList.pop_back();
				mergedParams.push_back(curMergeParam);
				break;
			}
		}
	}

	// Second pass -> merge the reminders parameters.
	for (unsigned int row=0; row < 4; ++row)
	{
		ShaderParameterList& curParamList = paramsTable[3 - row];		

		// Merge the all the parameters of the current list.
		while (curParamList.size() > 0)
		{
			ParameterPtr srcParameter  = curParamList.back();
			int splitCount			   = 0;		// How many times the source parameter has been split.
			int srcParameterComponents;
			int srcParameterFloats;
			int curSrcParameterFloats;

			srcParameterFloats = getParameterFloatCount(srcParameter->getType());
			curSrcParameterFloats = srcParameterFloats;
			srcParameterComponents = getParameterMaskByType(srcParameter->getType());

			
			// While this parameter has remaining components -> split it.
			while (curSrcParameterFloats > 0)
			{			
				for (unsigned int slot=0; slot < remindersTotalSlotCount && curSrcParameterFloats > 0; ++slot)
				{
					MergeParameter& curMergeParam = mergedParams[mergedParamsBaseIndex + slot];
					const int freeFloatCount = 4 - curMergeParam.getUsedFloatCount();

					// Case this slot has free space.
					if (freeFloatCount > 0)
					{
						// Case current components of source parameter can go all into this slot without split.
						if (srcParameterFloats < freeFloatCount && splitCount == 0)
						{								
							curMergeParam.addSourceParameter(srcParameter, Operand::OPM_ALL);							
						}

						// Case we have to split the current source parameter.
						else
						{
							int srcComponentsMask;

							// Create the mask that tell us which part of the source component is added to the merged parameter.
							srcComponentsMask = getParameterMaskByFloatCount(freeFloatCount) << splitCount;							

							// Add the partial source parameter to merged parameter.
							curMergeParam.addSourceParameter(srcParameter, srcComponentsMask & srcParameterComponents);
						}
						splitCount++;

						// Update left floats count.
						if (srcParameterFloats < freeFloatCount)
						{
							curSrcParameterFloats -= srcParameterFloats;
						}
						else
						{
							curSrcParameterFloats -= freeFloatCount;
						}						 
					}
				}
			}									

			// Add to split params list.
			if (splitCount > 1)
				splitParams.push_back(srcParameter);


			curParamList.pop_back();
//.........这里部分代码省略.........
开发者ID:changsin,项目名称:ogre,代码行数:101,代码来源:OgreShaderProgramProcessor.cpp


注:本文中的ShaderParameterList类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。