aco: Extract setup_gs_variables into a separate function.
authorTimur Kristóf <timur.kristof@gmail.com>
Wed, 12 Feb 2020 13:23:17 +0000 (14:23 +0100)
committerMarge Bot <eric+marge@anholt.net>
Wed, 11 Mar 2020 08:34:10 +0000 (08:34 +0000)
Signed-off-by: Timur Kristóf <timur.kristof@gmail.com>
Reviewed-by: Rhys Perry <pendingchaos02@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3964>

src/amd/compiler/aco_instruction_selection_setup.cpp

index b3c7ff059ad35a37076bd13a86cf4ab08c7e0335..9a58a2a955a70992c21a61b2f2445afe7f4e6a45 100644 (file)
@@ -753,6 +753,27 @@ setup_vs_variables(isel_context *ctx, nir_shader *nir)
    }
 }
 
+void setup_gs_variables(isel_context *ctx, nir_shader *nir)
+{
+   assert(ctx->stage == vertex_geometry_gs || ctx->stage == geometry_gs);
+   if (ctx->stage == vertex_geometry_gs) {
+      nir_foreach_variable(variable, &nir->inputs) {
+         variable->data.driver_location = util_bitcount64(ctx->input_masks[nir->info.stage] & ((1ull << variable->data.location) - 1ull)) * 4;
+      }
+   } else {
+      //TODO: make this more compact
+      nir_foreach_variable(variable, &nir->inputs) {
+         variable->data.driver_location = shader_io_get_unique_index((gl_varying_slot)variable->data.location) * 4;
+      }
+   }
+   nir_foreach_variable(variable, &nir->outputs) {
+      variable->data.driver_location = variable->data.location * 4;
+   }
+
+   if (ctx->stage == vertex_geometry_gs)
+      ctx->program->info->gs.es_type = MESA_SHADER_VERTEX; /* tesselation shaders are not yet supported */
+}
+
 void
 setup_variables(isel_context *ctx, nir_shader *nir)
 {
@@ -775,22 +796,7 @@ setup_variables(isel_context *ctx, nir_shader *nir)
       break;
    }
    case MESA_SHADER_GEOMETRY: {
-      assert(ctx->stage == vertex_geometry_gs || ctx->stage == geometry_gs);
-      if (ctx->stage == vertex_geometry_gs) {
-         nir_foreach_variable(variable, &nir->inputs) {
-            variable->data.driver_location = util_bitcount64(ctx->input_masks[nir->info.stage] & ((1ull << variable->data.location) - 1ull)) * 4;
-         }
-      } else {
-         //TODO: make this more compact
-         nir_foreach_variable(variable, &nir->inputs) {
-            variable->data.driver_location = shader_io_get_unique_index((gl_varying_slot)variable->data.location) * 4;
-         }
-      }
-      nir_foreach_variable(variable, &nir->outputs) {
-         variable->data.driver_location = variable->data.location * 4;
-      }
-      if (ctx->stage == vertex_geometry_gs)
-         ctx->program->info->gs.es_type = MESA_SHADER_VERTEX; /* tesselation shaders are not yet supported */
+      setup_gs_variables(ctx, nir);
       break;
    }
    default: