Module: Mesa
Branch: main
Commit: 9907573d9813f932863a581a1ab3c73c16e7705d
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=9907573d9813f932863a581a1ab3c73c16e7705d

Author: Mike Blumenkrantz <[email protected]>
Date:   Fri Aug 18 11:06:49 2023 -0400

zink: add a fixup method for extra driver props

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 | 28 ++++++++++++++++++++++++++++
 src/gallium/drivers/zink/zink_types.h  |  1 +
 2 files changed, 29 insertions(+)

diff --git a/src/gallium/drivers/zink/zink_screen.c 
b/src/gallium/drivers/zink/zink_screen.c
index 894adec130c..dc5bd31bae9 100644
--- a/src/gallium/drivers/zink/zink_screen.c
+++ b/src/gallium/drivers/zink/zink_screen.c
@@ -2839,6 +2839,32 @@ init_driver_workarounds(struct zink_screen *screen)
       screen->info.have_EXT_host_image_copy = false;
 }
 
+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)
 {
@@ -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);
diff --git a/src/gallium/drivers/zink/zink_types.h 
b/src/gallium/drivers/zink/zink_types.h
index 5a85c612f39..ffbb03a80c1 100644
--- a/src/gallium/drivers/zink/zink_types.h
+++ b/src/gallium/drivers/zink/zink_types.h
@@ -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;

Reply via email to