mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-21 20:10:14 +01:00
nir/builder: Add nir_replicate helper
Splat a scalar to all components of a vector. Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io> Acked-by: Jesse Natalie <jenatali@microsoft.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23259>
This commit is contained in:
parent
11c8b84c53
commit
f534c2c539
1 changed files with 13 additions and 0 deletions
|
|
@ -707,6 +707,19 @@ nir_vector_insert(nir_builder *b, nir_ssa_def *vec, nir_ssa_def *scalar,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline nir_ssa_def *
|
||||||
|
nir_replicate(nir_builder *b, nir_ssa_def *scalar, unsigned num_components)
|
||||||
|
{
|
||||||
|
assert(scalar->num_components == 1);
|
||||||
|
assert(num_components < NIR_MAX_VEC_COMPONENTS);
|
||||||
|
|
||||||
|
nir_ssa_def *copies[NIR_MAX_VEC_COMPONENTS] = {NULL};
|
||||||
|
for (unsigned i = 0; i < num_components; ++i)
|
||||||
|
copies[i] = scalar;
|
||||||
|
|
||||||
|
return nir_vec(b, copies, num_components);
|
||||||
|
}
|
||||||
|
|
||||||
static inline nir_ssa_def *
|
static inline nir_ssa_def *
|
||||||
nir_iadd_imm(nir_builder *build, nir_ssa_def *x, uint64_t y)
|
nir_iadd_imm(nir_builder *build, nir_ssa_def *x, uint64_t y)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue