diff options
Diffstat (limited to 'src/gallium/drivers/zink/zink_screen.c')
-rw-r--r-- | src/gallium/drivers/zink/zink_screen.c | 34 |
1 files changed, 31 insertions, 3 deletions
diff --git a/src/gallium/drivers/zink/zink_screen.c b/src/gallium/drivers/zink/zink_screen.c index 667f242091c..a75389257af 100644 --- a/src/gallium/drivers/zink/zink_screen.c +++ b/src/gallium/drivers/zink/zink_screen.c @@ -569,10 +569,33 @@ static const VkFormat formats[PIPE_FORMAT_COUNT] = { [PIPE_FORMAT_BPTC_RGB_UFLOAT] = VK_FORMAT_BC6H_UFLOAT_BLOCK, }; +static bool +is_depth_format_supported(struct zink_screen *screen, VkFormat format) +{ + VkFormatProperties props; + vkGetPhysicalDeviceFormatProperties(screen->pdev, format, &props); + return (props.linearTilingFeatures | props.optimalTilingFeatures) & + VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT; +} + VkFormat -zink_get_format(enum pipe_format format) +zink_get_format(struct zink_screen *screen, enum pipe_format format) { - return formats[format]; + VkFormat ret = formats[format]; + + if (ret == VK_FORMAT_X8_D24_UNORM_PACK32 && + !screen->have_X8_D24_UNORM_PACK32) { + assert(is_depth_format_supported(screen, VK_FORMAT_D32_SFLOAT)); + return VK_FORMAT_D32_SFLOAT; + } + + if (ret == VK_FORMAT_D24_UNORM_S8_UINT && + !screen->have_D24_UNORM_S8_UINT) { + assert(is_depth_format_supported(screen, VK_FORMAT_D32_SFLOAT_S8_UINT)); + return VK_FORMAT_D32_SFLOAT_S8_UINT; + } + + return ret; } static VkSampleCountFlagBits @@ -605,7 +628,7 @@ zink_is_format_supported(struct pipe_screen *pscreen, return screen->props.limits.framebufferNoAttachmentsSampleCounts & vk_sample_count_flags(sample_count); - VkFormat vkformat = formats[format]; + VkFormat vkformat = zink_get_format(screen, format); if (vkformat == VK_FORMAT_UNDEFINED) return FALSE; @@ -830,6 +853,11 @@ zink_internal_create_screen(struct sw_winsys *winsys, int fd) vkGetPhysicalDeviceFeatures(screen->pdev, &screen->feats); vkGetPhysicalDeviceMemoryProperties(screen->pdev, &screen->mem_props); + screen->have_X8_D24_UNORM_PACK32 = is_depth_format_supported(screen, + VK_FORMAT_X8_D24_UNORM_PACK32); + screen->have_D24_UNORM_S8_UINT = is_depth_format_supported(screen, + VK_FORMAT_D24_UNORM_S8_UINT); + uint32_t num_extensions = 0; if (vkEnumerateDeviceExtensionProperties(screen->pdev, NULL, &num_extensions, NULL) == VK_SUCCESS && num_extensions > 0) { |