コード例 #1
0
ファイル: OgreGpuProgram.cpp プロジェクト: whztt07/ogre3d
    //---------------------------------------------------------------------
    void GpuProgram::setManualNamedConstants(const GpuNamedConstants& namedConstants)
    {
        createParameterMappingStructures();
        *mConstantDefs.get() = namedConstants;

        mFloatLogicalToPhysical->bufferSize = mConstantDefs->floatBufferSize;
        mIntLogicalToPhysical->bufferSize = mConstantDefs->intBufferSize;
        mFloatLogicalToPhysical->map.clear();
        mIntLogicalToPhysical->map.clear();
        // need to set up logical mappings too for some rendersystems
        for (GpuConstantDefinitionMap::const_iterator i = mConstantDefs->map.begin();
            i != mConstantDefs->map.end(); ++i)
        {
            const String& name = i->first;
            const GpuConstantDefinition& def = i->second;
            // only consider non-array entries
            if (name.find("[") == String::npos)
            {
                GpuLogicalIndexUseMap::value_type val(def.logicalIndex, 
                    GpuLogicalIndexUse(def.physicalIndex, def.arraySize * def.elementSize, def.variability));
                if (def.isFloat())
                {
                    mFloatLogicalToPhysical->map.insert(val);
                }
                else
                {
                    mIntLogicalToPhysical->map.insert(val);
                }
            }
        }


    }
コード例 #2
0
	//-----------------------------------------------------------------------
	void GLSLProgram::buildConstantDefinitions() const
	{
		// We need an accurate list of all the uniforms in the shader, but we
		// can't get at them until we link all the shaders into a program object.

		// Therefore instead, parse the source code manually and extract the uniforms
		createParameterMappingStructures(true);
        if(Root::getSingleton().getRenderSystem()->getCapabilities()->hasCapability(RSC_SEPARATE_SHADER_OBJECTS))
        {
            GLSLProgramPipelineManager::getSingleton().extractConstantDefs(mSource, *mConstantDefs.get(), mName);
        }
        else
        {
            GLSLLinkProgramManager::getSingleton().extractConstantDefs(mSource, *mConstantDefs.get(), mName);
        }

		// Also parse any attached sources
		for (GLSLProgramContainer::const_iterator i = mAttachedGLSLPrograms.begin();
			i != mAttachedGLSLPrograms.end(); ++i)
		{
			GLSLProgram* childShader = *i;

            if(Root::getSingleton().getRenderSystem()->getCapabilities()->hasCapability(RSC_SEPARATE_SHADER_OBJECTS))
            {
                GLSLProgramPipelineManager::getSingleton().extractConstantDefs(childShader->getSource(),
                                                                               *mConstantDefs.get(), childShader->getName());
            }
            else
            {
                GLSLLinkProgramManager::getSingleton().extractConstantDefs(childShader->getSource(),
                                                                           *mConstantDefs.get(), childShader->getName());
            }
		}
	}
コード例 #3
0
	//-----------------------------------------------------------------------
	void GLSLESProgram::buildConstantDefinitions() const
	{
		// We need an accurate list of all the uniforms in the shader, but we
		// can't get at them until we link all the shaders into a program object.

		// Therefore instead, parse the source code manually and extract the uniforms
		createParameterMappingStructures(true);
		GLSLESLinkProgramManager::getSingleton().extractConstantDefs(
			mSource, *mConstantDefs.get(), mName);
	}
コード例 #4
0
ファイル: OgreGpuProgram.cpp プロジェクト: whztt07/ogre3d
 //-----------------------------------------------------------------------------
 GpuProgram::GpuProgram(ResourceManager* creator, const String& name, ResourceHandle handle,
     const String& group, bool isManual, ManualResourceLoader* loader) 
     :Resource(creator, name, handle, group, isManual, loader),
     mType(GPT_VERTEX_PROGRAM), mLoadFromFile(true), mSkeletalAnimation(false),
     mMorphAnimation(false), mPoseAnimation(0),
     mVertexTextureFetch(false), mNeedsAdjacencyInfo(false),
     mCompileError(false), mLoadedManualNamedConstants(false)
 {
     createParameterMappingStructures();
 }
