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.");
        }
        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();
        }