| 623 | } |
| 624 | |
| 625 | static void GetDepthFormatAndTiling(VkPhysicalDevice vk_physical_device, const VkFormat* vk_format_list, uint8_t vk_format_list_size, VkFormat* vk_format_out, VkImageTiling* vk_tiling_out) |
| 626 | { |
| 627 | // Depth formats are optional, so we need to query |
| 628 | // what available formats we have. |
| 629 | const VkFormat vk_format_list_default[] = { |
| 630 | VK_FORMAT_D32_SFLOAT_S8_UINT, |
| 631 | VK_FORMAT_D32_SFLOAT, |
| 632 | VK_FORMAT_D24_UNORM_S8_UINT, |
| 633 | VK_FORMAT_D16_UNORM_S8_UINT, |
| 634 | VK_FORMAT_D16_UNORM |
| 635 | }; |
| 636 | |
| 637 | const VkFormat* vk_formats_to_test = vk_format_list ? vk_format_list : vk_format_list_default; |
| 638 | uint8_t vk_formats_to_test_size = vk_format_list ? vk_format_list_size : sizeof(vk_format_list_default) / sizeof(vk_format_list_default[0]); |
| 639 | |
| 640 | // Check if we can use optimal tiling for this format, otherwise |
| 641 | // we try to find the best format that supports linear |
| 642 | VkImageTiling vk_image_tiling = VK_IMAGE_TILING_OPTIMAL; |
| 643 | VkFormat vk_depth_format = GetSupportedTilingFormat(vk_physical_device, &vk_formats_to_test[0], |
| 644 | vk_formats_to_test_size, vk_image_tiling, VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT); |
| 645 | |
| 646 | if (vk_depth_format == VK_FORMAT_UNDEFINED) |
| 647 | { |
| 648 | vk_image_tiling = VK_IMAGE_TILING_LINEAR; |
| 649 | vk_depth_format = GetSupportedTilingFormat(vk_physical_device, &vk_formats_to_test[0], |
| 650 | vk_formats_to_test_size, vk_image_tiling, VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT); |
| 651 | } |
| 652 | |
| 653 | *vk_format_out = vk_depth_format; |
| 654 | *vk_tiling_out = vk_image_tiling; |
| 655 | } |
| 656 | |
| 657 | static VkResult CreateDepthStencilTexture(VulkanContext* context, VkFormat vk_depth_format, VkImageTiling vk_depth_tiling, |
| 658 | uint32_t width, uint32_t height, VkSampleCountFlagBits vk_sample_count, VkImageAspectFlags vk_aspect_flags, VulkanTexture* depth_stencil_texture_out) |
no test coverage detected