nir/nir_lower_multiview: Don't assert if load_deref doesn't have var

If deref chain has nir_deref_type_cast nir_intrinsic_get_var will
return null, which is valid for e.g. shader inputs, since the pass
only care about outputs.

NIR excerpt that caused issues:

```
    32x3    %6 = deref_cast (block *)%5 (ubo block)  (ptr_stride=0, align_mul=0, align_offset=0)
    32x3    %7 = deref_struct &%6->field0 (ubo vec4[4])  // &((block *)%5)->field0
    32      %8 = load_const (0x00000001)
    32x3    %9 = deref_array &(*%7)[1] (ubo vec4)  // &((block *)%5)->field0[1]
    32x4   %10 = @load_deref (%9) (access=none)
```

Signed-off-by: Danylo Piliaiev <dpiliaiev@igalia.com>
Reviewed-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/33647>
This commit is contained in:
Danylo Piliaiev 2025-02-20 17:36:28 +01:00 committed by Marge Bot
parent 4f11b8d950
commit 763ddd0fd3

View file

@ -306,7 +306,7 @@ nir_lower_multiview(nir_shader *shader, nir_lower_multiview_options options)
case nir_intrinsic_load_deref: {
nir_variable *var = nir_intrinsic_get_var(intrin, 0);
if (_mesa_hash_table_search(out_derefs, var)) {
if (var && _mesa_hash_table_search(out_derefs, var)) {
unreachable("Should have lowered I/O to temporaries "
"so no load_deref on output is expected.");
}