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


C++ GpuProgramParametersSharedPtr::_findRawAutoConstantEntryFloat方法代码示例

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


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

示例1: calculateMaxNumInstances

	//-----------------------------------------------------------------------
	size_t InstanceBatchShader::calculateMaxNumInstances( const SubMesh *baseSubMesh, uint16 flags ) const
	{
		const size_t numBones = std::max<size_t>( 1, baseSubMesh->blendIndexToBoneIndexMap.size() );

		mMaterial->load();
		Technique *technique = mMaterial->getBestTechnique();
		if( technique )
		{
			GpuProgramParametersSharedPtr vertexParam = technique->getPass(0)->getVertexProgramParameters();
			GpuConstantDefinitionIterator itor = vertexParam->getConstantDefinitionIterator();
			while( itor.hasMoreElements() )
			{
				const GpuConstantDefinition &constDef = itor.getNext();
				if(((constDef.constType == GCT_MATRIX_3X4 ||
					constDef.constType == GCT_MATRIX_4X3 ||             //OGL GLSL bitches without this
					constDef.constType == GCT_MATRIX_2X4 ||
					constDef.constType == GCT_FLOAT4)                   //OGL GLSL bitches without this
					&& constDef.isFloat()) ||
                   ((constDef.constType == GCT_MATRIX_DOUBLE_3X4 ||
					constDef.constType == GCT_MATRIX_DOUBLE_4X3 ||		//OGL GLSL bitches without this
					constDef.constType == GCT_MATRIX_DOUBLE_2X4 ||
					constDef.constType == GCT_DOUBLE4)                  //OGL GLSL bitches without this
                    && constDef.isDouble())
                   )
				{
					const GpuProgramParameters::AutoConstantEntry *entry =
									vertexParam->_findRawAutoConstantEntryFloat( constDef.physicalIndex );
					if( entry && (entry->paramType == GpuProgramParameters::ACT_WORLD_MATRIX_ARRAY_3x4 || entry->paramType == GpuProgramParameters::ACT_WORLD_DUALQUATERNION_ARRAY_2x4))
					{
						//Material is correctly done!
						size_t arraySize = constDef.arraySize;

						//Deal with GL "hacky" way of doing 4x3 matrices
						if(entry->paramType == GpuProgramParameters::ACT_WORLD_MATRIX_ARRAY_3x4 && constDef.constType == GCT_FLOAT4)
							arraySize /= 3;
						else if(entry->paramType == GpuProgramParameters::ACT_WORLD_DUALQUATERNION_ARRAY_2x4 && constDef.constType == GCT_FLOAT4)
							arraySize /= 2;

						//Check the num of arrays
						size_t retVal = arraySize / numBones;

						if( flags & IM_USE16BIT )
						{
							if( baseSubMesh->vertexData->vertexCount * retVal > 0xFFFF )
								retVal = 0xFFFF / baseSubMesh->vertexData->vertexCount;
						}

						if((retVal < 3 && entry->paramType == GpuProgramParameters::ACT_WORLD_MATRIX_ARRAY_3x4) ||
							(retVal < 2 && entry->paramType == GpuProgramParameters::ACT_WORLD_DUALQUATERNION_ARRAY_2x4))
						{
							LogManager::getSingleton().logMessage( "InstanceBatchShader: Mesh " +
										mMeshReference->getName() + " using material " +
										mMaterial->getName() + " contains many bones. The amount of "
										"instances per batch is very low. Performance benefits will "
										"be minimal, if any. It might be even slower!",
										LML_NORMAL );
						}

						return retVal;
					}
				}
			}

			//Reaching here means material is supported, but malformed
			OGRE_EXCEPT( Exception::ERR_INVALIDPARAMS, 
			"Material '" + mMaterial->getName() + "' is malformed for this instancing technique",
			"InstanceBatchShader::calculateMaxNumInstances");
		}

		//Reaching here the material is just unsupported.

		return 0;
	}
开发者ID:j-rivero,项目名称:ogre-acornacorn,代码行数:74,代码来源:OgreInstanceBatchShader.cpp


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