Mesa (main): zink: use a macro for spir-v versions
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Mon Jun 7 12:12:42 UTC 2021
Module: Mesa
Branch: main
Commit: baf4b05aadfc3fa44e4dabbefa306549e637d2ef
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=baf4b05aadfc3fa44e4dabbefa306549e637d2ef
Author: Erik Faye-Lund <erik.faye-lund at collabora.com>
Date: Mon Jun 7 13:37:49 2021 +0200
zink: use a macro for spir-v versions
Instead of repeating constants over and over, let's use a macro for the
SPIR-V version definition instead.
Reviewed-by: Hoe Hao Cheng <haochengho12907 at gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11044>
---
src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c | 4 ++--
src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.h | 2 ++
src/gallium/drivers/zink/zink_screen.c | 9 +++++----
3 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c b/src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c
index 99a3ce9b93c..8263d34b3cf 100644
--- a/src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c
+++ b/src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c
@@ -3559,8 +3559,8 @@ nir_to_spirv(struct nir_shader *s, const struct zink_so_info *so_info, uint32_t
struct ntv_context ctx = {};
ctx.mem_ctx = ralloc_context(NULL);
ctx.builder.mem_ctx = ctx.mem_ctx;
- assert(spirv_version >= 0x10000);
- ctx.spirv_1_4_interfaces = spirv_version >= 0x10400;
+ assert(spirv_version >= SPIRV_VERSION(1, 0));
+ ctx.spirv_1_4_interfaces = spirv_version >= SPIRV_VERSION(1, 4);
ctx.glsl_types = _mesa_pointer_hash_table_create(ctx.mem_ctx);
if (!ctx.glsl_types)
diff --git a/src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.h b/src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.h
index 2c59f408ac8..04b559473e4 100644
--- a/src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.h
+++ b/src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.h
@@ -34,6 +34,8 @@
#include "zink_compiler.h"
+#define SPIRV_VERSION(major, minor) (((major) << 16) | ((minor) << 8))
+
struct spirv_shader {
uint32_t *words;
size_t num_words;
diff --git a/src/gallium/drivers/zink/zink_screen.c b/src/gallium/drivers/zink/zink_screen.c
index 31fc2fb92e1..c5fe1a9f0e8 100644
--- a/src/gallium/drivers/zink/zink_screen.c
+++ b/src/gallium/drivers/zink/zink_screen.c
@@ -33,6 +33,7 @@
#include "zink_instance.h"
#include "zink_public.h"
#include "zink_resource.h"
+#include "nir_to_spirv/nir_to_spirv.h" // for SPIRV_VERSION
#include "os/os_process.h"
#include "util/u_debug.h"
@@ -257,7 +258,7 @@ zink_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
return 1;
case PIPE_CAP_TGSI_VOTE:
- return screen->spirv_version >= 0x00010300;
+ return screen->spirv_version >= SPIRV_VERSION(1, 3);
case PIPE_CAP_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION:
return screen->info.have_EXT_provoking_vertex;
@@ -1054,11 +1055,11 @@ choose_pdev(struct zink_screen *screen)
/* calculate SPIR-V version based on VK version */
if (screen->vk_version >= VK_MAKE_VERSION(1, 2, 0))
- screen->spirv_version = 0x00010500;
+ screen->spirv_version = SPIRV_VERSION(1, 5);
else if (screen->vk_version >= VK_MAKE_VERSION(1, 1, 0))
- screen->spirv_version = 0x00010300;
+ screen->spirv_version = SPIRV_VERSION(1, 3);
else
- screen->spirv_version = 0x00010000;
+ screen->spirv_version = SPIRV_VERSION(1, 0);
}
static void
More information about the mesa-commit
mailing list