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 *);
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 */
}; /* 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);
/* 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);