예제 #1
0
    //---------------------------------------------------------------------
    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());
            }
		}
	}
	//-----------------------------------------------------------------------
	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
 //-----------------------------------------------------------------------------
 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));
	}
    //---------------------------------------------------------------------------
    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
	//-----------------------------------------------------------------------
	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);
		}
	}