public BlockLinearLayout( int width, int height, int depth, int gobBlocksInY, int gobBlocksInZ, int bpp) { _texBpp = bpp; _bppShift = BitUtils.CountTrailingZeros32(bpp); _bhMask = gobBlocksInY - 1; _bdMask = gobBlocksInZ - 1; _bhShift = BitUtils.CountTrailingZeros32(gobBlocksInY); _bdShift = BitUtils.CountTrailingZeros32(gobBlocksInZ); _xShift = BitUtils.CountTrailingZeros32(GobSize * gobBlocksInY * gobBlocksInZ); RobAndSliceSizes rsSizes = GetRobAndSliceSizes(width, height, gobBlocksInY, gobBlocksInZ); _robSize = rsSizes.RobSize; _sliceSize = rsSizes.SliceSize; }
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); }
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; }