From: Dave Airlie <airl...@redhat.com>

We don't set the push constants slot up unless
something will cause us to need it.

Signed-off-by: Dave Airlie <airl...@redhat.com>
---
 src/amd/common/ac_nir_to_llvm.c | 22 +++++++++++++++++-----
 1 file changed, 17 insertions(+), 5 deletions(-)

diff --git a/src/amd/common/ac_nir_to_llvm.c b/src/amd/common/ac_nir_to_llvm.c
index f26251c..68c7317 100644
--- a/src/amd/common/ac_nir_to_llvm.c
+++ b/src/amd/common/ac_nir_to_llvm.c
@@ -461,6 +461,14 @@ 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;
+
+       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;
 
        /* 1 for each descriptor set */
        for (unsigned i = 0; i < num_sets; ++i) {
@@ -469,8 +477,10 @@ static void create_function(struct nir_to_llvm_context 
*ctx,
                }
        }
 
-       /* 1 for push constants and dynamic descriptors */
-       arg_types[arg_idx++] = const_array(ctx->i8, 1024 * 1024);
+       if (need_push_constants) {
+               /* 1 for push constants and dynamic descriptors */
+               arg_types[arg_idx++] = const_array(ctx->i8, 1024 * 1024);
+       }
 
        array_count = arg_idx;
        switch (nir->stage) {
@@ -551,9 +561,11 @@ static void create_function(struct nir_to_llvm_context 
*ctx,
                        ctx->descriptor_sets[i] = NULL;
        }
 
-       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;
+       if (need_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;
+       }
 
        switch (nir->stage) {
        case MESA_SHADER_COMPUTE:
-- 
2.9.3

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to