예제 #1
0
        public void Copy(
            byte[] src, int srcWidth, int srcHeight, int srcMipBias,
            Texture2D dst, int dstElement, int dstX, int dstY, int dstMipLimit)
        {
            var dstData = _cache.GetValue(dst, _getData);

            var fmtInfo = TextureFormatInfo.FromFormatID(dst.format);

            Debug.Assert(fmtInfo.HasValue);
            var bPixels = fmtInfo.Value.BlockPixelCount;
            var bBytes  = fmtInfo.Value.BlockDataSize;

            for (int m = 0; m < dstMipLimit; m++)
            {
                var srcOffset = GetMipOffset(srcWidth, srcHeight, m + srcMipBias, bPixels);
                var dstOffset = GetMipOffset(dst.width, dst.height, m, bPixels);

                for (int y = 0; y < srcHeight; y += bPixels)
                {
                    Buffer.BlockCopy(
                        src,
                        (srcOffset + (y / bPixels) * (srcWidth / bPixels)) * bBytes,
                        dstData,
                        (dstOffset + (((dstY + y) / bPixels) * (dst.width / bPixels) + (dstX / bPixels))) * bBytes,
                        (srcWidth / bPixels) * bBytes
                        );
                }
            }

            dst.LoadRawTextureData(dstData);
            dst.Apply(false, false);
        }
예제 #2
0
파일: VT0Info.cs 프로젝트: sasa42/VT0
 public float EstimateVRAM(int materialCount)
 {
     checked {
         return(Channels.Sum(c => {
             var fmt = TextureFormatInfo.FromFormatID(c.Format);
             if (fmt == null)
             {
                 return 0;
             }
             return c.Count * (4.0f / 3.0f) *
             (((float)VTSize * VTSize + materialCount * (float)ThumbSize * ThumbSize)
              * fmt.Value.BlockDataSize)
             / (fmt.Value.BlockPixelCount * fmt.Value.BlockPixelCount);
         }));
     }
 }