Ejemplo n.º 1
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="size">Texture view size</param>
        /// <param name="isCopy">True to check for copy compability, instead of view compatibility</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>True if a view with the given parameters can be created from this texture, false otherwise</returns>
        public bool IsViewCompatible(
            TextureInfo info,
            ulong size,
            bool isCopy,
            out int firstLayer,
            out int firstLevel)
        {
            // Out of range.
            if (info.Address < Address || info.Address + size > EndAddress)
            {
                firstLayer = 0;
                firstLevel = 0;

                return(false);
            }

            int offset = (int)(info.Address - Address);

            if (!_sizeInfo.FindView(offset, (int)size, out firstLayer, out firstLevel))
            {
                return(false);
            }

            if (!ViewLayoutCompatible(info, firstLevel))
            {
                return(false);
            }

            if (!ViewFormatCompatible(info))
            {
                return(false);
            }

            if (!ViewSizeMatches(info, firstLevel, isCopy))
            {
                return(false);
            }

            if (!ViewTargetCompatible(info, isCopy))
            {
                return(false);
            }

            return(Info.SamplesInX == info.SamplesInX &&
                   Info.SamplesInY == info.SamplesInY);
        }
Ejemplo n.º 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="size">Texture view size</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,
            ulong size,
            out int firstLayer,
            out int firstLevel)
        {
            // Out of range.
            if (info.Address < Address || info.Address + size > EndAddress)
            {
                firstLayer = 0;
                firstLevel = 0;

                return(TextureViewCompatibility.Incompatible);
            }

            int offset = (int)(info.Address - Address);

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

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

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

            TextureViewCompatibility result = TextureViewCompatibility.Full;

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

            return((Info.SamplesInX == info.SamplesInX &&
                    Info.SamplesInY == info.SamplesInY) ? result : TextureViewCompatibility.Incompatible);
        }
Ejemplo n.º 3
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);
        }