示例#1
0
    //---------------------------------------------------------------------
    void GpuProgramManager::loadMicrocodeCache( DataStreamPtr stream )
    {
        mMicrocodeCache.clear();

        // write the size of the array
        uint32 sizeOfArray = 0;
        stream->read(&sizeOfArray, sizeof(uint32));
        
        // loop the array and load it

        for ( uint32 i = 0 ; i < sizeOfArray ; i++ )
        {
            String nameOfShader;
            // loads the name of the shader
            uint32 stringLength  = 0;
            stream->read(&stringLength, sizeof(uint32));
            nameOfShader.resize(stringLength);              
            stream->read(&nameOfShader[0], stringLength);

            // loads the microcode
            uint32 microcodeLength = 0;
            stream->read(&microcodeLength, sizeof(uint32));     

            Microcode microcodeOfShader(OGRE_NEW MemoryDataStream(nameOfShader, microcodeLength));      
            microcodeOfShader->seek(0);
            stream->read(microcodeOfShader->getPtr(), microcodeLength);

            mMicrocodeCache.insert(make_pair(nameOfShader, microcodeOfShader));
        }

        // if cache is not modified, mark it as clean.
        mCacheDirty = false;
        
    }
	//---------------------------------------------------------------------
	void GpuProgramManager::loadMicrocodeCache( DataStreamPtr stream )
	{
		mMicrocodeCache.clear();

		// write the size of the array
		size_t sizeOfArray = 0;
		stream->read(&sizeOfArray, sizeof(size_t));
		
		// loop the array and load it

		for ( size_t i = 0 ; i < sizeOfArray ; i++ )
		{
			String nameOfShader;
			// loads the name of the shader
			size_t stringLength  = 0;
			stream->read(&stringLength, sizeof(size_t));
			nameOfShader.resize(stringLength);				
			stream->read(&nameOfShader[0], stringLength);

			// loads the microcode
			size_t microcodeLength = 0;
			stream->read(&microcodeLength, sizeof(size_t));		

			Microcode microcodeOfShader(OGRE_NEW MemoryDataStream(nameOfShader, microcodeLength)); 		
			microcodeOfShader->seek(0);
			stream->read(microcodeOfShader->getPtr(), microcodeLength);

			mMicrocodeCache.insert(make_pair(nameOfShader, microcodeOfShader));
		}
	}