FVulkanPipelineStateCache::~FVulkanPipelineStateCache() { DestroyCache(); VulkanRHI::vkDestroyPipelineCache(Device->GetInstanceHandle(), PipelineCache, nullptr); PipelineCache = VK_NULL_HANDLE; }
void FVulkanPipelineStateCache::RebuildCache() { UE_LOG(LogVulkanRHI, Warning, TEXT("Rebuilding pipeline cache; ditching %d entries"), DiskEntries.Num()); if (IsInGameThread()) { FlushRenderingCommands(); } DestroyCache(); }
BtreeBucket *BtreeCache::ConstructCache(unsigned num_bkts, BtreeSize_t dbkey_size, BtreeNodeOrder_t order) // Constructs and initialize and array of buckets. NOTE: This // implementation uses contiguous memory for the cache buckets. // Returns a pointer to the bucket array or a null value if an // error occurs. { if(!IsEmpty()) DestroyCache(); // Set minimum number of buckets. The gxBtree tree insert function // requires a minimum of 2 cache buckets (left and right pointers) // and both delete functions require a minimum of 3 cache buckets // (left, right, and parent pointers). if((num_bkts == 0) || (num_bkts < (unsigned)MIN_BTREECACHE_SEGMENTS)) { num_bkts = MIN_BTREECACHE_SEGMENTS; } num_buckets = num_bkts; buckets = new BtreeBucket[num_bkts]; // Construct an array of buckets if(buckets) InitCache(dbkey_size, order); ResetStats(); return buckets; }
static int CacheFile(char const *fname) { int r; CachedFile *cf; CachedLine *cl; char const *s; if (DebugFlag & DB_TRACE_FILES) { fprintf(ErrFp, "Caching file `%s' in memory\n", fname); } cl = NULL; /* Create a file header */ cf = NEW(CachedFile); cf->cache = NULL; if (!cf) { ShouldCache = 0; FCLOSE(fp); return E_NO_MEM; } cf->filename = StrDup(fname); if (!cf->filename) { ShouldCache = 0; FCLOSE(fp); free(cf); return E_NO_MEM; } if (RunDisabled & RUN_NOTOWNER) { cf->ownedByMe = 0; } else { cf->ownedByMe = 1; } /* Read the file */ while(fp) { r = ReadLineFromFile(); if (r) { DestroyCache(cf); ShouldCache = 0; FCLOSE(fp); return r; } /* Skip blank chars */ s = DBufValue(&LineBuffer); while (isempty(*s)) s++; if (*s && *s!=';' && *s!='#') { /* Add the line to the cache */ if (!cl) { cf->cache = NEW(CachedLine); if (!cf->cache) { DBufFree(&LineBuffer); DestroyCache(cf); ShouldCache = 0; FCLOSE(fp); return E_NO_MEM; } cl = cf->cache; } else { cl->next = NEW(CachedLine); if (!cl->next) { DBufFree(&LineBuffer); DestroyCache(cf); ShouldCache = 0; FCLOSE(fp); return E_NO_MEM; } cl = cl->next; } cl->next = NULL; cl->LineNo = LineNo; cl->text = StrDup(s); DBufFree(&LineBuffer); if (!cl->text) { DestroyCache(cf); ShouldCache = 0; FCLOSE(fp); return E_NO_MEM; } } } /* Put the cached file at the head of the queue */ cf->next = CachedFiles; CachedFiles = cf; return OK; }