int mipbias = 4; // 3 is sufficient, but at 4 it loads

        #endregion Fields

        #region Constructors

        public VirtualTexture( D3D10.Device device, VirtualTextureInfo info, int atlassize, int uploadsperframe, string filename )
        {
            this.device = device;
            this.info   = info;

            this.atlascount = atlassize / info.PageSize;
            this.uploadsperframe = uploadsperframe;

            indexer = new PageIndexer( info );
            toload = new List<PageCount>( indexer.Count );

            Console.Write( "Creating PageAtlas...");
            atlas = new TextureAtlas( device, info, atlascount, uploadsperframe );
            Console.WriteLine("done.");

            Console.Write( "Creating PageLoader..." );
            loader = new PageLoader( filename + ".cache", indexer, info );
            Console.WriteLine("done.");

            cache = new PageCache( info, atlas, loader, indexer, atlascount );

            Console.Write( "Creating PageTable...");
            pagetable = new PageTable( device, cache, info, indexer );
            Console.WriteLine("done.");
        }
Example #2
0
        public PageLoader( string filename, PageIndexer indexer, VirtualTextureInfo info )
        {
            this.filename = filename;
            this.info = info;
            this.indexer = indexer;

            file = new TileDataFile( filename, info, FileAccess.Read );

            readthread = new ProcessingThread<ReadState>( LoadPage, PageLoadComplete );
        }
Example #3
0
        int current; // This is used for generating the texture atlas indices before the lru is full

        #endregion Fields

        #region Constructors

        public PageCache( VirtualTextureInfo info, TextureAtlas atlas, PageLoader loader, PageIndexer indexer, int count )
        {
            this.info  = info;
            this.atlas = atlas;
            this.loader = loader;
            this.indexer = indexer;
            this.count = count;

            lru = new LruCollection<Page,Point>( count * count );
            lru.Removed += ( page, point ) => Removed( page, point );

            loader.LoadComplete += LoadComplete;

            loading = new HashSet<Page>();
        }
Example #4
0
        public PageTable( D3D10.Device device, PageCache cache, VirtualTextureInfo info, PageIndexer indexer )
        {
            this.info = info;
            this.device = device;
            this.indexer = indexer;

            quadtree = new Quadtree(new Rectangle(0, 0, info.PageTableSize, info.PageTableSize), MathExtensions.Log2(info.PageTableSize));

            int size = info.PageTableSize;
            texture = new Direct3D.Texture( device, size, size, DXGI.Format.R8G8B8A8_UNorm, D3D10.ResourceUsage.Default, 0 );
            staging = new Direct3D.WriteTexture( device, size, size, DXGI.Format.R8G8B8A8_UNorm );

            cache.Added   += ( Page page, Point pt ) => quadtree.Add( page, pt );
            cache.Removed += ( Page page, Point pt ) => quadtree.Remove( page );

            SetupDataAndInfo();
        }