/// <summary>
 /// Creates a new parallel disk cache loader.
 /// </summary>
 /// <param name="context">GPU context</param>
 /// <param name="graphicsCache">Graphics shader cache</param>
 /// <param name="computeCache">Compute shader cache</param>
 /// <param name="hostStorage">Disk cache host storage</param>
 /// <param name="cancellationToken">Cancellation token</param>
 /// <param name="stateChangeCallback">Function to be called when there is a state change, reporting state, compiled and total shaders count</param>
 public ParallelDiskCacheLoader(
     GpuContext context,
     ShaderCacheHashTable graphicsCache,
     ComputeShaderCacheHashTable computeCache,
     DiskCacheHostStorage hostStorage,
     CancellationToken cancellationToken,
     Action <ShaderCacheState, int, int> stateChangeCallback)
 {
     _context                       = context;
     _graphicsCache                 = graphicsCache;
     _computeCache                  = computeCache;
     _hostStorage                   = hostStorage;
     _cancellationToken             = cancellationToken;
     _stateChangeCallback           = stateChangeCallback;
     _validationQueue               = new Queue <ProgramEntry>();
     _compilationQueue              = new ConcurrentQueue <ProgramCompilation>();
     _asyncTranslationQueue         = new BlockingCollection <AsyncProgramTranslation>(ThreadCount);
     _programList                   = new SortedList <int, CachedShaderProgram>();
     _backendParallelCompileThreads = Math.Min(Environment.ProcessorCount, 8); // Must be kept in sync with the backend code.
 }
Exemple #2
0
 /// <summary>
 /// Creates a new background disk cache writer.
 /// </summary>
 /// <param name="context">GPU context</param>
 /// <param name="hostStorage">Disk cache host storage</param>
 public BackgroundDiskCacheWriter(GpuContext context, DiskCacheHostStorage hostStorage)
 {
     _context               = context;
     _hostStorage           = hostStorage;
     _fileWriterWorkerQueue = new AsyncWorkQueue <CacheFileOperationTask>(ProcessTask, "Gpu.BackgroundDiskCacheWriter");
 }