radv,aco: fix reading primitive ID in FS after TES
authorRhys Perry <pendingchaos02@gmail.com>
Thu, 17 Sep 2020 13:41:27 +0000 (14:41 +0100)
committerMarge Bot <eric+marge@anholt.net>
Mon, 21 Sep 2020 11:54:53 +0000 (11:54 +0000)
Signed-off-by: Rhys Perry <pendingchaos02@gmail.com>
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Cc: mesa-stable
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/3530
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6760>

src/amd/compiler/aco_instruction_selection.cpp
src/amd/vulkan/radv_nir_to_llvm.c

index 7aafe4a..bfab27b 100644 (file)
@@ -9851,7 +9851,10 @@ static void create_vs_exports(isel_context *ctx)
 
    if (outinfo->export_prim_id && !(ctx->stage & hw_ngg_gs)) {
       ctx->outputs.mask[VARYING_SLOT_PRIMITIVE_ID] |= 0x1;
-      ctx->outputs.temps[VARYING_SLOT_PRIMITIVE_ID * 4u] = get_arg(ctx, ctx->args->vs_prim_id);
+      if (ctx->stage & sw_tes)
+         ctx->outputs.temps[VARYING_SLOT_PRIMITIVE_ID * 4u] = get_arg(ctx, ctx->args->ac.tes_patch_id);
+      else
+         ctx->outputs.temps[VARYING_SLOT_PRIMITIVE_ID * 4u] = get_arg(ctx, ctx->args->vs_prim_id);
    }
 
    if (ctx->options->key.has_multiview_view_index) {
index db21ad8..328a8d2 100644 (file)
@@ -2012,8 +2012,12 @@ handle_vs_outputs_post(struct radv_shader_context *ctx,
                outputs[noutput].slot_name = VARYING_SLOT_PRIMITIVE_ID;
                outputs[noutput].slot_index = 0;
                outputs[noutput].usage_mask = 0x1;
-               outputs[noutput].values[0] =
-                       ac_get_arg(&ctx->ac, ctx->args->vs_prim_id);
+               if (ctx->stage == MESA_SHADER_TESS_EVAL)
+                       outputs[noutput].values[0] =
+                               ac_get_arg(&ctx->ac, ctx->args->ac.tes_patch_id);
+               else
+                       outputs[noutput].values[0] =
+                               ac_get_arg(&ctx->ac, ctx->args->vs_prim_id);
                for (unsigned j = 1; j < 4; j++)
                        outputs[noutput].values[j] = ctx->ac.f32_0;
                noutput++;