From c545c39c7e5af7808fcd58409f9f266c013535ff Mon Sep 17 00:00:00 2001 From: Yonggang Luo Date: Thu, 29 Jun 2023 01:06:53 +0800 Subject: [PATCH] glsl: Use nir_remove_non_entrypoints to simplify the code Signed-off-by: Yonggang Luo Reviewed-by: Faith Ekstrand Part-of: --- src/compiler/glsl/glsl_to_nir.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/compiler/glsl/glsl_to_nir.cpp b/src/compiler/glsl/glsl_to_nir.cpp index d6e29f825ee..50c02e34e77 100644 --- a/src/compiler/glsl/glsl_to_nir.cpp +++ b/src/compiler/glsl/glsl_to_nir.cpp @@ -249,14 +249,12 @@ glsl_to_nir(const struct gl_constants *consts, nir_validate_shader(shader, "after function inlining and return lowering"); - /* Now that we have inlined everything remove all of the functions except - * main(). + /* We set func->is_entrypoint after nir_function_create if the function + * is named "main", so we can use nir_remove_non_entrypoints() for this. + * Now that we have inlined everything remove all of the functions except + * func->is_entrypoint. */ - foreach_list_typed_safe(nir_function, function, node, &(shader)->functions){ - if (strcmp("main", function->name) != 0) { - exec_node_remove(&function->node); - } - } + nir_remove_non_entrypoints(shader); shader->info.name = ralloc_asprintf(shader, "GLSL%d", shader_prog->Name); if (shader_prog->Label)