radv: use nir constant helpers

Signed-off-by: Karol Herbst <kherbst@redhat.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
This commit is contained in:
Karol Herbst 2019-03-28 16:53:47 +01:00
parent adb2263014
commit 2a36699ed3
2 changed files with 10 additions and 20 deletions

View File

@ -34,33 +34,27 @@
static nir_ssa_def *radv_meta_build_resolve_srgb_conversion(nir_builder *b,
nir_ssa_def *input)
{
nir_const_value v;
unsigned i;
v.u32[0] = 0x3b4d2e1c; // 0.00313080009
nir_ssa_def *cmp[3];
for (i = 0; i < 3; i++)
cmp[i] = nir_flt(b, nir_channel(b, input, i),
nir_build_imm(b, 1, 32, v));
nir_imm_int(b, 0x3b4d2e1c));
nir_ssa_def *ltvals[3];
v.f32[0] = 12.92;
for (i = 0; i < 3; i++)
ltvals[i] = nir_fmul(b, nir_channel(b, input, i),
nir_build_imm(b, 1, 32, v));
nir_imm_float(b, 12.92));
nir_ssa_def *gtvals[3];
for (i = 0; i < 3; i++) {
v.f32[0] = 1.0/2.4;
gtvals[i] = nir_fpow(b, nir_channel(b, input, i),
nir_build_imm(b, 1, 32, v));
v.f32[0] = 1.055;
nir_imm_float(b, 1.0/2.4));
gtvals[i] = nir_fmul(b, gtvals[i],
nir_build_imm(b, 1, 32, v));
v.f32[0] = 0.055;
nir_imm_float(b, 1.055));
gtvals[i] = nir_fsub(b, gtvals[i],
nir_build_imm(b, 1, 32, v));
nir_imm_float(b, 0.055));
}
nir_ssa_def *comp[4];

View File

@ -59,9 +59,7 @@ get_deref_offset(nir_deref_instr *instr,
if (var->data.compact) {
assert(instr->deref_type == nir_deref_type_array);
nir_const_value *v = nir_src_as_const_value(instr->arr.index);
assert(v);
*const_out = v->u32[0];
*const_out = nir_src_as_uint(instr->arr.index);
return;
}
@ -80,9 +78,8 @@ get_deref_offset(nir_deref_instr *instr,
}
} else if(path.path[idx_lvl]->deref_type == nir_deref_type_array) {
unsigned size = glsl_count_attribute_slots(path.path[idx_lvl]->type, false);
nir_const_value *v = nir_src_as_const_value(path.path[idx_lvl]->arr.index);
if (v)
const_offset += v->u32[0] * size;
if (nir_src_is_const(path.path[idx_lvl]->arr.index))
const_offset += nir_src_as_uint(path.path[idx_lvl]->arr.index) * size;
} else
unreachable("Uhandled deref type in get_deref_instr_offset");
}
@ -189,13 +186,12 @@ gather_push_constant_info(const nir_shader *nir,
const nir_intrinsic_instr *instr,
struct radv_shader_info *info)
{
nir_const_value *cval = nir_src_as_const_value(instr->src[0]);
int base = nir_intrinsic_base(instr);
if (!cval) {
if (!nir_src_is_const(instr->src[0])) {
info->has_indirect_push_constants = true;
} else {
uint32_t min = base + cval->u32[0];
uint32_t min = base + nir_src_as_uint(instr->src[0]);
uint32_t max = min + instr->num_components * 4;
info->max_push_constant_used =