v2.run(sh->ir);
visit_exec_list(sh->ir, &v1);
- nir_lower_outputs_to_temporaries(shader);
+ nir_function *main = NULL;
+ nir_foreach_function(shader, func) {
+ if (strcmp(func->name, "main") == 0) {
+ main = func;
+ break;
+ }
+ }
+ assert(main);
+
+ nir_lower_outputs_to_temporaries(shader, main);
shader->info.name = ralloc_asprintf(shader, "GLSL%d", shader_prog->Name);
if (shader_prog->Label)
bool nir_lower_locals_to_regs(nir_shader *shader);
-void nir_lower_outputs_to_temporaries(nir_shader *shader);
-
-void nir_lower_outputs_to_temporaries(nir_shader *shader);
+void nir_lower_outputs_to_temporaries(nir_shader *shader,
+ nir_function *entrypoint);
void nir_shader_gather_info(nir_shader *shader, nir_function_impl *entrypoint);
}
void
-nir_lower_outputs_to_temporaries(nir_shader *shader)
+nir_lower_outputs_to_temporaries(nir_shader *shader, nir_function *entrypoint)
{
struct lower_outputs_state state;
* before each EmitVertex call.
*/
nir_foreach_block(function->impl, emit_output_copies_block, &state);
- } else if (strcmp(function->name, "main") == 0) {
+ } else if (function == entrypoint) {
/* For all other shader types, we need to do the copies right before
* the jumps to the end block.
*/
/* Because we can still have output reads in NIR, we need to lower
* outputs to temporaries before we are truely finished.
*/
- nir_lower_outputs_to_temporaries(entry_point->shader);
+ nir_lower_outputs_to_temporaries(entry_point->shader, entry_point);
return entry_point;
}