ac: fix the number of coordinates for ac_image_get_lod and arrays
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Mon, 23 Apr 2018 15:05:10 +0000 (17:05 +0200)
committerSamuel Pitoiset <samuel.pitoiset@gmail.com>
Mon, 23 Apr 2018 19:48:38 +0000 (21:48 +0200)
This fixes crashes for the following CTS:
dEQP-VK.glsl.texture_functions.query.texturequerylod.*

Cubemaps are the same as 2D arrays.

Fixes: 625dcbbc456 ("amd/common: pass address components individually to
ac_build_image_intrinsic")
Cc: 18.1 <mesa-stable@lists.freedesktop.org>
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
src/amd/common/ac_llvm_build.c

index 02739f9..f21a5d2 100644 (file)
@@ -1521,6 +1521,20 @@ LLVMValueRef ac_build_image_opcode(struct ac_llvm_context *ctx,
        LLVMValueRef addr;
        unsigned num_addr = 0;
 
+       if (a->opcode == ac_image_get_lod) {
+               switch (a->dim) {
+               case ac_image_1darray:
+                       num_coords = 1;
+                       break;
+               case ac_image_2darray:
+               case ac_image_cube:
+                       num_coords = 2;
+                       break;
+               default:
+                       break;
+               }
+       }
+
        if (a->offset)
                args[num_addr++] = ac_to_integer(ctx, a->offset);
        if (a->bias)