コード例 #5
0
    //-----------------------------------------------------------------------
    void CgProgram::buildConstantDefinitions() const
    {
        // Derive parameter names from Cg
		createParameterMappingStructures(true);

		if (!mCgProgram)
			return;

		recurseParams(cgGetFirstParameter(mCgProgram, CG_PROGRAM));
        recurseParams(cgGetFirstParameter(mCgProgram, CG_GLOBAL));
	}
コード例 #6
0
    //---------------------------------------------------------------------------
    void HighLevelGpuProgram::unloadHighLevel(void)
    {
        if (mHighLevelLoaded)
        {
            unloadHighLevelImpl();
			// Clear saved constant defs
			mConstantDefsBuilt = false;
			createParameterMappingStructures(true);

            mHighLevelLoaded = false;
        }
    }
コード例 #7
0
//-----------------------------------------------------------------------
void GLSLESProgram::buildConstantDefinitions() const
{
    // We need an accurate list of all the uniforms in the shader, but we
    // can't get at them until we link all the shaders into a program object.

    // Therefore instead, parse the source code manually and extract the uniforms
    createParameterMappingStructures(true);
    if(Root::getSingleton().getRenderSystem()->getCapabilities()->hasCapability(RSC_SEPARATE_SHADER_OBJECTS))
    {
        GLSLESProgramPipelineManager::getSingleton().extractConstantDefs(mSource, *mConstantDefs.get(), mName);
    }
    else
    {
        GLSLESLinkProgramManager::getSingleton().extractConstantDefs(mSource, *mConstantDefs.get(), mName);
    }
}
コード例 #8
0
ファイル: OgreCgProgram.cpp プロジェクト: wjwwood/ogre
	//-----------------------------------------------------------------------
	void CgProgram::buildConstantDefinitions() const
	{
		// Derive parameter names from Cg
		createParameterMappingStructures(true);

		if ( mProgramString.empty() )
			return;
				
		mConstantDefs->floatBufferSize = mFloatLogicalToPhysical->bufferSize;
		mConstantDefs->intBufferSize = mIntLogicalToPhysical->bufferSize;

		GpuConstantDefinitionMap::const_iterator iter = mParametersMap.begin();
		GpuConstantDefinitionMap::const_iterator iterE = mParametersMap.end();
		for (; iter != iterE ; iter++)
		{
			const String & paramName = iter->first;
			GpuConstantDefinition def = iter->second;

			mConstantDefs->map.insert(GpuConstantDefinitionMap::value_type(iter->first, iter->second));

			// Record logical / physical mapping
			if (def.isFloat())
			{
							OGRE_LOCK_MUTEX(mFloatLogicalToPhysical->mutex);
				mFloatLogicalToPhysical->map.insert(
					GpuLogicalIndexUseMap::value_type(def.logicalIndex, 
						GpuLogicalIndexUse(def.physicalIndex, def.arraySize * def.elementSize, GPV_GLOBAL)));
				mFloatLogicalToPhysical->bufferSize += def.arraySize * def.elementSize;
			}
			else
			{
							OGRE_LOCK_MUTEX(mIntLogicalToPhysical->mutex);
				mIntLogicalToPhysical->map.insert(
					GpuLogicalIndexUseMap::value_type(def.logicalIndex, 
						GpuLogicalIndexUse(def.physicalIndex, def.arraySize * def.elementSize, GPV_GLOBAL)));
				mIntLogicalToPhysical->bufferSize += def.arraySize * def.elementSize;
			}

			// Deal with array indexing
			mConstantDefs->generateConstantDefinitionArrayEntries(paramName, def);
		}
	}