diff --git a/Source/Engine/GraphicsDevice/Vulkan/GPUDeviceVulkan.cpp b/Source/Engine/GraphicsDevice/Vulkan/GPUDeviceVulkan.cpp index 33df0db47..ea9e6a990 100644 --- a/Source/Engine/GraphicsDevice/Vulkan/GPUDeviceVulkan.cpp +++ b/Source/Engine/GraphicsDevice/Vulkan/GPUDeviceVulkan.cpp @@ -1363,23 +1363,7 @@ PixelFormat GPUDeviceVulkan::GetClosestSupportedPixelFormat(PixelFormat format, if (flags & GPUTextureFlags::UnorderedAccess) wantedFeatureFlags |= VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT; - // Check actual device for format support - const auto isSupported = [&](VkFormat vkFormat) - { - VkFormatProperties props; - vkGetPhysicalDeviceFormatProperties(Adapter->Gpu, vkFormat, &props); - const VkFormatFeatureFlags featureFlags = optimalTiling ? props.optimalTilingFeatures : props.linearTilingFeatures; - if ((featureFlags & wantedFeatureFlags) != wantedFeatureFlags) - return false; - - //VkImageFormatProperties imageProps; - //vkGetPhysicalDeviceImageFormatProperties(Adapter->Gpu, vkFormat, , &imageProps); - - return true; - }; - - VkFormat vkFormat = RenderToolsVulkan::ToVulkanFormat(format); - if (!isSupported(vkFormat)) + if (!IsVkFormatSupported(RenderToolsVulkan::ToVulkanFormat(format), wantedFeatureFlags, optimalTiling)) { // Special case for depth-stencil formats if (flags & GPUTextureFlags::DepthStencil) @@ -1389,7 +1373,7 @@ PixelFormat GPUDeviceVulkan::GetClosestSupportedPixelFormat(PixelFormat format, // Spec guarantees at least one depth-only, and one depth-stencil format to be supported if (hasStencil) { - if (isSupported(VK_FORMAT_D32_SFLOAT_S8_UINT)) + if (IsVkFormatSupported(VK_FORMAT_D32_SFLOAT_S8_UINT, wantedFeatureFlags, optimalTiling)) format = PixelFormat::D32_Float; else format = PixelFormat::D24_UNorm_S8_UInt; @@ -1493,6 +1477,20 @@ bool GPUDeviceVulkan::SaveValidationCache() #endif +bool GPUDeviceVulkan::IsVkFormatSupported(VkFormat vkFormat, VkFormatFeatureFlags wantedFeatureFlags, bool optimalTiling) const +{ + VkFormatProperties props; + vkGetPhysicalDeviceFormatProperties(Adapter->Gpu, vkFormat, &props); + const VkFormatFeatureFlags featureFlags = optimalTiling ? props.optimalTilingFeatures : props.linearTilingFeatures; + if ((featureFlags & wantedFeatureFlags) != wantedFeatureFlags) + return false; + + //VkImageFormatProperties imageProps; + //vkGetPhysicalDeviceImageFormatProperties(Adapter->Gpu, vkFormat, , &imageProps); + + return true; +} + GPUContext* GPUDeviceVulkan::GetMainContext() { return reinterpret_cast(MainContext); diff --git a/Source/Engine/GraphicsDevice/Vulkan/GPUDeviceVulkan.h b/Source/Engine/GraphicsDevice/Vulkan/GPUDeviceVulkan.h index 9bab15dda..ba972932b 100644 --- a/Source/Engine/GraphicsDevice/Vulkan/GPUDeviceVulkan.h +++ b/Source/Engine/GraphicsDevice/Vulkan/GPUDeviceVulkan.h @@ -720,6 +720,10 @@ public: #endif +private: + + bool IsVkFormatSupported(VkFormat vkFormat, VkFormatFeatureFlags wantedFeatureFlags, bool optimalTiling) const; + public: // [GPUDevice]