Пример #1
0
        private RobAndSliceSizes GetRobAndSliceSizes(int width, int height, GobBlockSizes gbSizes)
        {
            int widthInGobs = BitUtils.DivRoundUp(width * _texBpp, GobWidth);

            int robSize = GobSize * gbSizes.Height * gbSizes.Depth * widthInGobs;

            int sliceSize = BitUtils.DivRoundUp(height, gbSizes.Height * GobHeight) * robSize;

            return(new RobAndSliceSizes(robSize, sliceSize));
        }
Пример #2
0
        public int GetMipOffset(int level)
        {
            int totalSize = 0;

            for (int index = 0; index < level; index++)
            {
                int width  = Math.Max(1, _texWidth >> index);
                int height = Math.Max(1, _texHeight >> index);
                int depth  = Math.Max(1, _texDepth >> index);

                GobBlockSizes gbSizes = AdjustGobBlockSizes(height, depth);

                RobAndSliceSizes rsSizes = GetRobAndSliceSizes(width, height, gbSizes);

                totalSize += BitUtils.DivRoundUp(depth, gbSizes.Depth) * rsSizes.SliceSize;
            }

            return(totalSize);
        }
Пример #3
0
        public void SetMipLevel(int level)
        {
            _baseOffset = GetMipOffset(level);

            int width  = Math.Max(1, _texWidth >> level);
            int height = Math.Max(1, _texHeight >> level);
            int depth  = Math.Max(1, _texDepth >> level);

            GobBlockSizes gbSizes = AdjustGobBlockSizes(height, depth);

            _bhMask = gbSizes.Height - 1;
            _bdMask = gbSizes.Depth - 1;

            _bhShift = BitUtils.CountTrailingZeros32(gbSizes.Height);
            _bdShift = BitUtils.CountTrailingZeros32(gbSizes.Depth);

            _xShift = BitUtils.CountTrailingZeros32(GobSize * gbSizes.Height * gbSizes.Depth);

            RobAndSliceSizes gsSizes = GetRobAndSliceSizes(width, height, gbSizes);

            _robSize   = gsSizes.RobSize;
            _sliceSize = gsSizes.SliceSize;
        }