nir: extract print_shader_info() from nir_print_shader_annotated()
authorMihai Preda <mhpreda@gmail.com>
Wed, 2 Nov 2022 10:07:36 +0000 (12:07 +0200)
committerMarge Bot <emma+marge@anholt.net>
Wed, 7 Dec 2022 12:59:33 +0000 (12:59 +0000)
This is a refactoring, it is not supposed to change the printed output.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19570>

src/compiler/nir/nir_print.c

index ace4467..05d2ef8 100644 (file)
@@ -1729,40 +1729,44 @@ primitive_name(unsigned primitive)
    }
 }
 
+static void
+print_shader_info(const struct shader_info *info, FILE *fp) {
 
-void
-nir_print_shader_annotated(nir_shader *shader, FILE *fp,
-                           struct hash_table *annotations)
-{
-   print_state state;
-   init_print_state(&state, shader, fp);
-
-   state.annotations = annotations;
-
-   fprintf(fp, "shader: %s\n", gl_shader_stage_name(shader->info.stage));
+   fprintf(fp, "shader: %s\n", gl_shader_stage_name(info->stage));
 
    fprintf(fp, "source_sha1: {");
-   _mesa_sha1_print(fp, shader->info.source_sha1);
+   _mesa_sha1_print(fp, info->source_sha1);
    fprintf(fp, "}\n");
 
-   if (shader->info.name)
-      fprintf(fp, "name: %s\n", shader->info.name);
 
-   if (shader->info.label)
-      fprintf(fp, "label: %s\n", shader->info.label);
+   if (info->name)
+      fprintf(fp, "name: %s\n", info->name);
+
+   if (info->label)
+      fprintf(fp, "label: %s\n", info->label);
 
-   if (gl_shader_stage_uses_workgroup(shader->info.stage)) {
+   if (gl_shader_stage_uses_workgroup(info->stage)) {
       fprintf(fp, "workgroup-size: %u, %u, %u%s\n",
-              shader->info.workgroup_size[0],
-              shader->info.workgroup_size[1],
-              shader->info.workgroup_size[2],
-              shader->info.workgroup_size_variable ? " (variable)" : "");
-      fprintf(fp, "shared-size: %u\n", shader->info.shared_size);
+              info->workgroup_size[0],
+              info->workgroup_size[1],
+              info->workgroup_size[2],
+              info->workgroup_size_variable ? " (variable)" : "");
+      fprintf(fp, "shared-size: %u\n", info->shared_size);
    }
-   if (shader->info.stage == MESA_SHADER_MESH ||
-       shader->info.stage == MESA_SHADER_TASK) {
-      fprintf(fp, "task_payload-size: %u\n", shader->info.task_payload_size);
+   if (info->stage == MESA_SHADER_MESH || info->stage == MESA_SHADER_TASK) {
+      fprintf(fp, "task_payload-size: %u\n", info->task_payload_size);
    }
+}
+
+void
+nir_print_shader_annotated(nir_shader *shader, FILE *fp,
+                           struct hash_table *annotations)
+{
+   print_state state;
+   init_print_state(&state, shader, fp);
+   state.annotations = annotations;
+
+   print_shader_info(&shader->info, fp);
 
    fprintf(fp, "inputs: %u\n", shader->num_inputs);
    fprintf(fp, "outputs: %u\n", shader->num_outputs);