From b51282500d80cfa48bfecfb0a2a640e3d49583db Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Wed, 28 Feb 2024 16:35:49 -0400 Subject: [PATCH] libagx: polyfill glsl ballot() Signed-off-by: Alyssa Rosenzweig Part-of: --- src/asahi/clc/asahi_clc.c | 5 +++++ src/asahi/lib/shaders/libagx.h | 3 +++ 2 files changed, 8 insertions(+) diff --git a/src/asahi/clc/asahi_clc.c b/src/asahi/clc/asahi_clc.c index 3d713925908..f1d923bd61a 100644 --- a/src/asahi/clc/asahi_clc.c +++ b/src/asahi/clc/asahi_clc.c @@ -111,6 +111,11 @@ lower_builtins(nir_builder *b, nir_instr *instr, void *data) nir_store_deref(b, nir_src_as_deref(call->params[0]), nir_load_helper_arg_hi_agx(b, 1, 32), 1); return true; + } else if (strcmp(func->name, "ballot") == 0) { + b->cursor = nir_instr_remove(&call->instr); + nir_store_deref(b, nir_src_as_deref(call->params[0]), + nir_ballot(b, 1, 32, call->params[1].ssa), 1); + return true; } else if (strcmp(func->name, "nir_fence_helper_exit_agx") == 0) { b->cursor = nir_instr_remove(&call->instr); nir_fence_helper_exit_agx(b); diff --git a/src/asahi/lib/shaders/libagx.h b/src/asahi/lib/shaders/libagx.h index cba08867748..040d6ad57d4 100644 --- a/src/asahi/lib/shaders/libagx.h +++ b/src/asahi/lib/shaders/libagx.h @@ -38,6 +38,9 @@ uint32_t nir_load_helper_arg_lo_agx(void); uint32_t nir_load_helper_arg_hi_agx(void); uint32_t nir_fence_helper_exit_agx(void); +/* I have no idea why CL doesn't have this */ +uint ballot(bool cond); + #define AGX_STATIC_ASSERT(_COND) \ typedef char static_assertion_##__line__[(_COND) ? 1 : -1]