diff options
author | Timothy Arceri <[email protected]> | 2016-10-13 15:20:38 +1100 |
---|---|---|
committer | Timothy Arceri <[email protected]> | 2016-10-26 14:29:36 +1100 |
commit | debed12fdde9766fd9cf99d679207a36a4599a82 (patch) | |
tree | 334d24b14f1ad541177bc601b9a31cf6f3cedda0 | |
parent | e1af20f18a86f52a9640faf2d4ff8a71b0a4fa9b (diff) |
glsl: add a shader info field to the gl_program type
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.
Reviewed-by: Jason Ekstrand <[email protected]>
-rw-r--r-- | src/compiler/glsl/glsl_to_nir.cpp | 3 | ||||
-rw-r--r-- | src/mesa/main/mtypes.h | 3 | ||||
-rw-r--r-- | src/mesa/program/prog_to_nir.c | 6 |
3 files changed, 11 insertions, 1 deletions
diff --git a/src/compiler/glsl/glsl_to_nir.cpp b/src/compiler/glsl/glsl_to_nir.cpp index b5318928792..934c9d14f94 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 79dd1c51df7..c9310ef3070 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 */ diff --git a/src/mesa/program/prog_to_nir.c b/src/mesa/program/prog_to_nir.c index a65d4bf8182..2f589ce77f3 100644 --- a/src/mesa/program/prog_to_nir.c +++ b/src/mesa/program/prog_to_nir.c @@ -1019,6 +1019,12 @@ prog_to_nir(const struct gl_program *prog, c->prog = prog; nir_builder_init_simple_shader(&c->build, NULL, stage, options); + + /* Use the shader_info from gl_program rather than the one nir_builder + * created for us. nir_sweep should clean up the other one for us. + */ + c->build.shader->info = (shader_info *) &prog->info; + s = c->build.shader; if (prog->Parameters->NumParameters > 0) { |