예제 #1
0
 /// <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.
 }
예제 #2
0
        /// <summary>
        /// Creates a new instance of the shader cache.
        /// </summary>
        /// <param name="context">GPU context that the shader cache belongs to</param>
        public ShaderCache(GpuContext context)
        {
            _context = context;

            _dumper = new ShaderDumper();

            _cpPrograms = new Dictionary <ulong, CachedShaderProgram>();
            _gpPrograms = new Dictionary <ShaderAddresses, CachedShaderProgram>();

            _programsToSaveQueue = new Queue <ProgramToSave>();

            string diskCacheTitleId = GetDiskCachePath();

            _computeShaderCache   = new ComputeShaderCacheHashTable();
            _graphicsShaderCache  = new ShaderCacheHashTable();
            _diskCacheHostStorage = new DiskCacheHostStorage(diskCacheTitleId);

            if (_diskCacheHostStorage.CacheEnabled)
            {
                _cacheWriter = new BackgroundDiskCacheWriter(context, _diskCacheHostStorage);
            }
        }
예제 #3
0
        /// <summary>
        /// Creates a new instance of the shader cache.
        /// </summary>
        /// <param name="context">GPU context that the shader cache belongs to</param>
        public ShaderCache(GpuContext context)
        {
            _context = context;

            _dumper = new ShaderDumper();

            _cpPrograms = new Dictionary <ulong, CachedShaderProgram>();
            _gpPrograms = new Dictionary <ShaderAddresses, CachedShaderProgram>();

            _programsToSaveQueue = new Queue <ProgramToSave>();

            string diskCacheTitleId = GraphicsConfig.EnableShaderCache && GraphicsConfig.TitleId != null
                ? CacheHelper.GetBaseCacheDirectory(GraphicsConfig.TitleId)
                : null;

            _computeShaderCache   = new ComputeShaderCacheHashTable();
            _graphicsShaderCache  = new ShaderCacheHashTable();
            _diskCacheHostStorage = new DiskCacheHostStorage(diskCacheTitleId);

            if (_diskCacheHostStorage.CacheEnabled)
            {
                _cacheWriter = new BackgroundDiskCacheWriter(context, _diskCacheHostStorage);
            }
        }