Mesa (main): ac/llvm: fix image_samples with null descriptors

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Oct 8 10:55:16 UTC 2021


Module: Mesa
Branch: main
Commit: 2564fbfc57d17139c8ec6fd735a7360584cd2354
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=2564fbfc57d17139c8ec6fd735a7360584cd2354

Author: Rhys Perry <pendingchaos02 at gmail.com>
Date:   Thu Oct  7 19:34:41 2021 +0100

ac/llvm: fix image_samples with null descriptors

Fixes various dEQP-VK.robustness.robustness2.* tests.

Signed-off-by: Rhys Perry <pendingchaos02 at gmail.com>
Reviewed-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13251>

---

 src/amd/llvm/ac_nir_to_llvm.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/src/amd/llvm/ac_nir_to_llvm.c b/src/amd/llvm/ac_nir_to_llvm.c
index c0477a21cc5..3ea47221b7a 100644
--- a/src/amd/llvm/ac_nir_to_llvm.c
+++ b/src/amd/llvm/ac_nir_to_llvm.c
@@ -2837,6 +2837,18 @@ static LLVMValueRef visit_image_samples(struct ac_nir_context *ctx, nir_intrinsi
    LLVMValueRef rsrc = get_image_descriptor(ctx, instr, dynamic_index, AC_DESC_IMAGE, false);
 
    LLVMValueRef ret = ac_build_image_get_sample_count(&ctx->ac, rsrc);
+   if (ctx->abi->robust_buffer_access) {
+      LLVMValueRef dword1, is_null_descriptor;
+
+      /* Extract the second dword of the descriptor, if it's
+       * all zero, then it's a null descriptor.
+       */
+      dword1 =
+         LLVMBuildExtractElement(ctx->ac.builder, rsrc, LLVMConstInt(ctx->ac.i32, 1, false), "");
+      is_null_descriptor = LLVMBuildICmp(ctx->ac.builder, LLVMIntEQ, dword1,
+                                         LLVMConstInt(ctx->ac.i32, 0, false), "");
+      ret = LLVMBuildSelect(ctx->ac.builder, is_null_descriptor, ctx->ac.i32_0, ret, "");
+   }
 
    return exit_waterfall(ctx, &wctx, ret);
 }



More information about the mesa-commit mailing list