void SharedStateSet::BeginRenderState( const ModelRendererContext& context, SharedRenderStateSet renderStateSetIndex) const { assert(_pimpl->_capturedContext == context._context); if (_currentRenderState == renderStateSetIndex) { return; } const Techniques::CompiledRenderStateSet* compiled = nullptr; auto statesHash = _pimpl->_renderStateHashes[renderStateSetIndex.Value()]; auto hash = HashCombine(statesHash, _pimpl->_currentGlobalRenderState); auto i = LowerBound(_pimpl->_compiledStates, hash); if (i != _pimpl->_compiledStates.end() && i->first == hash) { compiled = &i->second; } else { const auto& states = _pimpl->_renderStateSets[renderStateSetIndex.Value()]; auto newlyCompiled = _pimpl->_currentStateResolver->Resolve( states, *_pimpl->_environment, context._techniqueIndex); compiled = &_pimpl->_compiledStates.insert( i, std::make_pair(hash, std::move(newlyCompiled)))->second; } assert(compiled); if (compiled->_blendState.GetUnderlying()) context._context->Bind(compiled->_blendState); context._context->Bind(compiled->_rasterizerState); _currentRenderState = renderStateSetIndex; }
std::vector<const ModelSupplementScaffold*> ModelCache::Pimpl::LoadSupplementScaffolds( const ResChar modelFilename[], const ResChar materialFilename[], IteratorRange<const SupplementGUID*> supplements) { std::vector<const ModelSupplementScaffold*> result; for (auto s=supplements.cbegin(); s!=supplements.cend(); ++s) { auto hashName = HashCombine(HashCombine(Hash64(modelFilename), Hash64(materialFilename)), *s); auto supp = _supplements.Get(hashName); if (!supp || supp->GetDependencyValidation()->GetValidationIndex() > 0) { supp = Internal::CreateSupplement(*s, modelFilename, materialFilename); if (supp) _supplements.Insert(hashName, supp); } if (supp) result.push_back(supp.get()); } return std::move(result); }
FAssetDataGatherer::FAssetDataGatherer(const TArray<FString>& InPaths, const TArray<FString>& InSpecificFiles, bool bInIsSynchronous, EAssetDataCacheMode AssetDataCacheMode) : StopTaskCounter( 0 ) , bIsSynchronous( bInIsSynchronous ) , bIsDiscoveringFiles( false ) , SearchStartTime( 0 ) , NumPathsToSearchAtLastSyncPoint( InPaths.Num() ) , bLoadAndSaveCache( false ) , bFinishedInitialDiscovery( false ) , Thread(nullptr) { bGatherDependsData = GIsEditor && !FParse::Param( FCommandLine::Get(), TEXT("NoDependsGathering") ); if (FParse::Param(FCommandLine::Get(), TEXT("NoAssetRegistryCache")) || FParse::Param(FCommandLine::Get(), TEXT("multiprocess"))) { bLoadAndSaveCache = false; } else if (AssetDataCacheMode != EAssetDataCacheMode::NoCache) { if (AssetDataCacheMode == EAssetDataCacheMode::UseMonolithicCache) { bLoadAndSaveCache = true; CacheFilename = FPaths::GameIntermediateDir() / TEXT("CachedAssetRegistry.bin"); } else if (InPaths.Num() > 0) { // todo: handle hash collisions? uint32 CacheHash = GetTypeHash(InPaths[0]); for (int32 PathIndex = 1; PathIndex < InPaths.Num(); ++PathIndex) { CacheHash = HashCombine(CacheHash, GetTypeHash(InPaths[PathIndex])); } bLoadAndSaveCache = true; CacheFilename = FPaths::GameIntermediateDir() / TEXT("AssetRegistryCache") / FString::Printf(TEXT("%08x.bin"), CacheHash); } } // Add any specific files before doing search AddFilesToSearch(InSpecificFiles); if ( bIsSynchronous ) { // Run the package file discovery synchronously FAssetDataDiscovery PackageFileDiscovery(InPaths, bIsSynchronous); PackageFileDiscovery.GetAndTrimSearchResults(DiscoveredPaths, FilesToSearch, NumPathsToSearchAtLastSyncPoint); Run(); } else { BackgroundPackageFileDiscovery = MakeShareable(new FAssetDataDiscovery(InPaths, bIsSynchronous)); Thread = FRunnableThread::Create(this, TEXT("FAssetDataGatherer"), 0, TPri_BelowNormal); } }
FIndexKey::FIndexKey(FString InNodePath, UMovieSceneSection* InSection) : NodePath(MoveTemp(InNodePath)) , Section(InSection) , CachedHash(HashCombine(GetTypeHash(NodePath), GetTypeHash(InSection))) {}
uint32 GetTypeHash(const FPortableObjectEntryIdentity& ID) { const uint32 HashA = HashCombine(GetTypeHash(ID.MsgCtxt), GetTypeHash(ID.MsgId)); const uint32 HashB = GetTypeHash(ID.MsgIdPlural); return HashCombine(HashA, HashB); }