Пример #1
0
        public VkFormat ConvertToVkFormat(GAL.Format srcFormat)
        {
            var format = FormatTable.GetFormat(srcFormat);

            var requiredFeatures = FormatFeatureFlags.FormatFeatureSampledImageBit |
                                   FormatFeatureFlags.FormatFeatureTransferSrcBit |
                                   FormatFeatureFlags.FormatFeatureTransferDstBit;

            if (srcFormat.IsDepthOrStencil())
            {
                requiredFeatures |= FormatFeatureFlags.FormatFeatureDepthStencilAttachmentBit;
            }
            else if (srcFormat.IsRtColorCompatible())
            {
                requiredFeatures |= FormatFeatureFlags.FormatFeatureColorAttachmentBit;
            }

            if (srcFormat.IsImageCompatible())
            {
                requiredFeatures |= FormatFeatureFlags.FormatFeatureStorageImageBit;
            }

            if (!FormatSupports(srcFormat, requiredFeatures))
            {
                // The format is not supported. Can we convert it to a higher precision format?
                if (srcFormat == GAL.Format.D24UnormS8Uint)
                {
                    format = VkFormat.D32SfloatS8Uint;
                }
                else
                {
                    Logger.Error?.Print(LogClass.Gpu, $"Format {srcFormat} is not supported by the host.");
                }
            }

            return(format);
        }