/// <summary>
        /// Gets the aligned sizes of the specified texture information.
        /// The alignment depends on the texture layout and format bytes per pixel.
        /// </summary>
        /// <param name="info">Texture information to calculate the aligned size from</param>
        /// <param name="level">Mipmap level for texture views</param>
        /// <returns>The aligned texture size</returns>
        public static Size GetAlignedSize(TextureInfo info, int level = 0)
        {
            int width  = Math.Max(1, info.Width >> level);
            int height = Math.Max(1, info.Height >> level);

            if (info.IsLinear)
            {
                return(SizeCalculator.GetLinearAlignedSize(
                           width,
                           height,
                           info.FormatInfo.BlockWidth,
                           info.FormatInfo.BlockHeight,
                           info.FormatInfo.BytesPerPixel));
            }
            else
            {
                int depth = Math.Max(1, info.GetDepth() >> level);

                return(SizeCalculator.GetBlockLinearAlignedSize(
                           width,
                           height,
                           depth,
                           info.FormatInfo.BlockWidth,
                           info.FormatInfo.BlockHeight,
                           info.FormatInfo.BytesPerPixel,
                           info.GobBlocksInY,
                           info.GobBlocksInZ,
                           info.GobBlocksInTileX));
            }
        }
Example #2
0
 /// <summary>
 /// Gets the aligned sizes for the given dimensions, using the specified texture information.
 /// The alignment depends on the texture layout and format bytes per pixel.
 /// </summary>
 /// <param name="info">Texture information to calculate the aligned size from</param>
 /// <param name="width">The width to be aligned</param>
 /// <param name="height">The height to be aligned</param>
 /// <param name="depth">The depth to be aligned</param>
 /// <returns>The aligned texture size</returns>
 private static Size GetAlignedSize(TextureInfo info, int width, int height, int depth)
 {
     if (info.IsLinear)
     {
         return(SizeCalculator.GetLinearAlignedSize(
                    width,
                    height,
                    info.FormatInfo.BlockWidth,
                    info.FormatInfo.BlockHeight,
                    info.FormatInfo.BytesPerPixel));
     }
     else
     {
         return(SizeCalculator.GetBlockLinearAlignedSize(
                    width,
                    height,
                    depth,
                    info.FormatInfo.BlockWidth,
                    info.FormatInfo.BlockHeight,
                    info.FormatInfo.BytesPerPixel,
                    info.GobBlocksInY,
                    info.GobBlocksInZ,
                    info.GobBlocksInTileX));
     }
 }