radv/gfx10: make use the output usage mask when exporting NGG GS params
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Fri, 6 Sep 2019 08:34:35 +0000 (10:34 +0200)
committerSamuel Pitoiset <samuel.pitoiset@gmail.com>
Fri, 6 Sep 2019 15:25:28 +0000 (17:25 +0200)
It shouldn't matter much because output varyings should have been
compacted during NIR shader linking but it mirrors what the driver
does when emitting NGG GS vertex parameters.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
src/amd/vulkan/radv_nir_to_llvm.c

index 10cc82eb8d9ca810c8a34ae83830fe217ace441e..0c13860fe281000cda00f7ccdb43905f884b093b 100644 (file)
@@ -3489,16 +3489,21 @@ static void gfx10_ngg_gs_emit_epilogue_2(struct radv_shader_context *ctx)
                unsigned out_idx = 0;
                gep_idx[1] = ctx->ac.i32_0;
                for (unsigned i = 0; i < AC_LLVM_MAX_OUTPUTS; ++i) {
+                       unsigned output_usage_mask =
+                               ctx->shader_info->gs.output_usage_mask[i];
+                       int length = util_last_bit(output_usage_mask);
+
                        if (!(ctx->output_mask & (1ull << i)))
                                continue;
 
                        outputs[noutput].slot_name = i;
                        outputs[noutput].slot_index = i == VARYING_SLOT_CLIP_DIST1;
-
-                       outputs[noutput].usage_mask = ctx->shader_info->gs.output_usage_mask[i];
-                       int length = util_last_bit(outputs[noutput].usage_mask);
+                       outputs[noutput].usage_mask = output_usage_mask;
 
                        for (unsigned j = 0; j < length; j++, out_idx++) {
+                               if (!(output_usage_mask & (1 << j)))
+                                       continue;
+
                                gep_idx[2] = LLVMConstInt(ctx->ac.i32, out_idx, false);
                                tmp = LLVMBuildGEP(builder, vertexptr, gep_idx, 3, "");
                                tmp = LLVMBuildLoad(builder, tmp, "");