[Mesa-dev] [PATCH 12/24] spirv_extensions: define spirv_extensions_supported
Eduardo Lima Mitev
elima at igalia.com
Wed Nov 15 13:22:15 UTC 2017
From: Alejandro PiƱeiro <apinheiro at igalia.com>
Add a struct to maintain which SPIR-V extensions are supported, and an
utility method to initialize it based on
nir_spirv_supported_capabilities.
---
src/compiler/spirv/spirv_extensions.c | 29 +++++++++++++++++++++++++++++
src/compiler/spirv/spirv_extensions.h | 12 ++++++++++++
2 files changed, 41 insertions(+)
diff --git a/src/compiler/spirv/spirv_extensions.c b/src/compiler/spirv/spirv_extensions.c
index 64d61c49d31..8263b693abd 100644
--- a/src/compiler/spirv/spirv_extensions.c
+++ b/src/compiler/spirv/spirv_extensions.c
@@ -59,3 +59,32 @@ spirv_extensions_to_string(SpvExtension ext)
return "unknown";
}
+
+/**
+ * Sets the supported flags for known SPIR-V extensions based on the
+ * capabilites supported (spirv capabilities based on the spirv to nir
+ * support).
+ *
+ * One could argue that makes more sense in the other way around, as from the
+ * spec pov capabilities are enable for a given extension. But from our pov,
+ * we support or not (depending on the driver) some given capability, and
+ * spirv_to_nir check for capabilities not extensions. Also we usually fill
+ * first the supported capabilities, that are not always related to an
+ * extension.
+ */
+void
+fill_supported_spirv_extensions(struct spirv_supported_extensions *ext,
+ const struct nir_spirv_supported_capabilities *cap)
+{
+ for (unsigned i = 0; i < SPV_EXTENSIONS_COUNT; i++)
+ ext->supported[i] = false;
+
+ ext->count = 0;
+
+ ext->supported[SPV_KHR_shader_draw_parameters] = cap->draw_parameters;
+ ext->supported[SPV_KHR_multiview] = cap->multiview;
+ ext->supported[SPV_KHR_variable_pointers] = cap->variable_pointers;
+
+ for (unsigned i = 0; i < SPV_EXTENSIONS_COUNT; i++)
+ if (ext->supported[i]) ext->count++;
+}
diff --git a/src/compiler/spirv/spirv_extensions.h b/src/compiler/spirv/spirv_extensions.h
index 54bc7f2dbe0..22238b727d7 100644
--- a/src/compiler/spirv/spirv_extensions.h
+++ b/src/compiler/spirv/spirv_extensions.h
@@ -25,6 +25,7 @@
#define _SPIRV_EXTENSIONS_H_
#include "compiler/nir/nir.h"
+#include "nir_spirv.h"
#ifdef __cplusplus
extern "C" {
@@ -60,8 +61,19 @@ typedef enum SpvExtension_ {
SPV_EXTENSIONS_COUNT
} SpvExtension;
+struct spirv_supported_extensions {
+ /** Flags the supported extensions. Array to make it easier to iterate. */
+ bool supported[SPV_EXTENSIONS_COUNT];
+
+ /** Number of supported extensions */
+ unsigned int count;
+};
+
const char *spirv_extensions_to_string(SpvExtension ext);
+void fill_supported_spirv_extensions(struct spirv_supported_extensions *ext,
+ const struct nir_spirv_supported_capabilities *cap);
+
#ifdef __cplusplus
}
#endif
--
2.11.0
More information about the mesa-dev
mailing list