nir: Add nir_alu_src_as_uint helper
We have a few ALU instructions that take a constant source. Technically, they have a swizzle so you can't just nir_src_as_uint them, even though a bunch of backends do. To help backends do the right thing, add a helper that's just as easy to use that will chase the swizzle properly. Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io> Reviewed-by: Faith Ekstrand <faith.ekstrand@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22695>
This commit is contained in:
@@ -2725,6 +2725,13 @@ nir_ssa_scalar_resolved(nir_ssa_def *def, unsigned channel)
|
||||
return nir_ssa_scalar_chase_movs(nir_get_ssa_scalar(def, channel));
|
||||
}
|
||||
|
||||
static inline uint64_t
|
||||
nir_alu_src_as_uint(nir_alu_src src)
|
||||
{
|
||||
assert(src.src.is_ssa && "precondition");
|
||||
nir_ssa_scalar scalar = nir_get_ssa_scalar(src.src.ssa, src.swizzle[0]);
|
||||
return nir_ssa_scalar_as_uint(scalar);
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
bool success;
|
||||
|
||||
Reference in New Issue
Block a user