From: Jason Ekstrand Date: Sat, 20 Oct 2018 17:25:31 +0000 (-0500) Subject: anv: Use nir_src_is_const and friends in lowering code X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=bcc6aab065a9a4f7fc089065227c36c6c8efd52b;p=mesa.git anv: Use nir_src_is_const and friends in lowering code Reviewed-by: Kenneth Graunke --- diff --git a/src/intel/vulkan/anv_nir_apply_pipeline_layout.c b/src/intel/vulkan/anv_nir_apply_pipeline_layout.c index 6868288e486..fa967c217e7 100644 --- a/src/intel/vulkan/anv_nir_apply_pipeline_layout.c +++ b/src/intel/vulkan/anv_nir_apply_pipeline_layout.c @@ -144,11 +144,9 @@ lower_res_index_intrinsic(nir_intrinsic_instr *intrin, 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 { @@ -299,9 +297,9 @@ lower_tex_deref(nir_tex_instr *tex, nir_tex_src_type deref_src_type, 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; @@ -337,8 +335,7 @@ tex_instr_get_and_remove_plane_src(nir_tex_instr *tex) 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); diff --git a/src/intel/vulkan/anv_nir_lower_ycbcr_textures.c b/src/intel/vulkan/anv_nir_lower_ycbcr_textures.c index 71e511f34b7..3962356708b 100644 --- a/src/intel/vulkan/anv_nir_lower_ycbcr_textures.c +++ b/src/intel/vulkan/anv_nir_lower_ycbcr_textures.c @@ -344,10 +344,10 @@ try_lower_tex_ycbcr(struct anv_pipeline_layout *layout, 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];