From f363504b42e75124d4f4412503771d651844cb32 Mon Sep 17 00:00:00 2001 From: Jesse Natalie Date: Thu, 15 Dec 2022 10:57:42 -0800 Subject: [PATCH] microsoft/compiler: Handle both input and output clip/cull distances For clip/cull coming into a GS and being written, this pass was wrong and would modify variable types incorrectly. Track both inputs and outputs separately. Part-of: --- src/microsoft/compiler/dxil_nir.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/microsoft/compiler/dxil_nir.c b/src/microsoft/compiler/dxil_nir.c index 8e23bb06a09..f382a6f4564 100644 --- a/src/microsoft/compiler/dxil_nir.c +++ b/src/microsoft/compiler/dxil_nir.c @@ -1054,7 +1054,7 @@ dxil_nir_lower_upcast_phis(nir_shader *shader, unsigned min_bit_size) } struct dxil_nir_split_clip_cull_distance_params { - nir_variable *new_var; + nir_variable *new_var[2]; nir_shader *shader; }; @@ -1072,7 +1072,6 @@ dxil_nir_split_clip_cull_distance_instr(nir_builder *b, void *cb_data) { struct dxil_nir_split_clip_cull_distance_params *params = cb_data; - nir_variable *new_var = params->new_var; if (instr->type != nir_instr_type_deref) return false; @@ -1085,6 +1084,9 @@ dxil_nir_split_clip_cull_distance_instr(nir_builder *b, !var->data.compact) return false; + unsigned new_var_idx = var->data.mode == nir_var_shader_in ? 0 : 1; + nir_variable *new_var = params->new_var[new_var_idx]; + /* The location should only be inside clip distance, because clip * and cull should've been merged by nir_lower_clip_cull_distance_arrays() */ @@ -1129,7 +1131,7 @@ dxil_nir_split_clip_cull_distance_instr(nir_builder *b, } new_var->data.location++; new_var->data.location_frac = 0; - params->new_var = new_var; + params->new_var[new_var_idx] = new_var; } /* Update the type for derefs of the old var */ @@ -1174,7 +1176,7 @@ bool dxil_nir_split_clip_cull_distance(nir_shader *shader) { struct dxil_nir_split_clip_cull_distance_params params = { - .new_var = NULL, + .new_var = { NULL, NULL }, .shader = shader, }; nir_shader_instructions_pass(shader, @@ -1183,7 +1185,7 @@ dxil_nir_split_clip_cull_distance(nir_shader *shader) nir_metadata_dominance | nir_metadata_loop_analysis, ¶ms); - return params.new_var != NULL; + return params.new_var[0] != NULL || params.new_var[1] != NULL; } static bool