ac/nir/ngg: fix clip dist culling mask uninitialized
authorQiang Yu <yuq825@gmail.com>
Sat, 14 Jan 2023 14:06:32 +0000 (22:06 +0800)
committerMarge Bot <emma+marge@anholt.net>
Fri, 3 Feb 2023 12:27:44 +0000 (12:27 +0000)
Fixes: f75452918b2 ("ac/nir/ngg: support clipdist culling")
Reviewed-by: Timur Kristóf <timur.kristof@gmail.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Signed-off-by: Qiang Yu <yuq825@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20691>

src/amd/common/ac_nir_lower_ngg.c

index 1b72d55..583e580 100644 (file)
@@ -1391,12 +1391,17 @@ add_deferred_attribute_culling(nir_builder *b, nir_cf_list *original_extracted_c
       nir_local_variable_create(impl, glsl_uint_type(), "repacked_arg_3"),
    };
 
+   b->cursor = nir_before_cf_list(&impl->body);
+
    if (nogs_state->options->clipdist_enable_mask ||
        nogs_state->options->user_clip_plane_enable_mask) {
       nogs_state->clip_vertex_var =
          nir_local_variable_create(impl, glsl_vec4_type(), "clip_vertex");
       nogs_state->clipdist_neg_mask_var =
          nir_local_variable_create(impl, glsl_uint8_t_type(), "clipdist_neg_mask");
+
+      /* init mask to 0 */
+      nir_store_var(b, nogs_state->clipdist_neg_mask_var, nir_imm_intN_t(b, 0, 8), 1);
    }
 
    /* Top part of the culling shader (aka. position shader part)
@@ -1406,8 +1411,6 @@ add_deferred_attribute_culling(nir_builder *b, nir_cf_list *original_extracted_c
     * The position output is stored into a temporary variable, and reloaded later.
     */
 
-   b->cursor = nir_before_cf_list(&impl->body);
-
    nir_ssa_def *es_thread = has_input_vertex(b);
    nir_if *if_es_thread = nir_push_if(b, es_thread);
    {