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

Author: Samuel Pitoiset <[email protected]>
Date:   Wed Feb 14 18:15:23 2018 +0100

ac/nir: do not reserve user SGPRs for unused descriptor sets

In theory this might lead to corruption if we bind a descriptor
set which is unused, because LLVM is smart and it can re-use
unused user SGPRs. In practice, this doesn't seem to fix
anything.

As a side effect, this will reduce the number of emitted
SH_REG packets.

Signed-off-by: Samuel Pitoiset <[email protected]>
Reviewed-by: Bas Nieuwenhuizen <[email protected]>

---

 src/amd/common/ac_nir_to_llvm.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/src/amd/common/ac_nir_to_llvm.c b/src/amd/common/ac_nir_to_llvm.c
index 7f0bb05862..dc471de977 100644
--- a/src/amd/common/ac_nir_to_llvm.c
+++ b/src/amd/common/ac_nir_to_llvm.c
@@ -610,7 +610,8 @@ declare_global_input_sgprs(struct radv_shader_context *ctx,
        /* 1 for each descriptor set */
        if (!user_sgpr_info->indirect_all_descriptor_sets) {
                for (unsigned i = 0; i < num_sets; ++i) {
-                       if (ctx->options->layout->set[i].layout->shader_stages 
& stage_mask) {
+                       if ((ctx->shader_info->info.desc_set_used_mask & (1 << 
i)) &&
+                           ctx->options->layout->set[i].layout->shader_stages 
& stage_mask) {
                                add_array_arg(args, type,
                                              &ctx->descriptor_sets[i]);
                        }
@@ -687,7 +688,8 @@ set_global_input_locs(struct radv_shader_context *ctx, 
gl_shader_stage stage,
 
        if (!user_sgpr_info->indirect_all_descriptor_sets) {
                for (unsigned i = 0; i < num_sets; ++i) {
-                       if (ctx->options->layout->set[i].layout->shader_stages 
& stage_mask) {
+                       if ((ctx->shader_info->info.desc_set_used_mask & (1 << 
i)) &&
+                           ctx->options->layout->set[i].layout->shader_stages 
& stage_mask) {
                                set_loc_desc(ctx, i, user_sgpr_idx, 0);
                        } else
                                ctx->descriptor_sets[i] = NULL;
@@ -697,7 +699,8 @@ set_global_input_locs(struct radv_shader_context *ctx, 
gl_shader_stage stage,
                               user_sgpr_idx, 2);
 
                for (unsigned i = 0; i < num_sets; ++i) {
-                       if (ctx->options->layout->set[i].layout->shader_stages 
& stage_mask) {
+                       if ((ctx->shader_info->info.desc_set_used_mask & (1 << 
i)) &&
+                           ctx->options->layout->set[i].layout->shader_stages 
& stage_mask) {
                                set_loc_desc(ctx, i, user_sgpr_idx, i * 8);
                                ctx->descriptor_sets[i] =
                                        ac_build_load_to_sgpr(&ctx->ac,

_______________________________________________
mesa-commit mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to