From: Kenneth Graunke Date: Wed, 23 Jan 2019 09:15:05 +0000 (-0800) Subject: nir: Avoid clip/cull distance lowering multiple times. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=ba9dcc80fb2fc103835eef17153895f403d8654e;p=mesa.git nir: Avoid clip/cull distance lowering multiple times. A couple places in st/nir assume that cull distances have been lowered away, so it will need to call this lowering pass for drivers which opt out of the GLSL IR lowering. The Intel backend also calls this pass, for i965 and anv. We need to only do it once. Reviewed-by: Timothy Arceri --- diff --git a/src/compiler/nir/nir_lower_clip_cull_distance_arrays.c b/src/compiler/nir/nir_lower_clip_cull_distance_arrays.c index 79d61fabea3..05cd6af2195 100644 --- a/src/compiler/nir/nir_lower_clip_cull_distance_arrays.c +++ b/src/compiler/nir/nir_lower_clip_cull_distance_arrays.c @@ -148,6 +148,12 @@ combine_clip_cull(nir_shader *nir, /* The GLSL IR lowering pass must have converted these to vectors */ if (!clip->data.compact) return false; + + /* If this pass has already run, don't repeat. We would think that + * the combined clip/cull distance array was clip-only and mess up. + */ + if (clip->data.how_declared == nir_var_hidden) + return false; } const unsigned clip_array_size = get_unwrapped_array_length(nir, clip); @@ -158,11 +164,15 @@ combine_clip_cull(nir_shader *nir, nir->info.cull_distance_array_size = cull_array_size; } - if (clip) + if (clip) { clip->data.compact = true; + clip->data.how_declared = nir_var_hidden; + } - if (cull) + if (cull) { cull->data.compact = true; + cull->data.how_declared = nir_var_hidden; + } if (cull_array_size > 0) { if (clip_array_size == 0) {