nir: Change nir_shader_get_entrypoint to return an impl.
authorKenneth Graunke <kenneth@whitecape.org>
Thu, 25 Aug 2016 02:09:57 +0000 (19:09 -0700)
committerKenneth Graunke <kenneth@whitecape.org>
Fri, 26 Aug 2016 02:18:24 +0000 (19:18 -0700)
Jason suggested adding an assert(function->impl) here.  All callers
of this function actually want ->impl, so I decided just to change
the API.

We also change the nir_lower_io_to_temporaries API here.  All but one
caller passed nir_shader_get_entrypoint(), and with the previous commit,
it now uses a nir_function_impl internally.  Folding this change in
avoids the need to change it and change it back.

v2: Fix one call I missed in ir3_compiler (caught by Eric).

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
src/compiler/nir/nir.h
src/compiler/nir/nir_lower_bitmap.c
src/compiler/nir/nir_lower_io_to_temporaries.c
src/compiler/nir/nir_lower_passthrough_edgeflags.c
src/gallium/drivers/freedreno/ir3/ir3_compiler_nir.c
src/intel/vulkan/anv_pipeline.c
src/mesa/drivers/dri/i965/blorp.c

index 1407b2d9f0ef2990923ed1957702142ad8005768..d0dfb0d04b3d2b196c81c04528f5ad05c8296005 100644 (file)
@@ -1902,7 +1902,7 @@ typedef struct nir_shader {
    gl_shader_stage stage;
 } nir_shader;
 
-static inline nir_function *
+static inline nir_function_impl *
 nir_shader_get_entrypoint(nir_shader *shader)
 {
    assert(exec_list_length(&shader->functions) == 1);
@@ -1910,7 +1910,8 @@ nir_shader_get_entrypoint(nir_shader *shader)
    nir_function *func = exec_node_data(nir_function, func_node, node);
    assert(func->return_type == glsl_void_type());
    assert(func->num_params == 0);
-   return func;
+   assert(func->impl);
+   return func->impl;
 }
 
 #define nir_foreach_function(func, shader) \
@@ -2378,7 +2379,8 @@ bool nir_lower_indirect_derefs(nir_shader *shader, nir_variable_mode modes);
 
 bool nir_lower_locals_to_regs(nir_shader *shader);
 
-void nir_lower_io_to_temporaries(nir_shader *shader, nir_function *entrypoint,
+void nir_lower_io_to_temporaries(nir_shader *shader,
+                                 nir_function_impl *entrypoint,
                                  bool outputs, bool inputs);
 
 void nir_shader_gather_info(nir_shader *shader, nir_function_impl *entrypoint);
index e182579a3984fb2ca5ed5ad83fecfd8bf46f53f7..bd5c30f8dc197f27b112cd8b9b839e8ee139d4dd 100644 (file)
@@ -128,12 +128,7 @@ void
 nir_lower_bitmap(nir_shader *shader,
                  const nir_lower_bitmap_options *options)
 {
-   nir_function *function;
-
    assert(shader->stage == MESA_SHADER_FRAGMENT);
 
-   function = nir_shader_get_entrypoint(shader);
-
-   if (function->impl)
-      lower_bitmap_impl(function->impl, options);
+   lower_bitmap_impl(nir_shader_get_entrypoint(shader), options);
 }
index 8cbf6838ee889f80f561af22346e56c5eadb8cd2..4f615d3e3bd739bf38db60a4951728e30fa89554 100644 (file)
@@ -148,7 +148,7 @@ create_shadow_temp(struct lower_io_state *state, nir_variable *var)
 }
 
 void
-nir_lower_io_to_temporaries(nir_shader *shader, nir_function *entrypoint,
+nir_lower_io_to_temporaries(nir_shader *shader, nir_function_impl *entrypoint,
                             bool outputs, bool inputs)
 {
    struct lower_io_state state;
@@ -157,7 +157,7 @@ nir_lower_io_to_temporaries(nir_shader *shader, nir_function *entrypoint,
       return;
 
    state.shader = shader;
-   state.entrypoint = entrypoint->impl;
+   state.entrypoint = entrypoint;
 
    if (inputs)
       exec_list_move_nodes_to(&shader->inputs, &state.old_inputs);
index c570c8ef3333127933e569730df73154ee3ed61d..f34078c89999d72bbb0e6df931c59b7f1eb86aeb 100644 (file)
@@ -52,7 +52,5 @@ lower_impl(nir_function_impl *impl)
 
 void nir_lower_passthrough_edgeflags(nir_shader *shader)
 {
-   nir_function *function = nir_shader_get_entrypoint(shader);
-   if (function->impl)
-      lower_impl(function->impl);
+   lower_impl(nir_shader_get_entrypoint(shader));
 }
index 22f5525c6aa55ed8072438195d5754991d0f15d3..b1b9d6b9734106a2da84863caca994cf29ee4940 100644 (file)
@@ -2151,7 +2151,7 @@ static void
 emit_instructions(struct ir3_compile *ctx)
 {
        unsigned ninputs, noutputs;
-       nir_function_impl *fxn = nir_shader_get_entrypoint(ctx->s)->impl;
+       nir_function_impl *fxn = nir_shader_get_entrypoint(ctx->s);
 
        ninputs  = (max_drvloc(&ctx->s->inputs) + 1) * 4;
        noutputs = (max_drvloc(&ctx->s->outputs) + 1) * 4;
index 48d267b91814433a65c5bdf22c3913700d401e19..88f414e023ad64fa939a177d632c145d39ed6981 100644 (file)
@@ -168,7 +168,8 @@ anv_shader_compile_to_nir(struct anv_device *device,
       nir_propagate_invariant(nir);
       nir_validate_shader(nir);
 
-      nir_lower_io_to_temporaries(entry_point->shader, entry_point, true, false);
+      nir_lower_io_to_temporaries(entry_point->shader, entry_point->impl,
+                                  true, false);
 
       nir_lower_system_values(nir);
       nir_validate_shader(nir);
@@ -616,7 +617,7 @@ anv_pipeline_compile_fs(struct anv_pipeline *pipeline,
 
       unsigned num_rts = 0;
       struct anv_pipeline_binding rt_bindings[8];
-      nir_function_impl *impl = nir_shader_get_entrypoint(nir)->impl;
+      nir_function_impl *impl = nir_shader_get_entrypoint(nir);
       nir_foreach_variable_safe(var, &nir->outputs) {
          if (var->data.location < FRAG_RESULT_DATA0)
             continue;
index 310061566d986a6efef67dd17b995ca3460c3b81..de627deb6193755a3c50c9495cd6f00d6bde86af 100644 (file)
@@ -174,7 +174,7 @@ brw_blorp_compile_nir_shader(struct brw_context *brw, struct nir_shader *nir,
 
    nir = brw_preprocess_nir(compiler, nir);
    nir_remove_dead_variables(nir, nir_var_shader_in);
-   nir_shader_gather_info(nir, nir_shader_get_entrypoint(nir)->impl);
+   nir_shader_gather_info(nir, nir_shader_get_entrypoint(nir));
 
    /* Uniforms are required to be lowered before going into compile_fs.  For
     * BLORP, we'll assume that whoever builds the shader sets the location