[Mesa-dev] [PATCH 13/24] spirv_extensions: add spirv_supported_extensions on gl_constants

Eduardo Lima Mitev elima at igalia.com
Wed Nov 15 13:22:16 UTC 2017


From: Alejandro PiƱeiro <apinheiro at igalia.com>

We can use it to get real values for ARB_spirv_extensions methods.
---
 src/mesa/main/mtypes.h          |  3 +++
 src/mesa/main/spirvextensions.c | 20 +++++++++++++++++++-
 2 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 1352ca98800..d624f2cbd19 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -4013,6 +4013,9 @@ struct gl_constants
 
    /** GL_ARB_gl_spirv */
    struct nir_spirv_supported_capabilities *SpirVCapabilities;
+
+   /** GL_ARB_spirv_extensions */
+   struct spirv_supported_extensions *SpirVExtensions;
 };
 
 
diff --git a/src/mesa/main/spirvextensions.c b/src/mesa/main/spirvextensions.c
index 6a9fea9fe31..9fdf5a61f7f 100644
--- a/src/mesa/main/spirvextensions.c
+++ b/src/mesa/main/spirvextensions.c
@@ -27,16 +27,34 @@
  */
 
 #include "spirvextensions.h"
+#include "compiler/spirv/spirv_extensions.h"
 
 GLuint
 _mesa_get_spirv_extension_count(struct gl_context *ctx)
 {
-   return 0;
+   if (ctx->Const.SpirVExtensions == NULL)
+      return 0;
+
+   return ctx->Const.SpirVExtensions->count;
 }
 
 const GLubyte *
 _mesa_get_enabled_spirv_extension(struct gl_context *ctx,
                                   GLuint index)
 {
+   unsigned int n = 0;
+
+   if (ctx->Const.SpirVExtensions == NULL)
+      return (const GLubyte *) 0;
+
+   for (unsigned int i = 0; i < SPV_EXTENSIONS_COUNT; i++) {
+      if (ctx->Const.SpirVExtensions->supported[i]) {
+         if (n == index)
+            return (const GLubyte *) spirv_extensions_to_string(i);
+         else
+            n++;
+      }
+   }
+
    return (const GLubyte *) 0;
 }
-- 
2.11.0



More information about the mesa-dev mailing list