spirv_to_dxil: expose version number
authorMichael Tang <tangm@microsoft.com>
Thu, 5 Aug 2021 19:55:19 +0000 (12:55 -0700)
committerMichael Tang <tangm@microsoft.com>
Thu, 5 Aug 2021 20:30:42 +0000 (13:30 -0700)
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12227>

src/microsoft/spirv_to_dxil/meson.build
src/microsoft/spirv_to_dxil/spirv_to_dxil.c
src/microsoft/spirv_to_dxil/spirv_to_dxil.def
src/microsoft/spirv_to_dxil/spirv_to_dxil.h

index c76d63c..78d33c5 100644 (file)
 
 libspirv_to_dxil = both_libraries(
   'spirv_to_dxil',
-  files(
-    'spirv_to_dxil.c',
-    'spirv_to_dxil.h',
-  ),
+  [
+    files(
+      'spirv_to_dxil.c',
+      'spirv_to_dxil.h',
+    ),
+    sha1_h,
+  ],
   vs_module_defs : 'spirv_to_dxil.def',
   dependencies : [idep_nir, idep_libdxil_compiler],
   include_directories : [inc_include, inc_src, inc_compiler, inc_gallium],
index f010007..b7f4314 100644 (file)
@@ -28,6 +28,8 @@
 #include "spirv/nir_spirv.h"
 #include "util/blob.h"
 
+#include "git_sha1.h"
+
 bool
 spirv_to_dxil(const uint32_t *words, size_t word_count,
               struct dxil_spirv_specialization *specializations,
@@ -173,3 +175,14 @@ spirv_to_dxil_free(void* buffer)
 {
    free(buffer);
 }
+
+uint64_t
+spirv_to_dxil_get_version()
+{
+   const char sha1[] = MESA_GIT_SHA1;
+   const char* dash = strchr(sha1, '-');
+   if (dash) {
+      return strtoull(dash + 1, NULL, 16);
+   }
+   return 0;
+}
index 5243f56..62851f2 100644 (file)
@@ -1,3 +1,4 @@
 EXPORTS
     spirv_to_dxil
     spirv_to_dxil_free
+    spirv_to_dxil_get_version
index 655d638..d19e662 100644 (file)
@@ -95,6 +95,9 @@ spirv_to_dxil(const uint32_t* words,
 void
 spirv_to_dxil_free(void* buffer);
 
+uint64_t
+spirv_to_dxil_get_version();
+
 #ifdef __cplusplus
 }
 #endif