nir: Use nir_src_is_const and nir_src_as_* in core code

Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
This commit is contained in:
Jason Ekstrand
2018-10-20 09:10:02 -05:00
parent ce36f412c9
commit 16870de8a0
17 changed files with 56 additions and 76 deletions

View File

@@ -112,10 +112,8 @@ get_io_offset(nir_builder *b, nir_deref_instr *deref,
assert(glsl_type_is_scalar((*p)->type));
/* We always lower indirect dereferences for "compact" array vars. */
nir_const_value *const_index = nir_src_as_const_value((*p)->arr.index);
assert(const_index);
const unsigned total_offset = *component + const_index->u32[0];
const unsigned index = nir_src_as_uint((*p)->arr.index);
const unsigned total_offset = *component + index;
const unsigned slot_offset = total_offset / 4;
*component = total_offset % 4;
return nir_imm_int(b, type_size(glsl_vec4_type()) * slot_offset);