Mesa (main): zink: calculate spir-v version based on vk version

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Jun 7 12:12:42 UTC 2021


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

Author: Erik Faye-Lund <erik.faye-lund at collabora.com>
Date:   Thu May 27 14:48:52 2021 +0200

zink: calculate spir-v version based on vk version

This moves the previous check up to the screen-creation, making it
possible to enable features based on the SPIR-V version.

The reason we want to be able to do this, is so we can force specific
SPIR-V versions, in order to work around bugs in tools.

Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Reviewed-by: Hoe Hao Cheng <haochengho12907 at gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11044>

---

 src/gallium/drivers/zink/zink_compiler.c | 4 +---
 src/gallium/drivers/zink/zink_screen.c   | 8 ++++++++
 src/gallium/drivers/zink/zink_screen.h   | 2 +-
 3 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/src/gallium/drivers/zink/zink_compiler.c b/src/gallium/drivers/zink/zink_compiler.c
index 63d570db30b..c5a592fa76e 100644
--- a/src/gallium/drivers/zink/zink_compiler.c
+++ b/src/gallium/drivers/zink/zink_compiler.c
@@ -640,9 +640,7 @@ zink_shader_compile(struct zink_screen *screen, struct zink_shader *zs, struct z
 
    assign_io_locations(nir, shader_slot_map, shader_slots_reserved);
 
-   uint32_t spirv_version = screen->vk_version >= VK_MAKE_VERSION(1, 2, 0) ?
-                            0x00010500 : 0x00010000;
-   struct spirv_shader *spirv = nir_to_spirv(nir, streamout, spirv_version);
+   struct spirv_shader *spirv = nir_to_spirv(nir, streamout, screen->spirv_version);
    if (!spirv)
       goto done;
 
diff --git a/src/gallium/drivers/zink/zink_screen.c b/src/gallium/drivers/zink/zink_screen.c
index 548c8d56dcd..8e012d38d69 100644
--- a/src/gallium/drivers/zink/zink_screen.c
+++ b/src/gallium/drivers/zink/zink_screen.c
@@ -1049,6 +1049,14 @@ choose_pdev(struct zink_screen *screen)
 
    /* runtime version is the lesser of the instance version and device version */
    screen->vk_version = MIN2(screen->info.device_version, screen->instance_info.loader_version);
+
+   /* calculate SPIR-V version based on VK version */
+   if (screen->vk_version >= VK_MAKE_VERSION(1, 2, 0))
+      screen->spirv_version = 0x00010500;
+   else if (screen->vk_version >= VK_MAKE_VERSION(1, 1, 0))
+      screen->spirv_version = 0x00010300;
+   else
+      screen->spirv_version = 0x00010000;
 }
 
 static void
diff --git a/src/gallium/drivers/zink/zink_screen.h b/src/gallium/drivers/zink/zink_screen.h
index 1c4fb29cac5..b8ef5d87254 100644
--- a/src/gallium/drivers/zink/zink_screen.h
+++ b/src/gallium/drivers/zink/zink_screen.h
@@ -93,7 +93,7 @@ struct zink_screen {
    struct zink_instance_info instance_info;
 
    VkPhysicalDevice pdev;
-   uint32_t vk_version;
+   uint32_t vk_version, spirv_version;
    struct util_idalloc_mt buffer_ids;
 
    struct zink_device_info info;



More information about the mesa-commit mailing list