From c6be5cefba7e9480f103c2ce2794a67ed9fa33eb Mon Sep 17 00:00:00 2001 From: Samuel Pitoiset Date: Fri, 6 Sep 2019 10:34:35 +0200 Subject: [PATCH] radv/gfx10: make use the output usage mask when exporting NGG GS params 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 Reviewed-by: Bas Nieuwenhuizen --- src/amd/vulkan/radv_nir_to_llvm.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/amd/vulkan/radv_nir_to_llvm.c b/src/amd/vulkan/radv_nir_to_llvm.c index 10cc82eb8d9..0c13860fe28 100644 --- a/src/amd/vulkan/radv_nir_to_llvm.c +++ b/src/amd/vulkan/radv_nir_to_llvm.c @@ -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, ""); -- 2.30.2