[Mesa-dev] [PATCH 5/8] i965/nir: Move IO lowering into helper functions.
Kenneth Graunke
kenneth at whitecape.org
Mon Aug 17 16:07:47 PDT 2015
I plan to expand these, so moving them into helper functions will keep
things cleaner.
Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
---
src/mesa/drivers/dri/i965/brw_nir.c | 51 ++++++++++++++++++++++---------------
1 file changed, 31 insertions(+), 20 deletions(-)
diff --git a/src/mesa/drivers/dri/i965/brw_nir.c b/src/mesa/drivers/dri/i965/brw_nir.c
index 3d04363..12f67b3 100644
--- a/src/mesa/drivers/dri/i965/brw_nir.c
+++ b/src/mesa/drivers/dri/i965/brw_nir.c
@@ -28,6 +28,33 @@
#include "program/prog_to_nir.h"
static void
+brw_lower_nir_io_scalar(nir_shader *nir, gl_shader_stage stage)
+{
+ nir_assign_var_locations_direct_first(nir, &nir->uniforms,
+ &nir->num_direct_uniforms,
+ &nir->num_uniforms,
+ type_size_scalar);
+ nir_assign_var_locations(&nir->inputs, &nir->num_inputs, type_size_scalar);
+ nir_assign_var_locations(&nir->outputs, &nir->num_outputs, type_size_scalar);
+ nir_lower_io(nir, type_size_scalar);
+}
+
+static void
+brw_lower_nir_io_vec4(nir_shader *nir, gl_shader_stage stage)
+{
+ nir_assign_var_locations(&nir->uniforms,
+ &nir->num_uniforms,
+ type_size_vec4);
+
+ nir_assign_var_locations(&nir->inputs, &nir->num_inputs, type_size_vec4);
+
+ foreach_list_typed(nir_variable, var, node, &nir->outputs)
+ var->data.driver_location = var->data.location;
+
+ nir_lower_io(nir, type_size_vec4);
+}
+
+static void
nir_optimize(nir_shader *nir, bool is_scalar)
{
bool progress;
@@ -110,26 +137,10 @@ brw_create_nir(struct brw_context *brw,
/* Get rid of split copies */
nir_optimize(nir, is_scalar);
- if (is_scalar) {
- nir_assign_var_locations_direct_first(nir, &nir->uniforms,
- &nir->num_direct_uniforms,
- &nir->num_uniforms,
- type_size_scalar);
- nir_assign_var_locations(&nir->inputs, &nir->num_inputs, type_size_scalar);
- nir_assign_var_locations(&nir->outputs, &nir->num_outputs, type_size_scalar);
- nir_lower_io(nir, type_size_scalar);
- } else {
- nir_assign_var_locations(&nir->uniforms,
- &nir->num_uniforms,
- type_size_vec4);
-
- nir_assign_var_locations(&nir->inputs, &nir->num_inputs, type_size_vec4);
-
- foreach_list_typed(nir_variable, var, node, &nir->outputs)
- var->data.driver_location = var->data.location;
-
- nir_lower_io(nir, type_size_vec4);
- }
+ if (is_scalar)
+ brw_lower_nir_io_scalar(nir, stage);
+ else
+ brw_lower_nir_io_vec4(nir, stage);
nir_validate_shader(nir);
--
2.5.0
More information about the mesa-dev
mailing list