uint32_t array_size =
state->layout->set[set].layout->binding[binding].array_size;
- nir_const_value *const_array_index = nir_src_as_const_value(intrin->src[0]);
-
nir_ssa_def *block_index;
- if (const_array_index) {
- unsigned array_index = const_array_index->u32[0];
+ if (nir_src_is_const(intrin->src[0])) {
+ unsigned array_index = nir_src_as_uint(intrin->src[0]);
array_index = MIN2(array_index, array_size - 1);
block_index = nir_imm_int(b, surface_index + array_index);
} else {
if (deref->deref_type != nir_deref_type_var) {
assert(deref->deref_type == nir_deref_type_array);
- nir_const_value *const_index = nir_src_as_const_value(deref->arr.index);
- if (const_index) {
- *base_index += MIN2(const_index->u32[0], array_size - 1);
+ if (nir_src_is_const(deref->arr.index)) {
+ unsigned arr_index = nir_src_as_uint(deref->arr.index);
+ *base_index += MIN2(arr_index, array_size - 1);
} else {
nir_builder *b = &state->builder;
if (plane_src_idx < 0)
return 0;
- unsigned plane =
- nir_src_as_const_value(tex->src[plane_src_idx].src)->u32[0];
+ unsigned plane = nir_src_as_uint(tex->src[plane_src_idx].src);
nir_tex_instr_remove_src(tex, plane_src_idx);
unsigned array_index = 0;
if (deref->deref_type != nir_deref_type_var) {
assert(deref->deref_type == nir_deref_type_array);
- nir_const_value *const_index = nir_src_as_const_value(deref->arr.index);
- if (!const_index)
+ if (!nir_src_is_const(deref->arr.index))
return false;
- array_index = MIN2(const_index->u32[0], binding->array_size - 1);
+ array_index = nir_src_as_uint(deref->arr.index);
+ array_index = MIN2(array_index, binding->array_size - 1);
}
const struct anv_sampler *sampler = binding->immutable_samplers[array_index];