[Mesa-dev] [PATCH 06/25] glsl: add a shader info field to the gl_program type

Timothy Arceri timothy.arceri at collabora.com
Tue Oct 18 06:12:09 UTC 2016


And use this field as the source for shader info in the nir_shader
this will allow us to set some of these fields from GLSL directly.

It will also simplify restoring from shader cache and allow the
removal of duplicate fields from GLSL.
---
 src/compiler/glsl/glsl_to_nir.cpp | 3 ++-
 src/mesa/main/mtypes.h            | 3 +++
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/compiler/glsl/glsl_to_nir.cpp b/src/compiler/glsl/glsl_to_nir.cpp
index b531892..934c9d1 100644
--- a/src/compiler/glsl/glsl_to_nir.cpp
+++ b/src/compiler/glsl/glsl_to_nir.cpp
@@ -136,7 +136,8 @@ glsl_to_nir(const struct gl_shader_program *shader_prog,
 {
    struct gl_linked_shader *sh = shader_prog->_LinkedShaders[stage];
 
-   nir_shader *shader = nir_shader_create(NULL, stage, options, NULL);
+   nir_shader *shader = nir_shader_create(NULL, stage, options,
+                                          &sh->Program->info);
 
    nir_visitor v1(shader);
    nir_function_visitor v2(&v1);
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index ff20226..3a517f2 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -43,6 +43,7 @@
 #include "glapi/glapi.h"
 #include "math/m_matrix.h"	/* GLmatrix */
 #include "compiler/shader_enums.h"
+#include "compiler/shader_info.h"
 #include "main/formats.h"       /* MESA_FORMAT_COUNT */
 #include "compiler/glsl/list.h"
 #include "util/bitscan.h"
@@ -1919,6 +1920,8 @@ struct gl_program
 
    struct nir_shader *nir;
 
+   struct shader_info info;
+
    GLbitfield64 InputsRead;     /**< Bitmask of which input regs are read */
    GLbitfield64 DoubleInputsRead;     /**< Bitmask of which input regs are read  and are doubles */
    GLbitfield64 OutputsWritten; /**< Bitmask of which output regs are written */
-- 
2.7.4



More information about the mesa-dev mailing list