gallivm/nir: fix const compact
authorDave Airlie <airlied@redhat.com>
Fri, 19 Jun 2020 07:11:12 +0000 (17:11 +1000)
committerDave Airlie <airlied@redhat.com>
Mon, 31 Aug 2020 03:20:11 +0000 (13:20 +1000)
Since adding support for compacts this crashes with indirects
don't get the const address unless it's a const.

Reviewed-by: Roland Scheidegger <sroland@vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6381>

src/gallium/auxiliary/gallivm/lp_bld_nir.c

index 99b35cfccd66ecef4b269b49c4e7a5f8b46991ae..b9fb3393a7c3c0a59e7c613a0967cb99d6a03ecb 100644 (file)
@@ -922,7 +922,7 @@ get_deref_offset(struct lp_build_nir_context *bld_base, nir_deref_instr *instr,
    uint32_t const_offset = 0;
    LLVMValueRef offset = NULL;
 
-   if (var->data.compact) {
+   if (var->data.compact && nir_src_is_const(instr->arr.index)) {
       assert(instr->deref_type == nir_deref_type_array);
       const_offset = nir_src_as_uint(instr->arr.index);
       goto out;