Example #1
0
 /// <summary>
 /// Checks if the potential child texture fits within the level and layer bounds of the parent.
 /// </summary>
 /// <param name="parent">Texture information for the parent</param>
 /// <param name="child">Texture information for the child</param>
 /// <param name="layer">Base layer of the child texture</param>
 /// <param name="level">Base level of the child texture</param>
 /// <returns>Full compatiblity if the child's layer and level count fit within the parent, incompatible otherwise</returns>
 public static TextureViewCompatibility ViewSubImagesInBounds(TextureInfo parent, TextureInfo child, int layer, int level)
 {
     if (level + child.Levels <= parent.Levels &&
         layer + child.GetSlices() <= parent.GetSlices())
     {
         return(TextureViewCompatibility.Full);
     }
     else
     {
         return(TextureViewCompatibility.LayoutIncompatible);
     }
 }
Example #2
0
        /// <summary>
        /// Check if it's possible to create a view, with the given parameters, from this texture.
        /// </summary>
        /// <param name="info">Texture view information</param>
        /// <param name="range">Texture view physical memory ranges</param>
        /// <param name="firstLayer">Texture view initial layer on this texture</param>
        /// <param name="firstLevel">Texture view first mipmap level on this texture</param>
        /// <returns>The level of compatiblilty a view with the given parameters created from this texture has</returns>
        public TextureViewCompatibility IsViewCompatible(TextureInfo info, MultiRange range, int layerSize, out int firstLayer, out int firstLevel)
        {
            int offset = Range.FindOffset(range);

            // Out of range.
            if (offset < 0)
            {
                firstLayer = 0;
                firstLevel = 0;

                return(TextureViewCompatibility.Incompatible);
            }

            if (!_sizeInfo.FindView(offset, out firstLayer, out firstLevel))
            {
                return(TextureViewCompatibility.Incompatible);
            }

            if (!TextureCompatibility.ViewLayoutCompatible(Info, info, firstLevel))
            {
                return(TextureViewCompatibility.Incompatible);
            }

            if (info.GetSlices() > 1 && LayerSize != layerSize)
            {
                return(TextureViewCompatibility.Incompatible);
            }

            TextureViewCompatibility result = TextureViewCompatibility.Full;

            result = TextureCompatibility.PropagateViewCompatibility(result, TextureCompatibility.ViewFormatCompatible(Info, info));
            result = TextureCompatibility.PropagateViewCompatibility(result, TextureCompatibility.ViewSizeMatches(Info, info, firstLevel));
            result = TextureCompatibility.PropagateViewCompatibility(result, TextureCompatibility.ViewTargetCompatible(Info, info));
            result = TextureCompatibility.PropagateViewCompatibility(result, TextureCompatibility.ViewSubImagesInBounds(Info, info, firstLayer, firstLevel));

            return((Info.SamplesInX == info.SamplesInX &&
                    Info.SamplesInY == info.SamplesInY) ? result : TextureViewCompatibility.Incompatible);
        }