microsoft/compiler: Fix array-of-array handling for derefs of textures/images
authorJesse Natalie <jenatali@microsoft.com>
Fri, 31 Dec 2021 01:52:11 +0000 (17:52 -0800)
committerMarge Bot <emma+marge@anholt.net>
Fri, 7 Jan 2022 03:31:16 +0000 (03:31 +0000)
Reviewed-by: Sil Vilerino <sivileri@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14342>

src/microsoft/compiler/nir_to_dxil.c

index e8b5061..9ef2b5a 100644 (file)
@@ -3609,6 +3609,12 @@ emit_deref(struct ntd_context* ctx, nir_deref_instr* instr)
       if (!base || !offset)
          return false;
 
+      if (glsl_type_is_array(instr->type)) {
+         offset = dxil_emit_binop(&ctx->mod, DXIL_BINOP_MUL, offset,
+            dxil_module_get_int32_const(&ctx->mod, glsl_get_aoa_size(instr->type)), 0);
+         if (!offset)
+            return false;
+      }
       binding = dxil_emit_binop(&ctx->mod, DXIL_BINOP_ADD, base, offset, 0);
    }