[Mesa-dev] [PATCH] radv: fix emitting the TCS regs on GFX9

Samuel Pitoiset samuel.pitoiset at gmail.com
Thu Jun 14 13:23:47 UTC 2018


The primitive ID is NULL if the vertex shader is LS. This
generates an invalid select instruction which crashes
because one operand is NULL.

This fixes crashes in The Long Journey Home, Quantum Break
and Just Cause 3 with DXVK.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=106756
CC: <mesa-stable at lists.freedesktop.org>
Signed-off-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
---
 src/amd/vulkan/radv_nir_to_llvm.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/amd/vulkan/radv_nir_to_llvm.c b/src/amd/vulkan/radv_nir_to_llvm.c
index 5168c9d554..f6de71176f 100644
--- a/src/amd/vulkan/radv_nir_to_llvm.c
+++ b/src/amd/vulkan/radv_nir_to_llvm.c
@@ -3107,9 +3107,16 @@ static void ac_nir_fixup_ls_hs_input_vgprs(struct radv_shader_context *ctx)
 	LLVMValueRef hs_empty = LLVMBuildICmp(ctx->ac.builder, LLVMIntEQ, count,
 	                                      ctx->ac.i32_0, "");
 	ctx->abi.instance_id = LLVMBuildSelect(ctx->ac.builder, hs_empty, ctx->rel_auto_id, ctx->abi.instance_id, "");
-	ctx->vs_prim_id = LLVMBuildSelect(ctx->ac.builder, hs_empty, ctx->abi.vertex_id, ctx->vs_prim_id, "");
-	ctx->rel_auto_id = LLVMBuildSelect(ctx->ac.builder, hs_empty, ctx->abi.tcs_rel_ids, ctx->rel_auto_id, "");
 	ctx->abi.vertex_id = LLVMBuildSelect(ctx->ac.builder, hs_empty, ctx->abi.tcs_patch_id, ctx->abi.vertex_id, "");
+	if (ctx->options->key.vs.as_ls) {
+		ctx->rel_auto_id =
+			LLVMBuildSelect(ctx->ac.builder, hs_empty,
+					ctx->abi.tcs_rel_ids, ctx->rel_auto_id, "");
+	} else {
+		ctx->vs_prim_id =
+			LLVMBuildSelect(ctx->ac.builder, hs_empty,
+					ctx->abi.vertex_id, ctx->vs_prim_id, "");
+	}
 }
 
 static void prepare_gs_input_vgprs(struct radv_shader_context *ctx)
-- 
2.17.1



More information about the mesa-dev mailing list