//--------------------------------------------------------------------- uint32 StreamSerialiser::calculateChecksum(Chunk* c) { // Always calculate checksums in little endian to make sure they match // Otherwise checksums for the same data on different endians will not match uint32 id = c->id; uint16 version = c->version; uint32 length = c->length; #if OGRE_ENDIAN == OGRE_ENDIAN_BIG Bitwise::bswapBuffer(&id, sizeof(uint32)); Bitwise::bswapBuffer(&version, sizeof(uint16)); Bitwise::bswapBuffer(&length, sizeof(uint32)); #endif uint32 hashVal = FastHash((const char*)&id, sizeof(uint32)); hashVal = FastHash((const char*)&version, sizeof(uint16), hashVal); hashVal = FastHash((const char*)&length, sizeof(uint32), hashVal); return hashVal; }
size_t QuickIndexImpl::GetHash( const std::string &path ) { size_t hash = FastHash(path); hash = hash & kEntryHashMask; if (hash >= kMaxEntriesCount) { hash = 0; } return hash; }
//----------------------------------------------------------------------- GLSLProgramPipeline* GLSLProgramPipelineManager::getActiveProgramPipeline(void) { // If there is an active link program then return it if (mActiveProgramPipeline) return mActiveProgramPipeline; // No active link program so find one or make a new one // Is there an active key? uint32 activeKey = 0; GLuint progID = 0; if (mActiveVertexGpuProgram) { progID = mActiveVertexGpuProgram->getProgramID(); activeKey = FastHash((const char *)(&progID), sizeof(GLuint), activeKey); } if (mActiveFragmentGpuProgram) { progID = mActiveFragmentGpuProgram->getProgramID(); activeKey = FastHash((const char *)(&progID), sizeof(GLuint), activeKey); } if (mActiveGeometryGpuProgram) { progID = mActiveGeometryGpuProgram->getProgramID(); activeKey = FastHash((const char *)(&progID), sizeof(GLuint), activeKey); } if (mActiveDomainGpuProgram) { progID = mActiveDomainGpuProgram->getProgramID(); activeKey = FastHash((const char *)(&progID), sizeof(GLuint), activeKey); } if (mActiveHullGpuProgram) { progID = mActiveHullGpuProgram->getProgramID(); activeKey = FastHash((const char *)(&progID), sizeof(GLuint), activeKey); } if (mActiveComputeGpuProgram) { progID = mActiveComputeGpuProgram->getProgramID(); activeKey = FastHash((const char *)(&progID), sizeof(GLuint), activeKey); } // Only return a program pipeline object if a vertex or fragment stage exist if (activeKey > 0) { // Find the key in the hash map ProgramPipelineIterator programFound = mProgramPipelines.find(activeKey); // Program object not found for key so need to create it if (programFound == mProgramPipelines.end()) { mActiveProgramPipeline = new GLSLProgramPipeline(mActiveVertexGpuProgram, mActiveGeometryGpuProgram, mActiveFragmentGpuProgram, mActiveHullGpuProgram, mActiveDomainGpuProgram, mActiveComputeGpuProgram); mProgramPipelines[activeKey] = mActiveProgramPipeline; } else { // Found a link program in map container so make it active mActiveProgramPipeline = programFound->second; } } // Make the program object active if (mActiveProgramPipeline) mActiveProgramPipeline->activate(); return mActiveProgramPipeline; }