nir: add bit_size info to nir_load_const_instr_create()
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
This commit is contained in:
@@ -469,12 +469,13 @@ nir_jump_instr_create(nir_shader *shader, nir_jump_type type)
|
||||
}
|
||||
|
||||
nir_load_const_instr *
|
||||
nir_load_const_instr_create(nir_shader *shader, unsigned num_components)
|
||||
nir_load_const_instr_create(nir_shader *shader, unsigned num_components,
|
||||
unsigned bit_size)
|
||||
{
|
||||
nir_load_const_instr *instr = ralloc(shader, nir_load_const_instr);
|
||||
instr_init(&instr->instr, nir_instr_type_load_const);
|
||||
|
||||
nir_ssa_def_init(&instr->instr, &instr->def, num_components, 32, NULL);
|
||||
nir_ssa_def_init(&instr->instr, &instr->def, num_components, bit_size, NULL);
|
||||
|
||||
return instr;
|
||||
}
|
||||
@@ -694,7 +695,8 @@ nir_deref_get_const_initializer_load(nir_shader *shader, nir_deref_var *deref)
|
||||
}
|
||||
|
||||
nir_load_const_instr *load =
|
||||
nir_load_const_instr_create(shader, glsl_get_vector_elements(tail->type));
|
||||
nir_load_const_instr_create(shader, glsl_get_vector_elements(tail->type),
|
||||
32);
|
||||
|
||||
matrix_offset *= load->def.num_components;
|
||||
for (unsigned i = 0; i < load->def.num_components; i++) {
|
||||
|
@@ -1830,7 +1830,8 @@ nir_alu_instr *nir_alu_instr_create(nir_shader *shader, nir_op op);
|
||||
nir_jump_instr *nir_jump_instr_create(nir_shader *shader, nir_jump_type type);
|
||||
|
||||
nir_load_const_instr *nir_load_const_instr_create(nir_shader *shader,
|
||||
unsigned num_components);
|
||||
unsigned num_components,
|
||||
unsigned bit_size);
|
||||
|
||||
nir_intrinsic_instr *nir_intrinsic_instr_create(nir_shader *shader,
|
||||
nir_intrinsic_op op);
|
||||
|
@@ -92,7 +92,7 @@ static inline nir_ssa_def *
|
||||
nir_build_imm(nir_builder *build, unsigned num_components, nir_const_value value)
|
||||
{
|
||||
nir_load_const_instr *load_const =
|
||||
nir_load_const_instr_create(build->shader, num_components);
|
||||
nir_load_const_instr_create(build->shader, num_components, 32);
|
||||
if (!load_const)
|
||||
return NULL;
|
||||
|
||||
|
@@ -359,7 +359,8 @@ static nir_load_const_instr *
|
||||
clone_load_const(clone_state *state, const nir_load_const_instr *lc)
|
||||
{
|
||||
nir_load_const_instr *nlc =
|
||||
nir_load_const_instr_create(state->ns, lc->def.num_components);
|
||||
nir_load_const_instr_create(state->ns, lc->def.num_components,
|
||||
lc->def.bit_size);
|
||||
|
||||
memcpy(&nlc->value, &lc->value, sizeof(nlc->value));
|
||||
|
||||
|
@@ -74,7 +74,8 @@ lower_instr(nir_intrinsic_instr *instr,
|
||||
nir_intrinsic_set_base(new_instr,
|
||||
state->shader_program->UniformStorage[uniform_loc].opaque[state->shader->stage].index);
|
||||
|
||||
nir_load_const_instr *offset_const = nir_load_const_instr_create(mem_ctx, 1);
|
||||
nir_load_const_instr *offset_const =
|
||||
nir_load_const_instr_create(mem_ctx, 1, 32);
|
||||
offset_const->value.u32[0] = instr->variables[0]->var->data.offset;
|
||||
|
||||
nir_instr_insert_before(&instr->instr, &offset_const->instr);
|
||||
@@ -95,7 +96,7 @@ lower_instr(nir_intrinsic_instr *instr,
|
||||
|
||||
if (deref_array->deref_array_type == nir_deref_array_type_indirect) {
|
||||
nir_load_const_instr *atomic_counter_size =
|
||||
nir_load_const_instr_create(mem_ctx, 1);
|
||||
nir_load_const_instr_create(mem_ctx, 1, 32);
|
||||
atomic_counter_size->value.u32[0] = child_array_elements * ATOMIC_COUNTER_SIZE;
|
||||
nir_instr_insert_before(&instr->instr, &atomic_counter_size->instr);
|
||||
|
||||
|
@@ -48,7 +48,8 @@ lower_load_const_instr_scalar(nir_load_const_instr *lower)
|
||||
/* Emit the individual loads. */
|
||||
nir_ssa_def *loads[4];
|
||||
for (unsigned i = 0; i < lower->def.num_components; i++) {
|
||||
nir_load_const_instr *load_comp = nir_load_const_instr_create(b.shader, 1);
|
||||
nir_load_const_instr *load_comp =
|
||||
nir_load_const_instr_create(b.shader, 1, 32);
|
||||
load_comp->value.u32[0] = lower->value.u32[i];
|
||||
nir_builder_instr_insert(&b, &load_comp->instr);
|
||||
loads[i] = &load_comp->def;
|
||||
|
@@ -161,7 +161,7 @@ get_deref_reg_src(nir_deref_var *deref, nir_instr *instr,
|
||||
|
||||
if (src.reg.indirect) {
|
||||
nir_load_const_instr *load_const =
|
||||
nir_load_const_instr_create(state->shader, 1);
|
||||
nir_load_const_instr_create(state->shader, 1, 32);
|
||||
load_const->value.u32[0] = glsl_get_length(parent_type);
|
||||
nir_instr_insert_before(instr, &load_const->instr);
|
||||
|
||||
|
@@ -98,9 +98,9 @@ constant_fold_alu_instr(nir_alu_instr *instr, void *mem_ctx)
|
||||
|
||||
nir_load_const_instr *new_instr =
|
||||
nir_load_const_instr_create(mem_ctx,
|
||||
instr->dest.dest.ssa.num_components);
|
||||
instr->dest.dest.ssa.num_components,
|
||||
instr->dest.dest.ssa.bit_size);
|
||||
|
||||
new_instr->def.bit_size = instr->dest.dest.ssa.bit_size;
|
||||
new_instr->value = dest;
|
||||
|
||||
nir_instr_insert_before(&instr->instr, &new_instr->instr);
|
||||
|
@@ -477,7 +477,8 @@ construct_value(const nir_search_value *value,
|
||||
|
||||
case nir_search_value_constant: {
|
||||
const nir_search_constant *c = nir_search_value_as_constant(value);
|
||||
nir_load_const_instr *load = nir_load_const_instr_create(mem_ctx, 1);
|
||||
nir_load_const_instr *load =
|
||||
nir_load_const_instr_create(mem_ctx, 1, bitsize->dest_size);
|
||||
|
||||
switch (c->type) {
|
||||
case nir_type_float:
|
||||
@@ -528,8 +529,6 @@ construct_value(const nir_search_value *value,
|
||||
unreachable("Invalid alu source type");
|
||||
}
|
||||
|
||||
load->def.bit_size = bitsize->dest_size;
|
||||
|
||||
nir_instr_insert_before(instr, &load->instr);
|
||||
|
||||
nir_alu_src val;
|
||||
|
@@ -454,7 +454,7 @@ ttn_emit_immediate(struct ttn_compile *c)
|
||||
nir_load_const_instr *load_const;
|
||||
int i;
|
||||
|
||||
load_const = nir_load_const_instr_create(b->shader, 4);
|
||||
load_const = nir_load_const_instr_create(b->shader, 4, 32);
|
||||
c->imm_defs[c->next_imm] = &load_const->def;
|
||||
c->next_imm++;
|
||||
|
||||
|
Reference in New Issue
Block a user