nir/builder: Add a nir_imm_zero helper
v2: replace nir_zero_vec with nir_imm_zero (Karol Herbst) Reviewed-by: Karol Herbst <kherbst@redhat.com>
This commit is contained in:

committed by
Karol Herbst

parent
daaf777376
commit
9b1e4bab6b
@@ -208,6 +208,19 @@ nir_build_imm(nir_builder *build, unsigned num_components,
|
||||
return &load_const->def;
|
||||
}
|
||||
|
||||
static inline nir_ssa_def *
|
||||
nir_imm_zero(nir_builder *build, unsigned num_components, unsigned bit_size)
|
||||
{
|
||||
nir_load_const_instr *load_const =
|
||||
nir_load_const_instr_create(build->shader, num_components, bit_size);
|
||||
|
||||
/* nir_load_const_instr_create uses rzalloc so it's already zero */
|
||||
|
||||
nir_builder_instr_insert(build, &load_const->instr);
|
||||
|
||||
return &load_const->def;
|
||||
}
|
||||
|
||||
static inline nir_ssa_def *
|
||||
nir_imm_bool(nir_builder *build, bool x)
|
||||
{
|
||||
|
@@ -493,9 +493,8 @@ lower_udiv64_mod64(nir_builder *b, nir_ssa_def *n, nir_ssa_def *d,
|
||||
nir_ssa_def *d_lo = nir_unpack_64_2x32_split_x(b, d);
|
||||
nir_ssa_def *d_hi = nir_unpack_64_2x32_split_y(b, d);
|
||||
|
||||
nir_const_value v = { .u32 = { 0, 0, 0, 0 } };
|
||||
nir_ssa_def *q_lo = nir_build_imm(b, n->num_components, 32, v);
|
||||
nir_ssa_def *q_hi = nir_build_imm(b, n->num_components, 32, v);
|
||||
nir_ssa_def *q_lo = nir_imm_zero(b, n->num_components, 32);
|
||||
nir_ssa_def *q_hi = nir_imm_zero(b, n->num_components, 32);
|
||||
|
||||
nir_ssa_def *n_hi_before_if = n_hi;
|
||||
nir_ssa_def *q_hi_before_if = q_hi;
|
||||
|
@@ -754,10 +754,8 @@ build_explicit_io_load(nir_builder *b, nir_intrinsic_instr *intrin,
|
||||
* as to what we can do with an OOB read. Unfortunately, returning
|
||||
* undefined values isn't one of them so we return an actual zero.
|
||||
*/
|
||||
nir_const_value zero_val;
|
||||
memset(&zero_val, 0, sizeof(zero_val));
|
||||
nir_ssa_def *zero = nir_build_imm(b, load->num_components,
|
||||
load->dest.ssa.bit_size, zero_val);
|
||||
nir_ssa_def *zero = nir_imm_zero(b, load->num_components,
|
||||
load->dest.ssa.bit_size);
|
||||
|
||||
const unsigned load_size =
|
||||
(load->dest.ssa.bit_size / 8) * load->num_components;
|
||||
|
@@ -312,15 +312,6 @@ get_format_info(enum isl_format fmt)
|
||||
};
|
||||
}
|
||||
|
||||
static nir_ssa_def *
|
||||
nir_zero_vec(nir_builder *b, unsigned num_components)
|
||||
{
|
||||
nir_const_value v;
|
||||
memset(&v, 0, sizeof(v));
|
||||
|
||||
return nir_build_imm(b, num_components, 32, v);
|
||||
}
|
||||
|
||||
static nir_ssa_def *
|
||||
convert_color_for_load(nir_builder *b, const struct gen_device_info *devinfo,
|
||||
nir_ssa_def *color,
|
||||
@@ -498,7 +489,7 @@ lower_image_load_instr(nir_builder *b,
|
||||
|
||||
nir_push_else(b, NULL);
|
||||
|
||||
nir_ssa_def *zero = nir_zero_vec(b, load->num_components);
|
||||
nir_ssa_def *zero = nir_imm_zero(b, load->num_components, 32);
|
||||
|
||||
nir_pop_if(b, NULL);
|
||||
|
||||
|
Reference in New Issue
Block a user