public VkFormat ConvertToVertexVkFormat(GAL.Format srcFormat) { var format = FormatTable.GetFormat(srcFormat); if (!BufferFormatSupports(FormatFeatureFlags.FormatFeatureVertexBufferBit, srcFormat) || (IsRGB16IntFloat(srcFormat) && VulkanConfiguration.ForceRGB16IntFloatUnsupported)) { // The format is not supported. Can we convert it to an alternative format? switch (srcFormat) { case GAL.Format.R16G16B16Float: format = VkFormat.R16G16B16A16Sfloat; break; case GAL.Format.R16G16B16Sint: format = VkFormat.R16G16B16A16Sint; break; case GAL.Format.R16G16B16Uint: format = VkFormat.R16G16B16A16Uint; break; default: Logger.Error?.Print(LogClass.Gpu, $"Format {srcFormat} is not supported by the host."); break; } } return(format); }
public TextureBuffer(VulkanRenderer gd, TextureCreateInfo info, float scale) { _gd = gd; Width = info.Width; Height = info.Height; VkFormat = FormatTable.GetFormat(info.Format); ScaleFactor = scale; gd.Textures.Add(this); }
public bool FormatSupports(GAL.Format format, FormatFeatureFlags flags) { var formatFeatureFlags = _table[(int)format]; if (formatFeatureFlags == 0) { _api.GetPhysicalDeviceFormatProperties(_physicalDevice, FormatTable.GetFormat(format), out var fp); formatFeatureFlags = fp.OptimalTilingFeatures; _table[(int)format] = formatFeatureFlags; } return((formatFeatureFlags & flags) == flags); }
public bool BufferFormatSupports(FormatFeatureFlags flags, GAL.Format format) { var formatFeatureFlags = _bufferTable[(int)format]; if (formatFeatureFlags == 0) { _api.GetPhysicalDeviceFormatProperties(_physicalDevice, FormatTable.GetFormat(format), out var fp); formatFeatureFlags = fp.BufferFeatures; _bufferTable[(int)format] = formatFeatureFlags; } return((formatFeatureFlags & flags) == flags); }
public BufferView GetBufferView(CommandBufferScoped cbs, GAL.Format format) { var vkFormat = FormatTable.GetFormat(format); if (vkFormat == VkFormat) { return GetBufferView(cbs); } if (_selfManagedViews != null && _selfManagedViews.TryGetValue(format, out var bufferView)) { return bufferView.Get(cbs, _offset, _size).Value; } bufferView = _gd.BufferManager.CreateView(_bufferHandle, vkFormat, _offset, _size); if (bufferView != null) { (_selfManagedViews ??= new Dictionary<GAL.Format, Auto<DisposableBufferView>>()).Add(format, bufferView); } return bufferView?.Get(cbs, _offset, _size).Value ?? default; }
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); }