nir: Use nir_shader::stage rather than passing it around.
authorKenneth Graunke <kenneth@whitecape.org>
Tue, 18 Aug 2015 08:53:29 +0000 (01:53 -0700)
committerKenneth Graunke <kenneth@whitecape.org>
Tue, 25 Aug 2015 18:12:35 +0000 (11:12 -0700)
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Jason Ekstrand <jason.ekstrand@intel.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
src/glsl/nir/glsl_to_nir.cpp
src/glsl/nir/nir.h
src/glsl/nir/nir_lower_samplers.cpp
src/mesa/drivers/dri/i965/brw_nir.c

index 9cc065f25a9ebcc67501c95d545667ef53e74856..5fb4ee25c4057e5587fbc22249b28ff75bcb247a 100644 (file)
@@ -44,7 +44,7 @@ namespace {
 class nir_visitor : public ir_visitor
 {
 public:
-   nir_visitor(nir_shader *shader, gl_shader_stage stage);
+   nir_visitor(nir_shader *shader);
    ~nir_visitor();
 
    virtual void visit(ir_variable *);
@@ -85,7 +85,6 @@ 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 */
@@ -134,7 +133,7 @@ glsl_to_nir(struct gl_shader *sh, const nir_shader_compiler_options *options)
 {
    nir_shader *shader = nir_shader_create(NULL, sh->Stage, options);
 
-   nir_visitor v1(shader, sh->Stage);
+   nir_visitor v1(shader);
    nir_function_visitor v2(&v1);
    v2.run(sh->ir);
    visit_exec_list(sh->ir, &v1);
@@ -142,11 +141,10 @@ glsl_to_nir(struct gl_shader *sh, const nir_shader_compiler_options *options)
    return shader;
 }
 
-nir_visitor::nir_visitor(nir_shader *shader, gl_shader_stage stage)
+nir_visitor::nir_visitor(nir_shader *shader)
 {
    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);
@@ -263,7 +261,7 @@ nir_visitor::visit(ir_variable *ir)
       break;
 
    case ir_var_shader_in:
-      if (stage == MESA_SHADER_FRAGMENT &&
+      if (shader->stage == MESA_SHADER_FRAGMENT &&
           ir->data.location == VARYING_SLOT_FACE) {
          /* For whatever reason, GLSL IR makes gl_FrontFacing an input */
          var->data.location = SYSTEM_VALUE_FRONT_FACE;
index 308298a50853ea7e3ae4b0f286b36352b25432c1..40871f73e965278826f1f878e3d3f0c7129befe0 100644 (file)
@@ -1648,8 +1648,7 @@ void nir_lower_load_const_to_scalar(nir_shader *shader);
 void nir_lower_phis_to_scalar(nir_shader *shader);
 
 void nir_lower_samplers(nir_shader *shader,
-                        const struct gl_shader_program *shader_program,
-                        gl_shader_stage stage);
+                        const struct gl_shader_program *shader_program);
 
 void nir_lower_system_values(nir_shader *shader);
 void nir_lower_tex_projector(nir_shader *shader);
index 7a0b0a09ffeb7dad0b11e8fc7d53a96cd22ba4e9..9583b457d8db6cee78ba98208b8b1e3737af756a 100644 (file)
@@ -168,11 +168,11 @@ lower_impl(nir_function_impl *impl, const struct gl_shader_program *shader_progr
 }
 
 extern "C" void
-nir_lower_samplers(nir_shader *shader, const struct gl_shader_program *shader_program,
-                   gl_shader_stage stage)
+nir_lower_samplers(nir_shader *shader,
+                   const struct gl_shader_program *shader_program)
 {
    nir_foreach_overload(shader, overload) {
       if (overload->impl)
-         lower_impl(overload->impl, shader_program, stage);
+         lower_impl(overload->impl, shader_program, shader->stage);
    }
 }
index dfac44fd406c55393bf52b512899870381a9e47f..8c6d28a7cd88931d31c902a0694dbe86611a954c 100644 (file)
@@ -136,7 +136,7 @@ brw_create_nir(struct brw_context *brw,
    nir_validate_shader(nir);
 
    if (shader_prog) {
-      nir_lower_samplers(nir, shader_prog, stage);
+      nir_lower_samplers(nir, shader_prog);
       nir_validate_shader(nir);
    }