Mesa (master): radv: make push constants optional

Dave Airlie airlied at kemper.freedesktop.org
Wed Dec 7 23:52:01 UTC 2016


Module: Mesa
Branch: master
Commit: c7dc1b010ae581f532240b661cb3d1c82e117e7e
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=c7dc1b010ae581f532240b661cb3d1c82e117e7e

Author: Dave Airlie <airlied at redhat.com>
Date:   Mon Nov 28 03:15:30 2016 +0000

radv: make push constants optional

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

Reviewed-by: Bas Nieuwenhuizen <bas at basnieuwenhuizen.nl>
Signed-off-by: Dave Airlie <airlied at 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 5c59d47..f644980 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:




More information about the mesa-commit mailing list