libagx: polyfill glsl ballot()

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28483>
This commit is contained in:
Alyssa Rosenzweig 2024-02-28 16:35:49 -04:00 committed by Marge Bot
parent 4a586c7e87
commit b51282500d
2 changed files with 8 additions and 0 deletions

View file

@ -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);

View file

@ -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]