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)
committerEric Engestrom <eric@engestrom.ch>
Wed, 8 Feb 2023 20:34:44 +0000 (20:34 +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>
(cherry picked from commit d798214c7b25b0bf2ce6b094475913a1f72585b8)

.pick_status.json
src/amd/common/ac_nir_lower_ngg.c

index 6483be7..0a61fba 100644 (file)
         "description": "ac/nir/ngg: fix clip dist culling mask uninitialized",
         "nominated": true,
         "nomination_type": 1,
-        "resolution": 0,
+        "resolution": 1,
         "main_sha": null,
         "because_sha": "f75452918b27690f9c7a80f3f049483f7dec14fb"
     },
index cdc7ad0..909690f 100644 (file)
@@ -1367,12 +1367,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)
@@ -1382,8 +1387,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);
    {