Mesa (main): ac/llvm: call the callback in all return paths of ac_cull_triangle

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Jun 29 22:07:40 UTC 2021


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

Author: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer at amd.com>
Date:   Mon Jun 21 15:04:19 2021 +0200

ac/llvm: call the callback in all return paths of ac_cull_triangle

Fixes: 12d2df15f17 ("ac/llvm: add a callback to ac_cull_triangle to generate code in inner-most block")
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/4959
Reviewed-by: Marek Olšák <marek.olsak at amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11625>

---

 src/amd/llvm/ac_llvm_cull.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/src/amd/llvm/ac_llvm_cull.c b/src/amd/llvm/ac_llvm_cull.c
index 028e125b386..c5ddef7bbb2 100644
--- a/src/amd/llvm/ac_llvm_cull.c
+++ b/src/amd/llvm/ac_llvm_cull.c
@@ -125,8 +125,11 @@ static LLVMValueRef cull_bbox(struct ac_llvm_context *ctx, LLVMValueRef pos[3][4
 {
    LLVMBuilderRef builder = ctx->builder;
 
-   if (!cull_view_xy && !cull_view_near_z && !cull_view_far_z && !cull_small_prims)
+   if (!cull_view_xy && !cull_view_near_z && !cull_view_far_z && !cull_small_prims) {
+      if (accept_func)
+         accept_func(ctx, initially_accepted, userdata);
       return initially_accepted;
+   }
 
    /* Skip the culling if the primitive has already been rejected or
     * if any W is negative. The bounding box culling doesn't work when
@@ -206,6 +209,11 @@ static LLVMValueRef cull_bbox(struct ac_llvm_context *ctx, LLVMValueRef pos[3][4
 
       LLVMBuildStore(builder, accepted, accepted_var);
    }
+   if (accept_func) {
+      /* If the caller provided a accept_func, call it in the else branch */
+      ac_build_else(ctx, 10000000);
+      accept_func(ctx, initially_accepted, userdata);
+   }
    ac_build_endif(ctx, 10000000);
 
    return LLVMBuildLoad(builder, accepted_var, "");



More information about the mesa-commit mailing list