From 87fa46c10d129eeef8abb1be11c51e1927957275 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Fri, 18 Aug 2023 09:39:58 -0400 Subject: [PATCH] zink: use VkFormatProperties3 but wrap it in a smaller type to save some space Part-of: --- src/gallium/drivers/zink/zink_resource.c | 6 +++--- src/gallium/drivers/zink/zink_screen.c | 15 +++++++++++---- src/gallium/drivers/zink/zink_types.h | 8 +++++++- 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/src/gallium/drivers/zink/zink_resource.c b/src/gallium/drivers/zink/zink_resource.c index 53696d6..2873d6c 100644 --- a/src/gallium/drivers/zink/zink_resource.c +++ b/src/gallium/drivers/zink/zink_resource.c @@ -371,7 +371,7 @@ check_ici(struct zink_screen *screen, VkImageCreateInfo *ici, uint64_t modifier) } static VkImageUsageFlags -get_image_usage_for_feats(struct zink_screen *screen, VkFormatFeatureFlags feats, const struct pipe_resource *templ, unsigned bind, bool *need_extended) +get_image_usage_for_feats(struct zink_screen *screen, VkFormatFeatureFlags2 feats, const struct pipe_resource *templ, unsigned bind, bool *need_extended) { VkImageUsageFlags usage = 0; bool is_planar = util_format_get_num_planes(templ->format) > 1; @@ -537,8 +537,8 @@ get_image_usage(struct zink_screen *screen, VkImageCreateInfo *ici, const struct } } } else { - VkFormatProperties props = screen->format_props[templ->format]; - VkFormatFeatureFlags feats = tiling == VK_IMAGE_TILING_LINEAR ? props.linearTilingFeatures : props.optimalTilingFeatures; + struct zink_format_props props = screen->format_props[templ->format]; + VkFormatFeatureFlags2 feats = tiling == VK_IMAGE_TILING_LINEAR ? props.linearTilingFeatures : props.optimalTilingFeatures; if (ici->flags & VK_IMAGE_CREATE_EXTENDED_USAGE_BIT) feats = UINT32_MAX; VkImageUsageFlags usage = get_image_usage_for_feats(screen, feats, templ, bind, &need_extended); diff --git a/src/gallium/drivers/zink/zink_screen.c b/src/gallium/drivers/zink/zink_screen.c index 3a597b8..935bf17 100644 --- a/src/gallium/drivers/zink/zink_screen.c +++ b/src/gallium/drivers/zink/zink_screen.c @@ -1394,7 +1394,7 @@ zink_is_format_supported(struct pipe_screen *pscreen, } } - VkFormatProperties props = screen->format_props[format]; + struct zink_format_props props = screen->format_props[format]; if (target == PIPE_BUFFER) { if (bind & PIPE_BIND_VERTEX_BUFFER) { @@ -2078,7 +2078,9 @@ retry: props3.pNext = props.pNext; props.pNext = &props3; VKSCR(GetPhysicalDeviceFormatProperties2)(screen->pdev, format, &props); - screen->format_props[i] = props.formatProperties; + screen->format_props[i].linearTilingFeatures = props3.linearTilingFeatures; + screen->format_props[i].optimalTilingFeatures = props3.optimalTilingFeatures; + screen->format_props[i].bufferFeatures = props3.bufferFeatures; if (props3.linearTilingFeatures & VK_FORMAT_FEATURE_2_LINEAR_COLOR_ATTACHMENT_BIT_NV) screen->format_props[i].linearTilingFeatures |= VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT; if (screen->info.have_EXT_image_drm_format_modifier && mod_props.drmFormatModifierCount) { @@ -2089,8 +2091,13 @@ retry: screen->modifier_props[i].pDrmFormatModifierProperties[j] = mod_props.pDrmFormatModifierProperties[j]; } } - } else - VKSCR(GetPhysicalDeviceFormatProperties)(screen->pdev, format, &screen->format_props[i]); + } else { + VkFormatProperties props = {0}; + VKSCR(GetPhysicalDeviceFormatProperties)(screen->pdev, format, &props); + screen->format_props[i].linearTilingFeatures = props.linearTilingFeatures; + screen->format_props[i].optimalTilingFeatures = props.optimalTilingFeatures; + screen->format_props[i].bufferFeatures = props.bufferFeatures; + } if (i == PIPE_FORMAT_A8_UNORM && !screen->driver_workarounds.missing_a8_unorm) { if (!screen->format_props[i].linearTilingFeatures && !screen->format_props[i].optimalTilingFeatures && diff --git a/src/gallium/drivers/zink/zink_types.h b/src/gallium/drivers/zink/zink_types.h index 8550ccf..5a85c61 100644 --- a/src/gallium/drivers/zink/zink_types.h +++ b/src/gallium/drivers/zink/zink_types.h @@ -1369,6 +1369,12 @@ struct zink_modifier_prop { VkDrmFormatModifierPropertiesEXT* pDrmFormatModifierProperties; }; +struct zink_format_props { + VkFormatFeatureFlags2 linearTilingFeatures; + VkFormatFeatureFlags2 optimalTilingFeatures; + VkFormatFeatureFlags2 bufferFeatures; +}; + struct zink_screen { struct pipe_screen base; @@ -1503,7 +1509,7 @@ struct zink_screen { bool zink_shader_object_enable; } driconf; - VkFormatProperties format_props[PIPE_FORMAT_COUNT]; + struct zink_format_props format_props[PIPE_FORMAT_COUNT]; struct zink_modifier_prop modifier_props[PIPE_FORMAT_COUNT]; VkExtent2D maxSampleLocationGridSize[5]; -- 2.7.4