zink: implement VK_EXT_robustness2
authorMike Blumenkrantz <michael.blumenkrantz@gmail.com>
Thu, 2 Jul 2020 18:53:45 +0000 (14:53 -0400)
committerMarge Bot <eric+marge@anholt.net>
Mon, 3 Aug 2020 14:22:39 +0000 (14:22 +0000)
this adds support for null descriptors, which is necessary for full
compliance with ARB_texture_buffer_object

Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5913>

src/gallium/drivers/zink/zink_screen.c
src/gallium/drivers/zink/zink_screen.h

index 1ccb1da0b0093c82a788abc14472009d5ec545b6..ad46d60b0979e52e87e79614a79cb8bc0a76b905 100644 (file)
@@ -759,7 +759,8 @@ static struct pipe_screen *
 zink_internal_create_screen(struct sw_winsys *winsys, int fd)
 {
    struct zink_screen *screen = CALLOC_STRUCT(zink_screen);
-   bool have_tf_ext = false, have_cond_render_ext = false, have_EXT_index_type_uint8 = false;
+   bool have_tf_ext = false, have_cond_render_ext = false, have_EXT_index_type_uint8 = false,
+      have_EXT_robustness2_features = false;
    if (!screen)
       return NULL;
 
@@ -801,6 +802,9 @@ zink_internal_create_screen(struct sw_winsys *winsys, int fd)
             if (!strcmp(extensions[i].extensionName,
                         VK_EXT_INDEX_TYPE_UINT8_EXTENSION_NAME))
                have_EXT_index_type_uint8 = true;
+            if (!strcmp(extensions[i].extensionName,
+                        VK_EXT_ROBUSTNESS_2_EXTENSION_NAME))
+               have_EXT_robustness2_features = true;
 
          }
          FREE(extensions);
@@ -827,6 +831,11 @@ zink_internal_create_screen(struct sw_winsys *winsys, int fd)
       index_uint8_feats.pNext = feats.pNext;
       feats.pNext = &index_uint8_feats;
    }
+   if (have_EXT_robustness2_features) {
+      screen->rb2_feats.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ROBUSTNESS_2_FEATURES_EXT;
+      screen->rb2_feats.pNext = feats.pNext;
+      feats.pNext = &screen->rb2_feats;
+   }
    vkGetPhysicalDeviceFeatures2(screen->pdev, &feats);
    memcpy(&screen->feats, &feats.features, sizeof(screen->feats));
    if (have_tf_ext && tf_feats.transformFeedback)
@@ -835,14 +844,20 @@ zink_internal_create_screen(struct sw_winsys *winsys, int fd)
       screen->have_EXT_conditional_rendering = true;
    if (have_EXT_index_type_uint8 && index_uint8_feats.indexTypeUint8)
       screen->have_EXT_index_type_uint8 = true;
+   screen->have_EXT_robustness2_features = have_EXT_robustness2_features;
 
    VkPhysicalDeviceProperties2 props = {};
    props.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2;
    if (screen->have_EXT_transform_feedback) {
       screen->tf_props.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TRANSFORM_FEEDBACK_PROPERTIES_EXT;
-      screen->tf_props.pNext = NULL;
+      screen->tf_props.pNext = props.pNext;
       props.pNext = &screen->tf_props;
    }
+   if (have_EXT_robustness2_features) {
+      screen->rb2_props.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ROBUSTNESS_2_PROPERTIES_EXT;
+      screen->rb2_props.pNext = props.pNext;
+      props.pNext = &screen->rb2_props;
+   }
    vkGetPhysicalDeviceProperties2(screen->pdev, &props);
    memcpy(&screen->props, &props.properties, sizeof(screen->props));
 
@@ -866,7 +881,7 @@ zink_internal_create_screen(struct sw_winsys *winsys, int fd)
     * this requires us to pass the whole VkPhysicalDeviceFeatures2 struct
     */
    dci.pNext = &feats;
-   const char *extensions[6] = {
+   const char *extensions[7] = {
       VK_KHR_MAINTENANCE1_EXTENSION_NAME,
    };
    num_extensions = 1;
@@ -889,6 +904,8 @@ zink_internal_create_screen(struct sw_winsys *winsys, int fd)
 
    if (screen->have_EXT_transform_feedback)
       extensions[num_extensions++] = VK_EXT_TRANSFORM_FEEDBACK_EXTENSION_NAME;
+   if (screen->have_EXT_robustness2_features)
+      extensions[num_extensions++] = VK_EXT_ROBUSTNESS_2_EXTENSION_NAME;
    assert(num_extensions <= ARRAY_SIZE(extensions));
 
    dci.ppEnabledExtensionNames = extensions;
index 4625116c80b8ba1de87932703227959250831edf..38d1ba9c01c25b00abb52ec33b85d4eb55aa6891 100644 (file)
@@ -49,12 +49,15 @@ struct zink_screen {
    VkPhysicalDeviceFeatures feats;
    VkPhysicalDeviceMemoryProperties mem_props;
    VkPhysicalDeviceTransformFeedbackPropertiesEXT tf_props;
+   VkPhysicalDeviceRobustness2PropertiesEXT rb2_props;
+   VkPhysicalDeviceRobustness2FeaturesEXT rb2_feats;
 
    bool have_KHR_maintenance1;
    bool have_KHR_external_memory_fd;
    bool have_EXT_conditional_rendering;
    bool have_EXT_transform_feedback;
    bool have_EXT_index_type_uint8;
+   bool have_EXT_robustness2_features;
 
    bool have_X8_D24_UNORM_PACK32;
    bool have_D24_UNORM_S8_UINT;