本文整理汇总了C++中ParameterPtr::getType方法的典型用法代码示例。如果您正苦于以下问题:C++ ParameterPtr::getType方法的具体用法?C++ ParameterPtr::getType怎么用?C++ ParameterPtr::getType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ParameterPtr
的用法示例。
在下文中一共展示了ParameterPtr::getType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: replaceParametersReferences
//-----------------------------------------------------------------------------
void ProgramProcessor::replaceParametersReferences(MergeParameterList& mergedParams, ParameterOperandMap& paramsRefMap)
{
for (unsigned int i=0; i < mergedParams.size(); ++i)
{
MergeParameter& curMergeParameter = mergedParams[i];
int paramBitMaskOffset = 0;
for (unsigned int j=0; j < curMergeParameter.getSourceParameterCount(); ++j)
{
ParameterPtr curSrcParam = curMergeParameter.getSourceParameter(j);
ParameterOperandMap::iterator itParamRefs = paramsRefMap.find(curSrcParam.get());
// Case the source parameter has some references
if (itParamRefs != paramsRefMap.end())
{
OperandPtrVector& srcParamRefs = itParamRefs->second;
ParameterPtr dstParameter;
// Case the source parameter is fully contained within the destination merged parameter.
if (curMergeParameter.getSourceParameterMask(j) == Operand::OPM_ALL)
{
dstParameter = curMergeParameter.getDestinationParameter(Operand::OPS_INOUT, i);
for (unsigned int op=0; op < srcParamRefs.size(); ++op)
{
Operand* srcOperandPtr = srcParamRefs[op];
int dstOpMask;
if (srcOperandPtr->getMask() == Operand::OPM_ALL)
{
// Case the merged parameter contains only one source - no point in adding special mask.
if (curMergeParameter.getSourceParameterCount() == 1)
{
dstOpMask = Operand::OPM_ALL;
}
else
{
dstOpMask = getParameterMaskByType(curSrcParam->getType()) << paramBitMaskOffset;
}
}
else
{
dstOpMask = srcOperandPtr->getMask() << paramBitMaskOffset;
}
// Replace the original source operand with a new operand the reference the new merged parameter.
*srcOperandPtr = Operand(dstParameter, srcOperandPtr->getSemantic(), dstOpMask);
}
}
}
// Update the bit mask offset.
paramBitMaskOffset += getParameterFloatCount(curSrcParam->getType());
}
}
}
示例2: writeFunctionParameter
//-----------------------------------------------------------------------
void CGProgramWriter::writeFunctionParameter(std::ostream& os, ParameterPtr parameter)
{
os << mGpuConstTypeMap[parameter->getType()];
os << "\t";
os << parameter->getName();
if (parameter->isArray() == true)
{
os << "[" << parameter->getSize() << "]";
}
if (parameter->getSemantic() != Parameter::SPS_UNKNOWN)
{
os << " : ";
os << mParamSemanticMap[parameter->getSemantic()];
if (parameter->getSemantic() != Parameter::SPS_POSITION &&
parameter->getSemantic() != Parameter::SPS_NORMAL &&
parameter->getSemantic() != Parameter::SPS_TANGENT &&
parameter->getSemantic() != Parameter::SPS_BLEND_INDICES &&
parameter->getSemantic() != Parameter::SPS_BLEND_WEIGHTS &&
(!(parameter->getSemantic() == Parameter::SPS_COLOR && parameter->getIndex() == 0)) &&
parameter->getIndex() >= 0)
{
os << StringConverter::toString(parameter->getIndex()).c_str();
}
}
}
示例3: resolveLocalParameter
//-----------------------------------------------------------------------------
ParameterPtr Function::resolveLocalParameter(Parameter::Semantic semantic, int index,
const String& name,
GpuConstantType type)
{
ParameterPtr param;
param = getParameterByName(mLocalParameters, name);
if (param.get() != NULL)
{
if (param->getType() == type &&
param->getSemantic() == semantic &&
param->getIndex() == index)
{
return param;
}
else
{
OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS,
"Can not resolve local parameter due to type mismatch. Function <" + getName() + ">",
"Function::resolveLocalParameter" );
}
}
param = ParameterPtr(OGRE_NEW Parameter(type, name, semantic, index, Parameter::SPC_UNKNOWN));
addParameter(mLocalParameters, param);
return param;
}
示例4: writeOutParameters
//-----------------------------------------------------------------------
void GLSLProgramWriter::writeOutParameters(std::ostream& os, Function* function, GpuProgramType gpuType)
{
const ShaderParameterList& outParams = function->getOutputParameters();
ShaderParameterConstIterator itParam = outParams.begin();
ShaderParameterConstIterator itParamEnd = outParams.end();
for ( ; itParam != itParamEnd; ++itParam)
{
ParameterPtr pParam = *itParam;
if(gpuType == GPT_VERTEX_PROGRAM)
{
// GLSL vertex program has to write always gl_Position (but this is also deprecated after version 130)
if(pParam->getContent() == Parameter::SPC_POSITION_PROJECTIVE_SPACE)
{
mInputToGLStatesMap[pParam->getName()] = "gl_Position";
}
else
{
// After GLSL 1.20 varying is deprecated
if(mGLSLVersion <= 120)
{
os << "varying\t";
}
else
{
os << "out\t";
}
os << mGpuConstTypeMap[pParam->getType()];
os << "\t";
os << pParam->getName();
if (pParam->isArray() == true)
{
os << "[" << pParam->getSize() << "]";
}
os << ";" << std::endl;
}
}
else if(gpuType == GPT_FRAGMENT_PROGRAM &&
pParam->getSemantic() == Parameter::SPS_COLOR)
{
// GLSL fragment program has to write always gl_FragColor (but this is also deprecated after version 130)
// Always add gl_FragColor as an output. The name is for compatibility.
if(mGLSLVersion <= 130)
{
mInputToGLStatesMap[pParam->getName()] = "gl_FragColor";
}
else
{
os << "out vec4 fragColour;" << std::endl;
mInputToGLStatesMap[pParam->getName()] = "fragColour";
}
}
}
}
示例5: 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;
}
}
}
}
示例6: writeLocalParameter
//-----------------------------------------------------------------------
void CGProgramWriter::writeLocalParameter(std::ostream& os, ParameterPtr parameter)
{
os << mGpuConstTypeMap[parameter->getType()];
os << "\t";
os << parameter->getName();
if (parameter->isArray() == true)
{
os << "[" << parameter->getSize() << "]";
}
}
示例7: getParameterFloatCount
//-----------------------------------------------------------------------------
void ProgramProcessor::MergeParameter::addSourceParameter(ParameterPtr srcParam, int mask)
{
// Case source count exceeded maximum
if (mSrcParameterCount >= 4)
{
OGRE_EXCEPT(Exception::ERR_INTERNAL_ERROR,
"Merged parameter source parameters overflow",
"MergeParameter::addSourceParameter");
}
mSrcParameter[mSrcParameterCount] = srcParam;
mSrcParameterMask[mSrcParameterCount] = mask;
if (mask == Operand::OPM_ALL)
{
mDstParameterMask[mSrcParameterCount] = mask;
mUsedFloatCount += getParameterFloatCount(srcParam->getType());
}
else
{
int srcParamFloatCount = Operand::getFloatCount(mask);
mDstParameterMask[mSrcParameterCount] = getParameterMaskByFloatCount(srcParamFloatCount) << mUsedFloatCount;
mUsedFloatCount += srcParamFloatCount;
}
mSrcParameterCount++;
// Case float count exceeded maximum
if (mUsedFloatCount > 4)
{
OGRE_EXCEPT(Exception::ERR_INTERNAL_ERROR,
"Merged parameter floats overflow",
"MergeParameter::addSourceParameter");
}
}
示例8: writeFunctionParameter
//-----------------------------------------------------------------------
void HLSLProgramWriter::writeFunctionParameter(std::ostream& os, ParameterPtr parameter)
{
os << mGpuConstTypeMap[parameter->getType()];
os << "\t";
os << parameter->getName();
if (parameter->getSemantic() != Parameter::SPS_UNKNOWN)
{
os << " : ";
os << mParamSemanticMap[parameter->getSemantic()];
if (parameter->getSemantic() != Parameter::SPS_POSITION &&
parameter->getSemantic() != Parameter::SPS_NORMAL &&
(!(parameter->getSemantic() == Parameter::SPS_COLOR && parameter->getIndex() == 0)) &&
parameter->getIndex() >= 0)
{
os << StringConverter::toString(parameter->getIndex()).c_str();
}
}
}
示例9: countVsTexcoordOutputs
//-----------------------------------------------------------------------------
void ProgramProcessor::countVsTexcoordOutputs(Function* vsMain,
int& outTexCoordSlots,
int& outTexCoordFloats)
{
outTexCoordSlots = 0;
outTexCoordFloats = 0;
const ShaderParameterList& vsOutputs = vsMain->getOutputParameters();
ShaderParameterConstIterator it = vsOutputs.begin();
ShaderParameterConstIterator itEnd = vsOutputs.end();
// Grab vertex shader output information.
for (; it != itEnd; ++it)
{
const ParameterPtr curParam = *it;
if (curParam->getSemantic() == Parameter::SPS_TEXTURE_COORDINATES)
{
outTexCoordSlots++;
outTexCoordFloats += getParameterFloatCount(curParam->getType());
}
}
}
示例10: writeInputParameters
//-----------------------------------------------------------------------
void GLSLProgramWriter::writeInputParameters(std::ostream& os, Function* function, GpuProgramType gpuType)
{
const ShaderParameterList& inParams = function->getInputParameters();
ShaderParameterConstIterator itParam = inParams.begin();
ShaderParameterConstIterator itParamEnd = inParams.end();
for ( ; itParam != itParamEnd; ++itParam)
{
ParameterPtr pParam = *itParam;
Parameter::Content paramContent = pParam->getContent();
String paramName = pParam->getName();
if (gpuType == GPT_FRAGMENT_PROGRAM)
{
// push fragment inputs they all could be written (in glsl you can not write
// input params in the fragment program)
mFragInputParams.push_back(paramName);
// In the vertex and fragment program the variable names must match.
// Unfortunately now the input params are prefixed with an 'i' and output params with 'o'.
// Thats why we are using a map for name mapping (we rename the params which are used in function atoms).
paramName.replace(paramName.begin(), paramName.begin() + 1, "o");
mInputToGLStatesMap[pParam->getName()] = paramName;
// After GLSL 1.20 varying is deprecated
if(mGLSLVersion <= 120)
{
os << "varying\t";
}
else
{
os << "in\t";
}
os << mGpuConstTypeMap[pParam->getType()];
os << "\t";
os << paramName;
os << ";" << std::endl;
}
else if (gpuType == GPT_VERTEX_PROGRAM &&
mContentToPerVertexAttributes.find(paramContent) != mContentToPerVertexAttributes.end())
{
// Due the fact that glsl does not have register like cg we have to rename the params
// according there content.
mInputToGLStatesMap[paramName] = mContentToPerVertexAttributes[paramContent];
// After GLSL 1.40 attribute is deprecated
if (mGLSLVersion >= 140)
{
os << "in\t";
}
else
{
os << "attribute\t";
}
// all uv texcoords passed by ogre are vec4
if (paramContent == Parameter::SPC_TEXTURE_COORDINATE0 ||
paramContent == Parameter::SPC_TEXTURE_COORDINATE1 ||
paramContent == Parameter::SPC_TEXTURE_COORDINATE2 ||
paramContent == Parameter::SPC_TEXTURE_COORDINATE3 ||
paramContent == Parameter::SPC_TEXTURE_COORDINATE4 ||
paramContent == Parameter::SPC_TEXTURE_COORDINATE5 ||
paramContent == Parameter::SPC_TEXTURE_COORDINATE6 ||
paramContent == Parameter::SPC_TEXTURE_COORDINATE7 )
{
os << "vec4";
}
else
{
os << mGpuConstTypeMap[pParam->getType()];
}
os << "\t";
os << mContentToPerVertexAttributes[paramContent];
os << ";" << std::endl;
}
else if(paramContent == Parameter::SPC_COLOR_DIFFUSE)
{
mInputToGLStatesMap[paramName] = "gl_Color";
}
else if(paramContent == Parameter::SPC_COLOR_SPECULAR)
{
mInputToGLStatesMap[paramName] = "gl_SecondaryColor";
}
else
{
os << "uniform \t ";
os << mGpuConstTypeMap[pParam->getType()];
os << "\t";
os << paramName;
os << ";" << std::endl;
}
}
}
示例11: writeForwardDeclarations
//-----------------------------------------------------------------------
void GLSLProgramWriter::writeForwardDeclarations(std::ostream& os, Program* program)
{
os << "//-----------------------------------------------------------------------------" << std::endl;
os << "// FORWARD DECLARATIONS" << std::endl;
os << "//-----------------------------------------------------------------------------" << std::endl;
StringVector forwardDecl; // holds all generated function declarations
const ShaderFunctionList& functionList = program->getFunctions();
ShaderFunctionConstIterator itFunction;
// Iterate over all functions in the current program (in our case this is always the main() function)
for ( itFunction = functionList.begin(); itFunction != functionList.end(); ++itFunction)
{
Function* curFunction = *itFunction;
const FunctionAtomInstanceList& atomInstances = curFunction->getAtomInstances();
FunctionAtomInstanceConstIterator itAtom = atomInstances.begin();
FunctionAtomInstanceConstIterator itAtomEnd = atomInstances.end();
// Now iterate over all function atoms
for ( ; itAtom != itAtomEnd; ++itAtom)
{
// Skip non function invocation atoms.
if ((*itAtom)->getFunctionAtomType() != FunctionInvocation::Type)
continue;
FunctionInvocation* pFuncInvoc = static_cast<FunctionInvocation*>(*itAtom);
FunctionInvocation::OperandVector::iterator itOperator = pFuncInvoc->getOperandList().begin();
FunctionInvocation::OperandVector::iterator itOperatorEnd = pFuncInvoc->getOperandList().end();
// Start with function declaration
String funcDecl = pFuncInvoc->getReturnType() + " " + pFuncInvoc->getFunctionName() + "(";
// Now iterate overall operands
for (; itOperator != itOperatorEnd; )
{
ParameterPtr pParam = (*itOperator).getParameter();
Operand::OpSemantic opSemantic = (*itOperator).getSemantic();
int opMask = (*itOperator).getMask();
GpuConstantType gpuType = GCT_UNKNOWN;
// Write the semantic in, out, inout
switch(opSemantic)
{
case Operand::OPS_IN:
funcDecl += "in ";
break;
case Operand::OPS_OUT:
funcDecl += "out ";
break;
case Operand::OPS_INOUT:
funcDecl += "inout ";
break;
default:
break;
}
// Swizzle masks are only defined for types like vec2, vec3, vec4.
if (opMask == Operand::OPM_ALL)
{
gpuType = pParam->getType();
}
else
{
// Now we have to convert the mask to operator
gpuType = Operand::getGpuConstantType(opMask);
}
// We need a valid type otherwise glsl compilation will not work
if (gpuType == GCT_UNKNOWN)
{
OGRE_EXCEPT( Exception::ERR_INTERNAL_ERROR,
"Can not convert Operand::OpMask to GpuConstantType",
"GLSLProgramWriter::writeForwardDeclarations" );
}
// Write the operand type.
funcDecl += mGpuConstTypeMap[gpuType];
++itOperator;
//move over all operators with indirection
while ((itOperator != itOperatorEnd) && (itOperator->getIndirectionLevel() != 0))
{
++itOperator;
}
// Prepare for the next operand
if (itOperator != itOperatorEnd)
{
funcDecl += ", ";
}
}
// Write function call closer.
funcDecl += ");\n";
// Push the generated declaration into the vector
// duplicate declarations will be removed later.
//.........这里部分代码省略.........
示例12: writeSourceCode
//-----------------------------------------------------------------------
void GLSLProgramWriter::writeSourceCode(std::ostream& os, Program* program)
{
GpuProgramType gpuType = program->getType();
if(gpuType == GPT_GEOMETRY_PROGRAM)
{
OGRE_EXCEPT( Exception::ERR_NOT_IMPLEMENTED,
"Geometry Program not supported in GLSL writer ",
"GLSLProgramWriter::writeSourceCode" );
}
// Clear out old input params
mFragInputParams.clear();
const ShaderFunctionList& functionList = program->getFunctions();
ShaderFunctionConstIterator itFunction;
const UniformParameterList& parameterList = program->getParameters();
UniformParameterConstIterator itUniformParam = parameterList.begin();
// Write the current version (this force the driver to more fulfill the glsl standard)
os << "#version "<< mGLSLVersion << std::endl;
// Generate source code header.
writeProgramTitle(os, program);
os<< std::endl;
// Write forward declarations
writeForwardDeclarations(os, program);
os<< std::endl;
// Generate global variable code.
writeUniformParametersTitle(os, program);
os << std::endl;
// Write the uniforms
for (itUniformParam = parameterList.begin(); itUniformParam != parameterList.end(); ++itUniformParam)
{
ParameterPtr pUniformParam = *itUniformParam;
os << "uniform\t";
os << mGpuConstTypeMap[pUniformParam->getType()];
os << "\t";
os << pUniformParam->getName();
if (pUniformParam->isArray() == true)
{
os << "[" << pUniformParam->getSize() << "]";
}
os << ";" << std::endl;
}
os << std::endl;
// Write program function(s).
for (itFunction=functionList.begin(); itFunction != functionList.end(); ++itFunction)
{
Function* curFunction = *itFunction;
writeFunctionTitle(os, curFunction);
// Clear output mapping this map is used when we use
// glsl built in types like gl_Color for example
mInputToGLStatesMap.clear();
// Write inout params and fill mInputToGLStatesMap
writeInputParameters(os, curFunction, gpuType);
writeOutParameters(os, curFunction, gpuType);
// The function name must always main.
os << "void main(void) {" << std::endl;
// Write local parameters.
const ShaderParameterList& localParams = curFunction->getLocalParameters();
ShaderParameterConstIterator itParam = localParams.begin();
ShaderParameterConstIterator itParamEnd = localParams.end();
for (; itParam != itParamEnd; ++itParam)
{
os << "\t";
writeLocalParameter(os, *itParam);
os << ";" << std::endl;
}
os << std::endl;
// Sort function atoms.
curFunction->sortAtomInstances();
const FunctionAtomInstanceList& atomInstances = curFunction->getAtomInstances();
FunctionAtomInstanceConstIterator itAtom = atomInstances.begin();
FunctionAtomInstanceConstIterator itAtomEnd = atomInstances.end();
for (; itAtom != itAtomEnd; ++itAtom)
{
FunctionInvocation* pFuncInvoc = (FunctionInvocation*)*itAtom;
FunctionInvocation::OperandVector::iterator itOperand = pFuncInvoc->getOperandList().begin();
FunctionInvocation::OperandVector::iterator itOperandEnd = pFuncInvoc->getOperandList().end();
// Local string stream
StringStream localOs;
// Write function name
//.........这里部分代码省略.........
示例13: 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);
}
}
}
}
}
示例14: 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();
//.........这里部分代码省略.........
示例15: writeLocalParameter
//-----------------------------------------------------------------------
void HLSLProgramWriter::writeLocalParameter(std::ostream& os, ParameterPtr parameter)
{
os << mGpuConstTypeMap[parameter->getType()];
os << "\t";
os << parameter->getName();
}