glsl: fix return value for subgroupBallot()

The original code attempted to create a second instance of the intrinsic
with only a different return value which isn't possible since the params
(in this case 0 params) are the same. To fix this were need to create
two differently named intrinsics.

Reviewed-by: Qiang Yu <yuq825@gmail.com>

Fixes: a496d84ac8 ("glsl: add KHR_shader_subgroup_ballot builtin functions")
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/12510
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/33231>
This commit is contained in:
Timothy Arceri 2025-01-27 12:19:16 +11:00 committed by Marge Bot
parent 9102d1775d
commit e639cd768d

View file

@ -1938,8 +1938,11 @@ builtin_builder::create_intrinsics()
FIUBD_AVAIL(_vote_intrinsic, vote_or_v460_desktop, ir_intrinsic_vote_eq),
NULL);
add_function("__intrinsic_ballot",
add_function("__intrinsic_ballot_uint64",
_ballot_intrinsic(&glsl_type_builtin_uint64_t),
NULL);
add_function("__intrinsic_ballot_uvec4",
_ballot_intrinsic(&glsl_type_builtin_uvec4),
NULL);
@ -9012,8 +9015,14 @@ builtin_builder::_ballot(const glsl_type *type, builtin_available_predicate avai
MAKE_SIG(type, avail, 1, value);
ir_variable *retval = body.make_temp(type, "retval");
body.emit(call(symbols->get_function("__intrinsic_ballot"),
retval, sig->parameters));
if (type == &glsl_type_builtin_uint64_t) {
body.emit(call(symbols->get_function("__intrinsic_ballot_uint64"),
retval, sig->parameters));
} else {
assert(type == &glsl_type_builtin_uvec4);
body.emit(call(symbols->get_function("__intrinsic_ballot_uvec4"),
retval, sig->parameters));
}
body.emit(ret(retval));
return sig;
}