zink: add a fixup method for extra driver props
authorMike Blumenkrantz <michael.blumenkrantz@gmail.com>
Fri, 18 Aug 2023 15:06:49 +0000 (11:06 -0400)
committerMarge Bot <emma+marge@anholt.net>
Sat, 9 Sep 2023 13:02:44 +0000 (13:02 +0000)
some extensions have "extra" props which need the get_count -> get_prop_array
dance, and codegen is too stupid to figure this out (and probably always will be)

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24775>

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

index 894adec..dc5bd31 100644 (file)
@@ -2840,6 +2840,32 @@ init_driver_workarounds(struct zink_screen *screen)
 }
 
 static void
+fixup_driver_props(struct zink_screen *screen)
+{
+   VkPhysicalDeviceProperties2 props = {
+      VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2
+   };
+   if (screen->info.have_EXT_host_image_copy) {
+      /* fill in layouts */
+      screen->info.hic_props.pNext = props.pNext;
+      props.pNext = &screen->info.hic_props;
+      screen->info.hic_props.pCopySrcLayouts = ralloc_array(screen, VkImageLayout, screen->info.hic_props.copySrcLayoutCount);
+      screen->info.hic_props.pCopyDstLayouts = ralloc_array(screen, VkImageLayout, screen->info.hic_props.copyDstLayoutCount);
+   }
+   if (props.pNext)
+      screen->vk.GetPhysicalDeviceProperties2(screen->pdev, &props);
+
+   if (screen->info.have_EXT_host_image_copy) {
+      for (unsigned i = 0; i < screen->info.hic_props.copyDstLayoutCount; i++) {
+         if (screen->info.hic_props.pCopyDstLayouts[i] == VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL) {
+            screen->can_hic_shader_read = true;
+            break;
+         }
+      }
+   }
+}
+
+static void
 init_optimal_keys(struct zink_screen *screen)
 {
    screen->optimal_keys = !screen->need_decompose_attrs &&
@@ -3160,6 +3186,8 @@ zink_internal_create_screen(const struct pipe_screen_config *config, int64_t dev
       screen->debug_mem_sizes = _mesa_hash_table_create(screen, _mesa_hash_string, _mesa_key_string_equal);
    }
 
+   fixup_driver_props(screen);
+
    init_driver_workarounds(screen);
 
    screen->dev = zink_create_logical_device(screen);
index 5a85c61..ffbb03a 100644 (file)
@@ -1469,6 +1469,7 @@ struct zink_screen {
    bool need_2D_zs;
    bool need_2D_sparse;
    bool faked_e5sparse; //drivers may not expose R9G9B9E5 but cts requires it
+   bool can_hic_shader_read;
 
    uint32_t gfx_queue;
    uint32_t sparse_queue;