radv/ac: move needs_push_constants to shader info.
authorDave Airlie <airlied@redhat.com>
Mon, 17 Apr 2017 19:29:34 +0000 (05:29 +1000)
committerDave Airlie <airlied@redhat.com>
Tue, 18 Apr 2017 23:00:42 +0000 (09:00 +1000)
First step to optimising push constants.

Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Signed-off-by: Dave Airlie <airlied@redhat.com>
src/amd/common/ac_nir_to_llvm.c
src/amd/common/ac_shader_info.c
src/amd/common/ac_shader_info.h

index f854356329321d70f9adc75ead1b1c2281426110..b3e522dd7326b8e70a3a425050717c0402926162 100644 (file)
@@ -565,7 +565,6 @@ static void create_function(struct nir_to_llvm_context *ctx)
        unsigned i;
        unsigned num_sets = ctx->options->layout ? ctx->options->layout->num_sets : 0;
        unsigned user_sgpr_idx;
-       bool need_push_constants;
        bool need_ring_offsets = false;
 
        /* until we sort out scratch/global buffers always assign ring offsets for gs/vs/es */
@@ -577,13 +576,6 @@ static void create_function(struct nir_to_llvm_context *ctx)
            ctx->is_gs_copy_shader)
                need_ring_offsets = true;
 
-       need_push_constants = true;
-       if (!ctx->options->layout)
-               need_push_constants = false;
-       else if (!ctx->options->layout->push_constant_size &&
-                !ctx->options->layout->dynamic_offset_count)
-               need_push_constants = false;
-
        if (need_ring_offsets && !ctx->options->supports_spill) {
                arg_types[arg_idx++] = const_array(ctx->v16i8, 16); /* address of rings */
        }
@@ -596,7 +588,7 @@ static void create_function(struct nir_to_llvm_context *ctx)
                }
        }
 
-       if (need_push_constants) {
+       if (ctx->shader_info->info.needs_push_constants) {
                /* 1 for push constants and dynamic descriptors */
                array_params_mask |= (1 << arg_idx);
                arg_types[arg_idx++] = const_array(ctx->i8, 1024 * 1024);
@@ -755,7 +747,7 @@ static void create_function(struct nir_to_llvm_context *ctx)
                        ctx->descriptor_sets[i] = NULL;
        }
 
-       if (need_push_constants) {
+       if (ctx->shader_info->info.needs_push_constants) {
                ctx->push_constants = LLVMGetParam(ctx->main_function, arg_idx++);
                set_userdata_location_shader(ctx, AC_UD_PUSH_CONSTANTS, user_sgpr_idx, 2);
                user_sgpr_idx += 2;
index ef3692563b2afac65ad4d5c0eb347fff6af762f7..79c13767f67ec60cf6ea00a6b6ae43a1f1a93aa9 100644 (file)
@@ -76,6 +76,14 @@ ac_nir_shader_info_pass(struct nir_shader *nir,
                        struct ac_shader_info *info)
 {
        struct nir_function *func = (struct nir_function *)exec_list_get_head(&nir->functions);
+
+       info->needs_push_constants = true;
+       if (!options->layout)
+               info->needs_push_constants = false;
+       else if (!options->layout->push_constant_size &&
+                !options->layout->dynamic_offset_count)
+               info->needs_push_constants = false;
+
        nir_foreach_variable(variable, &nir->inputs)
                gather_info_input_decl(nir, options, variable, info);
 
index ed97d06d56bb1cd166f580d13cfc1ac538f4f416..32153fb67fce0410063570ace4ae6f25d8c7c905 100644 (file)
@@ -28,6 +28,7 @@ struct ac_nir_compiler_options;
 /* a NIR pass to gather all the info needed to optimise the alloction patterns for the RADV user sgprs */
 
 struct ac_shader_info {
+       bool needs_push_constants;
        struct {
                bool has_vertex_buffers; /* needs vertex buffers and base/start */
                bool needs_draw_id;