Mesa (master): nir: Plumb the shader stage into glsl_to_nir().

Kenneth Graunke kwg at kemper.freedesktop.org
Mon Mar 9 05:37:23 UTC 2015


Module: Mesa
Branch: master
Commit: c6f2abe67e38c52361a1d342dca6ec5ed7747913
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=c6f2abe67e38c52361a1d342dca6ec5ed7747913

Author: Kenneth Graunke <kenneth at whitecape.org>
Date:   Fri Mar  6 01:22:49 2015 -0800

nir: Plumb the shader stage into glsl_to_nir().

The next commit needs to know the shader stage in glsl_to_nir().
To facilitate that, we pass the gl_shader rather than the raw exec_list
of instructions.  This has both the exec_list and the stage.

Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
Reviewed-by: Jason Ekstrand <jason.ekstrand at intel.com>

---

 src/glsl/nir/glsl_to_nir.cpp             |   14 ++++++++------
 src/glsl/nir/glsl_to_nir.h               |    2 +-
 src/mesa/drivers/dri/i965/brw_fs_nir.cpp |    2 +-
 3 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/src/glsl/nir/glsl_to_nir.cpp b/src/glsl/nir/glsl_to_nir.cpp
index 0d96e03..ddad207 100644
--- a/src/glsl/nir/glsl_to_nir.cpp
+++ b/src/glsl/nir/glsl_to_nir.cpp
@@ -43,7 +43,7 @@ namespace {
 class nir_visitor : public ir_visitor
 {
 public:
-   nir_visitor(nir_shader *shader);
+   nir_visitor(nir_shader *shader, gl_shader_stage stage);
    ~nir_visitor();
 
    virtual void visit(ir_variable *);
@@ -83,6 +83,7 @@ private:
    bool supports_ints;
 
    nir_shader *shader;
+   gl_shader_stage stage;
    nir_function_impl *impl;
    exec_list *cf_node_list;
    nir_instr *result; /* result of the expression tree last visited */
@@ -125,22 +126,23 @@ private:
 }; /* end of anonymous namespace */
 
 nir_shader *
-glsl_to_nir(exec_list *ir, const nir_shader_compiler_options *options)
+glsl_to_nir(struct gl_shader *sh, const nir_shader_compiler_options *options)
 {
    nir_shader *shader = nir_shader_create(NULL, options);
 
-   nir_visitor v1(shader);
+   nir_visitor v1(shader, sh->Stage);
    nir_function_visitor v2(&v1);
-   v2.run(ir);
-   visit_exec_list(ir, &v1);
+   v2.run(sh->ir);
+   visit_exec_list(sh->ir, &v1);
 
    return shader;
 }
 
-nir_visitor::nir_visitor(nir_shader *shader)
+nir_visitor::nir_visitor(nir_shader *shader, gl_shader_stage stage)
 {
    this->supports_ints = shader->options->native_integers;
    this->shader = shader;
+   this->stage = stage;
    this->is_global = true;
    this->var_table = _mesa_hash_table_create(NULL, _mesa_hash_pointer,
                                              _mesa_key_pointer_equal);
diff --git a/src/glsl/nir/glsl_to_nir.h b/src/glsl/nir/glsl_to_nir.h
index dd62793..3801e8c 100644
--- a/src/glsl/nir/glsl_to_nir.h
+++ b/src/glsl/nir/glsl_to_nir.h
@@ -32,7 +32,7 @@
 extern "C" {
 #endif
 
-nir_shader *glsl_to_nir(exec_list *ir,
+nir_shader *glsl_to_nir(struct gl_shader *sh,
                         const nir_shader_compiler_options *options);
 
 #ifdef __cplusplus
diff --git a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp
index ccb5cea..3bb6806 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp
@@ -87,7 +87,7 @@ fs_visitor::emit_nir_code()
 
    /* first, lower the GLSL IR shader to NIR */
    lower_output_reads(shader->base.ir);
-   nir_shader *nir = glsl_to_nir(shader->base.ir, options);
+   nir_shader *nir = glsl_to_nir(&shader->base, options);
    nir_validate_shader(nir);
 
    nir_lower_global_vars_to_local(nir);




More information about the mesa-commit mailing list