public BufferedPhysicalTexture(String name, IntSize2 size, VirtualTextureManager virtualTextureManager, int texelsPerPage, PixelFormat pixelFormat)
 {
     Index                      = currentId++;
     this.name                  = name;
     this.texelsPerPage         = texelsPerPage;
     this.size                  = size;
     this.virtualTextureManager = virtualTextureManager;
     this.textureName           = "PhysicalTexture" + name;
     this.pixelFormat           = pixelFormat;
     createTexture();
 }
Пример #2
0
        public FeedbackBuffer(VirtualTextureManager virtualTextureManager, IntSize2 renderSize, int id, uint visibilityMask)
        {
            this.id = id;
            this.virtualTextureManager = virtualTextureManager;
            this.visibilityMask        = visibilityMask;

            texture = TextureManager.getInstance().createManual(TextureName, VirtualTextureManager.ResourceGroup, TextureType.TEX_TYPE_2D, (uint)renderSize.Width, (uint)renderSize.Height, 1, 0, OgrePlugin.PixelFormat.PF_A8R8G8B8, TextureUsage.TU_RENDERTARGET, null, false, 0);

            fullBitmap    = new FreeImageBitmap((int)texture.Value.Width, (int)texture.Value.Height, FreeImageAPI.PixelFormat.Format32bppRgb);
            fullBitmapBox = fullBitmap.createPixelBox(OgrePlugin.PixelFormat.PF_A8R8G8B8);

            pixelBuffer = texture.Value.getBuffer();
            pixelBuffer.Value.OptimizeReadback = true;
            renderTexture = pixelBuffer.Value.getRenderTarget();
            renderTexture.setAutoUpdated(false);
        }
Пример #3
0
        public IndirectionTexture(String materialSetKey, IntSize2 realTextureSize, int texelsPerPage, VirtualTextureManager virtualTextureManager, bool keepHighestMip)
        {
            this.MaterialSetKey        = materialSetKey;
            this.keepHighestMip        = keepHighestMip;
            this.virtualTextureManager = virtualTextureManager;
            this.realTextureSize       = realTextureSize;
            numPages = realTextureSize / texelsPerPage;
            if (numPages.Width == 0)
            {
                numPages.Width = 1;
            }
            if (numPages.Height == 0)
            {
                numPages.Height = 1;
            }
            for (highestMip = 0; realTextureSize.Width >> highestMip >= texelsPerPage && realTextureSize.Height >> highestMip >= texelsPerPage; ++highestMip)
            {
            }
            indirectionTexture = TextureManager.getInstance().createManual(String.Format("{0}_IndirectionTexture_{1}", materialSetKey, id), VirtualTextureManager.ResourceGroup, TextureType.TEX_TYPE_2D,
                                                                           (uint)numPages.Width, (uint)numPages.Height, 1, highestMip - 1, bufferFormat, virtualTextureManager.RendersystemSpecificTextureUsage, null, false, 0);
            indirectionTexture.Value.AllowMipmapGeneration = false;

            fiBitmap = new Image[highestMip];
            buffer   = new HardwarePixelBufferSharedPtr[highestMip];
            pixelBox = new PixelBox[highestMip];

            for (int i = 0; i < highestMip; ++i)
            {
                fiBitmap[i] = new Image(indirectionTexture.Value.Width >> i, indirectionTexture.Value.Height >> i, 1, indirectionTexture.Value.Format, 1, 0);
                buffer[i]   = indirectionTexture.Value.getBuffer(0, (uint)i);
                pixelBox[i] = fiBitmap[i].getPixelBox();

#if DEBUG_MIP_LEVELS
                //Temp, debug mip levels
                for (uint x = 0; x < fiBitmap[i].Width; ++x)
                {
                    for (uint y = 0; y < fiBitmap[i].Height; ++y)
                    {
                        fiBitmap[i].setColorAtARGB(new IntColor((byte)255, (byte)x, (byte)y, (byte)i).ARGB, x, y, 0);
                    }
                }
#endif
            }

            restorePermanentPages();
        }
Пример #4
0
        public TextureLoader(VirtualTextureManager virtualTextureManager, IntSize2 physicalTextureSize, int textelsPerPage, int padding, int stagingBufferCount, int stagingImageCapacity, int maxMipCount, UInt64 maxCacheSizeBytes, bool texturesArePagedOnDisk)
        {
            textureCache = new TextureCache(maxCacheSizeBytes, texturesArePagedOnDisk);
            this.virtualTextureManager = virtualTextureManager;
            IntSize2 pageTableSize = physicalTextureSize / textelsPerPage;

            this.maxPages               = pageTableSize.Width * pageTableSize.Height;
            this.textelsPerPage         = textelsPerPage;
            this.padding                = padding;
            this.padding2               = padding * 2;
            this.textelsPerPhysicalPage = textelsPerPage + padding2;
            this.Overprevisioned        = true;
            this.physicalTextureSize    = physicalTextureSize;

            addedPages   = new HashSet <VTexPage>();
            removedPages = new List <VTexPage>(10);
            pagesToLoad  = new List <VTexPage>(10);

            stagingBufferSets = new List <StagingBufferSet>(stagingBufferCount);
            for (int i = 0; i < stagingBufferCount; ++i)
            {
                stagingBufferSets.Add(new StagingBufferSet(stagingImageCapacity, maxMipCount));
            }
            copyTostagingImageTasks = new Task <bool> [stagingImageCapacity];

            float scale = (float)textelsPerPage / textelsPerPhysicalPage;

            PagePaddingScale = new Vector2(scale, scale);

            scale             = (float)padding / textelsPerPhysicalPage;
            PagePaddingOffset = new Vector2(scale, scale);

            //Build pool
            physicalPageQueue = new List <PTexPage>(maxPages);
            physicalPagePool  = new Dictionary <VTexPage, PTexPage>();
            usedPhysicalPages = new Dictionary <VTexPage, PTexPage>();
            populatePhysicalPageQueue();
        }